Show custom map markers on the tooltip of the world map marker (Fixes #2711)

pull/669/head
scrawl 10 years ago
parent 41bed4c7d9
commit 6e493500c9

@ -783,15 +783,19 @@ namespace MWGui
MyGUI::Widget* markerWidget = mGlobalMap->createWidget<MyGUI::Widget>("MarkerButton",
widgetCoord, MyGUI::Align::Default);
markerWidget->setUserString("Caption_TextOneLine", name);
setGlobalMapMarkerTooltip(markerWidget, x, y);
markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine");
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);
mGlobalMapMarkers.push_back(markerWidget);
mGlobalMapMarkers[std::make_pair(x,y)] = markerWidget;
}
}
@ -816,6 +820,45 @@ namespace MWGui
NoDrop::onFrame(dt);
}
void MapWindow::setGlobalMapMarkerTooltip(MyGUI::Widget* markerWidget, int x, int y)
{
ESM::CellId cellId;
cellId.mIndex.mX = x;
cellId.mIndex.mY = y;
cellId.mWorldspace = "sys::default";
cellId.mPaged = true;
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(cellId);
std::vector<std::string> destNotes;
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second; ++it)
destNotes.push_back(it->second.mNote);
if (!destNotes.empty())
{
MarkerUserData data (NULL);
data.notes = destNotes;
data.caption = markerWidget->getUserString("Caption_TextOneLine");
markerWidget->setUserData(data);
markerWidget->setUserString("ToolTipType", "MapMarker");
}
else
{
markerWidget->setUserString("ToolTipType", "Layout");
}
}
void MapWindow::updateCustomMarkers()
{
LocalMapBase::updateCustomMarkers();
for (std::map<std::pair<int, int>, MyGUI::Widget*>::iterator widgetIt = mGlobalMapMarkers.begin(); widgetIt != mGlobalMapMarkers.end(); ++widgetIt)
{
int x = widgetIt->first.first;
int y = widgetIt->first.second;
MyGUI::Widget* markerWidget = widgetIt->second;
setGlobalMapMarkerTooltip(markerWidget, x, y);
}
}
void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
{
if (_id!=MyGUI::MouseButton::Left) return;
@ -913,8 +956,8 @@ namespace MWGui
mGlobalMapRender->clear();
mChanged = true;
for (std::vector<MyGUI::Widget*>::iterator it = mGlobalMapMarkers.begin(); it != mGlobalMapMarkers.end(); ++it)
MyGUI::Gui::getInstance().destroyWidget(*it);
for (std::map<std::pair<int, int>, MyGUI::Widget*>::iterator it = mGlobalMapMarkers.begin(); it != mGlobalMapMarkers.end(); ++it)
MyGUI::Gui::getInstance().destroyWidget(it->second);
mGlobalMapMarkers.clear();
}
@ -1034,6 +1077,8 @@ namespace MWGui
bool LocalMapBase::MarkerUserData::isPositionExplored() const
{
if (!mLocalMapRender)
return true;
return mLocalMapRender->isPositionExplored(nX, nY, cellX, cellY, interior);
}

@ -126,7 +126,7 @@ namespace MWGui
std::vector<MyGUI::Widget*> mMagicMarkerWidgets;
std::vector<MyGUI::Widget*> mCustomMarkerWidgets;
void updateCustomMarkers();
virtual void updateCustomMarkers();
void applyFogOfWar();
@ -203,6 +203,8 @@ namespace MWGui
void onFrame(float dt);
virtual void updateCustomMarkers();
/// Clear all savegame-specific data
void clear();
@ -221,6 +223,7 @@ namespace MWGui
void onNoteDoubleClicked(MyGUI::Widget* sender);
void onChangeScrollWindowCoord(MyGUI::Widget* sender);
void globalMapUpdatePlayer();
void setGlobalMapMarkerTooltip(MyGUI::Widget* widget, int x, int y);
MyGUI::ScrollView* mGlobalMap;
std::auto_ptr<MyGUI::ITexture> mGlobalMapTexture;
@ -248,7 +251,7 @@ namespace MWGui
MWRender::GlobalMap* mGlobalMapRender;
std::vector<MyGUI::Widget*> mGlobalMapMarkers;
std::map<std::pair<int, int>, MyGUI::Widget*> mGlobalMapMarkers;
EditNoteDialog mEditNoteDialog;
ESM::CustomMarker mEditingMarker;

Loading…
Cancel
Save