From d4841f5ec6d954bce7f628a33b8394550e32a057 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 5 Sep 2015 17:51:47 +0300 Subject: Add away being badge. --- src/being/being.cpp | 26 ++++++++++++++++++++++---- src/being/being.h | 2 ++ src/defaults.cpp | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/being/being.cpp b/src/being/being.cpp index 63be12ebe..b3cda4463 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2098,16 +2098,16 @@ std::string Being::getGenderSign() const else if (getGender() == Gender::MALE) str = "\u2642"; } - if (mShowPlayersStatus) + if (mShowPlayersStatus && !mShowBadges) { - if (mShop && !mShowBadges) + if (mShop) str.append("$"); if (mAway) { // TRANSLATORS: this away status writed in player nick str.append(_("A")); } - else if (mInactive && !mShowBadges) + else if (mInactive) { // TRANSLATORS: this inactive status writed in player nick str.append(_("I")); @@ -2519,6 +2519,7 @@ bool Being::updateFromCache() showShopBadge(mShop); showInactiveBadge(mInactive); + showAwayBadge(mInactive); updateAwayEffect(); if (mType == ActorType::Player || mTeamId) updateColors(); @@ -3372,6 +3373,7 @@ void Being::setState(const uint8_t state) updateAwayEffect(); showShopBadge(mShop); showInactiveBadge(mInactive); + showAwayBadge(mInactive); if (needUpdate) { @@ -3886,6 +3888,7 @@ void Being::showBadges(const bool show) showNameBadge(show); showShopBadge(show); showInactiveBadge(show); + showAwayBadge(show); } void Being::showPartyBadge(const bool show) @@ -3931,7 +3934,7 @@ void Being::showShopBadge(const bool show) void Being::showInactiveBadge(const bool show) { delete2(mBadges[BadgeIndex::Inactive]); - if (show && mShop && mShowBadges) + if (show && mInactive && mShowBadges) { const std::string badge = paths.getStringValue("inactivebadge"); if (!badge.empty()) @@ -3943,6 +3946,21 @@ void Being::showInactiveBadge(const bool show) updateBadgesCount(); } +void Being::showAwayBadge(const bool show) +{ + delete2(mBadges[BadgeIndex::Away]); + if (show && mAway && mShowBadges) + { + const std::string badge = paths.getStringValue("awaybadge"); + if (!badge.empty()) + { + mBadges[BadgeIndex::Away] = AnimatedSprite::load( + paths.getStringValue("badges") + badge); + } + } + updateBadgesCount(); +} + void Being::updateBadgesCount() { mBadgesCount = 0; diff --git a/src/being/being.h b/src/being/being.h index 47a904479..3105edc0e 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -946,6 +946,8 @@ class Being notfinal : public ActorSprite, void showInactiveBadge(const bool show); + void showAwayBadge(const bool show); + void showBadges(const bool show); uint16_t getTeamId() const diff --git a/src/defaults.cpp b/src/defaults.cpp index 83c53c129..ca2b31e04 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -609,6 +609,7 @@ DefaultsData* getPathsDefaults() AddDEF("gmbadge", "gm.xml"); AddDEF("shopbadge", "shop.xml"); AddDEF("inactivebadge", "inactive.xml"); + AddDEF("awaybadge", "away.xml"); return configData; } -- cgit v1.2.3-70-g09d2