diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-03-25 23:56:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-03-25 23:56:55 +0300 |
commit | 7cf334f49fe9157aabeef8eb1e69e115749d1b8f (patch) | |
tree | 7b5bb97a0b3079bf7e1aa6dcf277f8989952f98d /src | |
parent | e0ad1f9076f322f18b54c4f1e0894a9cdd52937c (diff) | |
download | manaverse-7cf334f49fe9157aabeef8eb1e69e115749d1b8f.tar.gz manaverse-7cf334f49fe9157aabeef8eb1e69e115749d1b8f.tar.bz2 manaverse-7cf334f49fe9157aabeef8eb1e69e115749d1b8f.tar.xz manaverse-7cf334f49fe9157aabeef8eb1e69e115749d1b8f.zip |
If player poisoned, hightlight his life bar in social window with special color.
Diffstat (limited to 'src')
-rw-r--r-- | src/avatar.cpp | 37 | ||||
-rw-r--r-- | src/avatar.h | 7 | ||||
-rw-r--r-- | src/being/actorsprite.cpp | 11 | ||||
-rw-r--r-- | src/being/actorsprite.h | 11 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/gui/theme.cpp | 1 | ||||
-rw-r--r-- | src/gui/theme.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 15 | ||||
-rw-r--r-- | src/gui/windows/socialwindow.cpp | 1 | ||||
-rw-r--r-- | src/statuseffect.cpp | 13 | ||||
-rw-r--r-- | src/statuseffect.h | 3 |
11 files changed, 69 insertions, 32 deletions
diff --git a/src/avatar.cpp b/src/avatar.cpp index 4c936ba7f..3e685f008 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -27,24 +27,25 @@ #include "debug.h" Avatar::Avatar(const std::string &name): - mId(0), - mCharId(0), - mName(name), - mOriginalName(name), - mHp(0), - mMaxHp(0), - mDamageHp(0), - mLevel(1), - mMap(), - mX(-1), - mY(-1), - mType(AVATAR_PLAYER), - mExp(0), - mGender(GENDER_UNSPECIFIED), - mRace(-1), - mIp(), - mOnline(false), - mDisplayBold(false) + mId(0), + mCharId(0), + mName(name), + mOriginalName(name), + mHp(0), + mMaxHp(0), + mDamageHp(0), + mLevel(1), + mMap(), + mX(-1), + mY(-1), + mType(AVATAR_PLAYER), + mExp(0), + mGender(GENDER_UNSPECIFIED), + mRace(-1), + mIp(), + mOnline(false), + mDisplayBold(false), + mPoison(false) { } diff --git a/src/avatar.h b/src/avatar.h index 9804b318e..03050a06f 100644 --- a/src/avatar.h +++ b/src/avatar.h @@ -172,6 +172,12 @@ public: void setIp(std::string ip) { mIp = ip; } + bool getPoison() const A_WARN_UNUSED + { return mPoison; } + + void setPoison(const bool b) + { mPoison = b; } + protected: int mId; int mCharId; @@ -191,6 +197,7 @@ protected: std::string mIp; bool mOnline; bool mDisplayBold; + bool mPoison; }; #endif // AVATAR_H diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index bbb016525..9c1eeddc7 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -57,7 +57,8 @@ ActorSprite::ActorSprite(const int id) : mActorSpriteListeners(), mCursorPaddingX(0), mCursorPaddingY(0), - mMustResetParticles(false) + mMustResetParticles(false), + mPoison(false) { } @@ -197,7 +198,13 @@ void ActorSprite::updateStunMode(const int oldMode, const int newMode) void ActorSprite::updateStatusEffect(const int index, const bool newStatus) { - handleStatusEffect(StatusEffect::getStatusEffect(index, newStatus), index); + StatusEffect *const effect = StatusEffect::getStatusEffect( + index, newStatus); + if (!effect) + return; + if (effect->isPoison() && getType() == PLAYER) + setPoison(newStatus); + handleStatusEffect(effect, index); } void ActorSprite::handleStatusEffect(StatusEffect *const effect, diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index 444232ddd..76e90182d 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -179,12 +179,18 @@ public: */ void removeActorSpriteListener(ActorSpriteListener *const listener); - int getActorX() const + int getActorX() const A_WARN_UNUSED { return getPixelX() - mapTileSize / 2; } - int getActorY() const + int getActorY() const A_WARN_UNUSED { return getPixelY() - mapTileSize; } + void setPoison(const bool b) + { mPoison = b; } + + bool getPoison() const A_WARN_UNUSED + { return mPoison; } + protected: /** * Notify self that the stun mode has been updated. Invoked by @@ -244,6 +250,7 @@ private: /** Reset particle status effects on next redraw? */ bool mMustResetParticles; + bool mPoison; }; #endif // BEING_ACTORSPRITE_H diff --git a/src/defaults.cpp b/src/defaults.cpp index d5f907696..9ec23540f 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -535,6 +535,7 @@ DefaultsData* getPathsDefaults() AddDEF("deadMessagesFile", "deadmessages.xml"); AddDEF("deadMessagesPatchFile", "deadmessages_patch.xml"); AddDEF("deadMessagesPatchDir", "deadmessages.d"); + AddDEF("poisonEffectName", "poison"); return configData; } diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index d281b81d8..b208ce960 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -1031,6 +1031,7 @@ static int readProgressType(const std::string &type) static const std::string colors[Theme::THEME_PROG_END] = { "HP", + "HP_POISON", "MP", "NO_MP", "EXP", diff --git a/src/gui/theme.h b/src/gui/theme.h index 8bc40fe00..023918cf0 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -435,6 +435,7 @@ class Theme final : public Palette, enum ProgressPalette { PROG_HP = 0, + PROG_HP_POISON, PROG_MP, PROG_NO_MP, PROG_EXP, diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 5ce74bfca..9411c2249 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -154,14 +154,16 @@ void AvatarListBox::draw(Graphics *graphics) text = strprintf("%s %d/%d", a->getComplexName().c_str(), a->getHp(), a->getMaxHp()); } - if (parent && a->getMaxHp()) + const bool isPoison = a->getPoison(); + if (a->getMaxHp() && (isPoison || parent)) { + const int themeColor = (isPoison + ? Theme::PROG_HP_POISON : Theme::PROG_HP); Color color = Theme::getProgressColor( - Theme::PROG_HP, static_cast<float>(a->getHp()) - / static_cast<float>(a->getMaxHp())); + themeColor, static_cast<float>(a->getHp()) + / static_cast<float>(a->getMaxHp())); color.a = 80; graphics->setColor(color); - graphics->fillRectangle(Rect(mPadding, y + mPadding, parent->getWidth() * a->getHp() / a->getMaxHp() - 2 * mPadding, fontHeight)); @@ -182,8 +184,9 @@ void AvatarListBox::draw(Graphics *graphics) if (parent) { - Color color = Theme::getProgressColor(Theme::PROG_HP, 1); - + const int themeColor = (a->getPoison() + ? Theme::PROG_HP_POISON : Theme::PROG_HP); + Color color = Theme::getProgressColor(themeColor, 1); color.a = 80; graphics->setColor(color); graphics->fillRectangle(Rect(mPadding, y + mPadding, diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 8e6becca1..520184364 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -568,6 +568,7 @@ public: avatar->setLevel(being->getLevel()); avatar->setGender(being->getGender()); avatar->setIp(being->getIp()); + avatar->setPoison(being->getPoison()); } } diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 647c6dd99..fd9f60851 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -47,7 +47,8 @@ StatusEffect::StatusEffect() : mParticleEffect(), mIcon(), mAction(), - mPersistentParticleEffect(false) + mPersistentParticleEffect(false), + mIsPoison(false) { } @@ -153,9 +154,9 @@ void StatusEffect::loadXmlFile(const std::string &fileName) { if (xmlNameEqual(node, "include")) { - const std::string name = XML::getProperty(node, "name", ""); - if (!name.empty()) - loadXmlFile(name); + const std::string incName = XML::getProperty(node, "name", ""); + if (!incName.empty()) + loadXmlFile(incName); continue; } @@ -181,11 +182,14 @@ void StatusEffect::loadXmlFile(const std::string &fileName) { StatusEffect *startEffect = (*the_map)[1][index]; StatusEffect *endEffect = (*the_map)[0][index]; + const std::string name = XML::getProperty(node, "name", ""); if (!startEffect) startEffect = new StatusEffect; if (!endEffect) endEffect = new StatusEffect; + startEffect->mIsPoison = + (name == paths.getStringValue("poisonEffectName")); startEffect->mMessage = XML::getProperty( node, "start-message", ""); startEffect->mSFXEffect = XML::getProperty( @@ -198,6 +202,7 @@ void StatusEffect::loadXmlFile(const std::string &fileName) startEffect->mPersistentParticleEffect = (XML::getProperty( node, "persistent-particle-effect", "no")) != "no"; + endEffect->mIsPoison = startEffect->mIsPoison; endEffect->mMessage = XML::getProperty(node, "end-message", ""); endEffect->mSFXEffect = XML::getProperty(node, "end-audio", ""); endEffect->mParticleEffect = XML::getProperty( diff --git a/src/statuseffect.h b/src/statuseffect.h index 8bb164820..e30d9d1bd 100644 --- a/src/statuseffect.h +++ b/src/statuseffect.h @@ -73,6 +73,8 @@ public: bool particleEffectIsPersistent() const A_WARN_UNUSED { return mPersistentParticleEffect; } + bool isPoison() const A_WARN_UNUSED + { return mIsPoison; } /** * Retrieves a status effect. @@ -118,6 +120,7 @@ private: std::string mIcon; std::string mAction; bool mPersistentParticleEffect; + bool mIsPoison; }; #endif // STATUSEFFECT_H |