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;
class ESMReader;
class ESMWriter;
struct CellId;
}
namespace MWWorld

@ -6,6 +6,8 @@
#include <components/settings/settings.hpp>
#include <components/esm/cellid.hpp>
#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() {}

@ -93,9 +93,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Door> *ref =
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;
}

@ -12,6 +12,8 @@
#include <MyGUI_RotatingSkin.h>
#include <MyGUI_FactoryManager.h>
#include <components/esm/globalmap.hpp>
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
@ -22,10 +24,9 @@
#include "../mwrender/globalmap.hpp"
#include <components/esm/globalmap.hpp>
#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<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);
}
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<MWWorld::Ptr>::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);
}

@ -65,13 +65,15 @@ namespace MWGui
bool toggleFogOfWar();
struct MarkerPosition
struct MarkerUserData
{
bool interior;
int cellX;
int cellY;
float nX;
float nY;
std::vector<std::string> 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() {}

@ -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::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;
}
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>();
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<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())
{
MyGUI::Widget* effectArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("",
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<Widgets::MWEffectList>
("MW_StatName", coord, MyGUI::Align::Default, "ToolTipEffectsWidget");
("MW_StatName", coord, MyGUI::Align::Default);
effectsWidget->setEffectList(info.effects);
std::vector<MyGUI::Widget*> effectItems;
@ -426,12 +447,12 @@ namespace MWGui
assert(enchant);
MyGUI::Widget* enchantArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("",
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<Widgets::MWEffectList>
("MW_StatName", coord, MyGUI::Align::Default, "ToolTipEnchantWidget");
("MW_StatName", coord, MyGUI::Align::Default);
enchantWidget->setEffectList(Widgets::MWEffectList::effectListFromESM(&enchant->mEffects));
std::vector<MyGUI::Widget*> 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<Widgets::MWDynamicStat>
("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<MyGUI::ImageBox>("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);
}

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

@ -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];

Loading…
Cancel
Save