Commit cdd4d83d authored by scrawl's avatar scrawl

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

parent c4825cdb
......@@ -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;
}
}
......@@ -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
......
......@@ -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;
}
}
......@@ -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;
......
......@@ -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;
}
}
......@@ -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.
......
......@@ -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;
}
}
......@@ -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.
......
......@@ -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;
}
}
......@@ -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.
......
......@@ -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;
}
}
......@@ -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
......
......@@ -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;
}
}
......@@ -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
......
......@@ -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;
}
}
......@@ -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
......
......@@ -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;
}
}
......@@ -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
......
......@@ -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 != "");
}