From ea6f492198a03cffc3be47df000fa16dfc3b262f Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 24 Jul 2009 14:19:21 -0600 Subject: Remove an ifdef in StatusWindow and update MP more Also make MiniStatus only update the bars when needed (called by StatusWindow). --- src/gui/ministatus.cpp | 54 +++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'src/gui/ministatus.cpp') 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(); - } - } -} -- cgit v1.2.3-70-g09d2