Show map notes on door marker leading to the cell with the note (Fixes #2284)

openmw-35
scrawl 10 years ago
parent efbbe73c2a
commit 7542fb5cd9

@ -35,6 +35,7 @@ namespace ESM
struct Class; struct Class;
class ESMReader; class ESMReader;
class ESMWriter; class ESMWriter;
struct CellId;
} }
namespace MWWorld namespace MWWorld

@ -6,6 +6,8 @@
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/esm/cellid.hpp>
#include "../mwworld/globals.hpp" #include "../mwworld/globals.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
@ -33,7 +35,6 @@ namespace ESM
struct Potion; struct Potion;
struct Spell; struct Spell;
struct NPC; struct NPC;
struct CellId;
struct Armor; struct Armor;
struct Weapon; struct Weapon;
struct Clothing; struct Clothing;
@ -92,6 +93,7 @@ namespace MWBase
{ {
std::string name; std::string name;
float x, y; // world position float x, y; // world position
ESM::CellId dest;
}; };
World() {} World() {}

@ -93,9 +93,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Door> *ref = MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>(); ptr.get<ESM::Door>();
if (ptr.getCellRef().getTeleport() && !ptr.getCellRef().getDestCell().empty()) // TODO doors that lead to exteriors
return ptr.getCellRef().getDestCell();
return ref->mBase->mName; return ref->mBase->mName;
} }

@ -12,6 +12,8 @@
#include <MyGUI_RotatingSkin.h> #include <MyGUI_RotatingSkin.h>
#include <MyGUI_FactoryManager.h> #include <MyGUI_FactoryManager.h>
#include <components/esm/globalmap.hpp>
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -22,10 +24,9 @@
#include "../mwrender/globalmap.hpp" #include "../mwrender/globalmap.hpp"
#include <components/esm/globalmap.hpp>
#include "widgets.hpp" #include "widgets.hpp"
#include "confirmationdialog.hpp" #include "confirmationdialog.hpp"
#include "tooltips.hpp"
namespace namespace
{ {
@ -226,7 +227,7 @@ namespace MWGui
redraw(); redraw();
} }
MyGUI::IntPoint LocalMapBase::getMarkerPosition(float worldX, float worldY, MarkerPosition& markerPos) MyGUI::IntPoint LocalMapBase::getMarkerPosition(float worldX, float worldY, MarkerUserData& markerPos)
{ {
MyGUI::IntPoint widgetPos; MyGUI::IntPoint widgetPos;
// normalized cell coordinates // normalized cell coordinates
@ -295,7 +296,7 @@ namespace MWGui
continue; continue;
} }
MarkerPosition markerPos; MarkerUserData markerPos;
MyGUI::IntPoint widgetPos = getMarkerPosition(marker.mWorldX, marker.mWorldY, markerPos); MyGUI::IntPoint widgetPos = getMarkerPosition(marker.mWorldX, marker.mWorldY, markerPos);
MyGUI::IntCoord widgetCoord(widgetPos.left - 4, MyGUI::IntCoord widgetCoord(widgetPos.left - 4,
@ -380,8 +381,17 @@ namespace MWGui
{ {
MWBase::World::DoorMarker marker = *it; MWBase::World::DoorMarker marker = *it;
MarkerPosition markerPos; std::vector<std::string> destNotes;
MyGUI::IntPoint widgetPos = getMarkerPosition(marker.x, marker.y, markerPos); for (std::vector<ESM::CustomMarker>::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, MyGUI::IntCoord widgetCoord(widgetPos.left - 4,
widgetPos.top - 4, widgetPos.top - 4,
8, 8); 8, 8);
@ -392,12 +402,10 @@ namespace MWGui
markerWidget->setHoverColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal_over}"))); markerWidget->setHoverColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal_over}")));
markerWidget->setDepth(Local_MarkerLayer); markerWidget->setDepth(Local_MarkerLayer);
markerWidget->setNeedMouseFocus(true); 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 // Used by tooltips to not show the tooltip if marker is hidden by fog of war
markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserString("ToolTipType", "MapMarker");
markerWidget->setUserData(markerPos);
markerWidget->setUserData(data);
doorMarkerCreated(markerWidget); doorMarkerCreated(markerWidget);
mDoorMarkerWidgets.push_back(markerWidget); mDoorMarkerWidgets.push_back(markerWidget);
@ -480,7 +488,7 @@ namespace MWGui
for (std::vector<MWWorld::Ptr>::iterator it = markers.begin(); it != markers.end(); ++it) for (std::vector<MWWorld::Ptr>::iterator it = markers.begin(); it != markers.end(); ++it)
{ {
const ESM::Position& worldPos = it->getRefData().getPosition(); const ESM::Position& worldPos = it->getRefData().getPosition();
MarkerPosition markerPos; MarkerUserData markerPos;
MyGUI::IntPoint widgetPos = getMarkerPosition(worldPos.pos[0], worldPos.pos[1], markerPos); MyGUI::IntPoint widgetPos = getMarkerPosition(worldPos.pos[0], worldPos.pos[1], markerPos);
MyGUI::IntCoord widgetCoord(widgetPos.left - 4, MyGUI::IntCoord widgetCoord(widgetPos.left - 4,
widgetPos.top - 4, widgetPos.top - 4,
@ -490,9 +498,8 @@ namespace MWGui
widgetCoord, MyGUI::Align::Default); widgetCoord, MyGUI::Align::Default);
markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setDepth(Local_MarkerAboveFogLayer);
markerWidget->setImageTexture(markerTexture); markerWidget->setImageTexture(markerTexture);
markerWidget->setUserString("IsMarker", "true");
markerWidget->setUserData(markerPos);
markerWidget->setColour(markerColour); markerWidget->setColour(markerColour);
markerWidget->setNeedMouseFocus(false);
mMagicMarkerWidgets.push_back(markerWidget); mMagicMarkerWidgets.push_back(markerWidget);
} }
} }
@ -526,7 +533,7 @@ namespace MWGui
if (markedCell && markedCell->isExterior() == !mInterior if (markedCell && markedCell->isExterior() == !mInterior
&& (!mInterior || Misc::StringUtils::ciEqual(markedCell->getCell()->mName, mPrefix))) && (!mInterior || Misc::StringUtils::ciEqual(markedCell->getCell()->mName, mPrefix)))
{ {
MarkerPosition markerPos; MarkerUserData markerPos;
MyGUI::IntPoint widgetPos = getMarkerPosition(markedPosition.pos[0], markedPosition.pos[1], markerPos); MyGUI::IntPoint widgetPos = getMarkerPosition(markedPosition.pos[0], markedPosition.pos[1], markerPos);
MyGUI::IntCoord widgetCoord(widgetPos.left - 4, MyGUI::IntCoord widgetCoord(widgetPos.left - 4,
widgetPos.top - 4, widgetPos.top - 4,
@ -535,8 +542,7 @@ namespace MWGui
widgetCoord, MyGUI::Align::Default); widgetCoord, MyGUI::Align::Default);
markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setDepth(Local_MarkerAboveFogLayer);
markerWidget->setImageTexture("textures\\menu_map_smark.dds"); markerWidget->setImageTexture("textures\\menu_map_smark.dds");
markerWidget->setUserString("IsMarker", "true"); markerWidget->setNeedMouseFocus(false);
markerWidget->setUserData(markerPos);
mMagicMarkerWidgets.push_back(markerWidget); mMagicMarkerWidgets.push_back(markerWidget);
} }

@ -65,13 +65,15 @@ namespace MWGui
bool toggleFogOfWar(); bool toggleFogOfWar();
struct MarkerPosition struct MarkerUserData
{ {
bool interior; bool interior;
int cellX; int cellX;
int cellY; int cellY;
float nX; float nX;
float nY; float nY;
std::vector<std::string> notes;
std::string caption;
}; };
protected: protected:
@ -100,7 +102,7 @@ namespace MWGui
void applyFogOfWar(); 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 notifyPlayerUpdate() {}
virtual void notifyMapChanged() {} virtual void notifyMapChanged() {}

@ -163,15 +163,19 @@ namespace MWGui
// special handling for markers on the local map: the tooltip should only be visible // 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 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::MarkerPosition>(); LocalMapBase::MarkerUserData data = *focus->getUserData<LocalMapBase::MarkerUserData>();
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; return;
}
if (type == "ItemPtr") ToolTipInfo info;
info.text = data.caption;
info.notes = data.notes;
tooltipSize = createToolTip(info);
}
else if (type == "ItemPtr")
{ {
mFocusObject = *focus->getUserData<MWWorld::Ptr>(); mFocusObject = *focus->getUserData<MWWorld::Ptr>();
tooltipSize = getToolTipViaPtr(false); 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), MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth),
((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
for (std::vector<std::string>::const_iterator it = info.notes.begin(); it != info.notes.end(); ++it)
{
MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("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<MyGUI::EditBox>("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()) if (!info.effects.empty())
{ {
MyGUI::Widget* effectArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("", MyGUI::Widget* effectArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("",
MyGUI::IntCoord(padding.left, totalSize.height, 300-padding.left, 300-totalSize.height), 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); MyGUI::IntCoord coord(0, 6, totalSize.width, 24);
Widgets::MWEffectListPtr effectsWidget = effectArea->createWidget<Widgets::MWEffectList> Widgets::MWEffectListPtr effectsWidget = effectArea->createWidget<Widgets::MWEffectList>
("MW_StatName", coord, MyGUI::Align::Default, "ToolTipEffectsWidget"); ("MW_StatName", coord, MyGUI::Align::Default);
effectsWidget->setEffectList(info.effects); effectsWidget->setEffectList(info.effects);
std::vector<MyGUI::Widget*> effectItems; std::vector<MyGUI::Widget*> effectItems;
@ -426,12 +447,12 @@ namespace MWGui
assert(enchant); assert(enchant);
MyGUI::Widget* enchantArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("", MyGUI::Widget* enchantArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("",
MyGUI::IntCoord(padding.left, totalSize.height, 300-padding.left, 300-totalSize.height), 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); MyGUI::IntCoord coord(0, 6, totalSize.width, 24);
Widgets::MWEffectListPtr enchantWidget = enchantArea->createWidget<Widgets::MWEffectList> Widgets::MWEffectListPtr enchantWidget = enchantArea->createWidget<Widgets::MWEffectList>
("MW_StatName", coord, MyGUI::Align::Default, "ToolTipEnchantWidget"); ("MW_StatName", coord, MyGUI::Align::Default);
enchantWidget->setEffectList(Widgets::MWEffectList::effectListFromESM(&enchant->mEffects)); enchantWidget->setEffectList(Widgets::MWEffectList::effectListFromESM(&enchant->mEffects));
std::vector<MyGUI::Widget*> enchantEffectItems; std::vector<MyGUI::Widget*> enchantEffectItems;
@ -470,7 +491,7 @@ namespace MWGui
chargeCoord = MyGUI::IntCoord((totalSize.width - chargeAndTextWidth)/2 + chargeTextWidth, coord.top+6, chargeWidth, 18); chargeCoord = MyGUI::IntCoord((totalSize.width - chargeAndTextWidth)/2 + chargeTextWidth, coord.top+6, chargeWidth, 18);
} }
Widgets::MWDynamicStatPtr chargeWidget = enchantArea->createWidget<Widgets::MWDynamicStat> Widgets::MWDynamicStatPtr chargeWidget = enchantArea->createWidget<Widgets::MWDynamicStat>
("MW_ChargeBar", chargeCoord, MyGUI::Align::Default, "ToolTipEnchantCharge"); ("MW_ChargeBar", chargeCoord, MyGUI::Align::Default);
chargeWidget->setValue(charge, maxCharge); chargeWidget->setValue(charge, maxCharge);
totalSize.height += 24; totalSize.height += 24;
} }
@ -505,7 +526,7 @@ namespace MWGui
{ {
MyGUI::ImageBox* imageWidget = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::ImageBox* imageWidget = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("ImageBox",
MyGUI::IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize), 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->setImageTexture(realImage);
imageWidget->setPosition (imageWidget->getPosition() + padding); imageWidget->setPosition (imageWidget->getPosition() + padding);
} }

@ -38,6 +38,9 @@ namespace MWGui
// effects (for potions, ingredients) // effects (for potions, ingredients)
Widgets::SpellEffectList effects; Widgets::SpellEffectList effects;
// local map notes
std::vector<std::string> notes;
bool isPotion; // potions do not show target in the tooltip bool isPotion; // potions do not show target in the tooltip
bool wordWrap; bool wordWrap;
}; };

@ -1735,6 +1735,23 @@ namespace MWWorld
World::DoorMarker newMarker; World::DoorMarker newMarker;
newMarker.name = MWClass::Door::getDestination(ref); 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 (); ESM::Position pos = ref.mData.getPosition ();
newMarker.x = pos.pos[0]; newMarker.x = pos.pos[0];

Loading…
Cancel
Save