diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-19 03:10:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-19 13:17:00 +0300 |
commit | 4464ef501c562cf6eeda3b59b1dfcf21d9dfb5a9 (patch) | |
tree | 1eab9247b1b58d448d64e25f6906447dfba53bd4 | |
parent | 2a09c2afe8bd1f476ef1901c9c639896534a081c (diff) | |
download | manaplus-4464ef501c562cf6eeda3b59b1dfcf21d9dfb5a9.tar.gz manaplus-4464ef501c562cf6eeda3b59b1dfcf21d9dfb5a9.tar.bz2 manaplus-4464ef501c562cf6eeda3b59b1dfcf21d9dfb5a9.tar.xz manaplus-4464ef501c562cf6eeda3b59b1dfcf21d9dfb5a9.zip |
Add support for away particle effect.
-rw-r--r-- | src/being.cpp | 27 | ||||
-rw-r--r-- | src/being.h | 8 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/effectmanager.cpp | 25 | ||||
-rw-r--r-- | src/effectmanager.h | 4 | ||||
-rw-r--r-- | src/localplayer.cpp | 2 |
6 files changed, 66 insertions, 1 deletions
diff --git a/src/being.cpp b/src/being.cpp index 29ffefcfd..aad803ba2 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -188,6 +188,7 @@ bool Being::mShowLevel = false; bool Being::mShowPlayersStatus = false; bool Being::mEnableReorderSprites = true; bool Being::mHideErased = false; +int Being::mAwayEffect = -1; std::list<BeingCacheEntry*> beingInfoCache; typedef std::map<int, Guild*>::const_iterator GuildsMapCIter; @@ -245,7 +246,8 @@ Being::Being(const int id, const Type type, const uint16_t subtype, mAway(false), mInactive(false), mNumber(100), - mHairColor(0) + mHairColor(0), + mAfkParticle(nullptr) { for (int f = 0; f < 20; f ++) @@ -1899,6 +1901,7 @@ void Being::reReadConfig() BLOCK_START("Being::reReadConfig") if (mUpdateConfigTime + 1 < cur_time) { + mAwayEffect = paths.getIntValue("afkEffectId"); mHighlightMapPortals = config.getBoolValue("highlightMapPortals"); mConfLineLim = config.getIntValue("chatMaxCharLimit"); mSpeechType = config.getIntValue("speech"); @@ -1951,6 +1954,7 @@ bool Being::updateFromCache() mInactive = false; } + updateAwayEffect(); if (mType == PLAYER) updateColors(); return true; @@ -2678,6 +2682,7 @@ void Being::setState(const uint8_t state) mShop = shop; mAway = away; mInactive = inactive; + updateAwayEffect(); if (needUpdate) { @@ -2753,6 +2758,26 @@ int Being::getSpriteID(const int slot) const return mSpriteIDs[slot]; } +void Being::addAfkEffect() +{ + if (effectManager && !mAfkParticle && mAwayEffect != -1) + mAfkParticle = effectManager->triggerReturn(mAwayEffect, this); +} + +void Being::removeAfkEffect() +{ + if (effectManager && mAfkParticle) + mChildParticleEffects.removeLocally(mAfkParticle); +} + +void Being::updateAwayEffect() +{ + if (mAway) + addAfkEffect(); + else + removeAfkEffect(); +} + BeingEquipBackend::BeingEquipBackend(Being *const being): mBeing(being) { diff --git a/src/being.h b/src/being.h index 32508670b..5649b94cd 100644 --- a/src/being.h +++ b/src/being.h @@ -856,6 +856,12 @@ class Being : public ActorSprite, public ConfigListener Cursor::Cursor getHoverCursor() const A_WARN_UNUSED { return mInfo ? mInfo->getHoverCursor() : Cursor::CURSOR_POINTER; } + void addAfkEffect(); + + void removeAfkEffect(); + + void updateAwayEffect(); + static uint8_t genderToInt(const Gender sex) A_WARN_UNUSED; static Gender intToGender(uint8_t sex) A_WARN_UNUSED; @@ -987,6 +993,7 @@ class Being : public ActorSprite, public ConfigListener static bool mShowPlayersStatus; static bool mEnableReorderSprites; static bool mHideErased; + static int mAwayEffect; unsigned int mMoveTime; unsigned int mAttackTime; @@ -1011,6 +1018,7 @@ class Being : public ActorSprite, public ConfigListener bool mInactive; unsigned mNumber; unsigned char mHairColor; + Particle *mAfkParticle; }; extern std::list<BeingCacheEntry*> beingInfoCache; diff --git a/src/defaults.cpp b/src/defaults.cpp index 083c9a118..9e3a57cb6 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -382,6 +382,7 @@ DefaultsData* getPathsDefaults() AddDEF("hitEffectId", 26); AddDEF("missEffectId", -1); AddDEF("criticalHitEffectId", 28); + AddDEF("afkEffectId", -1); AddDEF("minimaps", "graphics/minimaps/"); AddDEF("maps", "maps/"); diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 59b85c796..be7fa1e83 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -87,6 +87,31 @@ bool EffectManager::trigger(const int id, Being *const being, return rValue; } +Particle *EffectManager::triggerReturn(const int id, Being *const being, + const int rotation) +{ + if (!being || !particleEngine) + return nullptr; + + Particle *rValue = nullptr; + FOR_EACH (std::vector<EffectDescription>::const_iterator, i, mEffects) + { + if ((*i).id == id) + { + if (!(*i).GFX.empty()) + { + rValue = particleEngine->addEffect( + (*i).GFX, 0, 0, rotation); + being->controlParticle(rValue); + } + if (!(*i).SFX.empty()) + sound.playSfx((*i).SFX); + break; + } + } + return rValue; +} + bool EffectManager::trigger(const int id, const int x, const int y, const int rotation) { diff --git a/src/effectmanager.h b/src/effectmanager.h index 279426638..b5d8e5bfc 100644 --- a/src/effectmanager.h +++ b/src/effectmanager.h @@ -30,6 +30,7 @@ #include "localconsts.h" class Being; +class Particle; class EffectManager final { @@ -53,6 +54,9 @@ class EffectManager final */ bool trigger(const int id, Being *const being, const int rotation = 0); + Particle *triggerReturn(const int id, Being *const being, + const int rotation = 0); + /** * Triggers a effect with the id, at * the specified x and y coordinate. diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 003bf4133..b4c31b33a 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -2220,6 +2220,7 @@ void LocalPlayer::changeAwayMode() DIALOG_SILENCE, true, false); mAwayDialog->addActionListener(mAwayListener); sound.volumeOff(); + addAfkEffect(); } else { @@ -2230,6 +2231,7 @@ void LocalPlayer::changeAwayMode() chatWindow->displayAwayLog(); chatWindow->clearAwayLog(); } + removeAfkEffect(); } } |