moved the tooltip info to the appropriate MWWorld::Class classes

This commit is contained in:
scrawl 2012-04-16 22:58:16 +02:00
parent c4825cdb43
commit cdd4d83d9e
40 changed files with 769 additions and 323 deletions

View file

@ -7,7 +7,8 @@
#include <components/esm_store/cell_store.hpp>
#include "../mwworld/ptr.hpp"
#include "../mwworld/environment.hpp"
#include "../mwgui/window_manager.hpp"
namespace MWClass
{
@ -63,4 +64,28 @@ namespace MWClass
registerClass (typeid (ESM::Activator).name(), instance);
}
bool Activator::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
ptr.get<ESM::Activator>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
ptr.get<ESM::Activator>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
std::string text;
if (environment.mWindowManager->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
info.text = text;
return info;
}
}

View file

@ -18,6 +18,12 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr

View file

@ -8,9 +8,13 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwrender/objects.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass
@ -94,4 +98,35 @@ namespace MWClass
{
return std::string("Item Apparatus Down");
}
bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
ptr.get<ESM::Apparatus>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
ptr.get<ESM::Apparatus>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
text += "\n" + environment.mWorld->getStore().gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -28,6 +28,12 @@ namespace MWClass
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;

View file

@ -16,6 +16,8 @@
#include "../mwrender/objects.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass
@ -196,4 +198,51 @@ namespace MWClass
else
return std::string("Item Armor Heavy Down");
}
bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
// get armor type string (light/medium/heavy)
int armorType = getEquipmentSkill(ptr, environment);
std::string typeText;
if (armorType == ESM::Skill::LightArmor)
typeText = environment.mWorld->getStore().gameSettings.search("sLight")->str;
else if (armorType == ESM::Skill::MediumArmor)
typeText = environment.mWorld->getStore().gameSettings.search("sMedium")->str;
else
typeText = environment.mWorld->getStore().gameSettings.search("sHeavy")->str;
text += "\n" + environment.mWorld->getStore().gameSettings.search("sArmorRating")->str + ": " + MWGui::ToolTips::toString(ref->base->data.armor);
/// \todo store the current armor health somewhere
text += "\n" + environment.mWorld->getStore().gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health);
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight) + " (" + typeText + ")";
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -40,6 +40,12 @@ namespace MWClass
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.

View file

@ -8,9 +8,12 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwrender/objects.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass
@ -96,4 +99,36 @@ namespace MWClass
{
return std::string("Item Book Down");
}
bool Book::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
ptr.get<ESM::Book>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
ptr.get<ESM::Book>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -25,6 +25,12 @@ namespace MWClass
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.

View file

@ -9,6 +9,10 @@
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwrender/objects.hpp"
@ -161,4 +165,36 @@ namespace MWClass
}
return std::string("Item Clothes Down");
}
bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -34,6 +34,12 @@ namespace MWClass
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.

View file

@ -10,6 +10,10 @@
#include "../mwworld/containerstore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -137,4 +141,36 @@ namespace MWClass
registerClass (typeid (ESM::Container).name(), instance);
}
bool Container::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
ptr.get<ESM::Container>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
ptr.get<ESM::Container>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
std::string text;
if (ref->ref.lockLevel > 0)
text += "\n" + environment.mWorld->getStore().gameSettings.search("sLockLevel")->str + ": " + MWGui::ToolTips::toString(ref->ref.lockLevel);
if (ref->ref.trap != "")
text += "\n" + environment.mWorld->getStore().gameSettings.search("sTrapped")->str;
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -24,6 +24,12 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const;
///< Return container store

View file

@ -12,6 +12,8 @@
#include "../mwworld/customdata.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwgui/window_manager.hpp"
namespace
{
struct CustomData : public MWWorld::CustomData
@ -140,4 +142,27 @@ namespace MWClass
registerClass (typeid (ESM::Creature).name(), instance);
}
bool Creature::hasToolTip (const MWWorld::Ptr& ptr) const
{
/// \todo We don't want tooltips for Creatures in combat mode.
return true;
}
MWGui::ToolTipInfo Creature::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
ptr.get<ESM::Creature>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
std::string text;
if (environment.mWindowManager->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
info.text = text;
return info;
}
}

View file

@ -32,6 +32,12 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const;
///< Return creature stats

View file

@ -12,6 +12,9 @@
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
@ -142,4 +145,43 @@ namespace MWClass
registerClass (typeid (ESM::Door).name(), instance);
}
bool Door::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
ptr.get<ESM::Door>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
ptr.get<ESM::Door>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
std::string text;
/// \todo If destCell is empty, the teleport target is an exterior cell. In that case we
/// need to fetch that cell (via target position) and retrieve the region name.
if (ref->ref.teleport && (ref->ref.destCell != ""))
{
text += "\n" + environment.mWorld->getStore().gameSettings.search("sTo")->str;
text += "\n"+ref->ref.destCell;
}
if (ref->ref.lockLevel > 0)
text += "\n" + environment.mWorld->getStore().gameSettings.search("sLockLevel")->str + ": " + MWGui::ToolTips::toString(ref->ref.lockLevel);
if (ref->ref.trap != "")
text += "\n" + environment.mWorld->getStore().gameSettings.search("sTrapped")->str;
if (environment.mWindowManager->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
info.text = text;
return info;
}
}

View file

@ -22,6 +22,12 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel) const;
///< Lock object

View file

@ -8,6 +8,10 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -92,4 +96,36 @@ namespace MWClass
{
return std::string("Item Ingredient Down");
}
bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
ptr.get<ESM::Ingredient>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
ptr.get<ESM::Ingredient>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -22,6 +22,12 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr

View file

@ -10,6 +10,10 @@
#include "../mwworld/nullaction.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwsound/soundmanager.hpp"
@ -134,4 +138,36 @@ namespace MWClass
{
return std::string("Item Misc Down");
}
bool Light::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -23,6 +23,12 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation

View file

@ -9,6 +9,9 @@
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -105,4 +108,40 @@ namespace MWClass
{
return std::string("Item Lockpick Down");
}
bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
ptr.get<ESM::Tool>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
ptr.get<ESM::Tool>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
/// \todo store remaining uses somewhere
text += "\n" + environment.mWorld->getStore().gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses);
text += "\n" + environment.mWorld->getStore().gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -22,6 +22,12 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr

View file

@ -10,10 +10,15 @@
#include "../mwworld/world.hpp"
#include "../mwworld/environment.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
#include <boost/lexical_cast.hpp>
namespace MWClass
{
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -109,4 +114,41 @@ namespace MWClass
}
return std::string("Item Misc Down");
}
bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
if (ref->base->name == environment.mWorld->getStore().gameSettings.search("sGold")->str)
info.caption += " (" + boost::lexical_cast<std::string>(ref->base->data.value) + ")";
else
{
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
}
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -22,6 +22,12 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr

View file

@ -19,6 +19,8 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwgui/window_manager.hpp"
namespace
{
const Ogre::Radian kOgrePi (Ogre::Math::PI);
@ -299,4 +301,27 @@ namespace MWClass
std::cout << "class npc:" << typeid (ESM::NPC).name();
registerClass (typeid (ESM::NPC).name(), instance);
}
bool Npc::hasToolTip (const MWWorld::Ptr& ptr) const
{
/// \todo We don't want tooltips for NPCs in combat mode.
return true;
}
MWGui::ToolTipInfo Npc::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
ptr.get<ESM::NPC>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
std::string text;
if (environment.mWindowManager->getFullHelp())
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
info.text = text;
return info;
}
}

View file

@ -38,6 +38,12 @@ namespace MWClass
virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const;
///< Return container store
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual MWWorld::InventoryStore& getInventoryStore (const MWWorld::Ptr& ptr) const;
///< Return inventory store

View file

@ -8,6 +8,10 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -94,4 +98,36 @@ namespace MWClass
{
return std::string("Item Potion Down");
}
bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
ptr.get<ESM::Potion>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
ptr.get<ESM::Potion>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -22,6 +22,12 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr

View file

@ -9,6 +9,9 @@
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -104,4 +107,40 @@ namespace MWClass
{
return std::string("Item Probe Down");
}
bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
ptr.get<ESM::Probe>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
ptr.get<ESM::Probe>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
/// \todo store remaining uses somewhere
text += "\n" + environment.mWorld->getStore().gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses);
text += "\n" + environment.mWorld->getStore().gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -22,6 +22,12 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr

View file

@ -8,6 +8,9 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -94,4 +97,40 @@ namespace MWClass
{
return std::string("Item Repair Down");
}
bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
ptr.get<ESM::Repair>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
ptr.get<ESM::Repair>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
/// \todo store remaining uses somewhere
text += "\n" + environment.mWorld->getStore().gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses);
text += "\n" + environment.mWorld->getStore().gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -22,6 +22,12 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr

View file

@ -9,6 +9,10 @@
#include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwrender/objects.hpp"
@ -245,4 +249,41 @@ namespace MWClass
return std::string("Item Misc Down");
}
bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
return (ref->base->name != "");
}
MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
MWGui::ToolTipInfo info;
info.caption = ref->base->name;
info.icon = ref->base->icon;
std::string text;
/// \todo weapon type, damage
/// \todo store the current weapon health somewhere
text += "\n" + environment.mWorld->getStore().gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health);
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
if (environment.mWindowManager->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
}
info.text = text;
return info;
}
}

View file

@ -22,6 +22,12 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
///< \return Item health data available?

View file

@ -1,6 +1,8 @@
#include "tooltips.hpp"
#include "window_manager.hpp"
#include "../mwworld/class.hpp"
#include <boost/lexical_cast.hpp>
using namespace MWGui;
@ -130,314 +132,24 @@ IntSize ToolTips::getToolTipViaPtr ()
IntSize tooltipSize;
// -------------------- Door -------------------------------
if (mFocusObject.getTypeName() == typeid(ESM::Door).name())
const MWWorld::Class& object = MWWorld::Class::get (mFocusObject);
if (!object.hasToolTip(mFocusObject))
{
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData>* ref = mFocusObject.get<ESM::Door>();
std::string text;
/// \todo If destCell is empty, the teleport target is an exterior cell. In that case we
/// need to fetch that cell (via target position) and retrieve the region name.
if (ref->ref.teleport && (ref->ref.destCell != ""))
{
text += "\n" + mWindowManager->getGameSettingString("sTo", "to");
text += "\n"+ref->ref.destCell;
}
if (ref->ref.lockLevel > 0)
text += "\n" + mWindowManager->getGameSettingString("sLockLevel", "Lock") + ": " + toString(ref->ref.lockLevel);
if (ref->ref.trap != "")
text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!");
tooltipSize = createToolTip(ref->base->name, text);
mDynamicToolTipBox->setVisible(false);
}
// -------------------- NPC -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::NPC).name())
{
/// \todo We don't want tooltips for NPCs in combat mode.
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* ref = mFocusObject.get<ESM::NPC>();
std::string text;
if (mFullHelp) {
text += "\n Script: " + ref->base->script;
}
tooltipSize = createToolTip(ref->base->name, text);
}
// -------------------- Creature -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name())
{
/// \todo We don't want tooltips for Creatures in combat mode.
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData>* ref = mFocusObject.get<ESM::Creature>();
std::string text;
if (mFullHelp) {
text += "\n Script: " + ref->base->script;
}
tooltipSize = createToolTip(ref->base->name, text);
}
// -------------------- Container -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Container).name())
{
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData>* ref = mFocusObject.get<ESM::Container>();
std::string text;
if (ref->ref.lockLevel > 0)
text += "\n" + mWindowManager->getGameSettingString("sLockLevel", "Lock") + ": " + toString(ref->ref.lockLevel);
if (ref->ref.trap != "")
text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!");
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createToolTip(ref->base->name, text);
}
// -------------------- Potion -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Potion).name())
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData>* ref = mFocusObject.get<ESM::Potion>();
/// \todo magic effects
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Apparatus -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Apparatus).name())
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData>* ref = mFocusObject.get<ESM::Apparatus>();
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality);
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Armor -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Armor).name())
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData>* ref = mFocusObject.get<ESM::Armor>();
/// \todo magic effects, armor type (medium/light/heavy)
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sArmorRating", "Armor Rating") + ": " + toString(ref->base->data.armor);
/// \todo where is the current armor health stored?
//text += "\n" + mWindowManager->getGameSettingString("sCondition", "Condition") + ": " + toString(ref->base->data.health);
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Book -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Book).name())
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData>* ref = mFocusObject.get<ESM::Book>();
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Clothing -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Clothing).name())
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData>* ref = mFocusObject.get<ESM::Clothing>();
/// \todo magic effects
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Ingredient -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Ingredient).name())
{
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData>* ref = mFocusObject.get<ESM::Ingredient>();
/// \todo magic effects
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Light -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Light).name())
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData>* ref = mFocusObject.get<ESM::Light>();
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Tool -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Tool).name())
{
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData>* ref = mFocusObject.get<ESM::Tool>();
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses);
text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality);
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Miscellaneous -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Miscellaneous).name())
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData>* ref = mFocusObject.get<ESM::Miscellaneous>();
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Probe -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Probe).name())
{
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData>* ref = mFocusObject.get<ESM::Probe>();
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses);
text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality);
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Repair -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Repair).name())
{
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData>* ref = mFocusObject.get<ESM::Repair>();
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses);
text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality);
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Weapon -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Weapon).name())
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData>* ref = mFocusObject.get<ESM::Weapon>();
/// \todo weapon damage, magic effects, health (condition)
std::string text;
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
if (mFullHelp) {
text += "\n Owner: " + ref->ref.owner;
text += "\n Script: " + ref->base->script;
}
tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text);
}
// -------------------- Activator -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Activator).name())
{
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData>* ref = mFocusObject.get<ESM::Activator>();
std::string text;
if (mFullHelp) {
text += "\n Script: " + ref->base->script;
}
tooltipSize = createToolTip(ref->base->name, text);
}
else
{
// object without tooltip
mDynamicToolTipBox->setVisible(false);
mDynamicToolTipBox->setVisible(true);
ToolTipInfo info = object.getToolTipInfo(mFocusObject, mWindowManager->getEnvironment());
if (info.icon == "")
{
tooltipSize= createToolTip(info.caption, info.text);
}
else
{
tooltipSize = createImageToolTip(info.caption, info.icon, 32, info.text);
}
}
return tooltipSize;
@ -490,8 +202,6 @@ IntSize ToolTips::createImageToolTip(const std::string& caption, const std::stri
captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, (imageSize-captionSize.height)/2, captionSize.width-imageSize, captionSize.height);
mDynamicToolTipBox->setVisible(caption != "");
return totalSize;
}
@ -509,8 +219,6 @@ IntSize ToolTips::createToolTip(const std::string& caption, const std::string& t
box->setProperty("WordWrap", "true");
box->setCaption(caption + (realText != "" ? "\n#BF9959" + realText : ""));
mDynamicToolTipBox->setVisible(caption != "");
return box->getTextSize();
}
@ -523,8 +231,6 @@ IntSize ToolTips::createToolTip(const std::string& text)
box->setProperty("WordWrap", "true");
box->setCaption(text);
mDynamicToolTipBox->setVisible(text != "");
return box->getTextSize();
}
@ -542,15 +248,28 @@ std::string ToolTips::toString(const int value)
return stream.str();
}
std::string ToolTips::getValueString(const int value)
std::string ToolTips::getValueString(const int value, const std::string& prefix)
{
if (value == 0)
return "";
else
return "\n" + mWindowManager->getGameSettingString("sValue", "Value") + ": " + toString(value);
return "\n" + prefix + ": " + toString(value);
}
std::string ToolTips::getMiscString(const std::string& text, const std::string& prefix)
{
if (text == "")
return "";
else
return "\n" + prefix + ": " + text;
}
void ToolTips::toggleFullHelp()
{
mFullHelp = !mFullHelp;
}
bool ToolTips::getFullHelp() const
{
return mFullHelp;
}

View file

@ -10,13 +10,12 @@ namespace MWGui
class WindowManager;
// Info about tooltip that is supplied by the MWWorld::Class object
// Not used yet, but it will replace the if-else-if blocks in tooltips.cpp
struct ToolTipInfo
{
public:
std::string caption;
std::string text;
std::string image;
std::string icon;
/// \todo enchantments (armor, cloth, weapons), magic effects (potions, ingredients)
};
@ -32,9 +31,19 @@ namespace MWGui
void enterGuiMode();
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
void setFocusObject(const MWWorld::Ptr& focus);
static std::string getValueString(const int value, const std::string& prefix);
///< @return "prefix: value" or "" if value is 0
static std::string getMiscString(const std::string& text, const std::string& prefix);
///< @return "prefix: text" or "" if text is empty
static std::string toString(const float value);
static std::string toString(const int value);
private:
MyGUI::Widget* mDynamicToolTipBox;
@ -56,12 +65,6 @@ namespace MWGui
MyGUI::IntSize createToolTip(const std::string& text);
///< @return requested tooltip size
std::string getValueString(const int value);
///< get "Value: X" string or "" if value is 0
std::string toString(const float value);
std::string toString(const int value);
bool mGameMode;
bool mFullHelp;

View file

@ -502,3 +502,8 @@ void WindowManager::toggleFullHelp()
{
mToolTips->toggleFullHelp();
}
bool WindowManager::getFullHelp() const
{
return mToolTips->getFullHelp();
}

View file

@ -162,6 +162,7 @@ namespace MWGui
void toggleFogOfWar();
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
int toggleFps();
///< toggle fps display @return resulting fps level

View file

@ -174,7 +174,7 @@ namespace MWWorld
throw std::runtime_error ("class does not have an down sound");
}
MWGui::ToolTipInfo Class::getToolTipInfo (const Ptr& ptr) const
MWGui::ToolTipInfo Class::getToolTipInfo (const Ptr& ptr, MWWorld::Environment& environment) const
{
throw std::runtime_error ("class does not have a tool tip");
}

View file

@ -90,7 +90,7 @@ namespace MWWorld
virtual bool hasToolTip (const Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const Ptr& ptr) const;
virtual MWGui::ToolTipInfo getToolTipInfo (const Ptr& ptr, MWWorld::Environment& environment) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual MWMechanics::NpcStats& getNpcStats (const Ptr& ptr) const;