diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/ministatus.cpp | 54 | ||||
-rw-r--r-- | src/gui/ministatus.h | 13 | ||||
-rw-r--r-- | src/gui/statuswindow.cpp | 16 |
3 files changed, 48 insertions, 35 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index ab5560da..4cb0e1ac 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -33,6 +33,8 @@ #include "utils/stringutils.h" +extern volatile int tick_time; + MiniStatusWindow::MiniStatusWindow(): Popup("MiniStatus") { @@ -75,13 +77,37 @@ void MiniStatusWindow::eraseIcon(int index) mIcons.erase(mIcons.begin() + index); } -extern volatile int tick_time; +void MiniStatusWindow::drawIcons(Graphics *graphics) +{ + // Draw icons + int icon_x = mXpBar->getX() + mXpBar->getWidth() + 4; + for (unsigned int i = 0; i < mIcons.size(); i++) { + if (mIcons[i]) { + mIcons[i]->draw(graphics, icon_x, 3); + icon_x += 2 + mIcons[i]->getWidth(); + } + } +} + +void MiniStatusWindow::update(int id) +{ + if (id == StatusWindow::HP) + { + StatusWindow::updateHPBar(mHpBar); + } + else if (id == StatusWindow::MP) + { + StatusWindow::updateMPBar(mMpBar); + } + else if (id == StatusWindow::EXP) + { + StatusWindow::updateXPBar(mXpBar); + } +} -void MiniStatusWindow::update() +void MiniStatusWindow::logic() { - StatusWindow::updateHPBar(mHpBar); - StatusWindow::updateMPBar(mMpBar); - StatusWindow::updateXPBar(mXpBar); + Popup::logic(); // Displays the number of monsters to next lvl // (disabled for now but interesting idea) @@ -100,21 +126,3 @@ void MiniStatusWindow::update() if (mIcons[i]) mIcons[i]->update(tick_time * 10); } - -void MiniStatusWindow::draw(gcn::Graphics *graphics) -{ - update(); - drawChildren(graphics); -} - -void MiniStatusWindow::drawIcons(Graphics *graphics) -{ - // Draw icons - int icon_x = mXpBar->getX() + mXpBar->getWidth() + 4; - for (unsigned int i = 0; i < mIcons.size(); i++) { - if (mIcons[i]) { - mIcons[i]->draw(graphics, icon_x, 3); - icon_x += 2 + mIcons[i]->getWidth(); - } - } -} diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h index f5604486..de07e12d 100644 --- a/src/gui/ministatus.h +++ b/src/gui/ministatus.h @@ -40,8 +40,6 @@ class MiniStatusWindow : public Popup public: MiniStatusWindow(); - void draw(gcn::Graphics *graphics); - /** * Sets one of the icons. */ @@ -51,12 +49,11 @@ class MiniStatusWindow : public Popup void drawIcons(Graphics *graphics); - private: - /** - * Updates this dialog with values from player_node. - */ - void update(); + void update(int id); // Same types as status window + void logic(); // Updates icons + + private: /* * Mini Status Bars */ @@ -67,4 +64,6 @@ class MiniStatusWindow : public Popup std::vector<AnimatedSprite *> mIcons; }; +extern MiniStatusWindow *miniStatusWindow; + #endif diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 1b764615..5d4ad8c4 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -28,6 +28,8 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/vertcontainer.h" #include "gui/widgets/windowcontainer.h" + +#include "gui/ministatus.h" #include "gui/setup.h" #include "localplayer.h" @@ -181,18 +183,24 @@ std::string StatusWindow::update(int id) { updateHPBar(mHpBar, true); + miniStatusWindow->update(HP); + return _("HP"); } else if (id == MP) { updateMPBar(mMpBar, true); + miniStatusWindow->update(MP); + return _("MP"); } else if (id == EXP) { updateXPBar(mXpBar, false); + miniStatusWindow->update(EXP); + return _("Exp"); } else if (id == MONEY) @@ -370,12 +378,10 @@ void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax) else bar->setText(toString(player_node->getMP())); -#ifdef EATHENA_SUPPORT - if (player_node->getAttributeEffective(MATK) <= 0) - bar->setColor(100, 100, 100); // grey, to indicate that we lack magic - else -#endif + if (Net::getPlayerHandler()->canUseMagic()) bar->setColor(26, 102, 230); // blue, to indicate that we have magic + else + bar->setColor(100, 100, 100); // grey, to indicate that we lack magic bar->setProgress((float) player_node->getMP() / (float) player_node->getMaxMP()); |