summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2025-03-30 21:24:36 +0000
committerFedja Beader <fedja@protonmail.ch>2025-03-30 21:24:36 +0000
commit67eb506ca36749d40d9af3a22c32524a3566370c (patch)
treea5c85bfefc063a30b67410a68502f9757564f0d4
parenta99e41b95064f4c4c61591454916542aa6491795 (diff)
downloadmv-67eb506ca36749d40d9af3a22c32524a3566370c.tar.gz
mv-67eb506ca36749d40d9af3a22c32524a3566370c.tar.bz2
mv-67eb506ca36749d40d9af3a22c32524a3566370c.tar.xz
mv-67eb506ca36749d40d9af3a22c32524a3566370c.zip
Add free weight indication to mini status bar
Squashed with: * statuswindow: I like this way better **** mana/plus!151
-rw-r--r--src/gui/windows/ministatuswindow.cpp18
-rw-r--r--src/gui/windows/statuswindow.cpp4
2 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index e52a1a8d7..e62fd38dc 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -462,10 +462,20 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event)
}
else if (event.getSource() == mWeightBar)
{
- textPopup->show(x + rect.x, y + rect.y, event.getSource()->getId(),
- strprintf("%d/%d", PlayerInfo::getAttribute(
- Attributes::TOTAL_WEIGHT),
- PlayerInfo::getAttribute(Attributes::MAX_WEIGHT)));
+ const int totalWeight
+ = PlayerInfo::getAttribute(Attributes::TOTAL_WEIGHT);
+ const int maxWeight = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT);
+ const int freeWeight = maxWeight - totalWeight;
+ // see maxWeight == 0 edge case in statuswindow for why:
+ const std::string freeWeightStr
+ = (freeWeight >= 0)
+ ? strprintf("Free: %d", freeWeight)
+ : "";
+
+ textPopup->show(x + rect.x, y + rect.y,
+ event.getSource()->getId(),
+ strprintf("%d/%d", totalWeight, maxWeight),
+ freeWeightStr);
mStatusPopup->hide();
}
else if (event.getSource() == mInvSlotsBar)
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 04e12e384..95f76449f 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -519,8 +519,8 @@ void StatusWindow::updateWeightBar(ProgressBar *const bar)
}
else
{
- const int totalWeight = PlayerInfo::getAttribute(
- Attributes::TOTAL_WEIGHT);
+ const int totalWeight
+ = PlayerInfo::getAttribute(Attributes::TOTAL_WEIGHT);
const int maxWeight = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT);
float progress = 1.0F;
if (maxWeight != 0)