From c5092e2ce5cd6edecde4339d4d2436d4585b60a6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 27 Jul 2015 02:37:40 +0300 Subject: Draw team badge if set. --- src/being/being.cpp | 27 ++++++++++++++++++++++++++- src/being/being.h | 3 ++- 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'src/being') diff --git a/src/being/being.cpp b/src/being/being.cpp index 746cc729b..62b35b386 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -132,6 +132,7 @@ Being::Being(const BeingId id, mInfo(BeingInfo::unknown), mEmotionSprite(nullptr), mAnimationEffect(nullptr), + mTeamBadge(nullptr), mSpriteAction(SpriteAction::STAND), mName(), mRaceName(), @@ -1828,7 +1829,8 @@ void Being::petLogic() } } -void Being::drawEmotion(Graphics *const graphics, const int offsetX, +void Being::drawEmotion(Graphics *const graphics, + const int offsetX, const int offsetY) const { const int px = getPixelX() - offsetX - mapTileSize / 2; @@ -1837,6 +1839,20 @@ void Being::drawEmotion(Graphics *const graphics, const int offsetX, mEmotionSprite->draw(graphics, px, py); if (mAnimationEffect) mAnimationEffect->draw(graphics, px, py); + if (mTeamBadge) + { + if (mDispName && gui) + { + Font *const font = gui->getFont(); + mTeamBadge->draw(graphics, + mDispName->getX() - offsetX + mDispName->getWidth(), + mDispName->getY() - offsetY - font->getHeight()); + } + else + { + mTeamBadge->draw(graphics, px, py); + } + } } void Being::drawSpeech(const int offsetX, const int offsetY) @@ -3674,6 +3690,15 @@ void Being::setTeamId(const uint16_t teamId) { if (mTeamId != teamId) { + delete2(mTeamBadge); + if (teamId) + { + mTeamBadge = AnimatedSprite::load( + strprintf("%steam%d.xml", + paths.getStringValue("badges").c_str(), + teamId)); + } + mTeamId = teamId; updateColors(); } diff --git a/src/being/being.h b/src/being/being.h index bf389c324..a32a11487 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -957,7 +957,8 @@ class Being notfinal : public ActorSprite, BeingInfo *mInfo; AnimatedSprite *mEmotionSprite; - AnimatedSprite* mAnimationEffect; + AnimatedSprite *mAnimationEffect; + AnimatedSprite *mTeamBadge; std::string mSpriteAction; std::string mName; /**< Name of character */ -- cgit v1.2.3-60-g2f50