1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-07 13:20:25 +00:00

Do not update doors markers at each frame, only when needed

This commit is contained in:
Cédric Mocquillon 2021-08-12 22:06:21 +02:00
parent ee1ec53cd9
commit b0b60b05b8
2 changed files with 18 additions and 1 deletions

View File

@ -192,6 +192,7 @@ namespace MWGui
, mMarkerUpdateTimer(0.0f) , mMarkerUpdateTimer(0.0f)
, mLastDirectionX(0.0f) , mLastDirectionX(0.0f)
, mLastDirectionY(0.0f) , mLastDirectionY(0.0f)
, mNeedDoorMarkersUpdate(false)
{ {
mCustomMarkers.eventMarkersChanged += MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers); mCustomMarkers.eventMarkersChanged += MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers);
} }
@ -440,6 +441,10 @@ namespace MWGui
} }
} }
// Delay the door markers update until scripts have been given a chance to run.
// If we don't do this, door markers that should be disabled will still appear on the map.
mNeedDoorMarkersUpdate = true;
for (MyGUI::Widget* widget : currentDoorMarkersWidgets()) for (MyGUI::Widget* widget : currentDoorMarkersWidgets())
widget->setCoord(getMarkerCoordinates(widget, 8)); widget->setCoord(getMarkerCoordinates(widget, 8));
@ -544,7 +549,11 @@ namespace MWGui
void LocalMapBase::onFrame(float dt) void LocalMapBase::onFrame(float dt)
{ {
updateDoorMarkers(); if (mNeedDoorMarkersUpdate)
{
updateDoorMarkers();
mNeedDoorMarkersUpdate = false;
}
mMarkerUpdateTimer += dt; mMarkerUpdateTimer += dt;
@ -950,6 +959,9 @@ namespace MWGui
zoomOnCursor(zoomRatio); zoomOnCursor(zoomRatio);
return; //the zoom out is too big, we switch to the global map return; //the zoom out is too big, we switch to the global map
} }
if (zoomOut)
mNeedDoorMarkersUpdate = true;
} }
zoomOnCursor(speedDiff); zoomOnCursor(speedDiff);
} }
@ -1172,7 +1184,10 @@ namespace MWGui
MyGUI::IntPoint diff = MyGUI::IntPoint(_left, _top) - mLastDragPos; MyGUI::IntPoint diff = MyGUI::IntPoint(_left, _top) - mLastDragPos;
if (!mGlobal) if (!mGlobal)
{
mNeedDoorMarkersUpdate = true;
mLocalMap->setViewOffset( mLocalMap->getViewOffset() + diff ); mLocalMap->setViewOffset( mLocalMap->getViewOffset() + diff );
}
else else
mGlobalMap->setViewOffset( mGlobalMap->getViewOffset() + diff ); mGlobalMap->setViewOffset( mGlobalMap->getViewOffset() + diff );

View File

@ -187,6 +187,8 @@ namespace MWGui
float mLastDirectionX; float mLastDirectionX;
float mLastDirectionY; float mLastDirectionY;
bool mNeedDoorMarkersUpdate;
private: private:
void updateDoorMarkers(); void updateDoorMarkers();
}; };