mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-03 17:54:06 +00:00
Merge branch 'fix_hitting_people' into 'master'
Use string_view in the remaining Class methods and push string_views closer to the MyGUI boundary See merge request OpenMW/openmw!2331
This commit is contained in:
commit
a50b9b9876
@ -241,13 +241,12 @@ namespace MWBase
|
||||
/** No guarantee of actually closing the window **/
|
||||
virtual void exitCurrentGuiMode() = 0;
|
||||
|
||||
virtual void messageBox (const std::string& message, enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) = 0;
|
||||
virtual void messageBox(std::string_view message, enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) = 0;
|
||||
/// Puts message into a queue to show on the next update. Thread safe alternative for messageBox.
|
||||
virtual void scheduleMessageBox(std::string message, enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) = 0;
|
||||
virtual void staticMessageBox(const std::string& message) = 0;
|
||||
virtual void staticMessageBox(std::string_view message) = 0;
|
||||
virtual void removeStaticMessageBox() = 0;
|
||||
virtual void interactiveMessageBox (const std::string& message,
|
||||
const std::vector<std::string>& buttons = std::vector<std::string>(), bool block=false) = 0;
|
||||
virtual void interactiveMessageBox(std::string_view message, const std::vector<std::string>& buttons = {}, bool block = false) = 0;
|
||||
|
||||
/// returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||
virtual int readPressedButton() = 0;
|
||||
|
@ -283,18 +283,18 @@ namespace MWClass
|
||||
return ref->mBase->mData.mArmor * armorSkill / static_cast<float>(iBaseArmorSkill);
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
|
||||
std::pair<int, std::string_view> Armor::canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const
|
||||
{
|
||||
const MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
|
||||
|
||||
if (getItemHealth(ptr) == 0)
|
||||
return std::make_pair(0, "#{sInventoryMessage1}");
|
||||
return {0, "#{sInventoryMessage1}"};
|
||||
|
||||
// slots that this item can be equipped in
|
||||
std::pair<std::vector<int>, bool> slots_ = getEquipmentSlots(ptr);
|
||||
|
||||
if (slots_.first.empty())
|
||||
return std::make_pair(0, "");
|
||||
return {0, {}};
|
||||
|
||||
if (npc.getClass().isNpc())
|
||||
{
|
||||
@ -309,9 +309,9 @@ namespace MWClass
|
||||
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
||||
{
|
||||
if((*itr).mPart == ESM::PRT_Head)
|
||||
return std::make_pair(0, "#{sNotifyMessage13}");
|
||||
return {0, "#{sNotifyMessage13}"};
|
||||
if((*itr).mPart == ESM::PRT_LFoot || (*itr).mPart == ESM::PRT_RFoot)
|
||||
return std::make_pair(0, "#{sNotifyMessage14}");
|
||||
return {0, "#{sNotifyMessage14}"};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,13 +327,13 @@ namespace MWClass
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>();
|
||||
if (MWMechanics::getWeaponType(ref->mBase->mData.mType)->mFlags & ESM::WeaponType::TwoHanded)
|
||||
return std::make_pair(3,"");
|
||||
return {3, {}};
|
||||
}
|
||||
|
||||
return std::make_pair(1,"");
|
||||
return {1, {}};
|
||||
}
|
||||
}
|
||||
return std::make_pair(1,"");
|
||||
return {1, {}};
|
||||
}
|
||||
|
||||
std::unique_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr, bool force) const
|
||||
|
@ -65,7 +65,7 @@ namespace MWClass
|
||||
const std::string& applyEnchantment(const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge, const std::string& newName) const override;
|
||||
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
|
||||
|
||||
std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override;
|
||||
std::pair<int, std::string_view> canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const override;
|
||||
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. \n
|
||||
/// Second item in the pair specifies the error message
|
||||
|
||||
|
@ -195,13 +195,13 @@ namespace MWClass
|
||||
return record->mId;
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Clothing::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
|
||||
std::pair<int, std::string_view> Clothing::canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const
|
||||
{
|
||||
// slots that this item can be equipped in
|
||||
std::pair<std::vector<int>, bool> slots_ = getEquipmentSlots(ptr);
|
||||
|
||||
if (slots_.first.empty())
|
||||
return std::make_pair(0, "");
|
||||
return {0, {}};
|
||||
|
||||
if (npc.getClass().isNpc())
|
||||
{
|
||||
@ -216,14 +216,14 @@ namespace MWClass
|
||||
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
||||
{
|
||||
if((*itr).mPart == ESM::PRT_Head)
|
||||
return std::make_pair(0, "#{sNotifyMessage13}");
|
||||
return {0, "#{sNotifyMessage13}"};
|
||||
if((*itr).mPart == ESM::PRT_LFoot || (*itr).mPart == ESM::PRT_RFoot)
|
||||
return std::make_pair(0, "#{sNotifyMessage15}");
|
||||
return {0, "#{sNotifyMessage15}"};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair (1, "");
|
||||
return {1, {}};
|
||||
}
|
||||
|
||||
std::unique_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr, bool force) const
|
||||
|
@ -57,7 +57,7 @@ namespace MWClass
|
||||
const std::string& applyEnchantment(const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge, const std::string& newName) const override;
|
||||
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
|
||||
|
||||
std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override;
|
||||
std::pair<int, std::string_view> canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const override;
|
||||
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
||||
/// Second item in the pair specifies the error message
|
||||
|
||||
|
@ -224,16 +224,16 @@ namespace MWClass
|
||||
return ref->mBase->mData.mWeight;
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Light::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
|
||||
std::pair<int, std::string_view> Light::canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
|
||||
if (!(ref->mBase->mData.mFlags & ESM::Light::Carry))
|
||||
return std::make_pair(0,"");
|
||||
return {0, {}};
|
||||
|
||||
return std::make_pair(1,"");
|
||||
return {1, {}};
|
||||
}
|
||||
|
||||
std::string Light::getSound(const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Light::getSound(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return ptr.get<ESM::Light>()->mBase->mSound;
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ namespace MWClass
|
||||
|
||||
bool canSell (const MWWorld::ConstPtr& item, int npcServices) const override;
|
||||
|
||||
std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override;
|
||||
std::pair<int, std::string_view> canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const override;
|
||||
|
||||
std::string getSound(const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getSound(const MWWorld::ConstPtr& ptr) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -137,14 +137,14 @@ namespace MWClass
|
||||
return MWWorld::Ptr(cell.insert(ref), &cell);
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Lockpick::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
|
||||
std::pair<int, std::string_view> Lockpick::canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const
|
||||
{
|
||||
// Do not allow equip tools from inventory during attack
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(npc)
|
||||
&& MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
return std::make_pair(0, "#{sCantEquipWeapWarning}");
|
||||
return {0, "#{sCantEquipWeapWarning}"};
|
||||
|
||||
return std::make_pair(1, "");
|
||||
return {1, {}};
|
||||
}
|
||||
|
||||
bool Lockpick::canSell (const MWWorld::ConstPtr& item, int npcServices) const
|
||||
|
@ -47,7 +47,7 @@ namespace MWClass
|
||||
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return name of inventory icon.
|
||||
|
||||
std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override;
|
||||
std::pair<int, std::string_view> canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const override;
|
||||
|
||||
std::unique_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
||||
///< Generate action for using via inventory menu
|
||||
|
@ -499,7 +499,7 @@ namespace MWClass
|
||||
|
||||
for (std::vector<ESM::PartReference>::const_iterator it = parts.begin(); it != parts.end(); ++it)
|
||||
{
|
||||
std::string partname = female ? it->mFemale : it->mMale;
|
||||
std::string_view partname = female ? it->mFemale : it->mMale;
|
||||
if (partname.empty())
|
||||
partname = female ? it->mMale : it->mFemale;
|
||||
const ESM::BodyPart* part = MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(partname);
|
||||
@ -1400,7 +1400,7 @@ namespace MWClass
|
||||
return ref->mBase->mNpdt.mGold;
|
||||
}
|
||||
|
||||
bool Npc::isClass(const MWWorld::ConstPtr& ptr, const std::string &className) const
|
||||
bool Npc::isClass(const MWWorld::ConstPtr& ptr, std::string_view className) const
|
||||
{
|
||||
return Misc::StringUtils::ciEqual(ptr.get<ESM::NPC>()->mBase->mClass, className);
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ namespace MWClass
|
||||
|
||||
int getBaseGold(const MWWorld::ConstPtr& ptr) const override;
|
||||
|
||||
bool isClass(const MWWorld::ConstPtr& ptr, const std::string &className) const override;
|
||||
bool isClass(const MWWorld::ConstPtr& ptr, std::string_view className) const override;
|
||||
|
||||
bool canSwim (const MWWorld::ConstPtr &ptr) const override;
|
||||
|
||||
|
@ -137,14 +137,14 @@ namespace MWClass
|
||||
return MWWorld::Ptr(cell.insert(ref), &cell);
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Probe::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
|
||||
std::pair<int, std::string_view> Probe::canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const
|
||||
{
|
||||
// Do not allow equip tools from inventory during attack
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(npc)
|
||||
&& MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
return std::make_pair(0, "#{sCantEquipWeapWarning}");
|
||||
return {0, "#{sCantEquipWeapWarning}"};
|
||||
|
||||
return std::make_pair(1, "");
|
||||
return {1, {}};
|
||||
}
|
||||
|
||||
bool Probe::canSell (const MWWorld::ConstPtr& item, int npcServices) const
|
||||
|
@ -47,7 +47,7 @@ namespace MWClass
|
||||
const std::string& getInventoryIcon(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return name of inventory icon.
|
||||
|
||||
std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override;
|
||||
std::pair<int, std::string_view> canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const override;
|
||||
|
||||
std::unique_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
||||
///< Generate action for using via inventory menu
|
||||
|
@ -271,28 +271,28 @@ namespace MWClass
|
||||
return record->mId;
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Weapon::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
|
||||
std::pair<int, std::string_view> Weapon::canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const
|
||||
{
|
||||
if (hasItemHealth(ptr) && getItemHealth(ptr) == 0)
|
||||
return std::make_pair(0, "#{sInventoryMessage1}");
|
||||
return {0, "#{sInventoryMessage1}"};
|
||||
|
||||
// Do not allow equip weapons from inventory during attack
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(npc)
|
||||
&& MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
return std::make_pair(0, "#{sCantEquipWeapWarning}");
|
||||
return {0, "#{sCantEquipWeapWarning}"};
|
||||
|
||||
std::pair<std::vector<int>, bool> slots_ = getEquipmentSlots(ptr);
|
||||
|
||||
if (slots_.first.empty())
|
||||
return std::make_pair (0, "");
|
||||
return {0, {}};
|
||||
|
||||
int type = ptr.get<ESM::Weapon>()->mBase->mData.mType;
|
||||
if(MWMechanics::getWeaponType(type)->mFlags & ESM::WeaponType::TwoHanded)
|
||||
{
|
||||
return std::make_pair (2, "");
|
||||
return {2, {}};
|
||||
}
|
||||
|
||||
return std::make_pair(1, "");
|
||||
return {1, {}};
|
||||
}
|
||||
|
||||
std::unique_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr, bool force) const
|
||||
|
@ -63,7 +63,7 @@ namespace MWClass
|
||||
const std::string& applyEnchantment(const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge, const std::string& newName) const override;
|
||||
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
|
||||
|
||||
std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const override;
|
||||
std::pair<int, std::string_view> canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const override;
|
||||
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
||||
/// Second item in the pair specifies the error message
|
||||
|
||||
|
@ -126,7 +126,7 @@ namespace MWGui
|
||||
if (count == 1)
|
||||
winMgr->messageBox("#{sPotionSuccess}");
|
||||
else
|
||||
winMgr->messageBox("#{sPotionSuccess} "+mNameEdit->getCaption()+" ("+std::to_string(count)+")");
|
||||
winMgr->messageBox("#{sPotionSuccess} "+mNameEdit->getCaption().asUTF8()+" ("+std::to_string(count)+")");
|
||||
break;
|
||||
case MWMechanics::Alchemy::Result_NoEffects:
|
||||
case MWMechanics::Alchemy::Result_RandomFailure:
|
||||
|
@ -539,7 +539,7 @@ namespace MWGui
|
||||
|
||||
if (!force)
|
||||
{
|
||||
std::pair<int, std::string> canEquip = ptr.getClass().canBeEquipped(ptr, player);
|
||||
auto canEquip = ptr.getClass().canBeEquipped(ptr, player);
|
||||
|
||||
if (canEquip.first == 0)
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ namespace MWGui
|
||||
// we may still want to show the label if the caller requested it
|
||||
if (mImportantLabel)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(mLoadingText->getCaption());
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(mLoadingText->getCaption().asUTF8());
|
||||
mImportantLabel = false;
|
||||
}
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ namespace MWGui
|
||||
}
|
||||
}
|
||||
|
||||
void MessageBoxManager::createMessageBox (const std::string& message, bool stat)
|
||||
void MessageBoxManager::createMessageBox(std::string_view message, bool stat)
|
||||
{
|
||||
MessageBox *box = new MessageBox(*this, message);
|
||||
box->mCurrentTime = 0;
|
||||
std::string realMessage = MyGUI::LanguageManager::getInstance().replaceTags(message);
|
||||
auto realMessage = MyGUI::LanguageManager::getInstance().replaceTags({message.data(), message.size()});
|
||||
box->mMaxTime = realMessage.length()*mMessageBoxSpeed;
|
||||
|
||||
if(stat)
|
||||
@ -122,7 +122,7 @@ namespace MWGui
|
||||
mStaticMessageBox = nullptr;
|
||||
}
|
||||
|
||||
bool MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons)
|
||||
bool MessageBoxManager::createInteractiveMessageBox(std::string_view message, const std::vector<std::string>& buttons)
|
||||
{
|
||||
if (mInterMessageBoxe != nullptr)
|
||||
{
|
||||
@ -132,7 +132,7 @@ namespace MWGui
|
||||
mInterMessageBoxe = nullptr;
|
||||
}
|
||||
|
||||
mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons);
|
||||
mInterMessageBoxe = new InteractiveMessageBox(*this, std::string{message}, buttons);
|
||||
mLastButtonPressed = -1;
|
||||
|
||||
return true;
|
||||
@ -178,7 +178,7 @@ namespace MWGui
|
||||
messageBox->setVisible(value);
|
||||
}
|
||||
|
||||
MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message)
|
||||
MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, std::string_view message)
|
||||
: Layout("openmw_messagebox.layout")
|
||||
, mCurrentTime(0)
|
||||
, mMaxTime(0)
|
||||
|
@ -21,9 +21,9 @@ namespace MWGui
|
||||
MessageBoxManager (float timePerChar);
|
||||
~MessageBoxManager ();
|
||||
void onFrame (float frameDuration);
|
||||
void createMessageBox (const std::string& message, bool stat = false);
|
||||
void createMessageBox(std::string_view message, bool stat = false);
|
||||
void removeStaticMessageBox ();
|
||||
bool createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons);
|
||||
bool createInteractiveMessageBox(std::string_view message, const std::vector<std::string>& buttons);
|
||||
bool isInteractiveMessageBox ();
|
||||
|
||||
int getMessagesCount();
|
||||
@ -61,8 +61,7 @@ namespace MWGui
|
||||
class MessageBox : public Layout
|
||||
{
|
||||
public:
|
||||
MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message);
|
||||
void setMessage (const std::string& message);
|
||||
MessageBox (MessageBoxManager& parMessageBoxManager, std::string_view message);
|
||||
const std::string& getMessage() { return mMessage; };
|
||||
int getHeight ();
|
||||
void update (int height);
|
||||
|
@ -434,7 +434,7 @@ namespace MWGui
|
||||
}
|
||||
else if (key->type == Type_Magic)
|
||||
{
|
||||
std::string spellId = key->id;
|
||||
const std::string& spellId = key->id;
|
||||
|
||||
// Make sure the player still has this spell
|
||||
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||
@ -534,8 +534,7 @@ namespace MWGui
|
||||
break;
|
||||
}
|
||||
case Type_Magic:
|
||||
std::string spellId = button->getUserString("Spell");
|
||||
key.mId = spellId;
|
||||
key.mId = button->getUserString("Spell");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -714,7 +714,7 @@ namespace MWGui
|
||||
popGuiMode();
|
||||
}
|
||||
|
||||
void WindowManager::interactiveMessageBox(const std::string &message, const std::vector<std::string> &buttons, bool block)
|
||||
void WindowManager::interactiveMessageBox(std::string_view message, const std::vector<std::string> &buttons, bool block)
|
||||
{
|
||||
mMessageBoxManager->createInteractiveMessageBox(message, buttons);
|
||||
updateVisible();
|
||||
@ -749,10 +749,10 @@ namespace MWGui
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::messageBox (const std::string& message, enum MWGui::ShowInDialogueMode showInDialogueMode)
|
||||
void WindowManager::messageBox(std::string_view message, enum MWGui::ShowInDialogueMode showInDialogueMode)
|
||||
{
|
||||
if (getMode() == GM_Dialogue && showInDialogueMode != MWGui::ShowInDialogueMode_Never) {
|
||||
mDialogueWindow->addMessageBox(MyGUI::LanguageManager::getInstance().replaceTags(message));
|
||||
mDialogueWindow->addMessageBox(MyGUI::LanguageManager::getInstance().replaceTags({message.data(), message.size()}));
|
||||
} else if (showInDialogueMode != MWGui::ShowInDialogueMode_Only) {
|
||||
mMessageBoxManager->createMessageBox(message);
|
||||
}
|
||||
@ -763,7 +763,7 @@ namespace MWGui
|
||||
mScheduledMessageBoxes.lock()->emplace_back(std::move(message), showInDialogueMode);
|
||||
}
|
||||
|
||||
void WindowManager::staticMessageBox(const std::string& message)
|
||||
void WindowManager::staticMessageBox(std::string_view message)
|
||||
{
|
||||
mMessageBoxManager->createMessageBox(message, true);
|
||||
}
|
||||
|
@ -272,12 +272,11 @@ namespace MWGui
|
||||
///Gracefully attempts to exit the topmost GUI mode
|
||||
void exitCurrentGuiMode() override;
|
||||
|
||||
void messageBox (const std::string& message, enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) override;
|
||||
void messageBox(std::string_view message, enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) override;
|
||||
void scheduleMessageBox (std::string message, enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) override;
|
||||
void staticMessageBox(const std::string& message) override;
|
||||
void staticMessageBox(std::string_view message) override;
|
||||
void removeStaticMessageBox() override;
|
||||
void interactiveMessageBox (const std::string& message,
|
||||
const std::vector<std::string>& buttons = std::vector<std::string>(), bool block=false) override;
|
||||
void interactiveMessageBox(std::string_view message, const std::vector<std::string>& buttons = {}, bool block = false) override;
|
||||
|
||||
int readPressedButton () override; ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||
|
||||
|
@ -567,7 +567,7 @@ namespace MWRender
|
||||
|
||||
size_t Animation::detectBlendMask(const osg::Node* node) const
|
||||
{
|
||||
static const char sBlendMaskRoots[sNumBlendMasks][32] = {
|
||||
static const std::string_view sBlendMaskRoots[sNumBlendMasks] = {
|
||||
"", /* Lower body / character root */
|
||||
"Bip01 Spine1", /* Torso */
|
||||
"Bip01 L Clavicle", /* Left arm */
|
||||
@ -742,7 +742,7 @@ namespace MWRender
|
||||
|
||||
for(auto iterKey = keys.begin(); iterKey != keys.end(); ++iterKey)
|
||||
{
|
||||
if(iterKey->second.starts_with(textKey) == 0)
|
||||
if(iterKey->second.starts_with(textKey))
|
||||
return iterKey->first;
|
||||
}
|
||||
}
|
||||
|
@ -816,10 +816,10 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mSoundsDisabled)
|
||||
if (!mSoundsDisabled && group == MWWorld::InventoryStore::Slot_CarriedLeft)
|
||||
{
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator csi = inv.getSlot(group < 0 ? MWWorld::InventoryStore::Slot_Helmet : group);
|
||||
MWWorld::ConstContainerStoreIterator csi = inv.getSlot(group);
|
||||
if (csi != inv.end())
|
||||
{
|
||||
const auto soundId = csi->getClass().getSound(*csi);
|
||||
|
@ -32,7 +32,7 @@ class TextureOverrideVisitor : public osg::NodeVisitor
|
||||
}
|
||||
traverse(node);
|
||||
}
|
||||
std::string mTexture;
|
||||
std::string_view mTexture;
|
||||
Resource::ResourceSystem* mResourcesystem;
|
||||
};
|
||||
|
||||
|
@ -185,7 +185,7 @@ namespace MWScript
|
||||
mLocals->mFloats.at (index) = value;
|
||||
}
|
||||
|
||||
void InterpreterContext::messageBox (const std::string& message,
|
||||
void InterpreterContext::messageBox(std::string_view message,
|
||||
const std::vector<std::string>& buttons)
|
||||
{
|
||||
if (buttons.empty())
|
||||
|
@ -61,7 +61,7 @@ namespace MWScript
|
||||
|
||||
using Interpreter::Context::messageBox;
|
||||
|
||||
void messageBox (const std::string& message,
|
||||
void messageBox(std::string_view message,
|
||||
const std::vector<std::string>& buttons) override;
|
||||
|
||||
void report (const std::string& message) override;
|
||||
|
@ -36,7 +36,7 @@ namespace MWScript
|
||||
std::string file{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
runtime.pop();
|
||||
|
||||
std::string text{runtime.getStringLiteral(runtime[0].mInteger)};
|
||||
std::string_view text = runtime.getStringLiteral(runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->say (ptr, file);
|
||||
|
@ -34,7 +34,7 @@ namespace MWWorld
|
||||
|
||||
if (!mForce)
|
||||
{
|
||||
std::pair <int, std::string> result = object.getClass().canBeEquipped (object, actor);
|
||||
auto result = object.getClass().canBeEquipped (object, actor);
|
||||
|
||||
// display error message if the player tried to equip something
|
||||
if (!result.second.empty() && actor == MWMechanics::getPlayer())
|
||||
|
@ -325,9 +325,9 @@ namespace MWWorld
|
||||
throw std::runtime_error ("class can't be enchanted");
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Class::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
|
||||
std::pair<int, std::string_view> Class::canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const
|
||||
{
|
||||
return std::make_pair (1, "");
|
||||
return {1, {}};
|
||||
}
|
||||
|
||||
void Class::adjustPosition(const MWWorld::Ptr& ptr, bool force) const
|
||||
@ -449,7 +449,7 @@ namespace MWWorld
|
||||
throw std::runtime_error("class does not support base gold");
|
||||
}
|
||||
|
||||
bool Class::isClass(const MWWorld::ConstPtr& ptr, const std::string &className) const
|
||||
bool Class::isClass(const MWWorld::ConstPtr& ptr, std::string_view className) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -478,9 +478,9 @@ namespace MWWorld
|
||||
return encumbrance / capacity;
|
||||
}
|
||||
|
||||
std::string Class::getSound(const MWWorld::ConstPtr&) const
|
||||
std::string_view Class::getSound(const MWWorld::ConstPtr&) const
|
||||
{
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
int Class::getBaseFightRating(const ConstPtr &ptr) const
|
||||
|
@ -281,7 +281,7 @@ namespace MWWorld
|
||||
virtual const std::string& applyEnchantment(const MWWorld::ConstPtr& ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
|
||||
|
||||
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const;
|
||||
virtual std::pair<int, std::string_view> canBeEquipped(const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const;
|
||||
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
||||
/// Second item in the pair specifies the error message
|
||||
|
||||
@ -345,7 +345,7 @@ namespace MWWorld
|
||||
|
||||
virtual int getBaseGold(const MWWorld::ConstPtr& ptr) const;
|
||||
|
||||
virtual bool isClass(const MWWorld::ConstPtr& ptr, const std::string &className) const;
|
||||
virtual bool isClass(const MWWorld::ConstPtr& ptr, std::string_view className) const;
|
||||
|
||||
virtual DoorState getDoorState (const MWWorld::ConstPtr &ptr) const;
|
||||
/// This does not actually cause the door to move. Use World::activateDoor instead.
|
||||
@ -354,7 +354,7 @@ namespace MWWorld
|
||||
virtual void respawn (const MWWorld::Ptr& ptr) const {}
|
||||
|
||||
/// Returns sound id
|
||||
virtual std::string getSound(const MWWorld::ConstPtr& ptr) const;
|
||||
virtual std::string_view getSound(const MWWorld::ConstPtr& ptr) const;
|
||||
|
||||
virtual int getBaseFightRating (const MWWorld::ConstPtr& ptr) const;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
FailedAction::FailedAction(const std::string &msg, const Ptr& target)
|
||||
FailedAction::FailedAction(std::string_view msg, const Ptr& target)
|
||||
: Action(false, target), mMessage(msg)
|
||||
{ }
|
||||
|
||||
|
@ -8,12 +8,12 @@ namespace MWWorld
|
||||
{
|
||||
class FailedAction : public Action
|
||||
{
|
||||
std::string mMessage;
|
||||
std::string_view mMessage;
|
||||
|
||||
void executeImp(const Ptr &actor) override;
|
||||
|
||||
public:
|
||||
FailedAction(const std::string &message = std::string(), const Ptr& target = Ptr());
|
||||
FailedAction(std::string_view message = {}, const Ptr& target = Ptr());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2971,7 +2971,7 @@ namespace MWWorld
|
||||
{
|
||||
MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor);
|
||||
|
||||
std::string message;
|
||||
std::string_view message;
|
||||
MWWorld::SpellCastState result = MWWorld::SpellCastState::Success;
|
||||
bool isPlayer = (actor == getPlayerPtr());
|
||||
|
||||
|
@ -154,7 +154,7 @@ namespace
|
||||
|
||||
void setLocalFloat(int index, float value) override { mLocals.setFloat(index, value); };
|
||||
|
||||
void messageBox(const std::string& message, const std::vector<std::string>& buttons) override {};
|
||||
void messageBox(std::string_view message, const std::vector<std::string>& buttons) override {};
|
||||
|
||||
void report(const std::string& message) override {};
|
||||
|
||||
|
@ -27,10 +27,10 @@ namespace Interpreter
|
||||
|
||||
virtual void setLocalFloat (int index, float value) = 0;
|
||||
|
||||
virtual void messageBox (const std::string& message,
|
||||
virtual void messageBox(std::string_view message,
|
||||
const std::vector<std::string>& buttons) = 0;
|
||||
|
||||
void messageBox (const std::string& message)
|
||||
void messageBox(std::string_view message)
|
||||
{
|
||||
std::vector<std::string> empty;
|
||||
messageBox (message, empty);
|
||||
|
@ -171,7 +171,7 @@ float makeOsgColorComponent(unsigned int value, unsigned int shift)
|
||||
return float((value >> shift) & 0xFFu) / 255.0f;
|
||||
}
|
||||
|
||||
bool hasUserDescription(const osg::Node* node, const std::string& pattern)
|
||||
bool hasUserDescription(const osg::Node* node, std::string_view pattern)
|
||||
{
|
||||
if (node == nullptr)
|
||||
return false;
|
||||
|
@ -87,7 +87,7 @@ namespace SceneUtil
|
||||
|
||||
float makeOsgColorComponent (unsigned int value, unsigned int shift);
|
||||
|
||||
bool hasUserDescription(const osg::Node* node, const std::string& pattern);
|
||||
bool hasUserDescription(const osg::Node* node, std::string_view pattern);
|
||||
|
||||
osg::ref_ptr<GlowUpdater> addEnchantedGlow(osg::ref_ptr<osg::Node> node, Resource::ResourceSystem* resourceSystem, const osg::Vec4f& glowColor, float glowDuration=-1);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user