Fix global map markers being duplicated when cell is visited again

deque
scrawl 10 years ago
parent 6b82e3665b
commit 790e0150b1

@ -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<MyGUI::Widget>("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<MyGUI::Widget>("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<ESM::GlobalMap::CellId>::iterator it = map.mMarkers.begin(); it != map.mMarkers.end(); ++it)
for (std::set<ESM::GlobalMap::CellId>::iterator it = map.mMarkers.begin(); it != map.mMarkers.end(); ++it)
{
const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search(it->first, it->second);
if (cell && !cell->mName.empty())

@ -221,7 +221,7 @@ namespace MWGui
// Markers on global map
typedef std::pair<int, int> CellId;
std::vector<CellId> mMarkers;
std::set<CellId> 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)

@ -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<CellId>::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it)
for (std::set<CellId>::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it)
{
esm.startSubRecord("MRK_");
esm.writeT(it->first);

@ -2,6 +2,7 @@
#define OPENMW_COMPONENTS_ESM_GLOBALMAP_H
#include <vector>
#include <set>
namespace ESM
{
@ -26,7 +27,7 @@ namespace ESM
std::vector<char> mImageData;
typedef std::pair<int, int> CellId;
std::vector<CellId> mMarkers;
std::set<CellId> mMarkers;
void load (ESMReader &esm);
void save (ESMWriter &esm) const;

Loading…
Cancel
Save