forked from mirror/openmw-tes3mp
Fix clearing of local map markers
destroyWidget changes the child count, so the for loop is flawed.
This commit is contained in:
parent
1444cd9051
commit
d86585b153
2 changed files with 23 additions and 18 deletions
apps/openmw/mwgui
|
@ -86,6 +86,11 @@ namespace MWGui
|
|||
{
|
||||
mFogOfWar = !mFogOfWar;
|
||||
applyFogOfWar();
|
||||
|
||||
// clear all previous door markers
|
||||
for (std::vector<MyGUI::Widget*>::iterator it = mDoorMarkerWidgets.begin(); it != mDoorMarkerWidgets.end(); ++it)
|
||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||
mDoorMarkerWidgets.clear();
|
||||
}
|
||||
|
||||
void LocalMapBase::applyFogOfWar()
|
||||
|
@ -172,14 +177,10 @@ namespace MWGui
|
|||
mInterior = interior;
|
||||
mChanged = false;
|
||||
|
||||
// clear all previous markers
|
||||
for (unsigned int i=0; i< mLocalMap->getChildCount(); ++i)
|
||||
{
|
||||
if (mLocalMap->getChildAt(i)->getName ().substr (0, 4) == "Door")
|
||||
{
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mLocalMap->getChildAt(i));
|
||||
}
|
||||
}
|
||||
// clear all previous door markers
|
||||
for (std::vector<MyGUI::Widget*>::iterator it = mDoorMarkerWidgets.begin(); it != mDoorMarkerWidgets.end(); ++it)
|
||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||
mDoorMarkerWidgets.clear();
|
||||
|
||||
// Update the map textures
|
||||
for (int mx=0; mx<3; ++mx)
|
||||
|
@ -243,6 +244,8 @@ namespace MWGui
|
|||
// Used by tooltips to not show the tooltip if marker is hidden by fog of war
|
||||
markerWidget->setUserString("IsMarker", "true");
|
||||
markerWidget->setUserData(markerPos);
|
||||
|
||||
mDoorMarkerWidgets.push_back(markerWidget);
|
||||
}
|
||||
|
||||
updateMarkers();
|
||||
|
@ -344,13 +347,9 @@ namespace MWGui
|
|||
void LocalMapBase::updateMarkers()
|
||||
{
|
||||
// clear all previous markers
|
||||
for (unsigned int i=0; i< mLocalMap->getChildCount(); ++i)
|
||||
{
|
||||
if (mLocalMap->getChildAt(i)->getName ().substr (0, 6) == "Marker")
|
||||
{
|
||||
MyGUI::Gui::getInstance ().destroyWidget (mLocalMap->getChildAt(i));
|
||||
}
|
||||
}
|
||||
for (std::vector<MyGUI::Widget*>::iterator it = mMarkerWidgets.begin(); it != mMarkerWidgets.end(); ++it)
|
||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||
mMarkerWidgets.clear();
|
||||
|
||||
addDetectionMarkers(MWBase::World::Detect_Creature);
|
||||
addDetectionMarkers(MWBase::World::Detect_Key);
|
||||
|
@ -373,6 +372,7 @@ namespace MWGui
|
|||
markerWidget->setImageTexture("textures\\menu_map_smark.dds");
|
||||
markerWidget->setUserString("IsMarker", "true");
|
||||
markerWidget->setUserData(markerPos);
|
||||
mMarkerWidgets.push_back(markerWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,12 +55,13 @@ namespace MWGui
|
|||
bool mChanged;
|
||||
bool mFogOfWar;
|
||||
|
||||
typedef std::pair<int, int> CellId;
|
||||
std::vector<CellId> mMarkers;
|
||||
|
||||
std::vector<MyGUI::ImageBox*> mMapWidgets;
|
||||
std::vector<MyGUI::ImageBox*> mFogWidgets;
|
||||
|
||||
// Keep track of created marker widgets, just to easily remove them later.
|
||||
std::vector<MyGUI::Widget*> mDoorMarkerWidgets; // Doors
|
||||
std::vector<MyGUI::Widget*> mMarkerWidgets; // Other markers
|
||||
|
||||
void applyFogOfWar();
|
||||
|
||||
void onMarkerFocused(MyGUI::Widget* w1, MyGUI::Widget* w2);
|
||||
|
@ -127,6 +128,10 @@ namespace MWGui
|
|||
MyGUI::IntPoint mLastDragPos;
|
||||
bool mGlobal;
|
||||
|
||||
// Markers on global map
|
||||
typedef std::pair<int, int> CellId;
|
||||
std::vector<CellId> mMarkers;
|
||||
|
||||
MyGUI::Button* mEventBoxGlobal;
|
||||
MyGUI::Button* mEventBoxLocal;
|
||||
|
||||
|
|
Loading…
Reference in a new issue