diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-02-10 04:15:39 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-02-10 04:15:39 +0200 |
commit | f74cf5eb61deccc478d2a4cbc7a352748d96c65e (patch) | |
tree | 1f5c31014cc82a4ad079374ecfb775fe847b8d80 /src/gui/statuswindow.cpp | |
parent | c117ead1f66522c7b8cb29b4179a78e7dc775d28 (diff) | |
download | plus-f74cf5eb61deccc478d2a4cbc7a352748d96c65e.tar.gz plus-f74cf5eb61deccc478d2a4cbc7a352748d96c65e.tar.bz2 plus-f74cf5eb61deccc478d2a4cbc7a352748d96c65e.tar.xz plus-f74cf5eb61deccc478d2a4cbc7a352748d96c65e.zip |
Add inventory slots bar in top left corner (hidden by default).
Diffstat (limited to 'src/gui/statuswindow.cpp')
-rw-r--r-- | src/gui/statuswindow.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 853c490bf..30fec8773 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -23,6 +23,7 @@ #include "configuration.h" #include "event.h" +#include "inventory.h" #include "localplayer.h" #include "playerinfo.h" #include "units.h" @@ -522,7 +523,7 @@ void StatusWindow::updateProgressBar(ProgressBar *bar, int id, bool percent) updateProgressBar(bar, exp.first, exp.second, percent); } -void StatusWindow::updateWeightBar(ProgressBar *bar, bool percent) +void StatusWindow::updateWeightBar(ProgressBar *bar) { if (!bar) return; @@ -547,6 +548,24 @@ void StatusWindow::updateWeightBar(ProgressBar *bar, bool percent) } } +void StatusWindow::updateInvSlotsBar(ProgressBar *bar) +{ + Inventory *inv = PlayerInfo::getInventory(); + if (!inv) + return; + + const int usedSlots = inv->getNumberOfSlotsUsed(); + const int maxSlots = inv->getSize(); + + if (maxSlots) + { + bar->setProgress(static_cast<float>(usedSlots) + / static_cast<float>(maxSlots)); + } + + bar->setText(strprintf("%d", usedSlots)); +} + void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent _UNUSED_) { if (!player_node || !viewport) |