1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Do not cache hovered tile and always update state

This commit is contained in:
Ivan Savenko 2023-03-22 19:49:57 +02:00
parent fa9abf6adc
commit 8af76947cb
3 changed files with 11 additions and 30 deletions

View File

@ -1511,6 +1511,7 @@ void CPlayerInterface::objectRemoved(const CGObjectInstance * obj)
const CGHeroInstance * h = static_cast<const CGHeroInstance *>(obj);
heroKilled(h);
}
GH.fakeMouseMove();
}
void CPlayerInterface::objectRemovedAfter()
@ -2029,15 +2030,15 @@ bool CPlayerInterface::capturedAllEvents()
if (duringMovement)
{
//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();
}

View File

@ -24,7 +24,6 @@
MapViewActions::MapViewActions(MapView & owner, const std::shared_ptr<MapViewModel> & model)
: model(model)
, owner(owner)
, curHoveredTile(-1, -1, -1)
, isSwiping(false)
{
pos.w = model->getPixelsVisibleDimensions().x;
@ -47,17 +46,6 @@ void MapViewActions::setContext(const std::shared_ptr<IMapRendererContext> & con
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)
{
if(indeterminate(down))
@ -159,11 +147,7 @@ void MapViewActions::handleHover(const Point & cursorPosition)
return;
}
if(tile != curHoveredTile)
{
curHoveredTile = tile;
adventureInt->onTileHovered(tile);
}
adventureInt->onTileHovered(tile);
}
void MapViewActions::hover(bool on)

View File

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