diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-02-13 18:33:04 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-02-13 18:33:04 +0200 |
commit | 3aba05585b85989b5d0927939812f612c3b0d4d9 (patch) | |
tree | ff6ecef24d5bad6ced0112c8d81ea5c185c5f914 /src/gui | |
parent | 15b8c6e64326caf9cea7e948f48cf487cef625b5 (diff) | |
download | manaplus-3aba05585b85989b5d0927939812f612c3b0d4d9.tar.gz manaplus-3aba05585b85989b5d0927939812f612c3b0d4d9.tar.bz2 manaplus-3aba05585b85989b5d0927939812f612c3b0d4d9.tar.xz manaplus-3aba05585b85989b5d0927939812f612c3b0d4d9.zip |
Add money bar.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/ministatus.cpp | 15 | ||||
-rw-r--r-- | src/gui/ministatus.h | 1 | ||||
-rw-r--r-- | src/gui/statuswindow.cpp | 19 | ||||
-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 8308fe15b..ed124d3b4 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -90,6 +90,9 @@ MiniStatusWindow::MiniStatusWindow(): mInvSlotsBar = createBar(0, 45, 20, Theme::PROG_INVY_SLOTS, "inventory slots bar", _("inventory slots bar")); + mMoneyBar = createBar(0, 130, 20, Theme::PROG_INVY_SLOTS, + "money bar", _("money bar")); + mStatusBar = createBar(100, 150, 20, Theme::PROG_EXP, "status bar", _("status bar")); @@ -105,6 +108,8 @@ MiniStatusWindow::MiniStatusWindow(): Inventory *inv = PlayerInfo::getInventory(); if (inv) inv->addInventoyListener(this); + + StatusWindow::updateMoneyBar(mMoneyBar); updateStatus(); } @@ -214,6 +219,8 @@ void MiniStatusWindow::event(Channels channel _UNUSED_, StatusWindow::updateXPBar(mXpBar); else if (id == TOTAL_WEIGHT || id == MAX_WEIGHT) StatusWindow::updateWeightBar(mWeightBar); + else if (id == MONEY) + StatusWindow::updateMoneyBar(mMoneyBar); } else if (event.getName() == EVENT_UPDATESTAT) { @@ -341,6 +348,12 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) } mStatusPopup->hide(); } + else if (event.getSource() == mMoneyBar) + { + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + toString(PlayerInfo::getAttribute(MONEY))); + } else { mTextPopup->hide(); @@ -392,6 +405,8 @@ void MiniStatusWindow::loadBars() mWeightBar->setVisible(false); if (mInvSlotsBar) mInvSlotsBar->setVisible(false); + if (mMoneyBar) + mMoneyBar->setVisible(false); return; } diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h index 3cf9eef16..dad9d6b0f 100644 --- a/src/gui/ministatus.h +++ b/src/gui/ministatus.h @@ -108,6 +108,7 @@ class MiniStatusWindow : public Popup, ProgressBar *mJobBar; ProgressBar *mWeightBar; ProgressBar *mInvSlotsBar; + ProgressBar *mMoneyBar; ProgressBar *mStatusBar; TextPopup *mTextPopup; StatusPopup *mStatusPopup; diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 30fec8773..ffc00db5a 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -548,6 +548,25 @@ void StatusWindow::updateWeightBar(ProgressBar *bar) } } +void StatusWindow::updateMoneyBar(ProgressBar *bar) +{ + if (!bar) + return; + + int money = PlayerInfo::getAttribute(MONEY); + bar->setText(Units::formatCurrency(money).c_str()); + if (money > 0) + { + float progress = static_cast<float>(money) + / static_cast<float>(1000000000); + bar->setProgress(progress); + } + else + { + bar->setProgress(1.0); + } +} + void StatusWindow::updateInvSlotsBar(ProgressBar *bar) { Inventory *inv = PlayerInfo::getInventory(); diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index 38ae16e37..413ab9313 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -68,6 +68,7 @@ class StatusWindow : public Window, public Mana::Listener static void updateXPBar(ProgressBar *bar, bool percent = true); static void updateWeightBar(ProgressBar *bar); static void updateInvSlotsBar(ProgressBar *bar); + static void updateMoneyBar(ProgressBar *bar); static void updateStatusBar(ProgressBar *bar, bool percent = true); static void updateProgressBar(ProgressBar *bar, int value, int max, bool percent); |