diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index b16d09305f..af0cbbdfa1 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -101,7 +101,7 @@ namespace MWGui mPlayerSkillValues.emplace(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue()); } - void CharacterCreation::setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value) + void CharacterCreation::setValue(std::string_view id, const MWMechanics::AttributeValue& value) { static const char* ids[] = { "AttribVal1", @@ -117,7 +117,7 @@ namespace MWGui for (int i = 0; ids[i]; ++i) { - if (ids[i] == id.getRefIdString()) + if (ids[i] == id) { mPlayerAttributes[static_cast(i)] = value; if (mReviewDialog) @@ -128,19 +128,19 @@ namespace MWGui } } - void CharacterCreation::setValue(const ESM::RefId& id, const MWMechanics::DynamicStat& value) + void CharacterCreation::setValue(std::string_view id, const MWMechanics::DynamicStat& value) { if (mReviewDialog) { - if (id.getRefIdString() == "HBar") + if (id == "HBar") { mReviewDialog->setHealth(value); } - else if (id.getRefIdString() == "MBar") + else if (id == "MBar") { mReviewDialog->setMagicka(value); } - else if (id.getRefIdString() == "FBar") + else if (id == "FBar") { mReviewDialog->setFatigue(value); } diff --git a/apps/openmw/mwgui/charactercreation.hpp b/apps/openmw/mwgui/charactercreation.hpp index cd03e2e51d..e2e6c3ca26 100644 --- a/apps/openmw/mwgui/charactercreation.hpp +++ b/apps/openmw/mwgui/charactercreation.hpp @@ -46,8 +46,8 @@ namespace MWGui // Show a dialog void spawnDialog(const char id); - void setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value) override; - void setValue(const ESM::RefId& id, const MWMechanics::DynamicStat& value) override; + void setValue(std::string_view id, const MWMechanics::AttributeValue& value) override; + void setValue(std::string_view id, const MWMechanics::DynamicStat& value) override; void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::SkillValue& value) override; void configureSkills(const SkillList& major, const SkillList& minor) override; diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index ed634158da..d1bf3b1b6a 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -181,32 +181,31 @@ namespace MWGui mMainWidget->eventMouseButtonClick.clear(); } - void HUD::setValue(const ESM::RefId& id, const MWMechanics::DynamicStat& value) + void HUD::setValue(std::string_view id, const MWMechanics::DynamicStat& value) { int current = static_cast(value.getCurrent()); int modified = static_cast(value.getModified()); - const std::string idString = id.getRefIdString(); // Fatigue can be negative - if (idString != "FBar") + if (id != "FBar") current = std::max(0, current); MyGUI::Widget* w; std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified); - if (idString == "HBar") + if (id == "HBar") { mHealth->setProgressRange(std::max(0, modified)); mHealth->setProgressPosition(std::max(0, current)); getWidget(w, "HealthFrame"); w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); } - else if (idString == "MBar") + else if (id == "MBar") { mMagicka->setProgressRange(std::max(0, modified)); mMagicka->setProgressPosition(std::max(0, current)); getWidget(w, "MagickaFrame"); w->setUserString("Caption_HealthDescription", "#{sMagDesc}\n" + valStr); } - else if (idString == "FBar") + else if (id == "FBar") { mStamina->setProgressRange(std::max(0, modified)); mStamina->setProgressPosition(std::max(0, current)); diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index eb46e9e44a..1dd9cdb521 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -23,7 +23,7 @@ namespace MWGui public: HUD(CustomMarkerCollection& customMarkers, DragAndDrop* dragAndDrop, MWRender::LocalMap* localMapRender); virtual ~HUD(); - void setValue(const ESM::RefId& id, const MWMechanics::DynamicStat& value) override; + void setValue(std::string_view id, const MWMechanics::DynamicStat& value) override; /// Set time left for the player to start drowning /// @param time time left to start drowning diff --git a/apps/openmw/mwgui/statswatcher.cpp b/apps/openmw/mwgui/statswatcher.cpp index 0894b85046..5df0079a44 100644 --- a/apps/openmw/mwgui/statswatcher.cpp +++ b/apps/openmw/mwgui/statswatcher.cpp @@ -42,27 +42,24 @@ namespace MWGui if (stats.getAttribute(i) != mWatchedAttributes[i] || mWatchedStatsEmpty) { mWatchedAttributes[i] = stats.getAttribute(i); - setValue(ESM::RefId::stringRefId("AttribVal" + std::to_string(i + 1)), stats.getAttribute(i)); + setValue("AttribVal" + std::to_string(i + 1), stats.getAttribute(i)); } } if (stats.getHealth() != mWatchedHealth || mWatchedStatsEmpty) { - static const ESM::RefId hbar(ESM::RefId::stringRefId("HBar")); mWatchedHealth = stats.getHealth(); - setValue(hbar, stats.getHealth()); + setValue("HBar", stats.getHealth()); } if (stats.getMagicka() != mWatchedMagicka || mWatchedStatsEmpty) { - static const ESM::RefId mbar(ESM::RefId::stringRefId("MBar")); mWatchedMagicka = stats.getMagicka(); - setValue(mbar, stats.getMagicka()); + setValue("MBar", stats.getMagicka()); } if (stats.getFatigue() != mWatchedFatigue || mWatchedStatsEmpty) { - static const ESM::RefId fbar(ESM::RefId::stringRefId("FBar")); mWatchedFatigue = stats.getFatigue(); - setValue(fbar, stats.getFatigue()); + setValue("FBar", stats.getFatigue()); } float timeToDrown = stats.getTimeToStartDrowning(); @@ -100,7 +97,7 @@ namespace MWGui if (stats.getLevel() != mWatchedLevel || mWatchedStatsEmpty) { mWatchedLevel = stats.getLevel(); - setValue(ESM::RefId::stringRefId("level"), mWatchedLevel); + setValue("level", mWatchedLevel); } if (mWatched.getClass().isNpc()) @@ -110,7 +107,7 @@ namespace MWGui if (watchedRecord->mName != mWatchedName || mWatchedStatsEmpty) { mWatchedName = watchedRecord->mName; - setValue(ESM::RefId::stringRefId("name"), watchedRecord->mName); + setValue("name", watchedRecord->mName); } if (watchedRecord->mRace != mWatchedRace || mWatchedStatsEmpty) @@ -118,7 +115,7 @@ namespace MWGui mWatchedRace = watchedRecord->mRace; const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(watchedRecord->mRace); - setValue(ESM::RefId::stringRefId("race"), race->mName); + setValue("race", race->mName); } if (watchedRecord->mClass != mWatchedClass || mWatchedStatsEmpty) @@ -126,7 +123,7 @@ namespace MWGui mWatchedClass = watchedRecord->mClass; const ESM::Class* cls = MWBase::Environment::get().getWorld()->getStore().get().find(watchedRecord->mClass); - setValue(ESM::RefId::stringRefId("class"), cls->mName); + setValue("class", cls->mName); MWBase::WindowManager::SkillList majorSkills(5); MWBase::WindowManager::SkillList minorSkills(5); @@ -154,7 +151,7 @@ namespace MWGui mListeners.erase(listener); } - void StatsWatcher::setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value) + void StatsWatcher::setValue(std::string_view id, const MWMechanics::AttributeValue& value) { for (StatsListener* listener : mListeners) listener->setValue(id, value); @@ -168,19 +165,19 @@ namespace MWGui listener->setValue(parSkill, value); } - void StatsWatcher::setValue(const ESM::RefId& id, const MWMechanics::DynamicStat& value) + void StatsWatcher::setValue(std::string_view id, const MWMechanics::DynamicStat& value) { for (StatsListener* listener : mListeners) listener->setValue(id, value); } - void StatsWatcher::setValue(const ESM::RefId& id, const std::string& value) + void StatsWatcher::setValue(std::string_view id, const std::string& value) { for (StatsListener* listener : mListeners) listener->setValue(id, value); } - void StatsWatcher::setValue(const ESM::RefId& id, int value) + void StatsWatcher::setValue(std::string_view id, int value) { for (StatsListener* listener : mListeners) listener->setValue(id, value); diff --git a/apps/openmw/mwgui/statswatcher.hpp b/apps/openmw/mwgui/statswatcher.hpp index 92da92edae..639e1bf591 100644 --- a/apps/openmw/mwgui/statswatcher.hpp +++ b/apps/openmw/mwgui/statswatcher.hpp @@ -16,10 +16,10 @@ namespace MWGui { public: /// Set value for the given ID. - virtual void setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value) {} - virtual void setValue(const ESM::RefId& id, const MWMechanics::DynamicStat& value) {} - virtual void setValue(const ESM::RefId& id, const std::string& value) {} - virtual void setValue(const ESM::RefId& id, int value) {} + virtual void setValue(std::string_view id, const MWMechanics::AttributeValue& value) {} + virtual void setValue(std::string_view id, const MWMechanics::DynamicStat& value) {} + virtual void setValue(std::string_view, const std::string& value) {} + virtual void setValue(std::string_view, int value) {} virtual void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::SkillValue& value) {} virtual void configureSkills(const std::vector& major, const std::vector& minor) {} }; @@ -47,10 +47,10 @@ namespace MWGui std::set mListeners; - void setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value); - void setValue(const ESM::RefId& id, const MWMechanics::DynamicStat& value); - void setValue(const ESM::RefId& id, const std::string& value); - void setValue(const ESM::RefId& id, int value); + void setValue(std::string_view id, const MWMechanics::AttributeValue& value); + void setValue(std::string_view id, const MWMechanics::DynamicStat& value); + void setValue(std::string_view id, const std::string& value); + void setValue(std::string_view id, int value); void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::SkillValue& value); void configureSkills(const std::vector& major, const std::vector& minor); diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index 40327b4da8..6f56f83427 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -153,7 +153,7 @@ namespace MWGui mMainWidget->castType()->setCaption(playerName); } - void StatsWindow::setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value) + void StatsWindow::setValue(std::string_view id, const MWMechanics::AttributeValue& value) { static const char* ids[] = { "AttribVal1", @@ -168,12 +168,12 @@ namespace MWGui }; for (int i = 0; ids[i]; ++i) - if (ids[i] == id.getRefIdString()) + if (ids[i] == id) { - setText(id.getRefIdString(), std::to_string(static_cast(value.getModified()))); + setText(id, std::to_string(static_cast(value.getModified()))); MyGUI::TextBox* box; - getWidget(box, id.getRefIdString()); + getWidget(box, id); if (value.getModified() > value.getBase()) box->_setWidgetState("increased"); @@ -186,50 +186,50 @@ namespace MWGui } } - void StatsWindow::setValue(const ESM::RefId& id, const MWMechanics::DynamicStat& value) + void StatsWindow::setValue(std::string_view id, const MWMechanics::DynamicStat& value) { int current = static_cast(value.getCurrent()); int modified = static_cast(value.getModified(false)); // Fatigue can be negative - if (id.getRefIdString() != "FBar") + if (id != "FBar") current = std::max(0, current); - setBar(id.getRefIdString(), id.getRefIdString() + "T", current, modified); + setBar(std::string(id), std::string(id) + "T", current, modified); // health, magicka, fatigue tooltip MyGUI::Widget* w; std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified); - if (id.getRefIdString() == "HBar") + if (id == "HBar") { getWidget(w, "Health"); w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); } - else if (id.getRefIdString() == "MBar") + else if (id == "MBar") { getWidget(w, "Magicka"); w->setUserString("Caption_HealthDescription", "#{sMagDesc}\n" + valStr); } - else if (id.getRefIdString() == "FBar") + else if (id == "FBar") { getWidget(w, "Fatigue"); w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); } } - void StatsWindow::setValue(const ESM::RefId& id, const std::string& value) + void StatsWindow::setValue(std::string_view id, const std::string& value) { - if (id.getRefIdString() == "name") + if (id == "name") setPlayerName(value); - else if (id.getRefIdString() == "race") + else if (id == "race") setText("RaceText", value); - else if (id.getRefIdString() == "class") + else if (id == "class") setText("ClassText", value); } - void StatsWindow::setValue(const ESM::RefId& id, int value) + void StatsWindow::setValue(std::string_view id, int value) { - if (id.getRefIdString() == "level") + if (id == "level") { std::ostringstream text; text << value; diff --git a/apps/openmw/mwgui/statswindow.hpp b/apps/openmw/mwgui/statswindow.hpp index 1a6a6b4930..082570e7c9 100644 --- a/apps/openmw/mwgui/statswindow.hpp +++ b/apps/openmw/mwgui/statswindow.hpp @@ -23,10 +23,10 @@ namespace MWGui void setPlayerName(const std::string& playerName); /// Set value for the given ID. - void setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value) override; - void setValue(const ESM::RefId& id, const MWMechanics::DynamicStat& value) override; - void setValue(const ESM::RefId& id, const std::string& value) override; - void setValue(const ESM::RefId& id, int value) override; + void setValue(std::string_view id, const MWMechanics::AttributeValue& value) override; + void setValue(std::string_view id, const MWMechanics::DynamicStat& value) override; + void setValue(std::string_view id, const std::string& value) override; + void setValue(std::string_view id, int value) override; void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::SkillValue& value) override; void configureSkills(const SkillList& major, const SkillList& minor) override;