diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 67d8518ac..37bc4d1e3 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -734,33 +734,32 @@ namespace MWGui void MapWindow::addVisitedLocation(const std::string& name, int x, int y) { - float worldX, worldY; - mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY); - - int markerSize = 12; - int offset = mGlobalMapRender->getCellSize()/2 - markerSize/2; - MyGUI::IntCoord widgetCoord( - worldX * mGlobalMapRender->getWidth()+offset, - worldY * mGlobalMapRender->getHeight()+offset, - markerSize, markerSize); - - static int _counter=0; - MyGUI::Widget* markerWidget = mGlobalMap->createWidget("MarkerButton", - widgetCoord, MyGUI::Align::Default); - markerWidget->setNeedMouseFocus(true); - markerWidget->setColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); - markerWidget->setUserString("ToolTipType", "Layout"); - markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); - markerWidget->setUserString("Caption_TextOneLine", name); - markerWidget->setDepth(Global_MarkerLayer); - markerWidget->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); - markerWidget->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); - ++_counter; - CellId cell; cell.first = x; cell.second = y; - mMarkers.push_back(cell); + if (mMarkers.insert(cell).second) + { + float worldX, worldY; + mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY); + + int markerSize = 12; + int offset = mGlobalMapRender->getCellSize()/2 - markerSize/2; + MyGUI::IntCoord widgetCoord( + worldX * mGlobalMapRender->getWidth()+offset, + worldY * mGlobalMapRender->getHeight()+offset, + markerSize, markerSize); + + MyGUI::Widget* markerWidget = mGlobalMap->createWidget("MarkerButton", + widgetCoord, MyGUI::Align::Default); + markerWidget->setNeedMouseFocus(true); + markerWidget->setColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); + markerWidget->setUserString("ToolTipType", "Layout"); + markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); + markerWidget->setUserString("Caption_TextOneLine", name); + markerWidget->setDepth(Global_MarkerLayer); + markerWidget->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); + markerWidget->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); + } } void MapWindow::cellExplored(int x, int y) @@ -912,7 +911,7 @@ namespace MWGui mGlobalMapRender->read(map); - for (std::vector::iterator it = map.mMarkers.begin(); it != map.mMarkers.end(); ++it) + for (std::set::iterator it = map.mMarkers.begin(); it != map.mMarkers.end(); ++it) { const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get().search(it->first, it->second); if (cell && !cell->mName.empty()) diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index 9ea90061a..e9c0c1a69 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -221,7 +221,7 @@ namespace MWGui // Markers on global map typedef std::pair CellId; - std::vector mMarkers; + std::set mMarkers; // Cells that should be explored in the next frame (i.e. their map revealed on the global map) // We can't do this immediately, because the map update is not immediate either (see mNeedMapUpdate in scene.cpp) diff --git a/components/esm/globalmap.cpp b/components/esm/globalmap.cpp index f17c071ff..190329c61 100644 --- a/components/esm/globalmap.cpp +++ b/components/esm/globalmap.cpp @@ -21,7 +21,7 @@ void ESM::GlobalMap::load (ESMReader &esm) CellId cell; esm.getT(cell.first); esm.getT(cell.second); - mMarkers.push_back(cell); + mMarkers.insert(cell); } } @@ -33,7 +33,7 @@ void ESM::GlobalMap::save (ESMWriter &esm) const esm.write(&mImageData[0], mImageData.size()); esm.endRecord("DATA"); - for (std::vector::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it) + for (std::set::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it) { esm.startSubRecord("MRK_"); esm.writeT(it->first); diff --git a/components/esm/globalmap.hpp b/components/esm/globalmap.hpp index 158f70a6e..e89123f89 100644 --- a/components/esm/globalmap.hpp +++ b/components/esm/globalmap.hpp @@ -2,6 +2,7 @@ #define OPENMW_COMPONENTS_ESM_GLOBALMAP_H #include +#include namespace ESM { @@ -26,7 +27,7 @@ namespace ESM std::vector mImageData; typedef std::pair CellId; - std::vector mMarkers; + std::set mMarkers; void load (ESMReader &esm); void save (ESMWriter &esm) const;