1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-28 16:39:39 +00:00

Preparation work

Phase out canBeActivated() to unify activation checks
Use getName() for the name caption in tooltips
Always use tooltips for non-activator objects
Invert hasTooltip default value
This commit is contained in:
Capostrophic 2019-09-10 21:56:10 +03:00
parent 9788a776b9
commit 6b74630f6e
49 changed files with 66 additions and 187 deletions

View file

@ -89,9 +89,7 @@ namespace MWClass
bool Activator::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
return (ref->mBase->mName != "");
return !getName(ptr).empty();
}
bool Activator::allowTelekinesis(const MWWorld::ConstPtr &ptr) const {
@ -103,7 +101,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp())

View file

@ -24,7 +24,7 @@ namespace MWClass
/// can return an empty string.
virtual bool hasToolTip (const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
///< @return true if this object has a tooltip when focused (default implementation: true)
virtual bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const;
///< Return whether this class of object can be activated with telekinesis

View file

@ -91,14 +91,4 @@ namespace MWClass
{
return true;
}
bool Actor::canBeActivated(const MWWorld::Ptr& ptr) const
{
MWMechanics::CreatureStats &stats = getCreatureStats(ptr);
if (stats.getAiSequence().isInCombat() && !stats.isDead())
return false;
return true;
}
}

View file

@ -42,8 +42,6 @@ namespace MWClass
virtual bool isActor() const;
virtual bool canBeActivated(const MWWorld::Ptr& ptr) const;
// not implemented
Actor(const Actor&);
Actor& operator= (const Actor&);

View file

@ -93,19 +93,12 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Apparatus::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

@ -33,9 +33,6 @@ namespace MWClass
virtual int getValue (const MWWorld::ConstPtr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
virtual bool hasToolTip (const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

View file

@ -199,19 +199,12 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Armor::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

@ -43,9 +43,6 @@ namespace MWClass
/// Return the index of the skill this item corresponds to when equipped or -1, if there is
/// no such skill.
virtual bool hasToolTip (const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

View file

@ -31,6 +31,11 @@ namespace MWClass
return std::string();
}
bool BodyPart::hasToolTip(const MWWorld::ConstPtr& ptr) const
{
return false;
}
void BodyPart::registerSelf()
{
std::shared_ptr<MWWorld::Class> instance (new BodyPart);

View file

@ -21,6 +21,9 @@ 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::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: true)
static void registerSelf();
virtual std::string getModel(const MWWorld::ConstPtr &ptr) const;

View file

@ -109,19 +109,12 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Book::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

@ -27,9 +27,6 @@ namespace MWClass
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
///< Return name of the script attached to ptr
virtual bool hasToolTip (const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

View file

@ -157,19 +157,12 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Clothing::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

@ -35,9 +35,6 @@ namespace MWClass
/// Return the index of the skill this item corresponds to when equipped or -1, if there is
/// no such skill.
virtual bool hasToolTip (const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

View file

@ -252,26 +252,18 @@ namespace MWClass
bool Container::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
if (getName(ptr).empty())
return false;
if (const MWWorld::CustomData* data = ptr.getRefData().getCustomData())
return !canBeHarvested(ptr) || data->asContainerCustomData().mContainerStore.hasVisibleItems();
return true;
}
bool Container::canBeActivated(const MWWorld::Ptr& ptr) const
{
return hasToolTip(ptr);
}
MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr));
std::string text;
int lockLevel = ptr.getCellRef().getLockLevel();

View file

@ -28,7 +28,7 @@ namespace MWClass
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
///< @return true if this object has a tooltip when focused (default implementation: true)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
@ -63,8 +63,6 @@ namespace MWClass
const;
///< Write additional state from \a ptr into \a state.
virtual bool canBeActivated(const MWWorld::Ptr& ptr) const;
static void registerSelf();
virtual void respawn (const MWWorld::Ptr& ptr) const;

View file

@ -586,7 +586,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr));
std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp())

View file

@ -48,7 +48,7 @@ namespace MWClass
/// can return an empty string.
virtual bool hasToolTip(const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
///< @return true if this object has a tooltip when focused (default implementation: true)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

View file

@ -39,6 +39,11 @@ namespace MWClass
return "";
}
bool CreatureLevList::hasToolTip(const MWWorld::ConstPtr& ptr) const
{
return false;
}
void CreatureLevList::respawn(const MWWorld::Ptr &ptr) const
{
ensureCustomData(ptr);

View file

@ -15,6 +15,9 @@ 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::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: true)
static void registerSelf();
virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const;

View file

@ -281,19 +281,12 @@ namespace MWClass
registerClass (typeid (ESM::Door).name(), instance);
}
bool Door::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr));
std::string text;

View file

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

View file

@ -105,19 +105,12 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Ingredient::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

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

View file

@ -10,6 +10,11 @@ namespace MWClass
return "";
}
bool ItemLevList::hasToolTip(const MWWorld::ConstPtr& ptr) const
{
return false;
}
void ItemLevList::registerSelf()
{
std::shared_ptr<Class> instance (new ItemLevList);

View file

@ -13,6 +13,9 @@ 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::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: true)
static void registerSelf();
};
}

View file

@ -141,9 +141,7 @@ namespace MWClass
bool Light::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
return (ref->mBase->mName != "");
return showsInInventory(ptr);
}
MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
@ -151,7 +149,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

@ -23,7 +23,7 @@ namespace MWClass
/// can return an empty string.
virtual bool hasToolTip (const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
///< @return true if this object has a tooltip when focused (default implementation: true)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

View file

@ -104,19 +104,12 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Lockpick::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

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

View file

@ -134,13 +134,6 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Miscellaneous::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>();
@ -159,14 +152,16 @@ namespace MWClass
else // gold displays its count also if it's 1.
countString = " (" + std::to_string(count) + ")";
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + countString;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + countString;
info.icon = ref->mBase->mIcon;
if (ref->mRef.getSoul() != "")
{
const ESM::Creature *creature = store.get<ESM::Creature>().search(ref->mRef.getSoul());
if (creature)
if (creature && !creature->mName.empty())
info.caption += " (" + creature->mName + ")";
else if (creature)
info.caption += " (" + creature->mId + ")";
}
std::string text;

View file

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

View file

@ -1071,7 +1071,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr));
if(fullHelp && ptr.getRefData().getCustomData() && ptr.getRefData().getCustomData()->asNpcCustomData().mNpcStats.isWerewolf())
if(fullHelp && !ref->mBase->mName.empty() && ptr.getRefData().getCustomData() && ptr.getRefData().getCustomData()->asNpcCustomData().mNpcStats.isWerewolf())
{
info.caption += " (";
info.caption += MyGUI::TextIterator::toTagsString(ref->mBase->mName);

View file

@ -61,7 +61,7 @@ namespace MWClass
///< Return container store
virtual bool hasToolTip(const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
///< @return true if this object has a tooltip when focused (default implementation: true)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

View file

@ -98,19 +98,12 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Potion::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

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

View file

@ -104,19 +104,12 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Probe::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

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

View file

@ -93,13 +93,6 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Repair::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>();
return (ref->mBase->mName != "");
}
bool Repair::hasItemHealth (const MWWorld::ConstPtr& ptr) const
{
return true;
@ -117,7 +110,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>();
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

View file

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

View file

@ -45,6 +45,11 @@ namespace MWClass
return "";
}
bool Static::hasToolTip(const MWWorld::ConstPtr& ptr) const
{
return false;
}
void Static::registerSelf()
{
std::shared_ptr<Class> instance (new Static);

View file

@ -20,6 +20,9 @@ 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::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: true)
static void registerSelf();
virtual std::string getModel(const MWWorld::ConstPtr &ptr) const;

View file

@ -155,20 +155,13 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Weapon::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
return (ref->mBase->mName != "");
}
MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
const ESM::WeaponType* weaponType = MWMechanics::getWeaponType(ref->mBase->mData.mType);
MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(ref->mBase->mName) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();

View file

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

View file

@ -959,7 +959,7 @@ namespace MWMechanics
return true;
}
if (!target.getClass().canBeActivated(target))
if (!target.getClass().hasToolTip(target))
return true;
// TODO: implement a better check to check if target is owned bed

View file

@ -109,11 +109,6 @@ namespace MWWorld
throw std::runtime_error("class cannot block");
}
bool Class::canBeActivated(const Ptr& ptr) const
{
return !getName(ptr).empty();
}
void Class::onHit(const Ptr& ptr, float damage, bool ishealth, const Ptr& object, const Ptr& attacker, const osg::Vec3f& hitPosition, bool successful) const
{
throw std::runtime_error("class cannot be hit");
@ -298,7 +293,7 @@ namespace MWWorld
bool Class::hasToolTip (const ConstPtr& ptr) const
{
return false;
return true;
}
std::string Class::getEnchantment (const ConstPtr& ptr) const

View file

@ -95,7 +95,7 @@ namespace MWWorld
/// (default implementation: throw an exception)
virtual bool hasToolTip (const ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
///< @return true if this object has a tooltip when focused (default implementation: true)
virtual MWGui::ToolTipInfo getToolTipInfo (const ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
@ -140,10 +140,6 @@ namespace MWWorld
///< Play the appropriate sound for a blocked attack, depending on the currently equipped shield
/// (default implementation: throw an exception)
virtual bool canBeActivated(const Ptr& ptr) const;
///< \return Can the player activate this object?
/// (default implementation: true if object's user-readable name is not empty, false otherwise)
virtual std::shared_ptr<Action> activate (const Ptr& ptr, const Ptr& actor) const;
///< Generate action for activation (default implementation: return a null action).

View file

@ -236,7 +236,7 @@ namespace MWWorld
if (toActivate.isEmpty())
return;
if (!toActivate.getClass().canBeActivated(toActivate))
if (!toActivate.getClass().hasToolTip(toActivate))
return;
MWBase::Environment::get().getWorld()->activate(toActivate, player);

View file

@ -3023,7 +3023,7 @@ namespace MWWorld
target = getFacedObject();
// if the faced object can not be activated, do not use it
if (!target.isEmpty() && !target.getClass().canBeActivated(target))
if (!target.isEmpty() && !target.getClass().hasToolTip(target))
target = nullptr;
if (target.isEmpty())
@ -3082,7 +3082,7 @@ namespace MWWorld
{
target = result2.mHitObject;
hitPosition = result2.mHitPointWorld;
if (dist2 > getMaxActivationDistance() && !target.isEmpty() && !target.getClass().canBeActivated(target))
if (dist2 > getMaxActivationDistance() && !target.isEmpty() && !target.getClass().hasToolTip(target))
target = nullptr;
}
}
@ -3650,7 +3650,7 @@ namespace MWWorld
if (fromProjectile && effectInfo.mArea <= 0)
continue; // Don't play explosion for projectiles with 0-area effects
if (!fromProjectile && effectInfo.mRange == ESM::RT_Touch && (!ignore.isEmpty()) && (!ignore.getClass().isActor() && !ignore.getClass().canBeActivated(ignore)))
if (!fromProjectile && effectInfo.mRange == ESM::RT_Touch && !ignore.isEmpty() && !ignore.getClass().isActor() && !ignore.getClass().hasToolTip(ignore))
continue; // Don't play explosion for touch spells on non-activatable objects except when spell is from the projectile enchantment
// Spawn the explosion orb effect