diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 02cbc69e9..69027d734 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -35,6 +35,7 @@ namespace ESM struct Class; class ESMReader; class ESMWriter; + struct CellId; } namespace MWWorld diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index ccda90832..9d8fc90a1 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -6,6 +6,8 @@ #include +#include + #include "../mwworld/globals.hpp" #include "../mwworld/ptr.hpp" @@ -33,7 +35,6 @@ namespace ESM struct Potion; struct Spell; struct NPC; - struct CellId; struct Armor; struct Weapon; struct Clothing; @@ -92,6 +93,7 @@ namespace MWBase { std::string name; float x, y; // world position + ESM::CellId dest; }; World() {} diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 84c6c66fd..10b9b437d 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -93,9 +93,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ptr.getCellRef().getTeleport() && !ptr.getCellRef().getDestCell().empty()) // TODO doors that lead to exteriors - return ptr.getCellRef().getDestCell(); - return ref->mBase->mName; } diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 00d60f23b..61712a470 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -12,6 +12,8 @@ #include #include +#include + #include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" @@ -22,10 +24,9 @@ #include "../mwrender/globalmap.hpp" -#include - #include "widgets.hpp" #include "confirmationdialog.hpp" +#include "tooltips.hpp" namespace { @@ -226,7 +227,7 @@ namespace MWGui redraw(); } - MyGUI::IntPoint LocalMapBase::getMarkerPosition(float worldX, float worldY, MarkerPosition& markerPos) + MyGUI::IntPoint LocalMapBase::getMarkerPosition(float worldX, float worldY, MarkerUserData& markerPos) { MyGUI::IntPoint widgetPos; // normalized cell coordinates @@ -295,7 +296,7 @@ namespace MWGui continue; } - MarkerPosition markerPos; + MarkerUserData markerPos; MyGUI::IntPoint widgetPos = getMarkerPosition(marker.mWorldX, marker.mWorldY, markerPos); MyGUI::IntCoord widgetCoord(widgetPos.left - 4, @@ -380,8 +381,17 @@ namespace MWGui { MWBase::World::DoorMarker marker = *it; - MarkerPosition markerPos; - MyGUI::IntPoint widgetPos = getMarkerPosition(marker.x, marker.y, markerPos); + std::vector destNotes; + for (std::vector::const_iterator it = mCustomMarkers.begin(); it != mCustomMarkers.end(); ++it) + { + if (it->mCell == marker.dest) + destNotes.push_back(it->mNote); + } + + MarkerUserData data; + data.notes = destNotes; + data.caption = marker.name; + MyGUI::IntPoint widgetPos = getMarkerPosition(marker.x, marker.y, data); MyGUI::IntCoord widgetCoord(widgetPos.left - 4, widgetPos.top - 4, 8, 8); @@ -392,12 +402,10 @@ namespace MWGui markerWidget->setHoverColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal_over}"))); markerWidget->setDepth(Local_MarkerLayer); markerWidget->setNeedMouseFocus(true); - markerWidget->setUserString("ToolTipType", "Layout"); - markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); - markerWidget->setUserString("Caption_TextOneLine", marker.name); // Used by tooltips to not show the tooltip if marker is hidden by fog of war - markerWidget->setUserString("IsMarker", "true"); - markerWidget->setUserData(markerPos); + markerWidget->setUserString("ToolTipType", "MapMarker"); + + markerWidget->setUserData(data); doorMarkerCreated(markerWidget); mDoorMarkerWidgets.push_back(markerWidget); @@ -480,7 +488,7 @@ namespace MWGui for (std::vector::iterator it = markers.begin(); it != markers.end(); ++it) { const ESM::Position& worldPos = it->getRefData().getPosition(); - MarkerPosition markerPos; + MarkerUserData markerPos; MyGUI::IntPoint widgetPos = getMarkerPosition(worldPos.pos[0], worldPos.pos[1], markerPos); MyGUI::IntCoord widgetCoord(widgetPos.left - 4, widgetPos.top - 4, @@ -490,9 +498,8 @@ namespace MWGui widgetCoord, MyGUI::Align::Default); markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setImageTexture(markerTexture); - markerWidget->setUserString("IsMarker", "true"); - markerWidget->setUserData(markerPos); markerWidget->setColour(markerColour); + markerWidget->setNeedMouseFocus(false); mMagicMarkerWidgets.push_back(markerWidget); } } @@ -526,7 +533,7 @@ namespace MWGui if (markedCell && markedCell->isExterior() == !mInterior && (!mInterior || Misc::StringUtils::ciEqual(markedCell->getCell()->mName, mPrefix))) { - MarkerPosition markerPos; + MarkerUserData markerPos; MyGUI::IntPoint widgetPos = getMarkerPosition(markedPosition.pos[0], markedPosition.pos[1], markerPos); MyGUI::IntCoord widgetCoord(widgetPos.left - 4, widgetPos.top - 4, @@ -535,8 +542,7 @@ namespace MWGui widgetCoord, MyGUI::Align::Default); markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setImageTexture("textures\\menu_map_smark.dds"); - markerWidget->setUserString("IsMarker", "true"); - markerWidget->setUserData(markerPos); + markerWidget->setNeedMouseFocus(false); mMagicMarkerWidgets.push_back(markerWidget); } diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index 7b6c1f205..a80b3e4c5 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -65,13 +65,15 @@ namespace MWGui bool toggleFogOfWar(); - struct MarkerPosition + struct MarkerUserData { bool interior; int cellX; int cellY; float nX; float nY; + std::vector notes; + std::string caption; }; protected: @@ -100,7 +102,7 @@ namespace MWGui void applyFogOfWar(); - MyGUI::IntPoint getMarkerPosition (float worldX, float worldY, MarkerPosition& markerPos); + MyGUI::IntPoint getMarkerPosition (float worldX, float worldY, MarkerUserData& markerPos); virtual void notifyPlayerUpdate() {} virtual void notifyMapChanged() {} diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 303b8819f..2849688c2 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -163,15 +163,19 @@ namespace MWGui // special handling for markers on the local map: the tooltip should only be visible // if the marker is not hidden due to the fog of war. - if (focus->getUserString ("IsMarker") == "true") + if (type == "MapMarker") { - LocalMapBase::MarkerPosition pos = *focus->getUserData(); + LocalMapBase::MarkerUserData data = *focus->getUserData(); - if (!MWBase::Environment::get().getWorld ()->isPositionExplored (pos.nX, pos.nY, pos.cellX, pos.cellY, pos.interior)) + if (!MWBase::Environment::get().getWorld ()->isPositionExplored (data.nX, data.nY, data.cellX, data.cellY, data.interior)) return; - } - if (type == "ItemPtr") + ToolTipInfo info; + info.text = data.caption; + info.notes = data.notes; + tooltipSize = createToolTip(info); + } + else if (type == "ItemPtr") { mFocusObject = *focus->getUserData(); tooltipSize = getToolTipViaPtr(false); @@ -403,16 +407,33 @@ namespace MWGui MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth), ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); + for (std::vector::const_iterator it = info.notes.begin(); it != info.notes.end(); ++it) + { + MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget("MarkerButton", + MyGUI::IntCoord(padding.left, totalSize.height+padding.top, 8, 8), MyGUI::Align::Default); + icon->setColour(MyGUI::Colour(1.0,0.3,0.3)); + MyGUI::EditBox* edit = mDynamicToolTipBox->createWidget("SandText", + MyGUI::IntCoord(padding.left+8+4, totalSize.height+padding.top, 300-padding.left-8-4, 300-totalSize.height), + MyGUI::Align::Default); + edit->setEditMultiLine(true); + edit->setEditWordWrap(true); + edit->setCaption(*it); + edit->setSize(edit->getWidth(), edit->getTextSize().height); + icon->setPosition(icon->getLeft(),(edit->getTop()+edit->getBottom())/2-icon->getHeight()/2); + totalSize.height += std::max(edit->getHeight(), icon->getHeight()); + totalSize.width = std::max(totalSize.width, edit->getWidth()+8+4); + } + if (!info.effects.empty()) { MyGUI::Widget* effectArea = mDynamicToolTipBox->createWidget("", MyGUI::IntCoord(padding.left, totalSize.height, 300-padding.left, 300-totalSize.height), - MyGUI::Align::Stretch, "ToolTipEffectArea"); + MyGUI::Align::Stretch); MyGUI::IntCoord coord(0, 6, totalSize.width, 24); Widgets::MWEffectListPtr effectsWidget = effectArea->createWidget - ("MW_StatName", coord, MyGUI::Align::Default, "ToolTipEffectsWidget"); + ("MW_StatName", coord, MyGUI::Align::Default); effectsWidget->setEffectList(info.effects); std::vector effectItems; @@ -426,12 +447,12 @@ namespace MWGui assert(enchant); MyGUI::Widget* enchantArea = mDynamicToolTipBox->createWidget("", MyGUI::IntCoord(padding.left, totalSize.height, 300-padding.left, 300-totalSize.height), - MyGUI::Align::Stretch, "ToolTipEnchantArea"); + MyGUI::Align::Stretch); MyGUI::IntCoord coord(0, 6, totalSize.width, 24); Widgets::MWEffectListPtr enchantWidget = enchantArea->createWidget - ("MW_StatName", coord, MyGUI::Align::Default, "ToolTipEnchantWidget"); + ("MW_StatName", coord, MyGUI::Align::Default); enchantWidget->setEffectList(Widgets::MWEffectList::effectListFromESM(&enchant->mEffects)); std::vector enchantEffectItems; @@ -470,7 +491,7 @@ namespace MWGui chargeCoord = MyGUI::IntCoord((totalSize.width - chargeAndTextWidth)/2 + chargeTextWidth, coord.top+6, chargeWidth, 18); } Widgets::MWDynamicStatPtr chargeWidget = enchantArea->createWidget - ("MW_ChargeBar", chargeCoord, MyGUI::Align::Default, "ToolTipEnchantCharge"); + ("MW_ChargeBar", chargeCoord, MyGUI::Align::Default); chargeWidget->setValue(charge, maxCharge); totalSize.height += 24; } @@ -505,7 +526,7 @@ namespace MWGui { MyGUI::ImageBox* imageWidget = mDynamicToolTipBox->createWidget("ImageBox", MyGUI::IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize), - MyGUI::Align::Left | MyGUI::Align::Top, "ToolTipImage"); + MyGUI::Align::Left | MyGUI::Align::Top); imageWidget->setImageTexture(realImage); imageWidget->setPosition (imageWidget->getPosition() + padding); } diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index 21b5527cc..4bd4d88aa 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -38,6 +38,9 @@ namespace MWGui // effects (for potions, ingredients) Widgets::SpellEffectList effects; + // local map notes + std::vector notes; + bool isPotion; // potions do not show target in the tooltip bool wordWrap; }; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 8cdd7037b..462df7e70 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1735,6 +1735,23 @@ namespace MWWorld World::DoorMarker newMarker; newMarker.name = MWClass::Door::getDestination(ref); + ESM::CellId cellid; + if (!ref.mRef.getDestCell().empty()) + { + cellid.mWorldspace = ref.mRef.getDestCell(); + cellid.mPaged = false; + } + else + { + cellid.mPaged = true; + MWBase::Environment::get().getWorld()->positionToIndex( + ref.mRef.getDoorDest().pos[0], + ref.mRef.getDoorDest().pos[1], + cellid.mIndex.mX, + cellid.mIndex.mY); + } + newMarker.dest = cellid; + ESM::Position pos = ref.mData.getPosition (); newMarker.x = pos.pos[0];