summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-27 02:37:40 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-27 14:04:19 +0300
commitc5092e2ce5cd6edecde4339d4d2436d4585b60a6 (patch)
tree08a5bfaf289b55f44b6538408a81299a68855282 /src/being
parent94eb2cb314e2629a659245554106ffe5e48f4d62 (diff)
downloadplus-c5092e2ce5cd6edecde4339d4d2436d4585b60a6.tar.gz
plus-c5092e2ce5cd6edecde4339d4d2436d4585b60a6.tar.bz2
plus-c5092e2ce5cd6edecde4339d4d2436d4585b60a6.tar.xz
plus-c5092e2ce5cd6edecde4339d4d2436d4585b60a6.zip
Draw team badge if set.
Diffstat (limited to 'src/being')
-rw-r--r--src/being/being.cpp27
-rw-r--r--src/being/being.h3
2 files changed, 28 insertions, 2 deletions
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 */