Merge pull request #1424 from akortunov/guifixes

Display negative values on fatigue progress bars
pull/280/head
scrawl 7 years ago committed by GitHub
commit 8a1e014bb8

@ -179,29 +179,33 @@ namespace MWGui
void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value) void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value)
{ {
int current = std::max(0, static_cast<int>(value.getCurrent())); int current = static_cast<int>(value.getCurrent());
int modified = static_cast<int>(value.getModified()); int modified = static_cast<int>(value.getModified());
// Fatigue can be negative
if (id != "FBar")
current = std::max(0, current);
MyGUI::Widget* w; MyGUI::Widget* w;
std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified); std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified);
if (id == "HBar") if (id == "HBar")
{ {
mHealth->setProgressRange(modified); mHealth->setProgressRange(std::max(0, modified));
mHealth->setProgressPosition(current); mHealth->setProgressPosition(std::max(0, current));
getWidget(w, "HealthFrame"); getWidget(w, "HealthFrame");
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
} }
else if (id == "MBar") else if (id == "MBar")
{ {
mMagicka->setProgressRange (modified); mMagicka->setProgressRange(std::max(0, modified));
mMagicka->setProgressPosition (current); mMagicka->setProgressPosition(std::max(0, current));
getWidget(w, "MagickaFrame"); getWidget(w, "MagickaFrame");
w->setUserString("Caption_HealthDescription", "#{sMagDesc}\n" + valStr); w->setUserString("Caption_HealthDescription", "#{sMagDesc}\n" + valStr);
} }
else if (id == "FBar") else if (id == "FBar")
{ {
mStamina->setProgressRange (modified); mStamina->setProgressRange(std::max(0, modified));
mStamina->setProgressPosition (current); mStamina->setProgressPosition(std::max(0, current));
getWidget(w, "FatigueFrame"); getWidget(w, "FatigueFrame");
w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
} }

@ -180,7 +180,7 @@ namespace MWGui
void ReviewDialog::setFatigue(const MWMechanics::DynamicStat<float>& value) void ReviewDialog::setFatigue(const MWMechanics::DynamicStat<float>& value)
{ {
int current = std::max(0, static_cast<int>(value.getCurrent())); int current = static_cast<int>(value.getCurrent());
int modified = static_cast<int>(value.getModified()); int modified = static_cast<int>(value.getModified());
mFatigue->setValue(current, modified); mFatigue->setValue(current, modified);

@ -102,12 +102,13 @@ namespace MWGui
{ {
MyGUI::ProgressBar* pt; MyGUI::ProgressBar* pt;
getWidget(pt, name); getWidget(pt, name);
pt->setProgressRange(max);
pt->setProgressPosition(val);
std::stringstream out; std::stringstream out;
out << val << "/" << max; out << val << "/" << max;
setText(tname, out.str().c_str()); setText(tname, out.str().c_str());
pt->setProgressRange(std::max(0, max));
pt->setProgressPosition(std::max(0, val));
} }
void StatsWindow::setPlayerName(const std::string& playerName) void StatsWindow::setPlayerName(const std::string& playerName)
@ -147,9 +148,13 @@ namespace MWGui
void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value) void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value)
{ {
int current = std::max(0, static_cast<int>(value.getCurrent())); int current = static_cast<int>(value.getCurrent());
int modified = static_cast<int>(value.getModified()); int modified = static_cast<int>(value.getModified());
// Fatigue can be negative
if (id != "FBar")
current = std::max(0, current);
setBar (id, id + "T", current, modified); setBar (id, id + "T", current, modified);
// health, magicka, fatigue tooltip // health, magicka, fatigue tooltip

@ -502,11 +502,10 @@ namespace MWGui
if (mBarWidget) if (mBarWidget)
{ {
mBarWidget->setProgressRange(mMax); mBarWidget->setProgressRange(std::max(0, mMax));
mBarWidget->setProgressPosition(mValue); mBarWidget->setProgressPosition(std::max(0, mValue));
} }
if (mBarTextWidget) if (mBarTextWidget)
{ {
std::stringstream out; std::stringstream out;

Loading…
Cancel
Save