diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-08-02 02:32:18 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-08-02 02:48:03 -0600 |
commit | 42f6993e0deacc857302f48004031dd45b739874 (patch) | |
tree | f8a25e94b32257c1364864824fcf61c83b834d6d /src/gui/ministatus.cpp | |
parent | 6a0e5f20c9faf7623a465daa4a8b350d3a52e5e6 (diff) | |
download | mana-42f6993e0deacc857302f48004031dd45b739874.tar.gz mana-42f6993e0deacc857302f48004031dd45b739874.tar.bz2 mana-42f6993e0deacc857302f48004031dd45b739874.tar.xz mana-42f6993e0deacc857302f48004031dd45b739874.zip |
Remove non-GUI references to MiniStatusWindow
Reviewed-by: Freeyorp
Diffstat (limited to 'src/gui/ministatus.cpp')
-rw-r--r-- | src/gui/ministatus.cpp | 82 |
1 files changed, 70 insertions, 12 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index eb7c0756..620754ef 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -25,6 +25,7 @@ #include "configuration.h" #include "graphics.h" #include "playerinfo.h" +#include "statuseffect.h" #include "gui/gui.h" #include "gui/statuswindow.h" @@ -119,20 +120,79 @@ void MiniStatusWindow::drawIcons(Graphics *graphics) void MiniStatusWindow::event(const std::string &channel, const Mana::Event &event) { - if (event.getName() == "UpdateAttribute") + if (channel == "Attributes") { - int id = event.getInt("id"); - if (id == HP || id == MAX_HP) + if (event.getName() == "UpdateAttribute") { - StatusWindow::updateHPBar(mHpBar); + int id = event.getInt("id"); + if (id == HP || id == MAX_HP) + { + StatusWindow::updateHPBar(mHpBar); + } + else if (id == MP || id == MAX_MP) + { + StatusWindow::updateMPBar(mMpBar); + } + else if (id == EXP || id == EXP_NEEDED) + { + StatusWindow::updateXPBar(mXpBar); + } } - else if (id == MP || id == MAX_MP) - { - StatusWindow::updateMPBar(mMpBar); - } - else if (id == EXP || id == EXP_NEEDED) + } + else if (channel == "ActorSprite") + { + if (event.getName() == "UpdateStatusEffect") { - StatusWindow::updateXPBar(mXpBar); + int index = event.getInt("index"); + bool newStatus = event.getBool("newStatus"); + + StatusEffect *effect = StatusEffect::getStatusEffect(index, + newStatus); + + if (effect) + { + effect->deliverMessage(); + effect->playSFX(); + + AnimatedSprite *sprite = effect->getIcon(); + + typedef std::vector<int> IntMap; + + if (!sprite) + { + // delete sprite, if necessary + for (unsigned int i = 0; i < mStatusEffectIcons.size();) + if (mStatusEffectIcons[i] == index) + { + mStatusEffectIcons.erase(mStatusEffectIcons.begin() + + i); + miniStatusWindow->eraseIcon(i); + } + else + i++; + } + else + { + // replace sprite or append + bool found = false; + + for (unsigned int i = 0; i < mStatusEffectIcons.size(); + i++) + if (mStatusEffectIcons[i] == index) + { + miniStatusWindow->setIcon(i, sprite); + found = true; + break; + } + + if (!found) + { // add new + int offset = mStatusEffectIcons.size(); + miniStatusWindow->setIcon(offset, sprite); + mStatusEffectIcons.push_back(index); + } + } + } } } } @@ -199,5 +259,3 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) mTextPopup->setVisible(false); } - - |