|
|
|
@ -92,31 +92,41 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
void CustomMarkerCollection::addMarker(const ESM::CustomMarker &marker, bool triggerEvent)
|
|
|
|
|
{
|
|
|
|
|
mMarkers.push_back(marker);
|
|
|
|
|
mMarkers.insert(std::make_pair(marker.mCell, marker));
|
|
|
|
|
if (triggerEvent)
|
|
|
|
|
eventMarkersChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomMarkerCollection::deleteMarker(const ESM::CustomMarker &marker)
|
|
|
|
|
{
|
|
|
|
|
std::vector<ESM::CustomMarker>::iterator it = std::find(mMarkers.begin(), mMarkers.end(), marker);
|
|
|
|
|
if (it != mMarkers.end())
|
|
|
|
|
mMarkers.erase(it);
|
|
|
|
|
else
|
|
|
|
|
throw std::runtime_error("can't find marker to delete");
|
|
|
|
|
std::pair<ContainerType::iterator, ContainerType::iterator> range = mMarkers.equal_range(marker.mCell);
|
|
|
|
|
|
|
|
|
|
for (ContainerType::iterator it = range.first; it != range.second; ++it)
|
|
|
|
|
{
|
|
|
|
|
if (it->second == marker)
|
|
|
|
|
{
|
|
|
|
|
mMarkers.erase(it);
|
|
|
|
|
eventMarkersChanged();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw std::runtime_error("can't find marker to delete");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomMarkerCollection::updateMarker(const ESM::CustomMarker &marker, const std::string &newNote)
|
|
|
|
|
{
|
|
|
|
|
std::vector<ESM::CustomMarker>::iterator it = std::find(mMarkers.begin(), mMarkers.end(), marker);
|
|
|
|
|
if (it != mMarkers.end())
|
|
|
|
|
it->mNote = newNote;
|
|
|
|
|
else
|
|
|
|
|
throw std::runtime_error("can't find marker to update");
|
|
|
|
|
std::pair<ContainerType::iterator, ContainerType::iterator> range = mMarkers.equal_range(marker.mCell);
|
|
|
|
|
|
|
|
|
|
for (ContainerType::iterator it = range.first; it != range.second; ++it)
|
|
|
|
|
{
|
|
|
|
|
if (it->second == marker)
|
|
|
|
|
{
|
|
|
|
|
it->second.mNote = newNote;
|
|
|
|
|
eventMarkersChanged();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw std::runtime_error("can't find marker to update");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomMarkerCollection::clear()
|
|
|
|
@ -125,16 +135,21 @@ namespace MWGui
|
|
|
|
|
eventMarkersChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<ESM::CustomMarker>::const_iterator CustomMarkerCollection::begin() const
|
|
|
|
|
CustomMarkerCollection::ContainerType::const_iterator CustomMarkerCollection::begin() const
|
|
|
|
|
{
|
|
|
|
|
return mMarkers.begin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<ESM::CustomMarker>::const_iterator CustomMarkerCollection::end() const
|
|
|
|
|
CustomMarkerCollection::ContainerType::const_iterator CustomMarkerCollection::end() const
|
|
|
|
|
{
|
|
|
|
|
return mMarkers.end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomMarkerCollection::RangeType CustomMarkerCollection::getMarkers(const ESM::CellId &cellId) const
|
|
|
|
|
{
|
|
|
|
|
return mMarkers.equal_range(cellId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t CustomMarkerCollection::size() const
|
|
|
|
|
{
|
|
|
|
|
return mMarkers.size();
|
|
|
|
@ -299,24 +314,20 @@ namespace MWGui
|
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(*it);
|
|
|
|
|
mCustomMarkerWidgets.clear();
|
|
|
|
|
|
|
|
|
|
for (std::vector<ESM::CustomMarker>::const_iterator it = mCustomMarkers.begin(); it != mCustomMarkers.end(); ++it)
|
|
|
|
|
for (int dX = -1; dX <= 1; ++dX)
|
|
|
|
|
{
|
|
|
|
|
const ESM::CustomMarker& marker = *it;
|
|
|
|
|
|
|
|
|
|
if (marker.mCell.mPaged != !mInterior)
|
|
|
|
|
continue;
|
|
|
|
|
if (mInterior)
|
|
|
|
|
for (int dY =-1; dY <= 1; ++dY)
|
|
|
|
|
{
|
|
|
|
|
if (marker.mCell.mWorldspace != mPrefix)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ESM::CellId cellId;
|
|
|
|
|
cellId.mPaged = !mInterior;
|
|
|
|
|
cellId.mWorldspace = (mInterior ? mPrefix : "sys::default");
|
|
|
|
|
cellId.mIndex.mX = mCurX+dX;
|
|
|
|
|
cellId.mIndex.mY = mCurY+dY;
|
|
|
|
|
|
|
|
|
|
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(cellId);
|
|
|
|
|
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second; ++it)
|
|
|
|
|
{
|
|
|
|
|
if (std::abs(marker.mCell.mIndex.mX - mCurX) > 1)
|
|
|
|
|
continue;
|
|
|
|
|
if (std::abs(marker.mCell.mIndex.mY - mCurY) > 1)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const ESM::CustomMarker& marker = it->second;
|
|
|
|
|
|
|
|
|
|
MarkerUserData markerPos (mLocalMapRender);
|
|
|
|
|
MyGUI::IntPoint widgetPos = getMarkerPosition(marker.mWorldX, marker.mWorldY, markerPos);
|
|
|
|
@ -337,6 +348,9 @@ namespace MWGui
|
|
|
|
|
customMarkerCreated(markerWidget);
|
|
|
|
|
mCustomMarkerWidgets.push_back(markerWidget);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -411,11 +425,9 @@ namespace MWGui
|
|
|
|
|
MWBase::World::DoorMarker marker = *it;
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> destNotes;
|
|
|
|
|
for (std::vector<ESM::CustomMarker>::const_iterator it = mCustomMarkers.begin(); it != mCustomMarkers.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
if (it->mCell == marker.dest)
|
|
|
|
|
destNotes.push_back(it->mNote);
|
|
|
|
|
}
|
|
|
|
|
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(marker.dest);
|
|
|
|
|
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second; ++it)
|
|
|
|
|
destNotes.push_back(it->second.mNote);
|
|
|
|
|
|
|
|
|
|
MarkerUserData data (mLocalMapRender);
|
|
|
|
|
data.notes = destNotes;
|
|
|
|
|