diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-02-10 03:38:34 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-02-10 03:38:34 +0200 |
commit | c117ead1f66522c7b8cb29b4179a78e7dc775d28 (patch) | |
tree | 4152b3cb42b648c18f7b5fbf96565767109abd58 /src/gui/statuswindow.cpp | |
parent | 61470cb03d26a9c6059c33b0f0e16125f5f6eae4 (diff) | |
download | manaverse-c117ead1f66522c7b8cb29b4179a78e7dc775d28.tar.gz manaverse-c117ead1f66522c7b8cb29b4179a78e7dc775d28.tar.bz2 manaverse-c117ead1f66522c7b8cb29b4179a78e7dc775d28.tar.xz manaverse-c117ead1f66522c7b8cb29b4179a78e7dc775d28.zip |
Add weight bar to top left corner (hidden by default).
Diffstat (limited to 'src/gui/statuswindow.cpp')
-rw-r--r-- | src/gui/statuswindow.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
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<float>( + PlayerInfo::getAttribute(TOTAL_WEIGHT)) + / static_cast<float>(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) |