Accept a ConstPtr in hasToolTip

openmw-38
scrawl 9 years ago
parent 29d0f448b4
commit b0894ea20d

@ -74,10 +74,9 @@ namespace MWClass
registerClass (typeid (ESM::Activator).name(), instance);
}
bool Activator::hasToolTip (const MWWorld::Ptr& ptr) const
bool Activator::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>();
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
return (ref->mBase->mName != "");
}

@ -21,7 +21,7 @@ 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;
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) const;

@ -61,11 +61,6 @@ namespace MWClass
}
}
bool Actor::hasToolTip(const MWWorld::Ptr& ptr) const
{
return !ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat() || getCreatureStats(ptr).isDead();
}
osg::Vec3f Actor::getRotationVector(const MWWorld::Ptr& ptr) const
{
MWMechanics::Movement &movement = getMovementSettings(ptr);

@ -28,9 +28,6 @@ namespace MWClass
virtual void block(const MWWorld::Ptr &ptr) const;
virtual bool hasToolTip(const MWWorld::Ptr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual osg::Vec3f getRotationVector(const MWWorld::Ptr& ptr) const;
///< Return desired rotations, as euler angles.

@ -95,10 +95,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const
bool Apparatus::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>();
const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>();
return (ref->mBase->mName != "");
}

@ -33,7 +33,7 @@ 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::Ptr& ptr) const;
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) const;

@ -202,10 +202,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const
bool Armor::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>();
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();
return (ref->mBase->mName != "");
}

@ -43,7 +43,7 @@ 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::Ptr& ptr) const;
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) const;

@ -109,10 +109,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Book::hasToolTip (const MWWorld::Ptr& ptr) const
bool Book::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>();
const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>();
return (ref->mBase->mName != "");
}

@ -27,7 +27,7 @@ namespace MWClass
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
///< Return name of the script attached to ptr
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -158,10 +158,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const
bool Clothing::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>();
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
return (ref->mBase->mName != "");
}

@ -35,7 +35,7 @@ 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::Ptr& ptr) const;
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) const;

@ -215,10 +215,9 @@ namespace MWClass
registerClass (typeid (ESM::Container).name(), instance);
}
bool Container::hasToolTip (const MWWorld::Ptr& ptr) const
bool Container::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>();
const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
return (ref->mBase->mName != "");
}

@ -27,7 +27,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -62,6 +62,10 @@ namespace MWClass
{
return *this;
}
virtual const CreatureCustomData& asCreatureCustomData() const
{
return *this;
}
CreatureCustomData() : mContainerStore(0) {}
virtual ~CreatureCustomData() { delete mContainerStore; }
@ -510,6 +514,15 @@ namespace MWClass
return ptr.getRefData().getCustomData()->asCreatureCustomData().mMovement;
}
bool Creature::hasToolTip(const MWWorld::ConstPtr& ptr) const
{
if (!ptr.getRefData().getCustomData())
return true;
const CreatureCustomData& customData = ptr.getRefData().getCustomData()->asCreatureCustomData();
return !customData.mCreatureStats.getAiSequence().isInCombat() || customData.mCreatureStats.isDead();
}
MWGui::ToolTipInfo Creature::getToolTipInfo (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();

@ -47,6 +47,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: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

@ -227,10 +227,9 @@ namespace MWClass
registerClass (typeid (ESM::Door).name(), instance);
}
bool Door::hasToolTip (const MWWorld::Ptr& ptr) const
bool Door::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>();
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();
return (ref->mBase->mName != "");
}

@ -28,7 +28,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -108,10 +108,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const
bool Ingredient::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>();
const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>();
return (ref->mBase->mName != "");
}

@ -24,7 +24,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -140,10 +140,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Light::hasToolTip (const MWWorld::Ptr& ptr) const
bool Light::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>();
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
return (ref->mBase->mName != "");
}

@ -20,7 +20,7 @@ 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;
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) const;

@ -105,10 +105,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const
bool Lockpick::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>();
return (ref->mBase->mName != "");
}

@ -24,7 +24,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -123,10 +123,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const
bool Miscellaneous::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>();
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>();
return (ref->mBase->mName != "");
}

@ -24,7 +24,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -913,6 +913,15 @@ namespace MWClass
registerClass (typeid (ESM::NPC).name(), instance);
}
bool Npc::hasToolTip(const MWWorld::ConstPtr& ptr) const
{
if (!ptr.getRefData().getCustomData())
return true;
const NpcCustomData& customData = ptr.getRefData().getCustomData()->asNpcCustomData();
return !customData.mNpcStats.getAiSequence().isInCombat() || customData.mNpcStats.isDead();
}
MWGui::ToolTipInfo Npc::getToolTipInfo (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();

@ -60,6 +60,9 @@ namespace MWClass
virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const;
///< Return container store
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) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

@ -100,10 +100,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const
bool Potion::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>();
const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>();
return (ref->mBase->mName != "");
}

@ -24,7 +24,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -105,10 +105,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const
bool Probe::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>();
const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>();
return (ref->mBase->mName != "");
}

@ -24,7 +24,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -96,10 +96,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const
bool Repair::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>();
const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>();
return (ref->mBase->mName != "");
}

@ -24,7 +24,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -242,10 +242,9 @@ namespace MWClass
return ref->mBase->mIcon;
}
bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const
bool Weapon::hasToolTip (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>();
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
return (ref->mBase->mName != "");
}
@ -391,8 +390,7 @@ namespace MWClass
return action;
}
MWWorld::Ptr
Weapon::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
MWWorld::Ptr Weapon::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
{
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();

@ -25,7 +25,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasToolTip (const MWWorld::Ptr& ptr) const;
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) const;

@ -272,7 +272,7 @@ namespace MWWorld
throw std::runtime_error ("class does not have a tool tip");
}
bool Class::hasToolTip (const Ptr& ptr) const
bool Class::hasToolTip (const ConstPtr& ptr) const
{
return false;
}

@ -92,7 +92,7 @@ namespace MWWorld
///< Return creature stats or throw an exception, if class does not have creature stats
/// (default implementation: throw an exception)
virtual bool hasToolTip (const Ptr& ptr) const;
virtual bool hasToolTip (const ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual MWGui::ToolTipInfo getToolTipInfo (const ConstPtr& ptr) const;

@ -14,6 +14,13 @@ MWClass::CreatureCustomData &CustomData::asCreatureCustomData()
throw std::logic_error(error.str());
}
const MWClass::CreatureCustomData &CustomData::asCreatureCustomData() const
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to CreatureCustomData";
throw std::logic_error(error.str());
}
MWClass::NpcCustomData &CustomData::asNpcCustomData()
{
std::stringstream error;

@ -24,6 +24,7 @@ namespace MWWorld
// Fast version of dynamic_cast<X&>. Needs to be overridden in the respective class.
virtual MWClass::CreatureCustomData& asCreatureCustomData();
virtual const MWClass::CreatureCustomData& asCreatureCustomData() const;
virtual MWClass::NpcCustomData& asNpcCustomData();
virtual const MWClass::NpcCustomData& asNpcCustomData() const;

Loading…
Cancel
Save