diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-07-27 14:58:06 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-07-27 14:58:06 +0300 |
commit | 144204fd38ea7388d9ca97922862844636052bfc (patch) | |
tree | b30a4e6f5369a7ebc9bda465ec472956599ce9fc | |
parent | c5092e2ce5cd6edecde4339d4d2436d4585b60a6 (diff) | |
download | mv-144204fd38ea7388d9ca97922862844636052bfc.tar.gz mv-144204fd38ea7388d9ca97922862844636052bfc.tar.bz2 mv-144204fd38ea7388d9ca97922862844636052bfc.tar.xz mv-144204fd38ea7388d9ca97922862844636052bfc.zip |
Add option to show/hide badges. By default badges visible.
-rw-r--r-- | src/actormanager.cpp | 16 | ||||
-rw-r--r-- | src/actormanager.h | 2 | ||||
-rw-r--r-- | src/being/being.cpp | 27 | ||||
-rw-r--r-- | src/being/being.h | 3 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_players.cpp | 4 |
6 files changed, 43 insertions, 10 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 8bd4ed638..2161f8f33 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1578,6 +1578,8 @@ void ActorManager::optionChanged(const std::string &name) mCycleNPC = config.getBoolValue("cycleNPC"); else if (name == "extMouseTargeting") mExtMouseTargeting = config.getBoolValue("extMouseTargeting"); + else if (name == "showBadges") + updateBadges(); } void ActorManager::removeAttackMob(const std::string &name) @@ -1844,6 +1846,20 @@ Being *ActorManager::cloneBeing(const Being *const srcBeing, return dstBeing; } +void ActorManager::updateBadges() +{ + const bool showBadges = config.getBoolValue("showBadges"); + for_actors + { + ActorSprite *const actor = *it; + if (actor && actor->getType() == ActorType::Player) + { + Being *const being = static_cast<Being*>(actor); + being->showBadges(showBadges); + } + } +} + #ifdef EATHENA_SUPPORT void ActorManager::removeRoom(const int chatId) { diff --git a/src/actormanager.h b/src/actormanager.h index 02b060935..d9c85336b 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -330,6 +330,8 @@ class ActorManager final: public ConfigListener void updateEffects(const std::map<BeingTypeId, int> &addEffects, const std::set<BeingTypeId> &removeEffects) const; + void updateBadges(); + #ifdef EATHENA_SUPPORT void removeRoom(const int chatId); diff --git a/src/being/being.cpp b/src/being/being.cpp index 62b35b386..ad86d56fe 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -117,6 +117,7 @@ bool Being::mEnableReorderSprites = true; bool Being::mHideErased = false; Move Being::mMoveNames = Move_false; bool Being::mUseDiagonal = true; +bool Being::mShowBadges = true; int Being::mAwayEffect = -1; std::list<BeingCacheEntry*> beingInfoCache; @@ -288,6 +289,7 @@ Being::~Being() delete2(mText); delete2(mEmotionSprite); delete2(mAnimationEffect); + delete2(mTeamBadge); #ifdef EATHENA_SUPPORT delete2(mChat); #endif @@ -1839,7 +1841,7 @@ void Being::drawEmotion(Graphics *const graphics, mEmotionSprite->draw(graphics, px, py); if (mAnimationEffect) mAnimationEffect->draw(graphics, px, py); - if (mTeamBadge) + if (mTeamBadge && mShowBadges) { if (mDispName && gui) { @@ -2365,6 +2367,7 @@ void Being::reReadConfig() mHideErased = config.getBoolValue("hideErased"); mMoveNames = fromBool(config.getBoolValue("moveNames"), Move); mUseDiagonal = config.getBoolValue("useDiagonalSpeed"); + mShowBadges = config.getBoolValue("showBadges"); mUpdateConfigTime = cur_time; } @@ -3690,20 +3693,24 @@ 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; + showBadges(mTeamId != 0); updateColors(); } } +void Being::showBadges(const bool show) +{ + delete2(mTeamBadge); + if (show && mTeamId) + { + mTeamBadge = AnimatedSprite::load( + strprintf("%steam%d.xml", + paths.getStringValue("badges").c_str(), + mTeamId)); + } +} + #ifdef EATHENA_SUPPORT void Being::setChat(ChatObject *const obj) { diff --git a/src/being/being.h b/src/being/being.h index a32a11487..e73789434 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -932,6 +932,8 @@ class Being notfinal : public ActorSprite, void setTeamId(const uint16_t teamId); + void showBadges(const bool show); + uint16_t getTeamId() const { return mTeamId; } @@ -1101,6 +1103,7 @@ class Being notfinal : public ActorSprite, static bool mHideErased; static Move mMoveNames; static bool mUseDiagonal; + static bool mShowBadges; static int mAwayEffect; unsigned int mMoveTime; diff --git a/src/defaults.cpp b/src/defaults.cpp index 1c2323956..ac4e5ebb0 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -380,6 +380,7 @@ DefaultsData* getConfigDefaults() AddDEF("ignorelogpackets", ""); AddDEF("disableLoggingInGame", false); AddDEF("sellShopName", "unnamed"); + AddDEF("showBadges", true); return configData; } diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp index 005617ef0..1872cd216 100644 --- a/src/gui/widgets/tabs/setup_players.cpp +++ b/src/gui/widgets/tabs/setup_players.cpp @@ -70,6 +70,10 @@ Setup_Players::Setup_Players(const Widget2 *const widget) : "moveNames", this, "moveNamesEvent"); // TRANSLATORS: settings option + new SetupItemCheckBox(_("Show badges"), "", + "showBadges", this, "showBadgesEvent"); + + // TRANSLATORS: settings option new SetupItemCheckBox(_("Secure trades"), "", "securetrades", this, "securetradesEvent"); |