mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-19 19:11:32 +00:00
Show custom map markers on the tooltip of the world map marker (Fixes #2711)
This commit is contained in:
parent
41bed4c7d9
commit
6e493500c9
2 changed files with 56 additions and 8 deletions
|
@ -783,15 +783,19 @@ namespace MWGui
|
||||||
|
|
||||||
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->setUserString("Caption_TextOneLine", name);
|
||||||
|
|
||||||
|
setGlobalMapMarkerTooltip(markerWidget, x, y);
|
||||||
|
|
||||||
|
markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine");
|
||||||
|
|
||||||
markerWidget->setNeedMouseFocus(true);
|
markerWidget->setNeedMouseFocus(true);
|
||||||
markerWidget->setColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}")));
|
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->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);
|
||||||
mGlobalMapMarkers.push_back(markerWidget);
|
mGlobalMapMarkers[std::make_pair(x,y)] = markerWidget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,6 +820,45 @@ namespace MWGui
|
||||||
NoDrop::onFrame(dt);
|
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)
|
void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||||
{
|
{
|
||||||
if (_id!=MyGUI::MouseButton::Left) return;
|
if (_id!=MyGUI::MouseButton::Left) return;
|
||||||
|
@ -913,8 +956,8 @@ namespace MWGui
|
||||||
mGlobalMapRender->clear();
|
mGlobalMapRender->clear();
|
||||||
mChanged = true;
|
mChanged = true;
|
||||||
|
|
||||||
for (std::vector<MyGUI::Widget*>::iterator it = mGlobalMapMarkers.begin(); it != mGlobalMapMarkers.end(); ++it)
|
for (std::map<std::pair<int, int>, MyGUI::Widget*>::iterator it = mGlobalMapMarkers.begin(); it != mGlobalMapMarkers.end(); ++it)
|
||||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
MyGUI::Gui::getInstance().destroyWidget(it->second);
|
||||||
mGlobalMapMarkers.clear();
|
mGlobalMapMarkers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1034,6 +1077,8 @@ namespace MWGui
|
||||||
|
|
||||||
bool LocalMapBase::MarkerUserData::isPositionExplored() const
|
bool LocalMapBase::MarkerUserData::isPositionExplored() const
|
||||||
{
|
{
|
||||||
|
if (!mLocalMapRender)
|
||||||
|
return true;
|
||||||
return mLocalMapRender->isPositionExplored(nX, nY, cellX, cellY, interior);
|
return mLocalMapRender->isPositionExplored(nX, nY, cellX, cellY, interior);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace MWGui
|
||||||
std::vector<MyGUI::Widget*> mMagicMarkerWidgets;
|
std::vector<MyGUI::Widget*> mMagicMarkerWidgets;
|
||||||
std::vector<MyGUI::Widget*> mCustomMarkerWidgets;
|
std::vector<MyGUI::Widget*> mCustomMarkerWidgets;
|
||||||
|
|
||||||
void updateCustomMarkers();
|
virtual void updateCustomMarkers();
|
||||||
|
|
||||||
void applyFogOfWar();
|
void applyFogOfWar();
|
||||||
|
|
||||||
|
@ -203,6 +203,8 @@ namespace MWGui
|
||||||
|
|
||||||
void onFrame(float dt);
|
void onFrame(float dt);
|
||||||
|
|
||||||
|
virtual void updateCustomMarkers();
|
||||||
|
|
||||||
/// Clear all savegame-specific data
|
/// Clear all savegame-specific data
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
@ -221,6 +223,7 @@ namespace MWGui
|
||||||
void onNoteDoubleClicked(MyGUI::Widget* sender);
|
void onNoteDoubleClicked(MyGUI::Widget* sender);
|
||||||
void onChangeScrollWindowCoord(MyGUI::Widget* sender);
|
void onChangeScrollWindowCoord(MyGUI::Widget* sender);
|
||||||
void globalMapUpdatePlayer();
|
void globalMapUpdatePlayer();
|
||||||
|
void setGlobalMapMarkerTooltip(MyGUI::Widget* widget, int x, int y);
|
||||||
|
|
||||||
MyGUI::ScrollView* mGlobalMap;
|
MyGUI::ScrollView* mGlobalMap;
|
||||||
std::auto_ptr<MyGUI::ITexture> mGlobalMapTexture;
|
std::auto_ptr<MyGUI::ITexture> mGlobalMapTexture;
|
||||||
|
@ -248,7 +251,7 @@ namespace MWGui
|
||||||
|
|
||||||
MWRender::GlobalMap* mGlobalMapRender;
|
MWRender::GlobalMap* mGlobalMapRender;
|
||||||
|
|
||||||
std::vector<MyGUI::Widget*> mGlobalMapMarkers;
|
std::map<std::pair<int, int>, MyGUI::Widget*> mGlobalMapMarkers;
|
||||||
|
|
||||||
EditNoteDialog mEditNoteDialog;
|
EditNoteDialog mEditNoteDialog;
|
||||||
ESM::CustomMarker mEditingMarker;
|
ESM::CustomMarker mEditingMarker;
|
||||||
|
|
Loading…
Reference in a new issue