Return string_view from getGameSettingString

crashfix_debugdraw
Evil Eye 2 years ago
parent 0cded25033
commit 1d21330fcc

@ -260,7 +260,7 @@ namespace MWBase
* @param id Identifier for the GMST setting, e.g. "aName"
* @param default Default value if the GMST setting cannot be used.
*/
virtual std::string getGameSettingString(const std::string &id, const std::string &default_) = 0;
virtual std::string_view getGameSettingString(std::string_view id, std::string_view default_) = 0;
virtual void processChangedSettings(const std::set< std::pair<std::string, std::string> >& changed) = 0;

@ -24,6 +24,7 @@
#include "../mwrender/vismask.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwmechanics/npcstats.hpp"
@ -96,7 +97,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp())

@ -15,6 +15,7 @@
#include "../mwrender/renderinginterface.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "classmodel.hpp"
@ -88,7 +89,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -23,6 +23,7 @@
#include "../mwmechanics/weapontype.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "classmodel.hpp"
@ -194,7 +195,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -18,6 +18,7 @@
#include "../mwrender/renderinginterface.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwmechanics/npcstats.hpp"
@ -105,7 +106,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -15,6 +15,7 @@
#include "../mwworld/esmstore.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -152,7 +153,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -22,6 +22,7 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/animation.hpp"
#include "../mwrender/objects.hpp"
@ -246,7 +247,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()});
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name));
std::string text;
int lockLevel = ptr.getCellRef().getLockLevel();

@ -40,6 +40,7 @@
#include "../mwrender/objects.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "classmodel.hpp"
@ -589,7 +590,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()});
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name));
std::string text;
if (MWBase::Environment::get().getWindowManager()->getFullHelp())

@ -24,6 +24,7 @@
#include "../mwworld/containerstore.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -267,7 +268,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()});
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name));
std::string text;

@ -14,6 +14,7 @@
#include "../mwworld/actioneat.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -100,7 +101,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -19,6 +19,7 @@
#include "../mwphysics/physicssystem.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -151,7 +152,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -14,6 +14,7 @@
#include "../mwworld/cellstore.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -99,7 +100,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -16,6 +16,7 @@
#include "../mwworld/actionsoulgem.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -142,7 +143,7 @@ namespace MWClass
countString = " (" + std::to_string(count) + ")";
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -55,6 +55,7 @@
#include "../mwrender/npcanimation.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
namespace
{
@ -1118,7 +1119,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()});
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name));
if(fullHelp && !ref->mBase->mName.empty() && ptr.getRefData().getCustomData() && ptr.getRefData().getCustomData()->asNpcCustomData().mNpcStats.isWerewolf())
{
info.caption += " (";

@ -13,6 +13,7 @@
#include "../mwworld/cellstore.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -92,7 +93,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -14,6 +14,7 @@
#include "../mwworld/cellstore.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -99,7 +100,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -12,6 +12,7 @@
#include "../mwworld/actionrepair.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -101,7 +102,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
std::string text;

@ -20,6 +20,7 @@
#include "../mwmechanics/weapontype.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwgui/ustring.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -149,7 +150,7 @@ namespace MWClass
MWGui::ToolTipInfo info;
std::string_view name = getName(ptr);
info.caption = MyGUI::TextIterator::toTagsString({name.data(), name.size()}) + MWGui::ToolTips::getCountString(count);
info.caption = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();

@ -24,6 +24,7 @@
#include "sortfilteritemmodel.hpp"
#include "itemview.hpp"
#include "itemwidget.hpp"
#include "ustring.hpp"
#include "widgets.hpp"
namespace MWGui
@ -151,10 +152,9 @@ namespace MWGui
void AlchemyWindow::initFilter()
{
auto const& wm = MWBase::Environment::get().getWindowManager();
auto const ingredient = wm->getGameSettingString("sIngredients", "Ingredients");
auto const effect = wm->getGameSettingString("sMagicEffects", "Magic Effects");
std::string_view ingredient = wm->getGameSettingString("sIngredients", "Ingredients");
if (mFilterType->getCaption() == ingredient)
if (mFilterType->getCaption() == toUString(ingredient))
mCurrentFilter = FilterType::ByName;
else
mCurrentFilter = FilterType::ByEffect;
@ -166,13 +166,12 @@ namespace MWGui
void AlchemyWindow::switchFilterType(MyGUI::Widget* _sender)
{
auto const& wm = MWBase::Environment::get().getWindowManager();
auto const ingredient = wm->getGameSettingString("sIngredients", "Ingredients");
auto const effect = wm->getGameSettingString("sMagicEffects", "Magic Effects");
MyGUI::UString ingredient = toUString(wm->getGameSettingString("sIngredients", "Ingredients"));
auto *button = _sender->castType<MyGUI::Button>();
if (button->getCaption() == ingredient)
{
button->setCaption(effect);
button->setCaption(toUString(wm->getGameSettingString("sMagicEffects", "Magic Effects")));
mCurrentFilter = FilterType::ByEffect;
}
else

@ -15,6 +15,7 @@
#include "../mwworld/esmstore.hpp"
#include "../mwworld/player.hpp"
#include "ustring.hpp"
#include "widgets.hpp"
namespace
@ -51,7 +52,7 @@ namespace MWGui
MyGUI::Button* okButton;
getWidget(okButton, "OKButton");
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked);
updateBirths();
@ -64,9 +65,9 @@ namespace MWGui
getWidget(okButton, "OKButton");
if (shown)
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
else
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
}
void BirthDialog::onOpen()
@ -235,7 +236,7 @@ namespace MWGui
if (!categories[category].spells.empty())
{
MyGUI::TextBox* label = mSpellArea->createWidget<MyGUI::TextBox>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label"));
label->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString(categories[category].label, ""));
label->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString(categories[category].label, {})));
mSpellItems.push_back(label);
coord.top += lineHeight;

@ -18,6 +18,7 @@
#include <components/vfs/manager.hpp>
#include "tooltips.hpp"
#include "ustring.hpp"
namespace
{
@ -37,7 +38,7 @@ namespace MWGui
GenerateClassResultDialog::GenerateClassResultDialog()
: WindowModal("openmw_chargen_generate_class_result.layout")
{
setText("ReflectT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sMessageQuestionAnswer1", ""));
setText("ReflectT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sMessageQuestionAnswer1", {}));
getWidget(mClassImage, "ClassImage");
getWidget(mClassName, "ClassName");
@ -123,9 +124,9 @@ namespace MWGui
getWidget(okButton, "OKButton");
if (shown)
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
else
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
}
void PickClassDialog::onOpen()
@ -248,12 +249,12 @@ namespace MWGui
ESM::Class::Specialization specialization = static_cast<ESM::Class::Specialization>(klass->mData.mSpecialization);
static const char *specIds[3] = {
static const std::string_view specIds[3] = {
"sSpecializationCombat",
"sSpecializationMagic",
"sSpecializationStealth"
};
std::string specName = MWBase::Environment::get().getWindowManager()->getGameSettingString(specIds[specialization], specIds[specialization]);
std::string specName{MWBase::Environment::get().getWindowManager()->getGameSettingString(specIds[specialization], specIds[specialization])};
mSpecializationName->setCaption(specName);
ToolTips::createSpecializationToolTip(mSpecializationName, specName, specialization);
@ -383,10 +384,10 @@ namespace MWGui
{
setText("");
ButtonList buttons;
buttons.push_back(MWBase::Environment::get().getWindowManager()->getGameSettingString("sClassChoiceMenu1", ""));
buttons.push_back(MWBase::Environment::get().getWindowManager()->getGameSettingString("sClassChoiceMenu2", ""));
buttons.push_back(MWBase::Environment::get().getWindowManager()->getGameSettingString("sClassChoiceMenu3", ""));
buttons.push_back(MWBase::Environment::get().getWindowManager()->getGameSettingString("sBack", ""));
buttons.emplace_back(MWBase::Environment::get().getWindowManager()->getGameSettingString("sClassChoiceMenu1", {}));
buttons.emplace_back(MWBase::Environment::get().getWindowManager()->getGameSettingString("sClassChoiceMenu2", {}));
buttons.emplace_back(MWBase::Environment::get().getWindowManager()->getGameSettingString("sClassChoiceMenu3", {}));
buttons.emplace_back(MWBase::Environment::get().getWindowManager()->getGameSettingString("sBack", {}));
setButtons(buttons);
}
@ -410,8 +411,8 @@ namespace MWGui
mFavoriteAttribute0->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
mFavoriteAttribute1->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
setText("MajorSkillT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSkillClassMajor", ""));
setText("MinorSkillT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSkillClassMinor", ""));
setText("MajorSkillT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSkillClassMajor", {}));
setText("MinorSkillT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSkillClassMinor", {}));
for(int i = 0; i < 5; i++)
{
char theIndex = '0'+i;
@ -426,7 +427,7 @@ namespace MWGui
skill->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
}
setText("LabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sName", ""));
setText("LabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sName", {}));
getWidget(mEditName, "EditName");
// Make sure the edit box has focus
@ -530,9 +531,9 @@ namespace MWGui
getWidget(okButton, "OKButton");
if (shown)
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
else
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
}
// widget controls
@ -564,12 +565,12 @@ namespace MWGui
void CreateClassDialog::setSpecialization(int id)
{
mSpecializationId = (ESM::Class::Specialization) id;
static const char *specIds[3] = {
static const std::string_view specIds[3] = {
"sSpecializationCombat",
"sSpecializationMagic",
"sSpecializationStealth"
};
std::string specName = MWBase::Environment::get().getWindowManager()->getGameSettingString(specIds[mSpecializationId], specIds[mSpecializationId]);
std::string specName{MWBase::Environment::get().getWindowManager()->getGameSettingString(specIds[mSpecializationId], specIds[mSpecializationId])};
mSpecializationName->setCaption(specName);
ToolTips::createSpecializationToolTip(mSpecializationName, specName, mSpecializationId);
}
@ -669,9 +670,9 @@ namespace MWGui
getWidget(mSpecialization0, "Specialization0");
getWidget(mSpecialization1, "Specialization1");
getWidget(mSpecialization2, "Specialization2");
std::string combat = MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Combat], "");
std::string magic = MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Magic], "");
std::string stealth = MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Stealth], "");
std::string combat{MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Combat], {})};
std::string magic{MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Magic], {})};
std::string stealth{MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Stealth], {})};
mSpecialization0->setCaption(combat);
mSpecialization0->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
@ -875,7 +876,7 @@ namespace MWGui
MyGUI::Button* okButton;
getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked);
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sInputMenu1", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sInputMenu1", {})));
// Make sure the edit box has focus
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);

@ -25,6 +25,7 @@
#include "itemwidget.hpp"
#include "sortfilteritemmodel.hpp"
#include "ustring.hpp"
namespace MWGui
{
@ -100,7 +101,7 @@ namespace MWGui
else
{
std::string_view name = item.getClass().getName(item);
mName->setCaption({name.data(), name.size()});
mName->setCaption(toUString(name));
mItemBox->setItem(item);
mItemBox->setUserString ("ToolTipType", "ItemPtr");
mItemBox->setUserData(MWWorld::Ptr(item));
@ -119,19 +120,19 @@ namespace MWGui
switch(mEnchanting.getCastStyle())
{
case ESM::Enchantment::CastOnce:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastOnce","Cast Once"));
mTypeButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastOnce", "Cast Once")));
setConstantEffect(false);
break;
case ESM::Enchantment::WhenStrikes:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenStrikes", "When Strikes"));
mTypeButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenStrikes", "When Strikes")));
setConstantEffect(false);
break;
case ESM::Enchantment::WhenUsed:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenUsed", "When Used"));
mTypeButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenUsed", "When Used")));
setConstantEffect(false);
break;
case ESM::Enchantment::ConstantEffect:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastConstant", "Cast Constant"));
mTypeButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastConstant", "Cast Constant")));
setConstantEffect(true);
break;
}

@ -17,6 +17,7 @@
#include "itemmodel.hpp"
#include "itemwidget.hpp"
#include "ustring.hpp"
namespace MWGui
{
@ -170,7 +171,7 @@ namespace MWGui
void ItemChargeView::updateLine(const ItemChargeView::Line& line)
{
std::string_view name = line.mItemPtr.getClass().getName(line.mItemPtr);
line.mText->setCaption({name.data(), name.size()});
line.mText->setCaption(toUString(name));
line.mCharge->setVisible(false);
switch (mDisplayMode)

@ -6,6 +6,8 @@
#include <MyGUI_TextBox.h>
#include <MyGUI_Window.h>
#include "ustring.hpp"
namespace MWGui
{
void Layout::initialise(std::string_view _layout)
@ -45,17 +47,17 @@ namespace MWGui
mMainWidget->setVisible(b);
}
void Layout::setText(std::string_view name, const std::string &caption)
void Layout::setText(std::string_view name, std::string_view caption)
{
MyGUI::Widget* pt;
getWidget(pt, name);
static_cast<MyGUI::TextBox*>(pt)->setCaption(caption);
static_cast<MyGUI::TextBox*>(pt)->setCaption(toUString(caption));
}
void Layout::setTitle(std::string_view title)
{
MyGUI::Window* window = static_cast<MyGUI::Window*>(mMainWidget);
MyGUI::UString uTitle{title.data(), title.size()};
MyGUI::UString uTitle = toUString(title);
if (window->getCaption() != uTitle)
window->setCaptionWithReplacing(uTitle);

@ -61,7 +61,7 @@ namespace MWGui
virtual void setVisible(bool b);
void setText(std::string_view name, const std::string& caption);
void setText(std::string_view name, std::string_view caption);
// NOTE: this assume that mMainWidget is of type Window.
void setTitle(std::string_view title);

@ -17,6 +17,7 @@
#include "../mwrender/characterpreview.hpp"
#include "tooltips.hpp"
#include "ustring.hpp"
namespace
{
@ -105,7 +106,7 @@ namespace MWGui
MyGUI::Button* okButton;
getWidget(okButton, "OKButton");
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
updateRaces();
@ -119,9 +120,9 @@ namespace MWGui
getWidget(okButton, "OKButton");
if (shown)
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
else
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
}
void RaceDialog::onOpen()

@ -14,6 +14,7 @@
#include "../mwmechanics/autocalcspell.hpp"
#include "tooltips.hpp"
#include "ustring.hpp"
namespace
{
@ -58,15 +59,15 @@ namespace MWGui
// Setup dynamic stats
getWidget(mHealth, "Health");
mHealth->setTitle(MWBase::Environment::get().getWindowManager()->getGameSettingString("sHealth", ""));
mHealth->setTitle(MWBase::Environment::get().getWindowManager()->getGameSettingString("sHealth", {}));
mHealth->setValue(45, 45);
getWidget(mMagicka, "Magicka");
mMagicka->setTitle(MWBase::Environment::get().getWindowManager()->getGameSettingString("sMagic", ""));
mMagicka->setTitle(MWBase::Environment::get().getWindowManager()->getGameSettingString("sMagic", {}));
mMagicka->setValue(50, 50);
getWidget(mFatigue, "Fatigue");
mFatigue->setTitle(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFatigue", ""));
mFatigue->setTitle(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFatigue", {}));
mFatigue->setValue(160, 160);
// Setup attributes
@ -250,11 +251,11 @@ namespace MWGui
coord2.top += separator->getHeight();
}
void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
void ReviewDialog::addGroup(std::string_view label, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
{
MyGUI::TextBox* groupWidget = mSkillView->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default);
groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel);
groupWidget->setCaption(label);
groupWidget->setCaption(toUString(label));
mSkillWidgets.push_back(groupWidget);
int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
@ -262,13 +263,13 @@ namespace MWGui
coord2.top += lineHeight;
}
MyGUI::TextBox* ReviewDialog::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
MyGUI::TextBox* ReviewDialog::addValueItem(std::string_view text, const std::string& value, const std::string& state, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
{
MyGUI::TextBox* skillNameWidget;
MyGUI::TextBox* skillValueWidget;
skillNameWidget = mSkillView->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Default);
skillNameWidget->setCaption(text);
skillNameWidget->setCaption(toUString(text));
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel);
skillValueWidget = mSkillView->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Default);

@ -76,8 +76,8 @@ namespace MWGui
private:
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
MyGUI::TextBox* addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addGroup(std::string_view label, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
MyGUI::TextBox* addValueItem(std::string_view text, const std::string& value, const std::string& state, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
void addItem(const std::string& text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addItem(const ESM::Spell* spell, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void updateSkillArea();

@ -38,6 +38,7 @@
#include "../mwbase/windowmanager.hpp"
#include "confirmationdialog.hpp"
#include "ustring.hpp"
namespace
{
@ -584,11 +585,11 @@ namespace MWGui
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
{
std::string on = MWBase::Environment::get().getWindowManager()->getGameSettingString("sOn", "On");
std::string off = MWBase::Environment::get().getWindowManager()->getGameSettingString("sOff", "On");
MyGUI::UString on = toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOn", "On"));
bool newState;
if (_sender->castType<MyGUI::Button>()->getCaption() == on)
{
MyGUI::UString off = toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOff", "Off"));
_sender->castType<MyGUI::Button>()->setCaption(off);
newState = false;
}

@ -146,7 +146,7 @@ namespace MWGui
mDurationValue->setCaption("1");
mMagnitudeMinValue->setCaption("1");
const std::string to = MWBase::Environment::get().getWindowManager()->getGameSettingString("sTo", "-");
const std::string to{MWBase::Environment::get().getWindowManager()->getGameSettingString("sTo", "-")};
mMagnitudeMaxValue->setCaption(to + " 1");
mAreaValue->setCaption("0");
@ -314,7 +314,7 @@ namespace MWGui
}
mEffect.mMagnMax = pos+1;
const std::string to = MWBase::Environment::get().getWindowManager()->getGameSettingString("sTo", "-");
const std::string to{MWBase::Environment::get().getWindowManager()->getGameSettingString("sTo", "-")};
mMagnitudeMaxValue->setCaption(to + " " + MyGUI::utility::toString(pos+1));

@ -67,7 +67,7 @@ namespace MWGui
for (const MagicEffectInfo& effectInfo : effectInfos)
{
if (addNewLine)
sourcesDescription += "\n";
sourcesDescription += '\n';
// if at least one of the effect sources is permanent, the effect will never wear off
if (effectInfo.mPermanent)
@ -84,18 +84,21 @@ namespace MWGui
sourcesDescription += effectInfo.mSource;
if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill)
sourcesDescription += " (" +
MWBase::Environment::get().getWindowManager()->getGameSettingString(
ESM::Skill::sSkillNameIds[effectInfo.mKey.mArg], "") + ")";
{
sourcesDescription += " (";
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Skill::sSkillNameIds[effectInfo.mKey.mArg], {});
sourcesDescription += ')';
}
if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
sourcesDescription += " (" +
MWBase::Environment::get().getWindowManager()->getGameSettingString(
ESM::Attribute::sGmstAttributeIds[effectInfo.mKey.mArg], "") + ")";
{
sourcesDescription += " (";
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Attribute::sGmstAttributeIds[effectInfo.mKey.mArg], {});
sourcesDescription += ')';
}
ESM::MagicEffect::MagnitudeDisplayType displayType = effect->getMagnitudeDisplayType();
if (displayType == ESM::MagicEffect::MDT_TimesInt)
{
std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
std::string_view timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", {});
std::stringstream formatter;
formatter << std::fixed << std::setprecision(1) << " " << (effectInfo.mMagnitude / 10.0f) << timesInt;
sourcesDescription += formatter.str();
@ -105,20 +108,27 @@ namespace MWGui
sourcesDescription += ": " + MyGUI::utility::toString(effectInfo.mMagnitude);
if ( displayType == ESM::MagicEffect::MDT_Percentage )
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", "");
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", {});
else if ( displayType == ESM::MagicEffect::MDT_Feet )
sourcesDescription += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", "");
{
sourcesDescription += ' ';
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", {});
}
else if ( displayType == ESM::MagicEffect::MDT_Level )
{
sourcesDescription += " " + ((effectInfo.mMagnitude > 1) ?
MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", "") :
MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", "") );
sourcesDescription += ' ';
if (effectInfo.mMagnitude > 1)
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", {});
else
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", {});
}
else // ESM::MagicEffect::MDT_Points
{
sourcesDescription += " " + ((effectInfo.mMagnitude > 1) ?
MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "") :
MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "") );
sourcesDescription += ' ';
if (effectInfo.mMagnitude > 1)
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", {});
else
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", {});
}
}
if (effectInfo.mRemainingTime > -1 && Settings::Manager::getBool("show effect duration","Game"))

@ -21,11 +21,7 @@ namespace
{
if (left.mType != right.mType)
return left.mType < right.mType;
std::string leftName = Misc::StringUtils::lowerCase(left.mName);
std::string rightName = Misc::StringUtils::lowerCase(right.mName);
return leftName.compare(rightName) < 0;
return Misc::StringUtils::ciLess(left.mName, right.mName);
}
}
@ -57,17 +53,19 @@ namespace MWGui
{
const ESM::MagicEffect *magicEffect =
store.get<ESM::MagicEffect>().find(effectId);
std::string effectIDStr = ESM::MagicEffect::effectIdToString(effectId);
std::string fullEffectName = wm->getGameSettingString(effectIDStr, "");
const std::string& effectIDStr = ESM::MagicEffect::effectIdToString(effectId);
std::string fullEffectName{wm->getGameSettingString(effectIDStr, {})};
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill && effect.mSkill != -1)
{
fullEffectName += " " + wm->getGameSettingString(ESM::Skill::sSkillNameIds[effect.mSkill], "");
fullEffectName += ' ';
fullEffectName += wm->getGameSettingString(ESM::Skill::sSkillNameIds[effect.mSkill], {});
}
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute && effect.mAttribute != -1)
{
fullEffectName += " " + wm->getGameSettingString(ESM::Attribute::sGmstAttributeIds[effect.mAttribute], "");
fullEffectName += ' ';
fullEffectName += wm->getGameSettingString(ESM::Attribute::sGmstAttributeIds[effect.mAttribute], {});
}
std::string convert = Utf8Stream::lowerCaseUtf8(fullEffectName);

@ -158,17 +158,17 @@ namespace MWGui
isInherent = sign->mPowers.exists(spell->mId);
}
const auto windowManager = MWBase::Environment::get().getWindowManager();
if (isInherent)
{
MWBase::Environment::get().getWindowManager()->messageBox("#{sDeleteSpellError}");
windowManager->messageBox("#{sDeleteSpellError}");
}
else
{
// ask for confirmation
mSpellToDelete = spellId;
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
std::string question = MWBase::Environment::get().getWindowManager()->getGameSettingString("sQuestionDeleteSpell", "Delete %s?");
question = Misc::StringUtils::format(question, spell->mName);
ConfirmationDialog* dialog = windowManager->getConfirmationDialog();
std::string question = Misc::StringUtils::format(windowManager->getGameSettingString("sQuestionDeleteSpell", "Delete %s?"), spell->mName);
dialog->askForConfirmation(question);
dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &SpellWindow::onDeleteSpellAccept);

@ -23,6 +23,7 @@
#include "../mwmechanics/actorutil.hpp"
#include "tooltips.hpp"
#include "ustring.hpp"
namespace MWGui
{
@ -411,12 +412,12 @@ namespace MWGui
coord2.top += separator->getHeight();
}
void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
void StatsWindow::addGroup(std::string_view label, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
{
MyGUI::TextBox* groupWidget = mSkillView->createWidget<MyGUI::TextBox>("SandBrightText",
MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height),
MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
groupWidget->setCaption(label);
groupWidget->setCaption(toUString(label));
groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
mSkillWidgets.push_back(groupWidget);
@ -425,12 +426,12 @@ namespace MWGui
coord2.top += lineHeight;
}
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> StatsWindow::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> StatsWindow::addValueItem(std::string_view text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{
MyGUI::TextBox *skillNameWidget, *skillValueWidget;
skillNameWidget = mSkillView->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
skillNameWidget->setCaption(text);
skillNameWidget->setCaption(toUString(text));
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
skillValueWidget = mSkillView->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Right | MyGUI::Align::Top);
@ -501,7 +502,7 @@ namespace MWGui
esmStore.get<ESM::Attribute>().find(skill->mData.mAttribute);
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> widgets = addValueItem(MWBase::Environment::get().getWindowManager()->getGameSettingString(skillNameId, skillNameId),
"", "normal", coord1, coord2);
{}, "normal", coord1, coord2);
mSkillWidgetMap[skillId] = widgets;
for (int i=0; i<2; ++i)

@ -38,8 +38,8 @@ namespace MWGui
private:
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addGroup(std::string_view label, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> addValueItem(std::string_view text, const std::string &value, const std::string& state, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
MyGUI::Widget* addItem(const std::string& text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void setFactions (const FactionList& factions);

@ -6,6 +6,8 @@
#include <MyGUI_EditBox.h>
#include <MyGUI_Button.h>
#include "ustring.hpp"
namespace MWGui
{
@ -32,12 +34,12 @@ namespace MWGui
getWidget(okButton, "OKButton");
if (shown)
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
else
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
okButton->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
}
void TextInputDialog::setTextLabel(const std::string &label)
void TextInputDialog::setTextLabel(std::string_view label)
{
setText("LabelT", label);
}
@ -53,7 +55,7 @@ namespace MWGui
void TextInputDialog::onOkClicked(MyGUI::Widget* _sender)
{
if (mTextEdit->getCaption() == "")
if (mTextEdit->getCaption().empty())
{
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage37}");
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget (mTextEdit);

@ -14,7 +14,7 @@ namespace MWGui
void setTextInput(const std::string &text);
void setNextButtonShow(bool shown);
void setTextLabel(const std::string &label);
void setTextLabel(std::string_view label);
void onOpen() override;
bool exit() override { return false; }

@ -0,0 +1,15 @@
#ifndef MWGUI_USTRING_H
#define MWGUI_USTRING_H
#include <MyGUI_UString.h>
namespace MWGui
{
// FIXME: Remove once we get a version of MyGUI that supports string_view
inline MyGUI::UString toUString(std::string_view string)
{
return {string.data(), string.size()};
}
}
#endif

@ -17,6 +17,7 @@
#include "../mwworld/esmstore.hpp"
#include "controllers.hpp"
#include "ustring.hpp"
namespace MWGui::Widgets
{
@ -61,7 +62,7 @@ namespace MWGui::Widgets
}
else
{
const std::string &name = MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Skill::sSkillNameIds[mSkillId], "");
MyGUI::UString name = toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Skill::sSkillNameIds[mSkillId], {}));
mSkillNameWidget->setCaption(name);
}
}
@ -147,7 +148,7 @@ namespace MWGui::Widgets
}
else
{
static const char *attributes[8] = {
static const std::string_view attributes[8] = {
"sAttributeStrength",
"sAttributeIntelligence",
"sAttributeWillpower",
@ -157,7 +158,7 @@ namespace MWGui::Widgets
"sAttributePersonality",
"sAttributeLuck"
};
const std::string &name = MWBase::Environment::get().getWindowManager()->getGameSettingString(attributes[mId], "");
MyGUI::UString name = toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString(attributes[mId], {}));
mAttributeNameWidget->setCaption(name);
}
}
@ -390,32 +391,34 @@ namespace MWGui::Widgets
assert(magicEffect);
std::string pt = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "");
std::string pts = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "");
std::string pct = MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", "");
std::string ft = MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", "");
std::string lvl = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", "");
std::string lvls = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", "");
std::string to = " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sTo", "") + " ";
std::string sec = " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("ssecond", "");
std::string secs = " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sseconds", "");
std::string_view pt = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", {});
std::string_view pts = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", {});
std::string_view pct = MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", {});
std::string_view ft = MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", {});
std::string_view lvl = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", {});
std::string_view lvls = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", {});
std::string to = " " + std::string{MWBase::Environment::get().getWindowManager()->getGameSettingString("sTo", {})} + " ";
std::string sec = " " + std::string{MWBase::Environment::get().getWindowManager()->getGameSettingString("ssecond", {})};
std::string secs = " " + std::string{MWBase::Environment::get().getWindowManager()->getGameSettingString("sseconds", {})};
std::string effectIDStr = ESM::MagicEffect::effectIdToString(mEffectParams.mEffectID);
std::string spellLine = MWBase::Environment::get().getWindowManager()->getGameSettingString(effectIDStr, "");
const std::string& effectIDStr = ESM::MagicEffect::effectIdToString(mEffectParams.mEffectID);
std::string spellLine{MWBase::Environment::get().getWindowManager()->getGameSettingString(effectIDStr, {})};
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill && mEffectParams.mSkill != -1)
{
spellLine += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Skill::sSkillNameIds[mEffectParams.mSkill], "");
spellLine += ' ';
spellLine += MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Skill::sSkillNameIds[mEffectParams.mSkill], {});
}
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute && mEffectParams.mAttribute != -1)
{
spellLine += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Attribute::sGmstAttributeIds[mEffectParams.mAttribute], "");
spellLine += ' ';
spellLine += MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Attribute::sGmstAttributeIds[mEffectParams.mAttribute], {});
}
if (mEffectParams.mMagnMin || mEffectParams.mMagnMax) {
ESM::MagicEffect::MagnitudeDisplayType displayType = magicEffect->getMagnitudeDisplayType();
if ( displayType == ESM::MagicEffect::MDT_TimesInt ) {
std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
std::string_view timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", {});
std::stringstream formatter;
formatter << std::fixed << std::setprecision(1) << " " << (mEffectParams.mMagnMin / 10.0f);
@ -433,11 +436,26 @@ namespace MWGui::Widgets
if ( displayType == ESM::MagicEffect::MDT_Percentage )
spellLine += pct;
else if ( displayType == ESM::MagicEffect::MDT_Feet )
spellLine += " " + ft;
{
spellLine += ' ';
spellLine += ft;
}
else if ( displayType == ESM::MagicEffect::MDT_Level )
spellLine += " " + ((mEffectParams.mMagnMin == mEffectParams.mMagnMax && std::abs(mEffectParams.mMagnMin) == 1) ? lvl : lvls );
{
spellLine += ' ';
if (mEffectParams.mMagnMin == mEffectParams.mMagnMax && std::abs(mEffectParams.mMagnMin) == 1)
spellLine += lvl;
else
spellLine += lvls;
}
else // ESM::MagicEffect::MDT_Points
spellLine += " " + ((mEffectParams.mMagnMin == mEffectParams.mMagnMax && std::abs(mEffectParams.mMagnMin) == 1) ? pt : pts );
{
spellLine += ' ';
if (mEffectParams.mMagnMin == mEffectParams.mMagnMax && std::abs(mEffectParams.mMagnMin) == 1)
spellLine += pt;
else
spellLine += pts;
}
}
}
@ -449,7 +467,9 @@ namespace MWGui::Widgets
if (mEffectParams.mDuration > 0 && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration))
{
spellLine += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sfor", "") + " " + MyGUI::utility::toString(mEffectParams.mDuration) + ((mEffectParams.mDuration == 1) ? sec : secs);
spellLine += ' ';
spellLine += MWBase::Environment::get().getWindowManager()->getGameSettingString("sfor", {});
spellLine += ' ' + MyGUI::utility::toString(mEffectParams.mDuration) + ((mEffectParams.mDuration == 1) ? sec : secs);
}
if (mEffectParams.mArea > 0)
@ -460,13 +480,15 @@ namespace MWGui::Widgets
// potions have no target
if (!mEffectParams.mNoTarget)
{
std::string on = MWBase::Environment::get().getWindowManager()->getGameSettingString("sonword", "");
spellLine += ' ';
spellLine += MWBase::Environment::get().getWindowManager()->getGameSettingString("sonword", {});
spellLine += ' ';
if (mEffectParams.mRange == ESM::RT_Self)
spellLine += " " + on + " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sRangeSelf", "");
spellLine += MWBase::Environment::get().getWindowManager()->getGameSettingString("sRangeSelf", {});
else if (mEffectParams.mRange == ESM::RT_Touch)
spellLine += " " + on + " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sRangeTouch", "");
spellLine += MWBase::Environment::get().getWindowManager()->getGameSettingString("sRangeTouch", {});
else if (mEffectParams.mRange == ESM::RT_Target)
spellLine += " " + on + " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sRangeTarget", "");
spellLine += MWBase::Environment::get().getWindowManager()->getGameSettingString("sRangeTarget", {});
}
}
@ -517,10 +539,10 @@ namespace MWGui::Widgets
mBarTextWidget->setCaption(out.str().c_str());
}
}
void MWDynamicStat::setTitle(const std::string& text)
void MWDynamicStat::setTitle(std::string_view text)
{
if (mTextWidget)
mTextWidget->setCaption(text);
mTextWidget->setCaption(toUString(text));
}
MWDynamicStat::~MWDynamicStat()

@ -282,7 +282,7 @@ namespace MWGui
MWDynamicStat();
void setValue(int value, int max);
void setTitle(const std::string& text);
void setTitle(std::string_view text);
int getValue() const { return mValue; }
int getMax() const { return mMax; }

@ -124,6 +124,7 @@
#include "itemchargeview.hpp"
#include "keyboardnavigation.hpp"
#include "resourceskin.hpp"
#include "ustring.hpp"
namespace MWGui
{
@ -752,7 +753,7 @@ namespace MWGui
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.data(), message.size()}));
mDialogueWindow->addMessageBox(MyGUI::LanguageManager::getInstance().replaceTags(toUString(message)));
} else if (showInDialogueMode != MWGui::ShowInDialogueMode_Only) {
mMessageBoxManager->createMessageBox(message);
}
@ -783,7 +784,7 @@ namespace MWGui
return mMessageBoxManager->readPressedButton();
}
std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_)
std::string_view WindowManager::getGameSettingString(std::string_view id, std::string_view default_)
{
const ESM::GameSetting *setting = mStore->get<ESM::GameSetting>().search(id);

@ -289,7 +289,7 @@ namespace MWGui
* @param id Identifier for the GMST setting, e.g. "aName"
* @param default Default value if the GMST setting cannot be used.
*/
std::string getGameSettingString(const std::string &id, const std::string &default_) override;
std::string_view getGameSettingString(std::string_view id, std::string_view default_) override;
void processChangedSettings(const Settings::CategorySettingVector& changed) override;

@ -267,8 +267,8 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas
/// \todo check if character is the player, if levelling is ever implemented for NPCs
MWBase::Environment::get().getWindowManager()->playSound("skillraise");
std::string message = MWBase::Environment::get().getWindowManager ()->getGameSettingString ("sNotifyMessage39", "");
message = Misc::StringUtils::format(message, ("#{" + ESM::Skill::sSkillNameIds[skillIndex] + "}"), static_cast<int>(base));
std::string message = Misc::StringUtils::format(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNotifyMessage39", {}),
("#{" + ESM::Skill::sSkillNameIds[skillIndex] + "}"), static_cast<int>(base));
if (readBook)
message = "#{sBookSkillMessage}\n" + message;

@ -124,8 +124,8 @@ void MWState::StateManager::askLoadRecent()
std::vector<std::string> buttons;
buttons.emplace_back("#{sYes}");
buttons.emplace_back("#{sNo}");
std::string tag("%s");
std::string message = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLoadLastSaveMsg", tag);
std::string_view tag = "%s";
std::string message{MWBase::Environment::get().getWindowManager()->getGameSettingString("sLoadLastSaveMsg", tag)};
size_t pos = message.find(tag);
message.replace(pos, tag.length(), lastSave.mProfile.mDescription);
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(message, buttons);

@ -51,9 +51,9 @@ namespace Misc::StringUtils
}
template <typename ... Args>
std::string format(const std::string& fmt, Args const & ... args)
std::string format(std::string_view fmt, Args const & ... args)
{
return format(fmt.c_str(), args ...);
return format(fmt.data(), args ...);
}
}

Loading…
Cancel
Save