diff options
author | Fedja Beader <fedja@protonmail.ch> | 2025-03-30 21:24:36 +0000 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2025-04-01 01:53:36 +0200 |
commit | 455c819448271963ded9c635d86422065c65aef3 (patch) | |
tree | 00ba6746b525236e8c541b72740fa6c83fff6c64 | |
parent | 3a5a3409a870ddf22e8d37f87c7f0172811e4aa1 (diff) | |
download | manaplus-455c819448271963ded9c635d86422065c65aef3.tar.gz manaplus-455c819448271963ded9c635d86422065c65aef3.tar.bz2 manaplus-455c819448271963ded9c635d86422065c65aef3.tar.xz manaplus-455c819448271963ded9c635d86422065c65aef3.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.cpp | 18 | ||||
-rw-r--r-- | 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) |