From 67eb506ca36749d40d9af3a22c32524a3566370c Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Sun, 30 Mar 2025 21:24:36 +0000 Subject: Add free weight indication to mini status bar Squashed with: * statuswindow: I like this way better **** mana/plus!151 --- src/gui/windows/ministatuswindow.cpp | 18 ++++++++++++++---- src/gui/windows/statuswindow.cpp | 4 ++-- 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) -- cgit v1.2.3-70-g09d2