1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-29 08:41:34 +00:00

Fixed GUI that used RefId when it should have used strings

This commit is contained in:
fteppe 2022-10-02 23:16:43 +02:00 committed by florent.teppe
parent 125b21de20
commit 69d70d64f6
8 changed files with 54 additions and 58 deletions

View file

@ -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<ESM::Attribute::AttributeID>(i)] = value;
if (mReviewDialog)
@ -128,19 +128,19 @@ namespace MWGui
}
}
void CharacterCreation::setValue(const ESM::RefId& id, const MWMechanics::DynamicStat<float>& value)
void CharacterCreation::setValue(std::string_view id, const MWMechanics::DynamicStat<float>& 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);
}

View file

@ -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<float>& value) override;
void setValue(std::string_view id, const MWMechanics::AttributeValue& value) override;
void setValue(std::string_view id, const MWMechanics::DynamicStat<float>& value) override;
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::SkillValue& value) override;
void configureSkills(const SkillList& major, const SkillList& minor) override;

View file

@ -181,32 +181,31 @@ namespace MWGui
mMainWidget->eventMouseButtonClick.clear();
}
void HUD::setValue(const ESM::RefId& id, const MWMechanics::DynamicStat<float>& value)
void HUD::setValue(std::string_view id, const MWMechanics::DynamicStat<float>& value)
{
int current = static_cast<int>(value.getCurrent());
int modified = static_cast<int>(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));

View file

@ -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<float>& value) override;
void setValue(std::string_view id, const MWMechanics::DynamicStat<float>& value) override;
/// Set time left for the player to start drowning
/// @param time time left to start drowning

View file

@ -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<ESM::Race>().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<ESM::Class>().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<float>& value)
void StatsWatcher::setValue(std::string_view id, const MWMechanics::DynamicStat<float>& 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);

View file

@ -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<float>& 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<float>& 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<int>& major, const std::vector<int>& minor) {}
};
@ -47,10 +47,10 @@ namespace MWGui
std::set<StatsListener*> mListeners;
void setValue(const ESM::RefId& id, const MWMechanics::AttributeValue& value);
void setValue(const ESM::RefId& id, const MWMechanics::DynamicStat<float>& 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<float>& 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<int>& major, const std::vector<int>& minor);

View file

@ -153,7 +153,7 @@ namespace MWGui
mMainWidget->castType<MyGUI::Window>()->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<int>(value.getModified())));
setText(id, std::to_string(static_cast<int>(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<float>& value)
void StatsWindow::setValue(std::string_view id, const MWMechanics::DynamicStat<float>& value)
{
int current = static_cast<int>(value.getCurrent());
int modified = static_cast<int>(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;

View file

@ -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<float>& 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<float>& 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;