From f74cf5eb61deccc478d2a4cbc7a352748d96c65e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 10 Feb 2011 04:15:39 +0200 Subject: Add inventory slots bar in top left corner (hidden by default). --- src/gui/statuswindow.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/gui/statuswindow.cpp') 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(usedSlots) + / static_cast(maxSlots)); + } + + bar->setText(strprintf("%d", usedSlots)); +} + void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent _UNUSED_) { if (!player_node || !viewport) -- cgit v1.2.3-60-g2f50