Browse Source

Do not cache hovered tile and always update state

Ivan Savenko 2 năm trước cách đây
mục cha
commit
8af76947cb

+ 10 - 9
client/CPlayerInterface.cpp

@@ -1511,6 +1511,7 @@ void CPlayerInterface::objectRemoved(const CGObjectInstance * obj)
 		const CGHeroInstance * h = static_cast<const CGHeroInstance *>(obj);
 		const CGHeroInstance * h = static_cast<const CGHeroInstance *>(obj);
 		heroKilled(h);
 		heroKilled(h);
 	}
 	}
+	GH.fakeMouseMove();
 }
 }
 
 
 void CPlayerInterface::objectRemovedAfter()
 void CPlayerInterface::objectRemovedAfter()
@@ -2029,15 +2030,15 @@ bool CPlayerInterface::capturedAllEvents()
 	if (duringMovement)
 	if (duringMovement)
 	{
 	{
 		//just inform that we are capturing events. they will be processed by heroMoved() in client thread.
 		//just inform that we are capturing events. they will be processed by heroMoved() in client thread.
-		return true;
-	}
-
-	bool needToLockAdventureMap = adventureInt->active && CGI->mh->hasOngoingAnimations();
-
-	if (ignoreEvents || needToLockAdventureMap)
-	{
-		boost::unique_lock<boost::mutex> un(eventsM);
-		while(!SDLEventsQueue.empty())
+		return true;
+	}
+
+	bool needToLockAdventureMap = adventureInt->active && CGI->mh->hasOngoingAnimations();
+
+	if (ignoreEvents || needToLockAdventureMap)
+	{
+		boost::unique_lock<boost::mutex> un(eventsM);
+		while(!SDLEventsQueue.empty())
 		{
 		{
 			SDLEventsQueue.pop();
 			SDLEventsQueue.pop();
 		}
 		}

+ 1 - 17
client/mapView/MapViewActions.cpp

@@ -24,7 +24,6 @@
 MapViewActions::MapViewActions(MapView & owner, const std::shared_ptr<MapViewModel> & model)
 MapViewActions::MapViewActions(MapView & owner, const std::shared_ptr<MapViewModel> & model)
 	: model(model)
 	: model(model)
 	, owner(owner)
 	, owner(owner)
-	, curHoveredTile(-1, -1, -1)
 	, isSwiping(false)
 	, isSwiping(false)
 {
 {
 	pos.w = model->getPixelsVisibleDimensions().x;
 	pos.w = model->getPixelsVisibleDimensions().x;
@@ -47,17 +46,6 @@ void MapViewActions::setContext(const std::shared_ptr<IMapRendererContext> & con
 	this->context = context;
 	this->context = context;
 }
 }
 
 
-void MapViewActions::activate()
-{
-	CIntObject::activate();
-}
-
-void MapViewActions::deactivate()
-{
-	CIntObject::deactivate();
-	curHoveredTile = int3(-1, -1, -1); //we lost info about hovered tile when disabling
-}
-
 void MapViewActions::clickLeft(tribool down, bool previousState)
 void MapViewActions::clickLeft(tribool down, bool previousState)
 {
 {
 	if(indeterminate(down))
 	if(indeterminate(down))
@@ -159,11 +147,7 @@ void MapViewActions::handleHover(const Point & cursorPosition)
 		return;
 		return;
 	}
 	}
 
 
-	if(tile != curHoveredTile)
-	{
-		curHoveredTile = tile;
-		adventureInt->onTileHovered(tile);
-	}
+	adventureInt->onTileHovered(tile);
 }
 }
 
 
 void MapViewActions::hover(bool on)
 void MapViewActions::hover(bool on)

+ 0 - 4
client/mapView/MapViewActions.h

@@ -23,8 +23,6 @@ class MapViewActions : public CIntObject
 	Point swipeInitialViewPos;
 	Point swipeInitialViewPos;
 	Point swipeInitialRealPos;
 	Point swipeInitialRealPos;
 
 
-	int3 curHoveredTile;
-
 	MapView & owner;
 	MapView & owner;
 	std::shared_ptr<MapViewModel> model;
 	std::shared_ptr<MapViewModel> model;
 	std::shared_ptr<IMapRendererContext> context;
 	std::shared_ptr<IMapRendererContext> context;
@@ -39,8 +37,6 @@ public:
 
 
 	void setContext(const std::shared_ptr<IMapRendererContext> & context);
 	void setContext(const std::shared_ptr<IMapRendererContext> & context);
 
 
-	void activate() override;
-	void deactivate() override;
 	void clickLeft(tribool down, bool previousState) override;
 	void clickLeft(tribool down, bool previousState) override;
 	void clickRight(tribool down, bool previousState) override;
 	void clickRight(tribool down, bool previousState) override;
 	void clickMiddle(tribool down, bool previousState) override;
 	void clickMiddle(tribool down, bool previousState) override;