summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorFate <fate-tmw@googlemail.com>2008-12-07 04:00:55 -0700
committerFate <fate-tmw@googlemail.com>2008-12-07 04:00:55 -0700
commit3fcd6a549fc825f4185a6dc248922e02988caed5 (patch)
tree2def3534088760ec3d06860eb0af936ec1e66b5b /src/localplayer.cpp
parent68923d079602d8a8b7f35e1b56032e03e323ea09 (diff)
downloadmana-3fcd6a549fc825f4185a6dc248922e02988caed5.tar.gz
mana-3fcd6a549fc825f4185a6dc248922e02988caed5.tar.bz2
mana-3fcd6a549fc825f4185a6dc248922e02988caed5.tar.xz
mana-3fcd6a549fc825f4185a6dc248922e02988caed5.zip
Added client-side status change handlers (text, icon, particle effect, audio).
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 3550b092..3df80f0b 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -30,8 +30,10 @@
#include "particle.h"
#include "sound.h"
#include "monster.h"
+#include "statuseffect.h"
#include "gui/gui.h"
+#include "gui/ministatus.h"
#include "net/messageout.h"
#include "net/protocol.h"
@@ -479,3 +481,41 @@ void LocalPlayer::setGotoTarget(Being *target)
mGoingToTarget = true;
setDestination(target->mX, target->mY);
}
+
+
+extern MiniStatusWindow *miniStatusWindow;
+
+void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId)
+{
+ Being::handleStatusEffect(effect, effectId);
+ if (effect) {
+ effect->deliverMessage();
+
+ AnimatedSprite *sprite = effect->getIcon();
+
+ if (!sprite) {
+ // delete sprite, if necessary
+ for (unsigned int i = 0; i < mStatusEffectIcons.size();)
+ if (mStatusEffectIcons[i] == effectId) {
+ 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] == effectId) {
+ miniStatusWindow->setIcon(i, sprite);
+ found = true;
+ break;
+ }
+
+ if (!found) { // add new
+ int offset = mStatusEffectIcons.size();
+ miniStatusWindow->setIcon(offset, sprite);
+ mStatusEffectIcons.push_back(effectId);
+ }
+ }
+ }
+}