diff options
Diffstat (limited to 'src/being')
-rw-r--r-- | src/being/being.cpp | 33 | ||||
-rw-r--r-- | src/being/being.h | 1 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index ef5412d0a..6cc8bae4b 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -135,6 +135,7 @@ Being::Being(const BeingId id, mInfo(BeingInfo::unknown), mEmotionSprite(nullptr), mAnimationEffect(nullptr), + mGuildBadge(nullptr), mPartyBadge(nullptr), mTeamBadge(nullptr), mSpriteAction(SpriteAction::STAND), @@ -293,6 +294,7 @@ Being::~Being() delete2(mText); delete2(mEmotionSprite); delete2(mAnimationEffect); + delete2(mGuildBadge); delete2(mPartyBadge); delete2(mTeamBadge); mBadgesCount = 0; @@ -1005,7 +1007,21 @@ void Being::setShowName(const bool doShowName) void Being::setGuildName(const std::string &name) { - mGuildName = name; + if (mGuildName != name) + { + delete2(mGuildBadge); + mGuildName = name; + if (!mGuildName.empty() && mShowBadges) + { + const std::string badge = BadgesDB::getGuildBadge(mGuildName); + if (!badge.empty()) + { + mGuildBadge = AnimatedSprite::load( + paths.getStringValue("badges") + badge); + } + } + updateBadgesCount(); + } } void Being::setGuildPos(const std::string &pos A_UNUSED) @@ -1123,7 +1139,7 @@ void Being::updateGuild() { setGuild(guild); if (!guild->getName().empty()) - mGuildName = guild->getName(); + setGuildName(guild->getName()); } updateColors(); } @@ -1371,6 +1387,8 @@ void Being::setAction(const BeingActionT &action, const int attackId) mEmotionSprite->play(currentAction); if (mAnimationEffect) mAnimationEffect->play(currentAction); + if (mGuildBadge) + mGuildBadge->play(currentAction); if (mPartyBadge) mPartyBadge->play(currentAction); if (mTeamBadge) @@ -1438,6 +1456,8 @@ void Being::setDirection(const uint8_t direction) mEmotionSprite->setSpriteDirection(dir); if (mAnimationEffect) mAnimationEffect->setSpriteDirection(dir); + if (mGuildBadge) + mGuildBadge->setSpriteDirection(dir); if (mPartyBadge) mPartyBadge->setSpriteDirection(dir); if (mTeamBadge) @@ -1546,6 +1566,8 @@ void Being::logic() if (mAnimationEffect->isTerminated()) delete2(mAnimationEffect) } + if (mGuildBadge) + mGuildBadge->update(time); if (mPartyBadge) mPartyBadge->update(time); if (mTeamBadge) @@ -1879,6 +1901,11 @@ void Being::drawEmotion(Graphics *const graphics, mTeamBadge->draw(graphics, x, y); x += 16; } + if (mGuildBadge) + { + mGuildBadge->draw(graphics, x, y); + x += 16; + } if (mPartyBadge) { mPartyBadge->draw(graphics, x, y); @@ -3768,6 +3795,8 @@ void Being::updateBadgesCount() mBadgesCount = 0; if (mTeamBadge) mBadgesCount ++; + if (mGuildBadge) + mBadgesCount ++; if (mPartyBadge) mBadgesCount ++; } diff --git a/src/being/being.h b/src/being/being.h index 2f8796ba7..5d4c5d0ec 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -961,6 +961,7 @@ class Being notfinal : public ActorSprite, BeingInfo *mInfo; AnimatedSprite *mEmotionSprite; AnimatedSprite *mAnimationEffect; + AnimatedSprite *mGuildBadge; AnimatedSprite *mPartyBadge; AnimatedSprite *mTeamBadge; |