Use string_view in more places and reduce the number of empty string literals

simplify_debugging
Evil Eye 2 years ago
parent 5b36ea0179
commit 5491512905

@ -41,7 +41,7 @@ namespace MWBase
{ {
public: public:
virtual ~ResponseCallback() = default; virtual ~ResponseCallback() = default;
virtual void addResponse(const std::string& title, const std::string& text) = 0; virtual void addResponse(std::string_view title, std::string_view text) = 0;
}; };
DialogueManager() {} DialogueManager() {}
@ -67,7 +67,7 @@ namespace MWBase
virtual void say(const MWWorld::Ptr& actor, const ESM::RefId& topic) = 0; virtual void say(const MWWorld::Ptr& actor, const ESM::RefId& topic) = 0;
virtual void keywordSelected(const std::string& keyword, ResponseCallback* callback) = 0; virtual void keywordSelected(std::string_view keyword, ResponseCallback* callback) = 0;
virtual void goodbyeSelected() = 0; virtual void goodbyeSelected() = 0;
virtual void questionAnswered(int answer, ResponseCallback* callback) = 0; virtual void questionAnswered(int answer, ResponseCallback* callback) = 0;

@ -62,7 +62,7 @@ namespace MWClass
bool hasToolTip(const MWWorld::ConstPtr& ptr) const override { return false; } bool hasToolTip(const MWWorld::ConstPtr& ptr) const override { return false; }
std::string_view getName(const MWWorld::ConstPtr& ptr) const override { return ""; } std::string_view getName(const MWWorld::ConstPtr& ptr) const override { return {}; }
std::string getModel(const MWWorld::ConstPtr& ptr) const override std::string getModel(const MWWorld::ConstPtr& ptr) const override
{ {
@ -73,7 +73,7 @@ namespace MWClass
// TODO: Figure out a better way find markers and LOD meshes; show LOD only outside of active grid. // TODO: Figure out a better way find markers and LOD meshes; show LOD only outside of active grid.
if (model.empty() || Misc::StringUtils::ciStartsWith(model, "meshes\\marker") if (model.empty() || Misc::StringUtils::ciStartsWith(model, "meshes\\marker")
|| Misc::StringUtils::ciEndsWith(model, "lod.nif")) || Misc::StringUtils::ciEndsWith(model, "lod.nif"))
return ""; return {};
return model; return model;
} }

@ -174,7 +174,7 @@ namespace MWDialogue
} }
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor); MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor);
callback->addResponse("", Interpreter::fixDefinesDialog(info->mResponse, interpreterContext)); callback->addResponse({}, Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
executeScript(info->mResultScript, mActor); executeScript(info->mResultScript, mActor);
mLastTopic = it->mId; mLastTopic = it->mId;
@ -429,14 +429,14 @@ namespace MWDialogue
return 0; return 0;
} }
void DialogueManager::keywordSelected(const std::string& keyword, ResponseCallback* callback) void DialogueManager::keywordSelected(std::string_view keyword, ResponseCallback* callback)
{ {
if (!mIsInChoice) if (!mIsInChoice)
{ {
const ESM::Dialogue* dialogue = searchDialogue(ESM::RefId::stringRefId(keyword)); const ESM::Dialogue* dialogue = searchDialogue(ESM::RefId::stringRefId(keyword));
if (dialogue && dialogue->mType == ESM::Dialogue::Topic) if (dialogue && dialogue->mType == ESM::Dialogue::Topic)
{ {
executeTopic(ESM::RefId::stringRefId(keyword), callback); executeTopic(dialogue->mId, callback);
} }
} }
} }
@ -487,7 +487,7 @@ namespace MWDialogue
mChoices.clear(); mChoices.clear();
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor); MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor);
callback->addResponse("", Interpreter::fixDefinesDialog(text, interpreterContext)); callback->addResponse({}, Interpreter::fixDefinesDialog(text, interpreterContext));
if (dialogue->mType == ESM::Dialogue::Topic) if (dialogue->mType == ESM::Dialogue::Topic)
{ {
@ -731,8 +731,12 @@ namespace MWDialogue
int DialogueManager::getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const int DialogueManager::getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const
{ {
ModFactionReactionMap::const_iterator map = mChangedFactionReaction.find(faction1); ModFactionReactionMap::const_iterator map = mChangedFactionReaction.find(faction1);
if (map != mChangedFactionReaction.end() && map->second.find(faction2) != map->second.end()) if (map != mChangedFactionReaction.end())
return map->second.at(faction2); {
auto it = map->second.find(faction2);
if (it != map->second.end())
return it->second;
}
const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction1); const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction1);

@ -103,7 +103,7 @@ namespace MWDialogue
void say(const MWWorld::Ptr& actor, const ESM::RefId& topic) override; void say(const MWWorld::Ptr& actor, const ESM::RefId& topic) override;
// calbacks for the GUI // calbacks for the GUI
void keywordSelected(const std::string& keyword, ResponseCallback* callback) override; void keywordSelected(std::string_view keyword, ResponseCallback* callback) override;
void goodbyeSelected() override; void goodbyeSelected() override;
void questionAnswered(int answer, ResponseCallback* callback) override; void questionAnswered(int answer, ResponseCallback* callback) override;

@ -267,16 +267,17 @@ namespace MWGui
mNameEdit->setCaption({}); mNameEdit->setCaption({});
mBrewCountEdit->setValue(1); mBrewCountEdit->setValue(1);
int index = 0; size_t index = 0;
for (MWMechanics::Alchemy::TToolsIterator iter(mAlchemy->beginTools()); for (auto iter = mAlchemy->beginTools(); iter != mAlchemy->endTools() && index < mApparatus.size();
iter != mAlchemy->endTools() && index < static_cast<int>(mApparatus.size()); ++iter, ++index) ++iter, ++index)
{ {
mApparatus.at(index)->setItem(*iter); const auto& widget = mApparatus[index];
mApparatus.at(index)->clearUserStrings(); widget->setItem(*iter);
widget->clearUserStrings();
if (!iter->isEmpty()) if (!iter->isEmpty())
{ {
mApparatus.at(index)->setUserString("ToolTipType", "ItemPtr"); widget->setUserString("ToolTipType", "ItemPtr");
mApparatus.at(index)->setUserData(MWWorld::Ptr(*iter)); widget->setUserData(MWWorld::Ptr(*iter));
} }
} }

@ -225,15 +225,15 @@ namespace MWGui
struct struct
{ {
const std::vector<ESM::RefId>& spells; const std::vector<ESM::RefId>& spells;
const char* label; std::string_view label;
} categories[3] = { { abilities, "sBirthsignmenu1" }, { powers, "sPowers" }, { spells, "sBirthsignmenu2" } }; } categories[3] = { { abilities, "sBirthsignmenu1" }, { powers, "sPowers" }, { spells, "sBirthsignmenu2" } };
for (int category = 0; category < 3; ++category) for (size_t category = 0; category < 3; ++category)
{ {
if (!categories[category].spells.empty()) if (!categories[category].spells.empty())
{ {
MyGUI::TextBox* label = mSpellArea->createWidget<MyGUI::TextBox>( MyGUI::TextBox* label
"SandBrightText", coord, MyGUI::Align::Default, std::string("Label")); = mSpellArea->createWidget<MyGUI::TextBox>("SandBrightText", coord, MyGUI::Align::Default, "Label");
label->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString( label->setCaption(toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString(
categories[category].label, {}))); categories[category].label, {})));
mSpellItems.push_back(label); mSpellItems.push_back(label);
@ -243,8 +243,8 @@ namespace MWGui
for (it = categories[category].spells.begin(); it != end; ++it) for (it = categories[category].spells.begin(); it != end; ++it)
{ {
const ESM::RefId& spellId = *it; const ESM::RefId& spellId = *it;
spellWidget = mSpellArea->createWidget<Widgets::MWSpell>("MW_StatName", coord, spellWidget = mSpellArea->createWidget<Widgets::MWSpell>(
MyGUI::Align::Default, std::string("Spell") + MyGUI::utility::toString(i)); "MW_StatName", coord, MyGUI::Align::Default, "Spell" + MyGUI::utility::toString(i));
spellWidget->setSpellId(spellId); spellWidget->setSpellId(spellId);
mSpellItems.push_back(spellWidget); mSpellItems.push_back(spellWidget);

@ -103,27 +103,16 @@ namespace MWGui
void CharacterCreation::setValue(std::string_view id, const MWMechanics::AttributeValue& value) void CharacterCreation::setValue(std::string_view id, const MWMechanics::AttributeValue& value)
{ {
static const char* ids[] = { std::string_view prefix = "AttribVal";
"AttribVal1", if (id.starts_with(prefix) && id.size() == prefix.size() + 1)
"AttribVal2",
"AttribVal3",
"AttribVal4",
"AttribVal5",
"AttribVal6",
"AttribVal7",
"AttribVal8",
nullptr,
};
for (int i = 0; ids[i]; ++i)
{ {
if (ids[i] == id) char index = id[prefix.size()];
auto attribute = static_cast<ESM::Attribute::AttributeID>(index - '0' - 1);
if (attribute >= ESM::Attribute::Strength && attribute < ESM::Attribute::Length)
{ {
mPlayerAttributes[static_cast<ESM::Attribute::AttributeID>(i)] = value; mPlayerAttributes[attribute] = value;
if (mReviewDialog) if (mReviewDialog)
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID>(i), value); mReviewDialog->setAttribute(attribute, value);
break;
} }
} }
} }

@ -346,7 +346,7 @@ namespace MWGui
for (const std::string& text : buttons) for (const std::string& text : buttons)
{ {
button = mButtonBar->createWidget<MyGUI::Button>( button = mButtonBar->createWidget<MyGUI::Button>(
"MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, ""); "MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, {});
button->getSubWidgetText()->setWordWrap(true); button->getSubWidgetText()->setWordWrap(true);
button->setCaption(text); button->setCaption(text);
fitToText(button); fitToText(button);
@ -386,7 +386,7 @@ namespace MWGui
ClassChoiceDialog::ClassChoiceDialog() ClassChoiceDialog::ClassChoiceDialog()
: InfoBoxDialog() : InfoBoxDialog()
{ {
setText(""); setText({});
ButtonList buttons; ButtonList buttons;
buttons.emplace_back( buttons.emplace_back(
MWBase::Environment::get().getWindowManager()->getGameSettingString("sClassChoiceMenu1", {})); MWBase::Environment::get().getWindowManager()->getGameSettingString("sClassChoiceMenu1", {}));

@ -153,7 +153,7 @@ namespace MWGui
mProfitLabel->setCaptionWithReplacing("#{sProfitValue} " + MyGUI::utility::toString(getProfit(mPtr))); mProfitLabel->setCaptionWithReplacing("#{sProfitValue} " + MyGUI::utility::toString(getProfit(mPtr)));
} }
else else
mProfitLabel->setCaption(""); mProfitLabel->setCaption({});
} }
void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender) void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender)

@ -101,7 +101,7 @@ namespace MWGui
if (mNames.empty()) if (mNames.empty())
{ {
// keywords // keywords
std::istringstream input(""); std::istringstream input;
Compiler::Scanner scanner(*this, input, mCompilerContext.getExtensions()); Compiler::Scanner scanner(*this, input, mCompilerContext.getExtensions());
@ -312,7 +312,7 @@ namespace MWGui
if (oldCaption == newCaption && !matches.empty()) if (oldCaption == newCaption && !matches.empty())
{ {
int i = 0; int i = 0;
printOK(""); printOK({});
for (std::string& match : matches) for (std::string& match : matches)
{ {
if (i == 50) if (i == 50)
@ -377,7 +377,7 @@ namespace MWGui
// Reset the command line before the command execution. // Reset the command line before the command execution.
// It prevents the re-triggering of the acceptCommand() event for the same command // It prevents the re-triggering of the acceptCommand() event for the same command
// during the actual command execution // during the actual command execution
mCommandLine->setCaption(""); mCommandLine->setCaption({});
execute(cm); execute(cm);
} }
@ -618,7 +618,7 @@ namespace MWGui
if ((matches.front().find(' ') != std::string::npos)) if ((matches.front().find(' ') != std::string::npos))
{ {
if (!has_front_quote) if (!has_front_quote)
output.append(std::string("\"")); output += '"';
return output.append(matches.front() + std::string("\" ")); return output.append(matches.front() + std::string("\" "));
} }
else if (has_front_quote) else if (has_front_quote)

@ -32,7 +32,7 @@
namespace MWGui namespace MWGui
{ {
void ResponseCallback::addResponse(const std::string& title, const std::string& text) void ResponseCallback::addResponse(std::string_view title, std::string_view text)
{ {
mWindow->addResponse(title, text, mNeedMargin); mWindow->addResponse(title, text, mNeedMargin);
} }
@ -150,7 +150,7 @@ namespace MWGui
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
Response::Response(const std::string& text, const std::string& title, bool needMargin) Response::Response(std::string_view text, std::string_view title, bool needMargin)
: mTitle(title) : mTitle(title)
, mNeedMargin(needMargin) , mNeedMargin(needMargin)
{ {
@ -213,7 +213,7 @@ namespace MWGui
{ {
const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal, false); BookTypesetter::Style* style = typesetter->createStyle({}, textColours.normal, false);
size_t formatted = 0; // points to the first character that is not laid out yet size_t formatted = 0; // points to the first character that is not laid out yet
for (auto& hyperLink : hyperLinks) for (auto& hyperLink : hyperLinks)
{ {
@ -252,7 +252,7 @@ namespace MWGui
{ {
const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal, false); BookTypesetter::Style* style = typesetter->createStyle({}, textColours.normal, false);
if (topicId) if (topicId)
style = typesetter->createHotStyle( style = typesetter->createHotStyle(
@ -260,7 +260,7 @@ namespace MWGui
typesetter->write(style, begin, end); typesetter->write(style, begin, end);
} }
Message::Message(const std::string& text) Message::Message(std::string_view text)
{ {
mText = text; mText = text;
} }
@ -269,7 +269,7 @@ namespace MWGui
std::map<std::string, std::unique_ptr<Link>>& topicLinks) const std::map<std::string, std::unique_ptr<Link>>& topicLinks) const
{ {
const MyGUI::Colour& textColour = MWBase::Environment::get().getWindowManager()->getTextColours().notify; const MyGUI::Colour& textColour = MWBase::Environment::get().getWindowManager()->getTextColours().notify;
BookTypesetter::Style* title = typesetter->createStyle("", textColour, false); BookTypesetter::Style* title = typesetter->createStyle({}, textColour, false);
typesetter->sectionBreak(9); typesetter->sectionBreak(9);
typesetter->write(title, to_utf8_span(mText)); typesetter->write(title, to_utf8_span(mText));
} }
@ -335,7 +335,8 @@ namespace MWGui
void DialogueWindow::onTradeComplete() void DialogueWindow::onTradeComplete()
{ {
addResponse("", MyGUI::LanguageManager::getInstance().replaceTags("#{sBarterDialog5}")); MyGUI::UString message = MyGUI::LanguageManager::getInstance().replaceTags("#{sBarterDialog5}");
addResponse({}, message.asUTF8());
} }
bool DialogueWindow::exit() bool DialogueWindow::exit()
@ -611,7 +612,7 @@ namespace MWGui
for (const auto& text : mHistoryContents) for (const auto& text : mHistoryContents)
text->write(typesetter, &mKeywordSearch, mTopicLinks); text->write(typesetter, &mKeywordSearch, mTopicLinks);
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::White, false); BookTypesetter::Style* body = typesetter->createStyle({}, MyGUI::Colour::White, false);
typesetter->sectionBreak(9); typesetter->sectionBreak(9);
// choices // choices
@ -716,13 +717,13 @@ namespace MWGui
mHistory->setPosition(0, static_cast<int>(pos) * -1); mHistory->setPosition(0, static_cast<int>(pos) * -1);
} }
void DialogueWindow::addResponse(const std::string& title, const std::string& text, bool needMargin) void DialogueWindow::addResponse(std::string_view title, std::string_view text, bool needMargin)
{ {
mHistoryContents.push_back(std::make_unique<Response>(text, title, needMargin)); mHistoryContents.push_back(std::make_unique<Response>(text, title, needMargin));
updateHistory(); updateHistory();
} }
void DialogueWindow::addMessageBox(const std::string& text) void DialogueWindow::addMessageBox(std::string_view text)
{ {
mHistoryContents.push_back(std::make_unique<Message>(text)); mHistoryContents.push_back(std::make_unique<Message>(text));
updateHistory(); updateHistory();

@ -35,7 +35,7 @@ namespace MWGui
{ {
} }
void addResponse(const std::string& title, const std::string& text) override; void addResponse(std::string_view title, std::string_view text) override;
void updateTopics() const; void updateTopics() const;
}; };
@ -112,7 +112,7 @@ namespace MWGui
struct DialogueText struct DialogueText
{ {
virtual ~DialogueText() {} virtual ~DialogueText() = default;
virtual void write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, virtual void write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch,
std::map<std::string, std::unique_ptr<Link>>& topicLinks) const = 0; std::map<std::string, std::unique_ptr<Link>>& topicLinks) const = 0;
std::string mText; std::string mText;
@ -120,7 +120,7 @@ namespace MWGui
struct Response : DialogueText struct Response : DialogueText
{ {
Response(const std::string& text, const std::string& title = "", bool needMargin = true); Response(std::string_view text, std::string_view title = {}, bool needMargin = true);
void write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, void write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch,
std::map<std::string, std::unique_ptr<Link>>& topicLinks) const override; std::map<std::string, std::unique_ptr<Link>>& topicLinks) const override;
void addTopicLink(BookTypesetter::Ptr typesetter, intptr_t topicId, size_t begin, size_t end) const; void addTopicLink(BookTypesetter::Ptr typesetter, intptr_t topicId, size_t begin, size_t end) const;
@ -130,7 +130,7 @@ namespace MWGui
struct Message : DialogueText struct Message : DialogueText
{ {
Message(const std::string& text); Message(std::string_view text);
void write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, void write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch,
std::map<std::string, std::unique_ptr<Link>>& topicLinks) const override; std::map<std::string, std::unique_ptr<Link>>& topicLinks) const override;
}; };
@ -154,9 +154,9 @@ namespace MWGui
/// @return true if stale keywords were updated successfully /// @return true if stale keywords were updated successfully
bool setKeywords(const std::list<std::string>& keyWord); bool setKeywords(const std::list<std::string>& keyWord);
void addResponse(const std::string& title, const std::string& text, bool needMargin = true); void addResponse(std::string_view title, std::string_view text, bool needMargin = true);
void addMessageBox(const std::string& text); void addMessageBox(std::string_view text);
void onFrame(float dt) override; void onFrame(float dt) override;
void clear() override { resetReference(); } void clear() override { resetReference(); }

@ -140,7 +140,7 @@ namespace MWGui
void EnchantingDialog::setPtr(const MWWorld::Ptr& ptr) void EnchantingDialog::setPtr(const MWWorld::Ptr& ptr)
{ {
mName->setCaption(""); mName->setCaption({});
if (ptr.getClass().isActor()) if (ptr.getClass().isActor())
{ {

@ -34,7 +34,7 @@ namespace MWGui::Formatting
nullptr, MWWorld::Ptr()); // empty arguments, because there is no locals or actor nullptr, MWWorld::Ptr()); // empty arguments, because there is no locals or actor
mText = Interpreter::fixDefinesBook(mText, interpreterContext); mText = Interpreter::fixDefinesBook(mText, interpreterContext);
Misc::StringUtils::replaceAll(mText, "\r", ""); Misc::StringUtils::replaceAll(mText, "\r", {});
// vanilla game does not show any text after the last EOL tag. // vanilla game does not show any text after the last EOL tag.
const std::string lowerText = Misc::StringUtils::lowerCase(mText); const std::string lowerText = Misc::StringUtils::lowerCase(mText);
@ -82,9 +82,9 @@ namespace MWGui::Formatting
parseTag(mText.substr(tagStart, tagEnd - tagStart)); parseTag(mText.substr(tagStart, tagEnd - tagStart));
mIndex = tagEnd; mIndex = tagEnd;
if (mTagTypes.find(mTag) != mTagTypes.end()) if (auto it = mTagTypes.find(mTag); it != mTagTypes.end())
{ {
Events type = mTagTypes.at(mTag); Events type = it->second;
if (type == Event_BrTag || type == Event_PTag) if (type == Event_BrTag || type == Event_PTag)
{ {
@ -290,13 +290,19 @@ namespace MWGui::Formatting
{ {
const BookTextParser::Attributes& attr = parser.getAttributes(); const BookTextParser::Attributes& attr = parser.getAttributes();
if (attr.find("src") == attr.end() || attr.find("width") == attr.end() auto srcIt = attr.find("src");
|| attr.find("height") == attr.end()) if (srcIt == attr.end())
continue;
auto widthIt = attr.find("width");
if (widthIt == attr.end())
continue;
auto heightIt = attr.find("height");
if (heightIt == attr.end())
continue; continue;
std::string src = attr.at("src"); const std::string& src = srcIt->second;
int width = MyGUI::utility::parseInt(attr.at("width")); int width = MyGUI::utility::parseInt(widthIt->second);
int height = MyGUI::utility::parseInt(attr.at("height")); int height = MyGUI::utility::parseInt(heightIt->second);
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
std::string correctedSrc = Misc::ResourceHelpers::correctBookartPath(src, width, height, vfs); std::string correctedSrc = Misc::ResourceHelpers::correctBookartPath(src, width, height, vfs);
@ -349,10 +355,11 @@ namespace MWGui::Formatting
void BookFormatter::handleDiv(const BookTextParser::Attributes& attr) void BookFormatter::handleDiv(const BookTextParser::Attributes& attr)
{ {
if (attr.find("align") == attr.end()) auto it = attr.find("align");
if (it == attr.end())
return; return;
std::string align = attr.at("align"); const std::string& align = it->second;
if (Misc::StringUtils::ciEqual(align, "center")) if (Misc::StringUtils::ciEqual(align, "center"))
mBlockStyle.mAlign = MyGUI::Align::HCenter; mBlockStyle.mAlign = MyGUI::Align::HCenter;
@ -364,19 +371,21 @@ namespace MWGui::Formatting
void BookFormatter::handleFont(const BookTextParser::Attributes& attr) void BookFormatter::handleFont(const BookTextParser::Attributes& attr)
{ {
if (attr.find("color") != attr.end()) auto it = attr.find("color");
if (it != attr.end())
{ {
auto& colorString = attr.at("color"); const auto& colorString = it->second;
unsigned int color = 0; unsigned int color = 0;
std::from_chars(colorString.data(), colorString.data() + colorString.size(), color, 16); std::from_chars(colorString.data(), colorString.data() + colorString.size(), color, 16);
mTextStyle.mColour mTextStyle.mColour
= MyGUI::Colour((color >> 16 & 0xFF) / 255.f, (color >> 8 & 0xFF) / 255.f, (color & 0xFF) / 255.f); = MyGUI::Colour((color >> 16 & 0xFF) / 255.f, (color >> 8 & 0xFF) / 255.f, (color & 0xFF) / 255.f);
} }
if (attr.find("face") != attr.end()) it = attr.find("face");
if (it != attr.end())
{ {
std::string face = attr.at("face"); const std::string& face = it->second;
std::string name = Gui::FontLoader::getFontForFace(face); std::string name{ Gui::FontLoader::getFontForFace(face) };
mTextStyle.mFont = "Journalbook " + name; mTextStyle.mFont = "Journalbook " + name;
} }

@ -91,7 +91,7 @@ namespace MWGui
mModel->update(); mModel->update();
MyGUI::Widget* dragArea = mScrollView->createWidget<MyGUI::Widget>( MyGUI::Widget* dragArea = mScrollView->createWidget<MyGUI::Widget>(
"", 0, 0, mScrollView->getWidth(), mScrollView->getHeight(), MyGUI::Align::Stretch); {}, 0, 0, mScrollView->getWidth(), mScrollView->getHeight(), MyGUI::Align::Stretch);
dragArea->setNeedMouseFocus(true); dragArea->setNeedMouseFocus(true);
dragArea->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedBackground); dragArea->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedBackground);
dragArea->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheelMoved); dragArea->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheelMoved);

@ -23,7 +23,7 @@ namespace
static const int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight(); static const int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight();
if (count == 1) if (count == 1)
return ""; return {};
// With small text size we can use up to 4 characters, while with large ones - only up to 3. // With small text size we can use up to 4 characters, while with large ones - only up to 3.
if (fontHeight > 16) if (fontHeight > 16)
@ -148,11 +148,11 @@ namespace MWGui
if (ptr.isEmpty()) if (ptr.isEmpty())
{ {
if (mFrame) if (mFrame)
mFrame->setImageTexture(""); mFrame->setImageTexture({});
if (mItemShadow) if (mItemShadow)
mItemShadow->setImageTexture(""); mItemShadow->setImageTexture({});
mItem->setImageTexture(""); mItem->setImageTexture({});
mText->setCaption(""); mText->setCaption({});
mCurrentIcon.clear(); mCurrentIcon.clear();
mCurrentFrame.clear(); mCurrentFrame.clear();
return; return;
@ -175,7 +175,7 @@ namespace MWGui
else if (state == Barter) else if (state == Barter)
backgroundTex += "_barter"; backgroundTex += "_barter";
if (backgroundTex != "") if (!backgroundTex.empty())
backgroundTex += ".dds"; backgroundTex += ".dds";
float scale = 1.f; float scale = 1.f;
@ -210,7 +210,7 @@ namespace MWGui
if (mFrame && !mCurrentFrame.empty()) if (mFrame && !mCurrentFrame.empty())
{ {
mCurrentFrame.clear(); mCurrentFrame.clear();
mFrame->setImageTexture(""); mFrame->setImageTexture({});
} }
if (mCurrentIcon != icon) if (mCurrentIcon != icon)
{ {

@ -168,8 +168,8 @@ namespace MWGui
{ {
BookTypesetter::Ptr typesetter = createTypesetter(); BookTypesetter::Ptr typesetter = createTypesetter();
BookTypesetter::Style* header = typesetter->createStyle("", MyGUI::Colour(0.60f, 0.00f, 0.00f)); BookTypesetter::Style* header = typesetter->createStyle({}, MyGUI::Colour(0.60f, 0.00f, 0.00f));
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::Black); BookTypesetter::Style* body = typesetter->createStyle({}, MyGUI::Colour::Black);
typesetter->write(header, to_utf8_span("You have no journal entries!")); typesetter->write(header, to_utf8_span("You have no journal entries!"));
typesetter->lineBreak(); typesetter->lineBreak();
@ -183,10 +183,10 @@ namespace MWGui
{ {
BookTypesetter::Ptr typesetter = createTypesetter(); BookTypesetter::Ptr typesetter = createTypesetter();
BookTypesetter::Style* header = typesetter->createStyle("", MyGUI::Colour(0.60f, 0.00f, 0.00f)); BookTypesetter::Style* header = typesetter->createStyle({}, MyGUI::Colour(0.60f, 0.00f, 0.00f));
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::Black); BookTypesetter::Style* body = typesetter->createStyle({}, MyGUI::Colour::Black);
mModel->visitJournalEntries("", AddJournalEntry(typesetter, body, header, true)); mModel->visitJournalEntries({}, AddJournalEntry(typesetter, body, header, true));
return typesetter->complete(); return typesetter->complete();
} }
@ -195,8 +195,8 @@ namespace MWGui
{ {
BookTypesetter::Ptr typesetter = createTypesetter(); BookTypesetter::Ptr typesetter = createTypesetter();
BookTypesetter::Style* header = typesetter->createStyle("", MyGUI::Colour(0.60f, 0.00f, 0.00f)); BookTypesetter::Style* header = typesetter->createStyle({}, MyGUI::Colour(0.60f, 0.00f, 0.00f));
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::Black); BookTypesetter::Style* body = typesetter->createStyle({}, MyGUI::Colour::Black);
mModel->visitTopicName(topicId, AddTopicName(typesetter, header)); mModel->visitTopicName(topicId, AddTopicName(typesetter, header));
@ -211,8 +211,8 @@ namespace MWGui
{ {
BookTypesetter::Ptr typesetter = createTypesetter(); BookTypesetter::Ptr typesetter = createTypesetter();
BookTypesetter::Style* header = typesetter->createStyle("", MyGUI::Colour(0.60f, 0.00f, 0.00f)); BookTypesetter::Style* header = typesetter->createStyle({}, MyGUI::Colour(0.60f, 0.00f, 0.00f));
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::Black); BookTypesetter::Style* body = typesetter->createStyle({}, MyGUI::Colour::Black);
AddQuestName addName(typesetter, header); AddQuestName addName(typesetter, header);
addName(to_utf8_span(questName)); addName(to_utf8_span(questName));
@ -243,7 +243,7 @@ namespace MWGui
char ch = 'A'; char ch = 'A';
std::string buffer; std::string buffer;
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::Black); BookTypesetter::Style* body = typesetter->createStyle({}, MyGUI::Colour::Black);
for (int i = 0; i < 26; ++i) for (int i = 0; i < 26; ++i)
{ {
buffer = "( "; buffer = "( ";
@ -272,7 +272,7 @@ namespace MWGui
typesetter->setSectionAlignment(BookTypesetter::AlignCenter); typesetter->setSectionAlignment(BookTypesetter::AlignCenter);
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::Black); BookTypesetter::Style* body = typesetter->createStyle({}, MyGUI::Colour::Black);
int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight(); int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight();
@ -297,7 +297,7 @@ namespace MWGui
buffer += ch[1]; buffer += ch[1];
buffer += " )"; buffer += " )";
Utf8Stream stream((char*)ch); Utf8Stream stream(ch, ch + 2);
Utf8Stream::UnicodeChar first = stream.peek(); Utf8Stream::UnicodeChar first = stream.peek();
const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();

@ -107,7 +107,7 @@ namespace MWGui
void LevelupDialog::assignCoins() void LevelupDialog::assignCoins()
{ {
resetCoins(); resetCoins();
for (unsigned int i = 0; i < mSpentAttributes.size(); ++i) for (size_t i = 0; i < mSpentAttributes.size(); ++i)
{ {
MyGUI::ImageBox* image = mCoins[i]; MyGUI::ImageBox* image = mCoins[i];
image->detachFromWidget(); image->detachFromWidget();
@ -115,7 +115,7 @@ namespace MWGui
int attribute = mSpentAttributes[i]; int attribute = mSpentAttributes[i];
int xdiff = mAttributeMultipliers[attribute]->getCaption() == "" ? 0 : 20; int xdiff = mAttributeMultipliers[attribute]->getCaption().empty() ? 0 : 20;
MyGUI::IntPoint pos = mAttributes[attribute]->getAbsolutePosition() - mAssignWidget->getAbsolutePosition() MyGUI::IntPoint pos = mAttributes[attribute]->getAbsolutePosition() - mAssignWidget->getAbsolutePosition()
- MyGUI::IntPoint(22 + xdiff, 0); - MyGUI::IntPoint(22 + xdiff, 0);
@ -160,14 +160,17 @@ namespace MWGui
float mult = pcStats.getLevelupAttributeMultiplier(i); float mult = pcStats.getLevelupAttributeMultiplier(i);
mult = std::min(mult, 100 - pcStats.getAttribute(i).getBase()); mult = std::min(mult, 100 - pcStats.getAttribute(i).getBase());
text->setCaption(mult <= 1 ? "" : "x" + MyGUI::utility::toString(mult)); if (mult <= 1)
text->setCaption({});
else
text->setCaption("x" + MyGUI::utility::toString(mult));
} }
else else
{ {
mAttributes[i]->setEnabled(false); mAttributes[i]->setEnabled(false);
mAttributeValues[i]->setEnabled(false); mAttributeValues[i]->setEnabled(false);
text->setCaption(""); text->setCaption({});
} }
} }
@ -227,10 +230,10 @@ namespace MWGui
assignCoins(); assignCoins();
} }
std::string LevelupDialog::getLevelupClassImage( std::string_view LevelupDialog::getLevelupClassImage(
const int combatIncreases, const int magicIncreases, const int stealthIncreases) const int combatIncreases, const int magicIncreases, const int stealthIncreases)
{ {
std::string ret = "acrobat"; std::string_view ret = "acrobat";
int total = combatIncreases + magicIncreases + stealthIncreases; int total = combatIncreases + magicIncreases + stealthIncreases;
if (total == 0) if (total == 0)

@ -40,7 +40,7 @@ namespace MWGui
void setAttributeValues(); void setAttributeValues();
std::string getLevelupClassImage( std::string_view getLevelupClassImage(
const int combatIncreases, const int magicIncreases, const int stealthIncreases); const int combatIncreases, const int magicIncreases, const int stealthIncreases);
}; };

@ -226,7 +226,7 @@ namespace MWGui
mSplashImage->setVisible(true); mSplashImage->setVisible(true);
mSplashImage->setBackgroundImage(randomSplash, true, stretch); mSplashImage->setBackgroundImage(randomSplash, true, stretch);
} }
mSceneImage->setBackgroundImage(""); mSceneImage->setBackgroundImage({});
mSceneImage->setVisible(false); mSceneImage->setVisible(false);
} }
@ -313,7 +313,7 @@ namespace MWGui
mViewer->getCamera()->addInitialDrawCallback(mCopyFramebufferToTextureCallback); mViewer->getCamera()->addInitialDrawCallback(mCopyFramebufferToTextureCallback);
mCopyFramebufferToTextureCallback->reset(); mCopyFramebufferToTextureCallback->reset();
mSplashImage->setBackgroundImage(""); mSplashImage->setBackgroundImage({});
mSplashImage->setVisible(false); mSplashImage->setVisible(false);
mSceneImage->setRenderItemTexture(mGuiTexture.get()); mSceneImage->setRenderItemTexture(mGuiTexture.get());

@ -218,7 +218,7 @@ namespace MWGui
if (!mButtonBox) if (!mButtonBox)
mButtonBox mButtonBox
= mMainWidget->createWidget<MyGUI::Widget>("", MyGUI::IntCoord(0, 0, 0, 0), MyGUI::Align::Default); = mMainWidget->createWidget<MyGUI::Widget>({}, MyGUI::IntCoord(0, 0, 0, 0), MyGUI::Align::Default);
int curH = 0; int curH = 0;
@ -250,26 +250,24 @@ namespace MWGui
buttons.emplace_back("exitgame"); buttons.emplace_back("exitgame");
// Create new buttons if needed // Create new buttons if needed
std::vector<std::string> allButtons{ "return", "newgame", "savegame", "loadgame", "options", "credits", for (std::string_view id : { "return", "newgame", "savegame", "loadgame", "options", "credits", "exitgame" })
"exitgame" };
for (std::string& buttonId : allButtons)
{ {
if (mButtons.find(buttonId) == mButtons.end()) if (mButtons.find(id) == mButtons.end())
{ {
Gui::ImageButton* button = mButtonBox->createWidget<Gui::ImageButton>( Gui::ImageButton* button = mButtonBox->createWidget<Gui::ImageButton>(
"ImageBox", MyGUI::IntCoord(0, curH, 0, 0), MyGUI::Align::Default); "ImageBox", MyGUI::IntCoord(0, curH, 0, 0), MyGUI::Align::Default);
const std::string& buttonId = mButtons.emplace(id, button).first->first;
button->setProperty("ImageHighlighted", "textures\\menu_" + buttonId + "_over.dds"); button->setProperty("ImageHighlighted", "textures\\menu_" + buttonId + "_over.dds");
button->setProperty("ImageNormal", "textures\\menu_" + buttonId + ".dds"); button->setProperty("ImageNormal", "textures\\menu_" + buttonId + ".dds");
button->setProperty("ImagePushed", "textures\\menu_" + buttonId + "_pressed.dds"); button->setProperty("ImagePushed", "textures\\menu_" + buttonId + "_pressed.dds");
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::onButtonClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::onButtonClicked);
button->setUserData(std::string(buttonId)); button->setUserData(buttonId);
mButtons[buttonId] = button;
} }
} }
// Start by hiding all buttons // Start by hiding all buttons
int maxwidth = 0; int maxwidth = 0;
for (auto& buttonPair : mButtons) for (const auto& buttonPair : mButtons)
{ {
buttonPair.second->setVisible(false); buttonPair.second->setVisible(false);
MyGUI::IntSize requested = buttonPair.second->getRequestedSize(); MyGUI::IntSize requested = buttonPair.second->getRequestedSize();
@ -278,10 +276,11 @@ namespace MWGui
} }
// Now show and position the ones we want // Now show and position the ones we want
for (std::string& buttonId : buttons) for (const std::string& buttonId : buttons)
{ {
assert(mButtons.find(buttonId) != mButtons.end()); auto it = mButtons.find(buttonId);
Gui::ImageButton* button = mButtons[buttonId]; assert(it != mButtons.end());
Gui::ImageButton* button = it->second;
button->setVisible(true); button->setVisible(true);
// By default, assume that all menu buttons textures should have 64 height. // By default, assume that all menu buttons textures should have 64 height.

@ -51,7 +51,7 @@ namespace MWGui
MyGUI::ImageBox* mVideoBackground; MyGUI::ImageBox* mVideoBackground;
VideoWidget* mVideo; // For animated main menus VideoWidget* mVideo; // For animated main menus
std::map<std::string, Gui::ImageButton*> mButtons; std::map<std::string, Gui::ImageButton*, std::less<>> mButtons;
void onButtonClicked(MyGUI::Widget* sender); void onButtonClicked(MyGUI::Widget* sender);
void onNewGameConfirmed(); void onNewGameConfirmed();

@ -252,7 +252,7 @@ namespace MWGui
{ {
for (auto& entry : mMaps) for (auto& entry : mMaps)
{ {
entry.mFogWidget->setImageTexture(""); entry.mFogWidget->setImageTexture({});
entry.mFogTexture.reset(); entry.mFogTexture.reset();
} }
} }
@ -891,7 +891,7 @@ namespace MWGui
mEditNoteDialog.setVisible(true); mEditNoteDialog.setVisible(true);
mEditNoteDialog.showDeleteButton(false); mEditNoteDialog.showDeleteButton(false);
mEditNoteDialog.setText(""); mEditNoteDialog.setText({});
} }
void MapWindow::onMapZoomed(MyGUI::Widget* sender, int rel) void MapWindow::onMapZoomed(MyGUI::Widget* sender, int rel)
@ -1122,7 +1122,7 @@ namespace MWGui
if (!destNotes.empty()) if (!destNotes.empty())
{ {
MarkerUserData data(nullptr); MarkerUserData data(nullptr);
data.notes = destNotes; std::swap(data.notes, destNotes);
data.caption = markerWidget->getUserString("Caption_TextOneLine"); data.caption = markerWidget->getUserString("Caption_TextOneLine");
markerWidget->setUserData(data); markerWidget->setUserData(data);
markerWidget->setUserString("ToolTipType", "MapMarker"); markerWidget->setUserString("ToolTipType", "MapMarker");

@ -81,7 +81,7 @@ namespace MWGui
mConfigLayout->setVisibleVScroll(true); mConfigLayout->setVisibleVScroll(true);
mConfigArea = mConfigLayout->createWidget<MyGUI::Widget>("", {}, MyGUI::Align::Default); mConfigArea = mConfigLayout->createWidget<MyGUI::Widget>({}, {}, MyGUI::Align::Default);
mConfigLayout->eventMouseWheel += MyGUI::newDelegate(this, &PostProcessorHud::notifyMouseWheel); mConfigLayout->eventMouseWheel += MyGUI::newDelegate(this, &PostProcessorHud::notifyMouseWheel);
mConfigArea->eventMouseWheel += MyGUI::newDelegate(this, &PostProcessorHud::notifyMouseWheel); mConfigArea->eventMouseWheel += MyGUI::newDelegate(this, &PostProcessorHud::notifyMouseWheel);

@ -33,9 +33,9 @@ namespace MWGui
const std::string basisSkinType = basis->findAttribute("type"); const std::string basisSkinType = basis->findAttribute("type");
if (Misc::StringUtils::ciEqual(basisSkinType, "SimpleText")) if (Misc::StringUtils::ciEqual(basisSkinType, "SimpleText"))
continue; continue;
bool isTileRect = Misc::StringUtils::ciEqual(basisSkinType, "TileRect");
const std::string offset = basis->findAttribute("offset"); if (!basis->findAttribute("offset").empty())
if (!offset.empty())
continue; continue;
basis->addAttribute("offset", coord); basis->addAttribute("offset", coord);
@ -45,19 +45,17 @@ namespace MWGui
{ {
if (state->getName() == "State") if (state->getName() == "State")
{ {
const std::string stateOffset = state->findAttribute("offset"); if (!state->findAttribute("offset").empty())
if (!stateOffset.empty())
continue; continue;
state->addAttribute("offset", coord); state->addAttribute("offset", coord);
if (Misc::StringUtils::ciEqual(basisSkinType, "TileRect")) if (isTileRect)
{ {
MyGUI::xml::ElementEnumerator property = state->getElementEnumerator(); MyGUI::xml::ElementEnumerator property = state->getElementEnumerator();
bool hasTileSize = false; bool hasTileSize = false;
while (property.next("Property")) while (property.next("Property"))
{ {
const std::string key = property->findAttribute("key"); if (property->findAttribute("key") != "TileSize")
if (key != "TileSize")
continue; continue;
hasTileSize = true; hasTileSize = true;

@ -146,7 +146,7 @@ namespace MWGui
{ {
WindowModal::onOpen(); WindowModal::onOpen();
mSaveNameEdit->setCaption(""); mSaveNameEdit->setCaption({});
if (mSaving) if (mSaving)
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mSaveNameEdit); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mSaveNameEdit);
else else
@ -154,7 +154,7 @@ namespace MWGui
center(); center();
mCharacterSelection->setCaption(""); mCharacterSelection->setCaption({});
mCharacterSelection->removeAllItems(); mCharacterSelection->removeAllItems();
mCurrentCharacter = nullptr; mCurrentCharacter = nullptr;
mCurrentSlot = nullptr; mCurrentSlot = nullptr;
@ -167,7 +167,7 @@ namespace MWGui
mCurrentCharacter = mgr->getCurrentCharacter(); mCurrentCharacter = mgr->getCurrentCharacter();
std::string directory = Misc::StringUtils::lowerCase(Settings::Manager::getString("character", "Saves")); const std::string& directory = Settings::Manager::getString("character", "Saves");
size_t selectedIndex = MyGUI::ITEM_NONE; size_t selectedIndex = MyGUI::ITEM_NONE;
@ -203,9 +203,8 @@ namespace MWGui
if (mCurrentCharacter == &*it if (mCurrentCharacter == &*it
|| (!mCurrentCharacter && !mSaving || (!mCurrentCharacter && !mSaving
&& directory && Misc::StringUtils::ciEqual(
== Misc::StringUtils::lowerCase( directory, Files::pathToUnicodeString(it->begin()->mPath.parent_path().filename()))))
Files::pathToUnicodeString(it->begin()->mPath.parent_path().filename()))))
{ {
mCurrentCharacter = &*it; mCurrentCharacter = &*it;
selectedIndex = mCharacterSelection->getItemCount() - 1; selectedIndex = mCharacterSelection->getItemCount() - 1;
@ -389,8 +388,8 @@ namespace MWGui
if (pos == MyGUI::ITEM_NONE || !mCurrentCharacter) if (pos == MyGUI::ITEM_NONE || !mCurrentCharacter)
{ {
mCurrentSlot = nullptr; mCurrentSlot = nullptr;
mInfoText->setCaption(""); mInfoText->setCaption({});
mScreenshot->setImageTexture(""); mScreenshot->setImageTexture({});
return; return;
} }

@ -107,25 +107,25 @@ namespace
return MyGUI::utility::toString(xaspect) + " : " + MyGUI::utility::toString(yaspect); return MyGUI::utility::toString(xaspect) + " : " + MyGUI::utility::toString(yaspect);
} }
const char* checkButtonType = "CheckButton"; const std::string_view checkButtonType = "CheckButton";
const char* sliderType = "Slider"; const std::string_view sliderType = "Slider";
std::string getSettingType(MyGUI::Widget* widget) std::string_view getSettingType(MyGUI::Widget* widget)
{ {
return widget->getUserString("SettingType"); return widget->getUserString("SettingType");
} }
std::string getSettingName(MyGUI::Widget* widget) std::string_view getSettingName(MyGUI::Widget* widget)
{ {
return widget->getUserString("SettingName"); return widget->getUserString("SettingName");
} }
std::string getSettingCategory(MyGUI::Widget* widget) std::string_view getSettingCategory(MyGUI::Widget* widget)
{ {
return widget->getUserString("SettingCategory"); return widget->getUserString("SettingCategory");
} }
std::string getSettingValueType(MyGUI::Widget* widget) std::string_view getSettingValueType(MyGUI::Widget* widget)
{ {
return widget->getUserString("SettingValueType"); return widget->getUserString("SettingValueType");
} }
@ -165,7 +165,7 @@ namespace MWGui
{ {
MyGUI::Widget* current = widgets.current(); MyGUI::Widget* current = widgets.current();
std::string type = getSettingType(current); std::string_view type = getSettingType(current);
if (type == checkButtonType) if (type == checkButtonType)
{ {
const std::string initialValue const std::string initialValue
@ -179,7 +179,7 @@ namespace MWGui
{ {
MyGUI::ScrollBar* scroll = current->castType<MyGUI::ScrollBar>(); MyGUI::ScrollBar* scroll = current->castType<MyGUI::ScrollBar>();
std::string valueStr; std::string valueStr;
std::string valueType = getSettingValueType(current); std::string_view valueType = getSettingValueType(current);
if (valueType == "Float" || valueType == "Integer" || valueType == "Cell") if (valueType == "Float" || valueType == "Integer" || valueType == "Cell")
{ {
// TODO: ScrollBar isn't meant for this. should probably use a dedicated FloatSlider widget // TODO: ScrollBar isn't meant for this. should probably use a dedicated FloatSlider widget
@ -689,7 +689,7 @@ namespace MWGui
if (getSettingType(scroller) == "Slider") if (getSettingType(scroller) == "Slider")
{ {
std::string valueStr; std::string valueStr;
std::string valueType = getSettingValueType(scroller); std::string_view valueType = getSettingValueType(scroller);
if (valueType == "Float" || valueType == "Integer" || valueType == "Cell") if (valueType == "Float" || valueType == "Integer" || valueType == "Cell")
{ {
float value = pos / float(scroller->getScrollRange() - 1); float value = pos / float(scroller->getScrollRange() - 1);

@ -366,7 +366,7 @@ namespace MWGui
void SpellCreationDialog::setPtr(const MWWorld::Ptr& actor) void SpellCreationDialog::setPtr(const MWWorld::Ptr& actor)
{ {
mPtr = actor; mPtr = actor;
mNameEdit->setCaption(""); mNameEdit->setCaption({});
startEditing(); startEditing();
} }
@ -384,7 +384,7 @@ namespace MWGui
return; return;
} }
if (mNameEdit->getCaption() == "") if (mNameEdit->getCaption().empty())
{ {
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage10}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage10}");
return; return;
@ -700,7 +700,7 @@ namespace MWGui
params.mIsConstant = mConstantEffect; params.mIsConstant = mConstantEffect;
MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>( MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>(
"", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default); {}, MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default);
button->setUserData(i); button->setUserData(i);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onEditEffect); button->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onEditEffect);
button->setNeedMouseFocus(true); button->setNeedMouseFocus(true);

@ -100,7 +100,7 @@ namespace MWGui
if (curType != spell.mType) if (curType != spell.mType)
{ {
if (spell.mType == Spell::Type_Power) if (spell.mType == Spell::Type_Power)
addGroup("#{sPowers}", ""); addGroup("#{sPowers}", {});
else if (spell.mType == Spell::Type_Spell) else if (spell.mType == Spell::Type_Spell)
addGroup("#{sSpells}", mShowCostColumn ? "#{sCostChance}" : ""); addGroup("#{sSpells}", mShowCostColumn ? "#{sCostChance}" : "");
else else
@ -246,7 +246,7 @@ namespace MWGui
groupWidget->setTextAlign(MyGUI::Align::Left); groupWidget->setTextAlign(MyGUI::Align::Left);
groupWidget->setNeedMouseFocus(false); groupWidget->setNeedMouseFocus(false);
if (label2 != "") if (!label2.empty())
{ {
MyGUI::TextBox* groupWidget2 = mScrollView->createWidget<Gui::TextBox>("SandBrightText", MyGUI::TextBox* groupWidget2 = mScrollView->createWidget<Gui::TextBox>("SandBrightText",
MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24), MyGUI::Align::Left | MyGUI::Align::Top);

@ -241,7 +241,7 @@ namespace MWGui
if ((!godmode && stats.isParalyzed()) || stats.getKnockedDown() || stats.isDead() || stats.getHitRecovery()) if ((!godmode && stats.isParalyzed()) || stats.getKnockedDown() || stats.isDead() || stats.getHitRecovery())
return; return;
mSpellView->setModel(new SpellModel(MWMechanics::getPlayer(), "")); mSpellView->setModel(new SpellModel(MWMechanics::getPlayer()));
SpellModel::ModelIndex selected = mSpellView->getModel()->getSelectedIndex(); SpellModel::ModelIndex selected = mSpellView->getModel()->getSelectedIndex();
if (selected < 0) if (selected < 0)

@ -347,9 +347,12 @@ namespace MWGui
float mult = PCstats.getLevelupAttributeMultiplier(attribute); float mult = PCstats.getLevelupAttributeMultiplier(attribute);
mult = std::min(mult, 100 - PCstats.getAttribute(attribute).getBase()); mult = std::min(mult, 100 - PCstats.getAttribute(attribute).getBase());
if (mult > 1) if (mult > 1)
detail << (detail.str().empty() ? "" : "\n") << "#{" {
<< MyGUI::TextIterator::toTagsString(ESM::Attribute::sGmstAttributeIds[attribute]) << "} x" if (!detail.view().empty())
<< MyGUI::utility::toString(mult); detail << '\n';
detail << "#{" << MyGUI::TextIterator::toTagsString(ESM::Attribute::sGmstAttributeIds[attribute])
<< "} x" << MyGUI::utility::toString(mult);
}
} }
detailText = MyGUI::LanguageManager::getInstance().replaceTags(detail.str()); detailText = MyGUI::LanguageManager::getInstance().replaceTags(detail.str());

@ -169,9 +169,9 @@ namespace MWGui
return; return;
} }
std::string type = focus->getUserString("ToolTipType"); std::string_view type = focus->getUserString("ToolTipType");
if (type == "") if (type.empty())
{ {
return; return;
} }
@ -252,8 +252,8 @@ namespace MWGui
int school = MWMechanics::getSpellSchool(spell, player); int school = MWMechanics::getSpellSchool(spell, player);
info.text = "#{sSchool}: " + sSchoolNames[school]; info.text = "#{sSchool}: " + sSchoolNames[school];
} }
std::string cost = focus->getUserString("SpellCost"); const std::string& cost = focus->getUserString("SpellCost");
if (cost != "" && cost != "0") if (!cost.empty() && cost != "0")
info.text info.text
+= MWGui::ToolTips::getValueString(MWMechanics::calcSpellCost(*spell), "#{sCastCost}"); += MWGui::ToolTips::getValueString(MWMechanics::calcSpellCost(*spell), "#{sCastCost}");
info.effects = effects; info.effects = effects;
@ -267,7 +267,7 @@ namespace MWGui
tooltip->setVisible(true); tooltip->setVisible(true);
std::map<std::string, std::string> userStrings = focus->getUserStrings(); const auto& userStrings = focus->getUserStrings();
for (auto& userStringPair : userStrings) for (auto& userStringPair : userStrings)
{ {
size_t underscorePos = userStringPair.first.find('_'); size_t underscorePos = userStringPair.first.find('_');
@ -496,7 +496,7 @@ namespace MWGui
if (!info.effects.empty()) if (!info.effects.empty())
{ {
MyGUI::Widget* effectArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("", MyGUI::Widget* effectArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>({},
MyGUI::IntCoord(padding.left, totalSize.height, 300 - padding.left, 300 - totalSize.height), MyGUI::IntCoord(padding.left, totalSize.height, 300 - padding.left, 300 - totalSize.height),
MyGUI::Align::Stretch); MyGUI::Align::Stretch);
@ -518,7 +518,7 @@ namespace MWGui
if (enchant) if (enchant)
{ {
MyGUI::Widget* enchantArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("", MyGUI::Widget* enchantArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>({},
MyGUI::IntCoord(padding.left, totalSize.height, 300 - padding.left, 300 - totalSize.height), MyGUI::IntCoord(padding.left, totalSize.height, 300 - padding.left, 300 - totalSize.height),
MyGUI::Align::Stretch); MyGUI::Align::Stretch);
@ -932,7 +932,7 @@ namespace MWGui
void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass) void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass)
{ {
if (playerClass.mName == "") if (playerClass.mName.empty())
return; return;
int spec = playerClass.mData.mSpecialization; int spec = playerClass.mData.mSpecialization;

@ -128,7 +128,7 @@ namespace MWGui
setTitle(actor.getClass().getName(actor)); setTitle(actor.getClass().getName(actor));
onFilterChanged(mFilterAll); onFilterChanged(mFilterAll);
mFilterEdit->setCaption(""); mFilterEdit->setCaption({});
} }
void TradeWindow::onFrame(float dt) void TradeWindow::onFrame(float dt)

@ -171,7 +171,7 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->fadeScreenOut(1); MWBase::Environment::get().getWindowManager()->fadeScreenOut(1);
ESM::Position pos = *_sender->getUserData<ESM::Position>(); ESM::Position pos = *_sender->getUserData<ESM::Position>();
const std::string& cellname = _sender->getUserString("Destination"); std::string_view cellname = _sender->getUserString("Destination");
bool interior = _sender->getUserString("interior") == "y"; bool interior = _sender->getUserString("interior") == "y";
if (mPtr.getCell()->isExterior()) if (mPtr.getCell()->isExterior())
{ {

@ -62,7 +62,7 @@ namespace MWGui::Widgets
{ {
if (mSkillId == ESM::Skill::Length) if (mSkillId == ESM::Skill::Length)
{ {
mSkillNameWidget->setCaption(""); mSkillNameWidget->setCaption({});
} }
else else
{ {
@ -147,7 +147,7 @@ namespace MWGui::Widgets
{ {
if (mId < 0 || mId >= 8) if (mId < 0 || mId >= 8)
{ {
mAttributeNameWidget->setCaption(""); mAttributeNameWidget->setCaption({});
} }
else else
{ {
@ -251,7 +251,7 @@ namespace MWGui::Widgets
if (spell) if (spell)
mSpellNameWidget->setCaption(spell->mName); mSpellNameWidget->setCaption(spell->mName);
else else
mSpellNameWidget->setCaption(""); mSpellNameWidget->setCaption({});
} }
} }
@ -371,7 +371,7 @@ namespace MWGui::Widgets
mTextWidget->setCoord(sIconOffset / 2, mTextWidget->getCoord().top, mTextWidget->getCoord().width, mTextWidget->setCoord(sIconOffset / 2, mTextWidget->getCoord().top, mTextWidget->getCoord().width,
mTextWidget->getCoord().height); // Compensates for the missing image when effect is not known mTextWidget->getCoord().height); // Compensates for the missing image when effect is not known
mRequestedWidth = mTextWidget->getTextSize().width + sIconOffset; mRequestedWidth = mTextWidget->getTextSize().width + sIconOffset;
mImageWidget->setImageTexture(""); mImageWidget->setImageTexture({});
return; return;
} }

@ -212,7 +212,7 @@ namespace MWGui
resourceSystem->getVFS(), mScalingFactor, "mygui", logpath / "MyGUI.log"); resourceSystem->getVFS(), mScalingFactor, "mygui", logpath / "MyGUI.log");
mGui = std::make_unique<MyGUI::Gui>(); mGui = std::make_unique<MyGUI::Gui>();
mGui->initialise(""); mGui->initialise({});
createTextures(); createTextures();
@ -517,7 +517,7 @@ namespace MWGui
trackWindow(mPostProcessorHud, makePostprocessorWindowSettingValues()); trackWindow(mPostProcessorHud, makePostprocessorWindowSettingValues());
mInputBlocker = MyGUI::Gui::getInstance().createWidget<MyGUI::Widget>( mInputBlocker = MyGUI::Gui::getInstance().createWidget<MyGUI::Widget>(
"", 0, 0, w, h, MyGUI::Align::Stretch, "InputBlocker"); {}, 0, 0, w, h, MyGUI::Align::Stretch, "InputBlocker");
mHud->setVisible(true); mHud->setVisible(true);
@ -796,7 +796,8 @@ namespace MWGui
{ {
if (getMode() == GM_Dialogue && showInDialogueMode != MWGui::ShowInDialogueMode_Never) if (getMode() == GM_Dialogue && showInDialogueMode != MWGui::ShowInDialogueMode_Never)
{ {
mDialogueWindow->addMessageBox(MyGUI::LanguageManager::getInstance().replaceTags(toUString(message))); MyGUI::UString text = MyGUI::LanguageManager::getInstance().replaceTags(toUString(message));
mDialogueWindow->addMessageBox(text.asUTF8());
} }
else if (showInDialogueMode != MWGui::ShowInDialogueMode_Only) else if (showInDialogueMode != MWGui::ShowInDialogueMode_Only)
{ {

@ -29,15 +29,13 @@
namespace namespace
{ {
MyGUI::xml::ElementPtr getProperty(MyGUI::xml::ElementPtr resourceNode, const std::string propertyName) MyGUI::xml::ElementPtr getProperty(MyGUI::xml::ElementPtr resourceNode, std::string_view propertyName)
{ {
MyGUI::xml::ElementPtr propertyNode = nullptr; MyGUI::xml::ElementPtr propertyNode = nullptr;
MyGUI::xml::ElementEnumerator propertyIterator = resourceNode->getElementEnumerator(); MyGUI::xml::ElementEnumerator propertyIterator = resourceNode->getElementEnumerator();
while (propertyIterator.next("Property")) while (propertyIterator.next("Property"))
{ {
std::string key = propertyIterator->findAttribute("key"); if (propertyIterator->findAttribute("key") == propertyName)
if (key == propertyName)
{ {
propertyNode = propertyIterator.current(); propertyNode = propertyIterator.current();
break; break;
@ -55,15 +53,15 @@ namespace
MyGUI::xml::ElementEnumerator layersIterator = root->getElementEnumerator(); MyGUI::xml::ElementEnumerator layersIterator = root->getElementEnumerator();
while (layersIterator.next("Layer")) while (layersIterator.next("Layer"))
{ {
std::string name = layersIterator->findAttribute("name"); if (layersIterator->findAttribute("name") == "JournalBooks")
if (name == "JournalBooks")
{ {
MyGUI::xml::ElementPtr sizeProperty = getProperty(layersIterator.current(), "Size"); MyGUI::xml::ElementPtr sizeProperty = getProperty(layersIterator.current(), "Size");
const std::string& sizeValue if (sizeProperty != nullptr)
= sizeProperty != nullptr ? sizeProperty->findAttribute("value") : std::string(); {
if (!sizeValue.empty()) std::string sizeValue = sizeProperty->findAttribute("value");
return MyGUI::IntSize::parse(sizeValue); if (!sizeValue.empty())
return MyGUI::IntSize::parse(sizeValue);
}
} }
} }
@ -215,7 +213,7 @@ namespace
} }
} }
[[noreturn]] void fail(std::istream& stream, const std::string& fileName, const std::string& message) [[noreturn]] void fail(std::istream& stream, std::string_view fileName, std::string_view message)
{ {
std::stringstream error; std::stringstream error;
error << "Font loading error: " << message; error << "Font loading error: " << message;
@ -291,7 +289,7 @@ namespace Gui
MyGUI::IntSize bookSize = getBookSize(layersStream.get()); MyGUI::IntSize bookSize = getBookSize(layersStream.get());
float bookScale = osgMyGUI::ScalingLayer::getScaleFactor(bookSize); float bookScale = osgMyGUI::ScalingLayer::getScaleFactor(bookSize);
const auto oldDataPath = dataManager->getDataPath(""); const auto oldDataPath = dataManager->getDataPath({});
dataManager->setResourcePath("fonts"); dataManager->setResourcePath("fonts");
std::unique_ptr<MyGUI::IDataStream> dataStream(dataManager->getData(fileName)); std::unique_ptr<MyGUI::IDataStream> dataStream(dataManager->getData(fileName));
@ -303,8 +301,7 @@ namespace Gui
bool valid = false; bool valid = false;
if (resourceNode.next("Resource")) if (resourceNode.next("Resource"))
{ {
std::string type = resourceNode->findAttribute("type"); valid = resourceNode->findAttribute("type") == "ResourceTrueTypeFont";
valid = (type == "ResourceTrueTypeFont");
} }
if (valid == false) if (valid == false)
@ -450,7 +447,7 @@ namespace Gui
defaultHeight->addAttribute("value", fontSize); defaultHeight->addAttribute("value", fontSize);
MyGUI::xml::ElementPtr source = root->createChild("Property"); MyGUI::xml::ElementPtr source = root->createChild("Property");
source->addAttribute("key", "Source"); source->addAttribute("key", "Source");
source->addAttribute("value", std::string(bitmapFilename)); source->addAttribute("value", bitmapFilename);
MyGUI::xml::ElementPtr codes = root->createChild("Codes"); MyGUI::xml::ElementPtr codes = root->createChild("Codes");
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
@ -532,12 +529,12 @@ namespace Gui
additional.insert(std::make_pair(84, 0x2122)); // trademark sign additional.insert(std::make_pair(84, 0x2122)); // trademark sign
additional.insert(std::make_pair(45, 0x2212)); // minus sign additional.insert(std::make_pair(45, 0x2212)); // minus sign
for (std::multimap<int, int>::iterator it = additional.begin(); it != additional.end(); ++it) for (const auto [key, value] : additional)
{ {
if (it->first != i) if (key != i)
continue; continue;
code = codes->createChild("Code"); code = codes->createChild("Code");
code->addAttribute("index", it->second); code->addAttribute("index", value);
code->addAttribute("coord", code->addAttribute("coord",
MyGUI::utility::toString(x1) + " " + MyGUI::utility::toString(y1) + " " MyGUI::utility::toString(x1) + " " + MyGUI::utility::toString(y1) + " "
+ MyGUI::utility::toString(w) + " " + MyGUI::utility::toString(h)); + MyGUI::utility::toString(w) + " " + MyGUI::utility::toString(h));
@ -638,10 +635,9 @@ namespace Gui
return mFontHeight; return mFontHeight;
} }
std::string FontLoader::getFontForFace(const std::string& face) std::string_view FontLoader::getFontForFace(std::string_view face)
{ {
const std::string lowerFace = Misc::StringUtils::lowerCase(face); if (Misc::StringUtils::ciEqual(face, "daedric"))
if (lowerFace == "daedric")
return "ScrollFont"; return "ScrollFont";
return "DefaultFont"; return "DefaultFont";

@ -31,7 +31,7 @@ namespace Gui
int getFontHeight(); int getFontHeight();
static std::string getFontForFace(const std::string& face); static std::string_view getFontForFace(std::string_view face);
private: private:
ToUTF8::FromType mEncoding; ToUTF8::FromType mEncoding;

@ -171,17 +171,17 @@ namespace
namespace Interpreter namespace Interpreter
{ {
std::string fixDefinesDialog(const std::string& text, Context& context) std::string fixDefinesDialog(std::string_view text, Context& context)
{ {
return fixDefinesReal(text, true, context); return fixDefinesReal(text, true, context);
} }
std::string fixDefinesMsgBox(const std::string& text, Context& context) std::string fixDefinesMsgBox(std::string_view text, Context& context)
{ {
return fixDefinesReal(text, false, context); return fixDefinesReal(text, false, context);
} }
std::string fixDefinesBook(const std::string& text, Context& context) std::string fixDefinesBook(std::string_view text, Context& context)
{ {
return fixDefinesReal(text, false, context); return fixDefinesReal(text, false, context);
} }

@ -6,9 +6,9 @@
namespace Interpreter namespace Interpreter
{ {
std::string fixDefinesDialog(const std::string& text, Context& context); std::string fixDefinesDialog(std::string_view text, Context& context);
std::string fixDefinesMsgBox(const std::string& text, Context& context); std::string fixDefinesMsgBox(std::string_view text, Context& context);
std::string fixDefinesBook(const std::string& text, Context& context); std::string fixDefinesBook(std::string_view text, Context& context);
} }
#endif #endif

@ -55,7 +55,7 @@ namespace Resource
ImageManager::~ImageManager() {} ImageManager::~ImageManager() {}
bool checkSupported(osg::Image* image, const std::string& filename) bool checkSupported(osg::Image* image)
{ {
switch (image->getPixelFormat()) switch (image->getPixelFormat())
{ {
@ -83,7 +83,7 @@ namespace Resource
return true; return true;
} }
osg::ref_ptr<osg::Image> ImageManager::getImage(const std::string& filename, bool disableFlip) osg::ref_ptr<osg::Image> ImageManager::getImage(std::string_view filename, bool disableFlip)
{ {
const std::string normalized = mVFS->normalizeFilename(filename); const std::string normalized = mVFS->normalizeFilename(filename);
@ -149,7 +149,7 @@ namespace Resource
osg::ref_ptr<osg::Image> image = result.getImage(); osg::ref_ptr<osg::Image> image = result.getImage();
image->setFileName(normalized); image->setFileName(normalized);
if (!checkSupported(image, filename)) if (!checkSupported(image))
{ {
static bool uncompress = (getenv("OPENMW_DECOMPRESS_TEXTURES") != nullptr); static bool uncompress = (getenv("OPENMW_DECOMPRESS_TEXTURES") != nullptr);
if (!uncompress) if (!uncompress)

@ -28,7 +28,7 @@ namespace Resource
/// Create or retrieve an Image /// Create or retrieve an Image
/// Returns the dummy image if the given image is not found. /// Returns the dummy image if the given image is not found.
osg::ref_ptr<osg::Image> getImage(const std::string& filename, bool disableFlip = false); osg::ref_ptr<osg::Image> getImage(std::string_view filename, bool disableFlip = false);
osg::Image* getWarningImage(); osg::Image* getWarningImage();

@ -66,20 +66,20 @@ namespace SDLUtil
} }
} }
void SDLCursorManager::cursorChanged(const std::string& name) void SDLCursorManager::cursorChanged(std::string_view name)
{ {
mCurrentCursor = name; mCurrentCursor = name;
_setGUICursor(name); _setGUICursor(mCurrentCursor);
} }
void SDLCursorManager::_setGUICursor(const std::string& name) void SDLCursorManager::_setGUICursor(std::string_view name)
{ {
auto it = mCursorMap.find(name); auto it = mCursorMap.find(name);
if (it != mCursorMap.end()) if (it != mCursorMap.end())
SDL_SetCursor(it->second); SDL_SetCursor(it->second);
} }
void SDLCursorManager::createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x, void SDLCursorManager::createCursor(std::string_view name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
Uint8 hotspot_y, int cursorWidth, int cursorHeight) Uint8 hotspot_y, int cursorWidth, int cursorHeight)
{ {
#ifndef ANDROID #ifndef ANDROID
@ -128,7 +128,7 @@ namespace SDLUtil
return SDLUtil::SurfaceUniquePtr(targetSurface, SDL_FreeSurface); return SDLUtil::SurfaceUniquePtr(targetSurface, SDL_FreeSurface);
} }
void SDLCursorManager::_createCursorFromResource(const std::string& name, int rotDegrees, osg::Image* image, void SDLCursorManager::_createCursorFromResource(std::string_view name, int rotDegrees, osg::Image* image,
Uint8 hotspot_x, Uint8 hotspot_y, int cursorWidth, int cursorHeight) Uint8 hotspot_x, Uint8 hotspot_y, int cursorWidth, int cursorHeight)
{ {
if (mCursorMap.find(name) != mCursorMap.end()) if (mCursorMap.find(name) != mCursorMap.end())
@ -141,7 +141,7 @@ namespace SDLUtil
// set the cursor and store it for later // set the cursor and store it for later
SDL_Cursor* curs = SDL_CreateColorCursor(surface.get(), hotspot_x, hotspot_y); SDL_Cursor* curs = SDL_CreateColorCursor(surface.get(), hotspot_x, hotspot_y);
mCursorMap.insert(CursorMap::value_type(std::string(name), curs)); mCursorMap.emplace(name, curs);
} }
catch (std::exception& e) catch (std::exception& e)
{ {

@ -27,19 +27,19 @@ namespace SDLUtil
/// \brief Tell the manager that the cursor has changed, giving the /// \brief Tell the manager that the cursor has changed, giving the
/// name of the cursor we changed to ("arrow", "ibeam", etc) /// name of the cursor we changed to ("arrow", "ibeam", etc)
virtual void cursorChanged(const std::string& name); virtual void cursorChanged(std::string_view name);
virtual void createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x, virtual void createCursor(std::string_view name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
Uint8 hotspot_y, int cursorWidth, int cursorHeight); Uint8 hotspot_y, int cursorWidth, int cursorHeight);
private: private:
void _createCursorFromResource(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x, void _createCursorFromResource(std::string_view name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
Uint8 hotspot_y, int cursorWidth, int cursorHeight); Uint8 hotspot_y, int cursorWidth, int cursorHeight);
void _putPixel(SDL_Surface* surface, int x, int y, Uint32 pixel); void _putPixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
void _setGUICursor(const std::string& name); void _setGUICursor(std::string_view name);
typedef std::map<std::string, SDL_Cursor*> CursorMap; typedef std::map<std::string, SDL_Cursor*, std::less<>> CursorMap;
CursorMap mCursorMap; CursorMap mCursorMap;
std::string mCurrentCursor; std::string mCurrentCursor;

@ -42,7 +42,7 @@ namespace Gui
mImagePushed = _value; mImagePushed = _value;
else if (_key == "ImageNormal") else if (_key == "ImageNormal")
{ {
if (mImageNormal == "") if (mImageNormal.empty())
{ {
setImageTexture(_value); setImageTexture(_value);
} }

Loading…
Cancel
Save