1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 18:41:33 +00:00

Make Class::getName return string_view

This commit is contained in:
Evil Eye 2022-08-16 21:15:03 +02:00
parent 856fcb7742
commit 4ff12d8945
63 changed files with 149 additions and 108 deletions

View file

@ -2,6 +2,7 @@
#define GAME_MWBASE_JOURNAL_H #define GAME_MWBASE_JOURNAL_H
#include <string> #include <string>
#include <string_view>
#include <deque> #include <deque>
#include <map> #include <map>
@ -63,7 +64,7 @@ namespace MWBase
virtual void addTopic (const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor) = 0; virtual void addTopic (const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor) = 0;
/// \note topicId must be lowercase /// \note topicId must be lowercase
virtual void removeLastAddedTopicResponse (const std::string& topicId, const std::string& actorName) = 0; virtual void removeLastAddedTopicResponse(const std::string& topicId, std::string_view actorName) = 0;
///< Removes the last topic response added for the given topicId and actor name. ///< Removes the last topic response added for the given topicId and actor name.
/// \note topicId must be lowercase /// \note topicId must be lowercase

View file

@ -70,7 +70,7 @@ namespace MWClass
return true; return true;
} }
std::string Activator::getName (const MWWorld::ConstPtr& ptr) const std::string_view Activator::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>(); const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
@ -95,7 +95,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>(); const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
std::string text; std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) if (MWBase::Environment::get().getWindowManager()->getFullHelp())

View file

@ -23,7 +23,7 @@ namespace MWClass
void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override; void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override;
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override; bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;

View file

@ -39,7 +39,7 @@ namespace MWClass
return getClassModel<ESM::Apparatus>(ptr); return getClassModel<ESM::Apparatus>(ptr);
} }
std::string Apparatus::getName (const MWWorld::ConstPtr& ptr) const std::string_view Apparatus::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -89,7 +89,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
@ -97,7 +98,8 @@ namespace MWClass
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}"); text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef()); text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }

View file

@ -20,7 +20,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -47,7 +47,7 @@ namespace MWClass
return getClassModel<ESM::Armor>(ptr); return getClassModel<ESM::Armor>(ptr);
} }
std::string Armor::getName (const MWWorld::ConstPtr& ptr) const std::string_view Armor::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -195,13 +195,14 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
// get armor type string (light/medium/heavy) // get armor type string (light/medium/heavy)
std::string typeText; std::string_view typeText;
if (ref->mBase->mData.mWeight == 0) if (ref->mBase->mData.mWeight == 0)
{ {
// no type // no type
@ -224,12 +225,17 @@ namespace MWClass
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/" text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/"
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth); + MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
if (typeText != "") if (!typeText.empty())
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight) + " (" + typeText + ")"; {
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight) + " (";
text += typeText;
text += ')';
}
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef()); text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }

View file

@ -20,7 +20,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -28,9 +28,9 @@ namespace MWClass
} }
} }
std::string BodyPart::getName(const MWWorld::ConstPtr &ptr) const std::string_view BodyPart::getName(const MWWorld::ConstPtr &ptr) const
{ {
return std::string(); return {};
} }
bool BodyPart::hasToolTip(const MWWorld::ConstPtr& ptr) const bool BodyPart::hasToolTip(const MWWorld::ConstPtr& ptr) const

View file

@ -19,7 +19,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName (const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override; bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;

View file

@ -44,7 +44,7 @@ namespace MWClass
return getClassModel<ESM::Book>(ptr); return getClassModel<ESM::Book>(ptr);
} }
std::string Book::getName (const MWWorld::ConstPtr& ptr) const std::string_view Book::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -106,7 +106,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
@ -114,7 +115,8 @@ namespace MWClass
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}"); text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef()); text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }

View file

@ -18,7 +18,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -42,7 +42,7 @@ namespace MWClass
return getClassModel<ESM::Clothing>(ptr); return getClassModel<ESM::Clothing>(ptr);
} }
std::string Clothing::getName (const MWWorld::ConstPtr& ptr) const std::string_view Clothing::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -153,7 +153,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
@ -161,7 +162,8 @@ namespace MWClass
text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}"); text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}");
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { if (MWBase::Environment::get().getWindowManager()->getFullHelp())
{
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef()); text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
} }

View file

@ -18,7 +18,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -210,7 +210,7 @@ namespace MWClass
} }
} }
std::string Container::getName (const MWWorld::ConstPtr& ptr) const std::string_view Container::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -245,7 +245,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()});
std::string text; std::string text;
int lockLevel = ptr.getCellRef().getLockLevel(); int lockLevel = ptr.getCellRef().getLockLevel();

View file

@ -47,7 +47,7 @@ namespace MWClass
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override; void insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override;
void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override; void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override;
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -211,7 +211,7 @@ namespace MWClass
} }
} }
std::string Creature::getName (const MWWorld::ConstPtr& ptr) const std::string_view Creature::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -589,7 +589,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()});
std::string text; std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) if (MWBase::Environment::get().getWindowManager()->getFullHelp())

View file

@ -51,7 +51,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
bool hasToolTip(const MWWorld::ConstPtr& ptr) const override; bool hasToolTip(const MWWorld::ConstPtr& ptr) const override;

View file

@ -57,9 +57,9 @@ namespace MWClass
MWBase::Environment::get().getWorld()->adjustPosition(creature, force); MWBase::Environment::get().getWorld()->adjustPosition(creature, force);
} }
std::string CreatureLevList::getName (const MWWorld::ConstPtr& ptr) const std::string_view CreatureLevList::getName(const MWWorld::ConstPtr& ptr) const
{ {
return ""; return {};
} }
bool CreatureLevList::hasToolTip(const MWWorld::ConstPtr& ptr) const bool CreatureLevList::hasToolTip(const MWWorld::ConstPtr& ptr) const

View file

@ -15,7 +15,7 @@ namespace MWClass
public: public:
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override; bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;

View file

@ -100,7 +100,7 @@ namespace MWClass
return getClassModel<ESM::Door>(ptr); return getClassModel<ESM::Door>(ptr);
} }
std::string Door::getName (const MWWorld::ConstPtr& ptr) const std::string_view Door::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -115,8 +115,8 @@ namespace MWClass
const std::string &openSound = ref->mBase->mOpenSound; const std::string &openSound = ref->mBase->mOpenSound;
const std::string &closeSound = ref->mBase->mCloseSound; const std::string &closeSound = ref->mBase->mCloseSound;
const std::string lockedSound = "LockedDoor"; const std::string_view lockedSound = "LockedDoor";
const std::string trapActivationSound = "Disarm Trap Fail"; const std::string_view trapActivationSound = "Disarm Trap Fail";
MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor); MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
@ -267,7 +267,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()});
std::string text; std::string text;
@ -282,7 +283,7 @@ namespace MWClass
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ptr.getCellRef().getLockLevel()); text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ptr.getCellRef().getLockLevel());
else if (ptr.getCellRef().getLockLevel() < 0) else if (ptr.getCellRef().getLockLevel() < 0)
text += "\n#{sUnlocked}"; text += "\n#{sUnlocked}";
if (ptr.getCellRef().getTrap() != "") if (!ptr.getCellRef().getTrap().empty())
text += "\n#{sTrapped}"; text += "\n#{sTrapped}";
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) if (MWBase::Environment::get().getWindowManager()->getFullHelp())

View file

@ -29,7 +29,7 @@ namespace MWClass
bool useAnim() const override; bool useAnim() const override;
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -41,7 +41,7 @@ namespace MWClass
return getClassModel<ESM::Ingredient>(ptr); return getClassModel<ESM::Ingredient>(ptr);
} }
std::string Ingredient::getName (const MWWorld::ConstPtr& ptr) const std::string_view Ingredient::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -101,7 +101,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;

View file

@ -18,7 +18,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -9,9 +9,9 @@ namespace MWClass
{ {
} }
std::string ItemLevList::getName (const MWWorld::ConstPtr& ptr) const std::string_view ItemLevList::getName(const MWWorld::ConstPtr& ptr) const
{ {
return ""; return {};
} }
bool ItemLevList::hasToolTip(const MWWorld::ConstPtr& ptr) const bool ItemLevList::hasToolTip(const MWWorld::ConstPtr& ptr) const

View file

@ -13,7 +13,7 @@ namespace MWClass
public: public:
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override; bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;

View file

@ -72,12 +72,12 @@ namespace MWClass
return getClassModel<ESM::Light>(ptr); return getClassModel<ESM::Light>(ptr);
} }
std::string Light::getName (const MWWorld::ConstPtr& ptr) const std::string_view Light::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
if (ref->mBase->mModel.empty()) if (ref->mBase->mModel.empty())
return std::string(); return {};
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
return !name.empty() ? name : ref->mBase->mId; return !name.empty() ? name : ref->mBase->mId;
@ -150,7 +150,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;

View file

@ -23,7 +23,7 @@ namespace MWClass
bool useAnim() const override; bool useAnim() const override;
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override; bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;

View file

@ -41,7 +41,7 @@ namespace MWClass
return getClassModel<ESM::Lockpick>(ptr); return getClassModel<ESM::Lockpick>(ptr);
} }
std::string Lockpick::getName (const MWWorld::ConstPtr& ptr) const std::string_view Lockpick::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>(); const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -100,7 +100,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>(); const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;

View file

@ -18,7 +18,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -51,7 +51,7 @@ namespace MWClass
return getClassModel<ESM::Miscellaneous>(ptr); return getClassModel<ESM::Miscellaneous>(ptr);
} }
std::string Miscellaneous::getName (const MWWorld::ConstPtr& ptr) const std::string_view Miscellaneous::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -80,7 +80,7 @@ namespace MWClass
if (ptr.getCellRef().getGoldValue() > 1 && ptr.getRefData().getCount() == 1) if (ptr.getCellRef().getGoldValue() > 1 && ptr.getRefData().getCount() == 1)
value = ptr.getCellRef().getGoldValue(); value = ptr.getCellRef().getGoldValue();
if (ptr.getCellRef().getSoul() != "") if (!ptr.getCellRef().getSoul().empty())
{ {
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(ref->mRef.getSoul()); const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(ref->mRef.getSoul());
if (creature) if (creature)
@ -142,7 +142,8 @@ namespace MWClass
else // gold displays its count also if it's 1. else // gold displays its count also if it's 1.
countString = " (" + std::to_string(count) + ")"; countString = " (" + std::to_string(count) + ")";
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + countString + MWGui::ToolTips::getSoulString(ptr.getCellRef()); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;
@ -171,7 +172,7 @@ namespace MWClass
if (isGold(ptr)) { if (isGold(ptr)) {
int goldAmount = getValue(ptr) * count; int goldAmount = getValue(ptr) * count;
std::string base = "Gold_001"; std::string_view base = "Gold_001";
if (goldAmount >= 100) if (goldAmount >= 100)
base = "Gold_100"; base = "Gold_100";
else if (goldAmount >= 25) else if (goldAmount >= 25)
@ -203,7 +204,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const
{ {
const std::string soulgemPrefix = "misc_soulgem"; const std::string_view soulgemPrefix = "misc_soulgem";
if (::Misc::StringUtils::ciCompareLen(ptr.getCellRef().getRefId(), soulgemPrefix, soulgemPrefix.length()) == 0) if (::Misc::StringUtils::ciCompareLen(ptr.getCellRef().getRefId(), soulgemPrefix, soulgemPrefix.length()) == 0)
return std::make_unique<MWWorld::ActionSoulgem>(ptr); return std::make_unique<MWWorld::ActionSoulgem>(ptr);

View file

@ -18,7 +18,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -523,7 +523,7 @@ namespace MWClass
} }
std::string Npc::getName (const MWWorld::ConstPtr& ptr) const std::string_view Npc::getName(const MWWorld::ConstPtr& ptr) const
{ {
if(ptr.getRefData().getCustomData() && ptr.getRefData().getCustomData()->asNpcCustomData().mNpcStats.isWerewolf()) if(ptr.getRefData().getCustomData() && ptr.getRefData().getCustomData()->asNpcCustomData().mNpcStats.isWerewolf())
{ {
@ -1117,7 +1117,8 @@ namespace MWClass
bool fullHelp = MWBase::Environment::get().getWindowManager()->getFullHelp(); bool fullHelp = MWBase::Environment::get().getWindowManager()->getFullHelp();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()});
if(fullHelp && !ref->mBase->mName.empty() && 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 += " (";

View file

@ -53,7 +53,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const override; MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const override;

View file

@ -43,7 +43,7 @@ namespace MWClass
return getClassModel<ESM::Potion>(ptr); return getClassModel<ESM::Potion>(ptr);
} }
std::string Potion::getName (const MWWorld::ConstPtr& ptr) const std::string_view Potion::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -94,7 +94,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;

View file

@ -18,7 +18,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -41,7 +41,7 @@ namespace MWClass
return getClassModel<ESM::Probe>(ptr); return getClassModel<ESM::Probe>(ptr);
} }
std::string Probe::getName (const MWWorld::ConstPtr& ptr) const std::string_view Probe::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -100,7 +100,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;

View file

@ -18,7 +18,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -38,7 +38,7 @@ namespace MWClass
return getClassModel<ESM::Repair>(ptr); return getClassModel<ESM::Repair>(ptr);
} }
std::string Repair::getName (const MWWorld::ConstPtr& ptr) const std::string_view Repair::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -101,7 +101,8 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>();
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
std::string text; std::string text;

View file

@ -18,7 +18,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -44,9 +44,9 @@ namespace MWClass
return getClassModel<ESM::Static>(ptr); return getClassModel<ESM::Static>(ptr);
} }
std::string Static::getName (const MWWorld::ConstPtr& ptr) const std::string_view Static::getName(const MWWorld::ConstPtr& ptr) const
{ {
return ""; return {};
} }
bool Static::hasToolTip(const MWWorld::ConstPtr& ptr) const bool Static::hasToolTip(const MWWorld::ConstPtr& ptr) const

View file

@ -21,7 +21,7 @@ namespace MWClass
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override; void insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override;
void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override; void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const override;
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
bool hasToolTip (const MWWorld::ConstPtr& ptr) const override; bool hasToolTip (const MWWorld::ConstPtr& ptr) const override;

View file

@ -47,7 +47,7 @@ namespace MWClass
return getClassModel<ESM::Weapon>(ptr); return getClassModel<ESM::Weapon>(ptr);
} }
std::string Weapon::getName (const MWWorld::ConstPtr& ptr) const std::string_view Weapon::getName(const MWWorld::ConstPtr& ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
const std::string& name = ref->mBase->mName; const std::string& name = ref->mBase->mName;
@ -150,7 +150,8 @@ namespace MWClass
const ESM::WeaponType* weaponType = MWMechanics::getWeaponType(ref->mBase->mData.mType); const ESM::WeaponType* weaponType = MWMechanics::getWeaponType(ref->mBase->mData.mType);
MWGui::ToolTipInfo info; MWGui::ToolTipInfo info;
info.caption = MyGUI::TextIterator::toTagsString(getName(ptr)) + MWGui::ToolTips::getCountString(count); std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; info.icon = ref->mBase->mIcon;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
@ -164,7 +165,7 @@ namespace MWClass
int skill = MWMechanics::getWeaponType(ref->mBase->mData.mType)->mSkill; int skill = MWMechanics::getWeaponType(ref->mBase->mData.mType)->mSkill;
const std::string type = ESM::Skill::sSkillNameIds[skill]; const std::string type = ESM::Skill::sSkillNameIds[skill];
std::string oneOrTwoHanded; std::string_view oneOrTwoHanded;
if (weaponType->mWeaponClass == ESM::WeaponType::Melee) if (weaponType->mWeaponClass == ESM::WeaponType::Melee)
{ {
if (weaponType->mFlags & ESM::WeaponType::TwoHanded) if (weaponType->mFlags & ESM::WeaponType::TwoHanded)
@ -173,8 +174,9 @@ namespace MWClass
oneOrTwoHanded = "sOneHanded"; oneOrTwoHanded = "sOneHanded";
} }
text += store.get<ESM::GameSetting>().find(type)->mValue.getString() + text += store.get<ESM::GameSetting>().find(type)->mValue.getString();
((oneOrTwoHanded != "") ? ", " + store.get<ESM::GameSetting>().find(oneOrTwoHanded)->mValue.getString() : ""); if (!oneOrTwoHanded.empty())
text += ", " + store.get<ESM::GameSetting>().find(oneOrTwoHanded)->mValue.getString();
// weapon damage // weapon damage
if (weaponType->mWeaponClass == ESM::WeaponType::Thrown) if (weaponType->mWeaponClass == ESM::WeaponType::Thrown)

View file

@ -18,7 +18,7 @@ namespace MWClass
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override; void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
///< Add reference into a cell for rendering ///< Add reference into a cell for rendering
std::string getName (const MWWorld::ConstPtr& ptr) const override; std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr, std::unique_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -130,7 +130,7 @@ namespace MWDialogue
topic.addEntry (entry); topic.addEntry (entry);
} }
void Journal::removeLastAddedTopicResponse(const std::string &topicId, const std::string &actorName) void Journal::removeLastAddedTopicResponse(const std::string &topicId, std::string_view actorName)
{ {
Topic& topic = getTopic (topicId); Topic& topic = getTopic (topicId);

View file

@ -41,7 +41,7 @@ namespace MWDialogue
void addTopic (const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor) override; void addTopic (const std::string& topicId, const std::string& infoId, const MWWorld::Ptr& actor) override;
/// \note topicId must be lowercase /// \note topicId must be lowercase
void removeLastAddedTopicResponse (const std::string& topicId, const std::string& actorName) override; void removeLastAddedTopicResponse(const std::string& topicId, std::string_view actorName) override;
///< Removes the last topic response added for the given topicId and actor name. ///< Removes the last topic response added for the given topicId and actor name.
/// \note topicId must be lowercase /// \note topicId must be lowercase

View file

@ -59,7 +59,7 @@ namespace MWDialogue
return mEntries.end(); return mEntries.end();
} }
void Topic::removeLastAddedResponse (const std::string& actorName) void Topic::removeLastAddedResponse(std::string_view actorName)
{ {
for (std::vector<MWDialogue::Entry>::reverse_iterator it = mEntries.rbegin(); for (std::vector<MWDialogue::Entry>::reverse_iterator it = mEntries.rbegin();
it != mEntries.rend(); ++it) it != mEntries.rend(); ++it)

View file

@ -2,6 +2,7 @@
#define GAME_MWDIALOG_TOPIC_H #define GAME_MWDIALOG_TOPIC_H
#include <string> #include <string>
#include <string_view>
#include <vector> #include <vector>
#include "journalentry.hpp" #include "journalentry.hpp"
@ -48,7 +49,7 @@ namespace MWDialogue
virtual std::string getName() const; virtual std::string getName() const;
void removeLastAddedResponse (const std::string& actorName); void removeLastAddedResponse(std::string_view actorName);
TEntryIter begin() const; TEntryIter begin() const;
///< Iterator pointing to the begin of the journal for this topic. ///< Iterator pointing to the begin of the journal for this topic.

View file

@ -197,7 +197,7 @@ namespace MWGui
if (item.getType() != ESM::Ingredient::sRecordId) if (item.getType() != ESM::Ingredient::sRecordId)
continue; continue;
itemNames.insert(item.getClass().getName(item)); itemNames.emplace(item.getClass().getName(item));
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
auto const alchemySkill = player.getClass().getSkill(player, ESM::Skill::Alchemy); auto const alchemySkill = player.getClass().getSkill(player, ESM::Skill::Alchemy);

View file

@ -89,7 +89,8 @@ void CompanionWindow::onItemSelected(int index)
if (count > 1 && !shift) if (count > 1 && !shift)
{ {
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog(); CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
std::string name = object.getClass().getName(object) + MWGui::ToolTips::getSoulString(object.getCellRef()); std::string name{object.getClass().getName(object)};
name += MWGui::ToolTips::getSoulString(object.getCellRef());
dialog->openCountDialog(name, "#{sTake}", count); dialog->openCountDialog(name, "#{sTake}", count);
dialog->eventOkClicked.clear(); dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &CompanionWindow::dragItem); dialog->eventOkClicked += MyGUI::newDelegate(this, &CompanionWindow::dragItem);

View file

@ -83,7 +83,8 @@ namespace MWGui
if (count > 1 && !shift) if (count > 1 && !shift)
{ {
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog(); CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
std::string name = object.getClass().getName(object) + MWGui::ToolTips::getSoulString(object.getCellRef()); std::string name{object.getClass().getName(object)};
name += MWGui::ToolTips::getSoulString(object.getCellRef());
dialog->openCountDialog(name, "#{sTake}", count); dialog->openCountDialog(name, "#{sTake}", count);
dialog->eventOkClicked.clear(); dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem); dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem);

View file

@ -98,7 +98,8 @@ namespace MWGui
} }
else else
{ {
mName->setCaption(item.getClass().getName(item)); std::string_view name = item.getClass().getName(item);
mName->setCaption({name.data(), name.size()});
mItemBox->setItem(item); mItemBox->setItem(item);
mItemBox->setUserString ("ToolTipType", "ItemPtr"); mItemBox->setUserString ("ToolTipType", "ItemPtr");
mItemBox->setUserData(MWWorld::Ptr(item)); mItemBox->setUserData(MWWorld::Ptr(item));

View file

@ -422,7 +422,7 @@ namespace MWGui
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
{ {
std::string itemName = item.getClass().getName(item); std::string_view itemName = item.getClass().getName(item);
if (itemName != mSpellName && mSpellVisible) if (itemName != mSpellName && mSpellVisible)
{ {
mWeaponSpellTimer = 5.0f; mWeaponSpellTimer = 5.0f;
@ -442,7 +442,7 @@ namespace MWGui
void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent) void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
{ {
std::string itemName = item.getClass().getName(item); std::string_view itemName = item.getClass().getName(item);
if (itemName != mWeaponName && mWeaponVisible) if (itemName != mWeaponName && mWeaponVisible)
{ {
mWeaponSpellTimer = 5.0f; mWeaponSpellTimer = 5.0f;

View file

@ -293,7 +293,8 @@ namespace MWGui
{ {
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog(); CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
std::string message = mTrading ? "#{sQuanityMenuMessage01}" : "#{sTake}"; std::string message = mTrading ? "#{sQuanityMenuMessage01}" : "#{sTake}";
std::string name = object.getClass().getName(object) + MWGui::ToolTips::getSoulString(object.getCellRef()); std::string name{object.getClass().getName(object)};
name += MWGui::ToolTips::getSoulString(object.getCellRef());
dialog->openCountDialog(name, message, count); dialog->openCountDialog(name, message, count);
dialog->eventOkClicked.clear(); dialog->eventOkClicked.clear();
if (mTrading) if (mTrading)

View file

@ -169,7 +169,8 @@ namespace MWGui
void ItemChargeView::updateLine(const ItemChargeView::Line& line) void ItemChargeView::updateLine(const ItemChargeView::Line& line)
{ {
line.mText->setCaption(line.mItemPtr.getClass().getName(line.mItemPtr)); std::string_view name = line.mItemPtr.getClass().getName(line.mItemPtr);
line.mText->setCaption({name.data(), name.size()});
line.mCharge->setVisible(false); line.mCharge->setVisible(false);
switch (mDisplayMode) switch (mDisplayMode)

View file

@ -52,12 +52,13 @@ namespace MWGui
static_cast<MyGUI::TextBox*>(pt)->setCaption(caption); static_cast<MyGUI::TextBox*>(pt)->setCaption(caption);
} }
void Layout::setTitle(const std::string& title) void Layout::setTitle(std::string_view title)
{ {
MyGUI::Window* window = static_cast<MyGUI::Window*>(mMainWidget); MyGUI::Window* window = static_cast<MyGUI::Window*>(mMainWidget);
MyGUI::UString uTitle{title.data(), title.size()};
if (window->getCaption() != title) if (window->getCaption() != uTitle)
window->setCaptionWithReplacing(title); window->setCaptionWithReplacing(uTitle);
} }
MyGUI::Widget* Layout::getWidget(std::string_view _name) MyGUI::Widget* Layout::getWidget(std::string_view _name)

View file

@ -64,7 +64,7 @@ namespace MWGui
void setText(std::string_view name, const std::string& caption); void setText(std::string_view name, const std::string& caption);
// NOTE: this assume that mMainWidget is of type Window. // NOTE: this assume that mMainWidget is of type Window.
void setTitle(const std::string& title); void setTitle(std::string_view title);
MyGUI::Widget* mMainWidget; MyGUI::Widget* mMainWidget;

View file

@ -67,8 +67,8 @@ void MerchantRepair::setPtr(const MWWorld::Ptr &actor)
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mActor, x, true); int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mActor, x, true);
std::string name = iter->getClass().getName(*iter) std::string name{iter->getClass().getName(*iter)};
+ " - " + MyGUI::utility::toString(price) name += " - " + MyGUI::utility::toString(price)
+ MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>() + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("sgp")->mValue.getString(); .find("sgp")->mValue.getString();

View file

@ -188,7 +188,8 @@ namespace MWGui
{ {
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog(); CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
std::string message = "#{sQuanityMenuMessage02}"; std::string message = "#{sQuanityMenuMessage02}";
std::string name = object.getClass().getName(object) + MWGui::ToolTips::getSoulString(object.getCellRef()); std::string name{object.getClass().getName(object)};
name += MWGui::ToolTips::getSoulString(object.getCellRef());
dialog->openCountDialog(name, message, count); dialog->openCountDialog(name, message, count);
dialog->eventOkClicked.clear(); dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &TradeWindow::sellItem); dialog->eventOkClicked += MyGUI::newDelegate(this, &TradeWindow::sellItem);

View file

@ -160,7 +160,7 @@ namespace MWScript
{ {
// The two GMST entries below expand to strings informing the player of what, and how many of it has been added to their inventory // The two GMST entries below expand to strings informing the player of what, and how many of it has been added to their inventory
std::string msgBox; std::string msgBox;
std::string itemName = itemPtr.getClass().getName(itemPtr); std::string_view itemName = itemPtr.getClass().getName(itemPtr);
if (count == 1) if (count == 1)
{ {
msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage60}"); msgBox = MyGUI::LanguageManager::getInstance().replaceTags("#{sNotifyMessage60}");
@ -256,7 +256,7 @@ namespace MWScript
} }
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr); MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr);
std::string itemName; std::string_view itemName;
for (MWWorld::ConstContainerStoreIterator iter(store.cbegin()); iter != store.cend(); ++iter) for (MWWorld::ConstContainerStoreIterator iter(store.cbegin()); iter != store.cend(); ++iter)
{ {
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item)) if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))

View file

@ -43,7 +43,8 @@ namespace MWWorld
MWBase::Environment::get().getMechanicsManager()->itemTaken(actor, *it, target, itemCount); MWBase::Environment::get().getMechanicsManager()->itemTaken(actor, *it, target, itemCount);
actorStore.add(*it, itemCount, actor); actorStore.add(*it, itemCount, actor);
store.remove(*it, itemCount, getTarget()); store.remove(*it, itemCount, getTarget());
takenMap[it->getClass().getName(*it)]+=itemCount; std::string name{it->getClass().getName(*it)};
takenMap[name]+=itemCount;
} }
// Spawn a messagebox (only for items added to player's inventory) // Spawn a messagebox (only for items added to player's inventory)

View file

@ -84,7 +84,7 @@ namespace MWWorld
///< Add reference into a cell for rendering (default implementation: don't render anything). ///< Add reference into a cell for rendering (default implementation: don't render anything).
virtual void insertObjectPhysics(const Ptr& ptr, const std::string& mesh, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const; virtual void insertObjectPhysics(const Ptr& ptr, const std::string& mesh, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const;
virtual std::string getName (const ConstPtr& ptr) const = 0; virtual std::string_view getName(const ConstPtr& ptr) const = 0;
///< \return name or ID; can return an empty string. ///< \return name or ID; can return an empty string.
virtual void adjustPosition(const MWWorld::Ptr& ptr, bool force) const; virtual void adjustPosition(const MWWorld::Ptr& ptr, bool force) const;

View file

@ -16,10 +16,15 @@ namespace Misc::StringUtils
template <typename T> template <typename T>
T argument(T value) noexcept T argument(T value) noexcept
{ {
static_assert(!std::is_same_v<T, std::string_view>, "std::string_view is not supported");
return value; return value;
} }
template <typename T>
T const * argument(std::basic_string_view<T> const & value) noexcept
{
return value.data();
}
template <typename T> template <typename T>
T const * argument(std::basic_string<T> const & value) noexcept T const * argument(std::basic_string<T> const & value) noexcept
{ {

View file

@ -122,14 +122,14 @@ public:
return ch; return ch;
} }
static std::string lowerCaseUtf8(const std::string& str) static std::string lowerCaseUtf8(std::string_view str)
{ {
if (str.empty()) if (str.empty())
return str; return std::string{str};
// Decode string as utf8 characters, convert to lower case and pack them to string // Decode string as utf8 characters, convert to lower case and pack them to string
std::string out; std::string out;
Utf8Stream stream (str.c_str()); Utf8Stream stream (str);
while (!stream.eof ()) while (!stream.eof ())
{ {
UnicodeChar character = toLowerUtf8(stream.peek()); UnicodeChar character = toLowerUtf8(stream.peek());