diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-07-29 03:23:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-07-29 03:23:59 +0300 |
commit | cd2a71bfc4d3339dd6cf18b5a311e57d58fb548c (patch) | |
tree | 7149ca3ff5accb1dcc6e4d059480464d6aa66804 | |
parent | 73fc7aa882f53e47fb93e45f13e9428624f6876d (diff) | |
download | manaverse-cd2a71bfc4d3339dd6cf18b5a311e57d58fb548c.tar.gz manaverse-cd2a71bfc4d3339dd6cf18b5a311e57d58fb548c.tar.bz2 manaverse-cd2a71bfc4d3339dd6cf18b5a311e57d58fb548c.tar.xz manaverse-cd2a71bfc4d3339dd6cf18b5a311e57d58fb548c.zip |
Add support for guild badges.
-rw-r--r-- | src/being/being.cpp | 33 | ||||
-rw-r--r-- | src/being/being.h | 1 | ||||
-rw-r--r-- | src/resources/db/badgesdb.cpp | 10 | ||||
-rw-r--r-- | src/resources/db/badgesdb.h | 2 |
4 files changed, 44 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; diff --git a/src/resources/db/badgesdb.cpp b/src/resources/db/badgesdb.cpp index 80b480ee0..cdf61b406 100644 --- a/src/resources/db/badgesdb.cpp +++ b/src/resources/db/badgesdb.cpp @@ -26,6 +26,7 @@ namespace { + BadgesInfos mGuilds; BadgesInfos mParties; bool mLoaded = false; } @@ -46,6 +47,7 @@ void BadgesDB::load() if (mLoaded) unload(); + loadDB("guild", mGuilds); loadDB("party", mParties); } @@ -62,3 +64,11 @@ const std::string BadgesDB::getPartyBadge(const std::string &name) return std::string(); return (*it).second; } + +const std::string BadgesDB::getGuildBadge(const std::string &name) +{ + BadgesInfosIter it = mGuilds.find(name); + if (it == mGuilds.end()) + return std::string(); + return (*it).second; +} diff --git a/src/resources/db/badgesdb.h b/src/resources/db/badgesdb.h index 7c971e00f..5e53660b9 100644 --- a/src/resources/db/badgesdb.h +++ b/src/resources/db/badgesdb.h @@ -35,6 +35,8 @@ namespace BadgesDB void unload(); + const std::string getGuildBadge(const std::string &name); + const std::string getPartyBadge(const std::string &name); } // namespace BadgesDB |