diff options
Diffstat (limited to 'src/gui/ministatuswindow.cpp')
-rw-r--r-- | src/gui/ministatuswindow.cpp | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index a4fd358f..e050563f 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -31,6 +31,7 @@ #include "gui/statuswindow.h" #include "gui/textpopup.h" +#include "gui/widgets/layout.h" #include "gui/widgets/progressbar.h" #include "net/net.h" @@ -46,8 +47,7 @@ extern volatile int tick_time; -MiniStatusWindow::MiniStatusWindow(): - Popup("MiniStatus") +MiniStatusWindow::MiniStatusWindow() { listen(Event::AttributesChannel); listen(Event::ActorSpriteChannel); @@ -69,25 +69,20 @@ MiniStatusWindow::MiniStatusWindow(): mXpBar = new ProgressBar(0, 100, 20, Theme::PROG_EXP); StatusWindow::updateXPBar(mXpBar); - // Add the progressbars to the window - - mHpBar->setPosition(0, 3); - if (mMpBar) - mMpBar->setPosition(mHpBar->getWidth() + 3, 3); - mXpBar->setPosition(mMpBar ? mMpBar->getX() + mMpBar->getWidth() + 3 : - mHpBar->getX() + mHpBar->getWidth() + 3, 3); - - add(mHpBar); + int row = 0; + place(0, row++, mHpBar); if (mMpBar) - add(mMpBar); - add(mXpBar); - - setContentSize(mXpBar->getX() + mXpBar->getWidth(), - mXpBar->getY() + mXpBar->getHeight()); + place(0, row++, mMpBar); + place(0, row++, mXpBar); - setVisible((bool) config.getValue(getPopupName() + "Visible", true)); + Layout &layout = getLayout(); + int w = 0; + int h = 0; + layout.reflow(w, h); + setSize(w, h); - mTextPopup = new TextPopup(); + mTextPopup = new TextPopup; + setVisible(true); addMouseListener(this); } @@ -171,14 +166,18 @@ void MiniStatusWindow::event(Event::Channel channel, { // delete sprite, if necessary for (unsigned int i = 0; i < mStatusEffectIcons.size();) + { if (mStatusEffectIcons[i] == index) { mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i); - miniStatusWindow->eraseIcon(i); + eraseIcon(i); } else - i++; + { + ++i; + } + } } else { @@ -187,17 +186,19 @@ void MiniStatusWindow::event(Event::Channel channel, for (unsigned int i = 0; i < mStatusEffectIcons.size(); i++) + { if (mStatusEffectIcons[i] == index) { - miniStatusWindow->setIcon(i, sprite); + setIcon(i, sprite); found = true; break; } + } if (!found) { // add new int offset = mStatusEffectIcons.size(); - miniStatusWindow->setIcon(offset, sprite); + setIcon(offset, sprite); mStatusEffectIcons.push_back(index); } } @@ -208,7 +209,7 @@ void MiniStatusWindow::event(Event::Channel channel, void MiniStatusWindow::logic() { - Popup::logic(); + Container::logic(); // Displays the number of monsters to next lvl // (disabled for now but interesting idea) @@ -228,10 +229,16 @@ void MiniStatusWindow::logic() mIcons[i]->update(tick_time * 10); } -void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) +void MiniStatusWindow::draw(gcn::Graphics *graphics) { - Popup::mouseMoved(event); + Graphics *g = static_cast<Graphics*>(graphics); + + drawChildren(graphics); + drawIcons(g); +} +void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) +{ const int x = event.getX(); const int y = event.getY(); @@ -264,7 +271,5 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) { - Popup::mouseExited(event); - mTextPopup->setVisible(false); } |