From c117ead1f66522c7b8cb29b4179a78e7dc775d28 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 10 Feb 2011 03:38:34 +0200 Subject: Add weight bar to top left corner (hidden by default). --- src/gui/statuswindow.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/gui/statuswindow.cpp') diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 8dc1ed46d..853c490bf 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -522,6 +522,31 @@ void StatusWindow::updateProgressBar(ProgressBar *bar, int id, bool percent) updateProgressBar(bar, exp.first, exp.second, percent); } +void StatusWindow::updateWeightBar(ProgressBar *bar, bool percent) +{ + if (!bar) + return; + + if (PlayerInfo::getAttribute(MAX_WEIGHT) == 0) + { + bar->setText(_("Max")); + bar->setProgress(1.0); + } + else + { + float progress = static_cast( + PlayerInfo::getAttribute(TOTAL_WEIGHT)) + / static_cast(PlayerInfo::getAttribute(MAX_WEIGHT)); + + bar->setText(strprintf("%s/%s", Units::formatWeight( + PlayerInfo::getAttribute(TOTAL_WEIGHT)).c_str(), + Units::formatWeight(PlayerInfo::getAttribute( + MAX_WEIGHT)).c_str())); + + bar->setProgress(progress); + } +} + void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent _UNUSED_) { if (!player_node || !viewport) -- cgit v1.2.3-60-g2f50