mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Fix global map markers being duplicated when cell is visited again
This commit is contained in:
parent
6b82e3665b
commit
790e0150b1
4 changed files with 29 additions and 29 deletions
|
@ -733,6 +733,11 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWindow::addVisitedLocation(const std::string& name, int x, int y)
|
void MapWindow::addVisitedLocation(const std::string& name, int x, int y)
|
||||||
|
{
|
||||||
|
CellId cell;
|
||||||
|
cell.first = x;
|
||||||
|
cell.second = y;
|
||||||
|
if (mMarkers.insert(cell).second)
|
||||||
{
|
{
|
||||||
float worldX, worldY;
|
float worldX, worldY;
|
||||||
mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY);
|
mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY);
|
||||||
|
@ -744,7 +749,6 @@ namespace MWGui
|
||||||
worldY * mGlobalMapRender->getHeight()+offset,
|
worldY * mGlobalMapRender->getHeight()+offset,
|
||||||
markerSize, markerSize);
|
markerSize, markerSize);
|
||||||
|
|
||||||
static int _counter=0;
|
|
||||||
MyGUI::Widget* markerWidget = mGlobalMap->createWidget<MyGUI::Widget>("MarkerButton",
|
MyGUI::Widget* markerWidget = mGlobalMap->createWidget<MyGUI::Widget>("MarkerButton",
|
||||||
widgetCoord, MyGUI::Align::Default);
|
widgetCoord, MyGUI::Align::Default);
|
||||||
markerWidget->setNeedMouseFocus(true);
|
markerWidget->setNeedMouseFocus(true);
|
||||||
|
@ -755,12 +759,7 @@ namespace MWGui
|
||||||
markerWidget->setDepth(Global_MarkerLayer);
|
markerWidget->setDepth(Global_MarkerLayer);
|
||||||
markerWidget->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag);
|
markerWidget->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag);
|
||||||
markerWidget->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
|
markerWidget->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
|
||||||
++_counter;
|
}
|
||||||
|
|
||||||
CellId cell;
|
|
||||||
cell.first = x;
|
|
||||||
cell.second = y;
|
|
||||||
mMarkers.push_back(cell);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWindow::cellExplored(int x, int y)
|
void MapWindow::cellExplored(int x, int y)
|
||||||
|
@ -912,7 +911,7 @@ namespace MWGui
|
||||||
|
|
||||||
mGlobalMapRender->read(map);
|
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);
|
const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search(it->first, it->second);
|
||||||
if (cell && !cell->mName.empty())
|
if (cell && !cell->mName.empty())
|
||||||
|
|
|
@ -221,7 +221,7 @@ namespace MWGui
|
||||||
|
|
||||||
// Markers on global map
|
// Markers on global map
|
||||||
typedef std::pair<int, int> CellId;
|
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)
|
// 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)
|
// 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;
|
CellId cell;
|
||||||
esm.getT(cell.first);
|
esm.getT(cell.first);
|
||||||
esm.getT(cell.second);
|
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.write(&mImageData[0], mImageData.size());
|
||||||
esm.endRecord("DATA");
|
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.startSubRecord("MRK_");
|
||||||
esm.writeT(it->first);
|
esm.writeT(it->first);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define OPENMW_COMPONENTS_ESM_GLOBALMAP_H
|
#define OPENMW_COMPONENTS_ESM_GLOBALMAP_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
|
@ -26,7 +27,7 @@ namespace ESM
|
||||||
std::vector<char> mImageData;
|
std::vector<char> mImageData;
|
||||||
|
|
||||||
typedef std::pair<int, int> CellId;
|
typedef std::pair<int, int> CellId;
|
||||||
std::vector<CellId> mMarkers;
|
std::set<CellId> mMarkers;
|
||||||
|
|
||||||
void load (ESMReader &esm);
|
void load (ESMReader &esm);
|
||||||
void save (ESMWriter &esm) const;
|
void save (ESMWriter &esm) const;
|
||||||
|
|
Loading…
Reference in a new issue