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 | |
parent | 61470cb03d26a9c6059c33b0f0e16125f5f6eae4 (diff) | |
download | manaplus-c117ead1f66522c7b8cb29b4179a78e7dc775d28.tar.gz manaplus-c117ead1f66522c7b8cb29b4179a78e7dc775d28.tar.bz2 manaplus-c117ead1f66522c7b8cb29b4179a78e7dc775d28.tar.xz manaplus-c117ead1f66522c7b8cb29b4179a78e7dc775d28.zip |
Add weight bar to top left corner (hidden by default).
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/ministatus.cpp | 9 | ||||
-rw-r--r-- | src/gui/ministatus.h | 1 | ||||
-rw-r--r-- | src/gui/statuswindow.cpp | 25 | ||||
-rw-r--r-- | src/gui/statuswindow.h | 1 |
4 files changed, 36 insertions, 0 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 5f385a46a..71e81abf8 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -84,6 +84,9 @@ MiniStatusWindow::MiniStatusWindow(): mJobBar = 0; } + mWeightBar = createBar(0, 140, 20, Theme::PROG_WEIGHT, + "weight bar", _("weight bar")); + mStatusBar = createBar(100, 150, 20, Theme::PROG_EXP, "status bar", _("status bar")); @@ -199,6 +202,8 @@ void MiniStatusWindow::event(Channels channel _UNUSED_, StatusWindow::updateMPBar(mMpBar); else if (id == EXP || id == EXP_NEEDED) StatusWindow::updateXPBar(mXpBar); + else if (id == TOTAL_WEIGHT || id == MAX_WEIGHT) + StatusWindow::updateWeightBar(mWeightBar, false); } else if (event.getName() == EVENT_UPDATESTAT) { @@ -344,7 +349,11 @@ void MiniStatusWindow::showBar(std::string name, bool isVisible) void MiniStatusWindow::loadBars() { if (!config.getValue("ministatussaved", false)) + { + if (mWeightBar) + mWeightBar->setVisible(false); return; + } for (int f = 0; f < 10; f ++) { diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h index 96cad5ed8..ead2a5f51 100644 --- a/src/gui/ministatus.h +++ b/src/gui/ministatus.h @@ -101,6 +101,7 @@ class MiniStatusWindow : public Popup, public Mana::Listener ProgressBar *mMpBar; ProgressBar *mXpBar; ProgressBar *mJobBar; + ProgressBar *mWeightBar; ProgressBar *mStatusBar; TextPopup *mTextPopup; StatusPopup *mStatusPopup; 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) diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index 859ac613b..47f87254f 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -66,6 +66,7 @@ class StatusWindow : public Window, public Mana::Listener static void updateMPBar(ProgressBar *bar, bool showMax = false); static void updateJobBar(ProgressBar *bar, bool percent = true); static void updateXPBar(ProgressBar *bar, bool percent = true); + static void updateWeightBar(ProgressBar *bar, bool percent = true); static void updateStatusBar(ProgressBar *bar, bool percent = true); static void updateProgressBar(ProgressBar *bar, int value, int max, bool percent); |