summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-29 21:11:40 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-29 21:11:40 +0300
commit0fe12f569879f90b8b6efab790ba896b9769a3d4 (patch)
treeb81fe57e9defa337c79ab89d37c35bb3bbd8de06
parentaa0bda1d887709c13c64308d33087ad7fc1ac0bf (diff)
downloadmanaplus-0fe12f569879f90b8b6efab790ba896b9769a3d4.tar.gz
manaplus-0fe12f569879f90b8b6efab790ba896b9769a3d4.tar.bz2
manaplus-0fe12f569879f90b8b6efab790ba896b9769a3d4.tar.xz
manaplus-0fe12f569879f90b8b6efab790ba896b9769a3d4.zip
Fix enable/disable badges without client restart.
-rw-r--r--src/actormanager.cpp4
-rw-r--r--src/being/being.cpp92
-rw-r--r--src/being/being.h8
3 files changed, 69 insertions, 35 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 0699ecf57..510202435 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -218,6 +218,7 @@ ActorManager::ActorManager() :
config.addListener("cycleMonsters", this);
config.addListener("cycleNPC", this);
config.addListener("extMouseTargeting", this);
+ config.addListener("showBadges", this);
loadAttackList();
}
@@ -1848,7 +1849,8 @@ Being *ActorManager::cloneBeing(const Being *const srcBeing,
void ActorManager::updateBadges()
{
- const bool showBadges = config.getBoolValue("showBadges");
+ const int showBadges = config.getIntValue("showBadges");
+ Being::mShowBadges = showBadges;
for_actors
{
ActorSprite *const actor = *it;
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 987971a78..23e4da309 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -1006,21 +1006,26 @@ void Being::setShowName(const bool doShowName)
delete2(mDispName)
}
+void Being::showGuildBadge(const bool show)
+{
+ delete2(mGuildBadge);
+ if (show && !mGuildName.empty() && mShowBadges)
+ {
+ const std::string badge = BadgesDB::getGuildBadge(mGuildName);
+ if (!badge.empty())
+ {
+ mGuildBadge = AnimatedSprite::load(
+ paths.getStringValue("badges") + badge);
+ }
+ }
+}
+
void Being::setGuildName(const std::string &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);
- }
- }
+ showGuildBadge(!mGuildName.empty());
updateBadgesCount();
}
}
@@ -2577,23 +2582,29 @@ void Being::setGender(const GenderT gender)
}
}
+void Being::showGmBadge(const bool show)
+{
+ delete2(mGmBadge);
+ if (show && mIsGM && mShowBadges)
+ {
+ const std::string gmBadge = paths.getStringValue("gmbadge");
+ if (!gmBadge.empty())
+ {
+ mGmBadge = AnimatedSprite::load(
+ paths.getStringValue("badges") + gmBadge);
+ }
+ }
+ updateBadgesCount();
+}
+
void Being::setGM(const bool gm)
{
if (mIsGM != gm)
{
- delete2(mGmBadge);
mIsGM = gm;
- if (mIsGM && mShowBadges)
- {
- const std::string gmBadge = paths.getStringValue("gmbadge");
- if (!gmBadge.empty())
- {
- mGmBadge = AnimatedSprite::load(
- paths.getStringValue("badges") + gmBadge);
- }
- }
+
+ showGmBadge(mIsGM);
updateColors();
- updateBadgesCount();
}
}
@@ -3781,12 +3792,12 @@ void Being::setTeamId(const uint16_t teamId)
if (mTeamId != teamId)
{
mTeamId = teamId;
- showBadges(mTeamId != 0);
+ showTeamBadge(mTeamId != 0);
updateColors();
}
}
-void Being::showBadges(const bool show)
+void Being::showTeamBadge(const bool show)
{
delete2(mTeamBadge);
if (show && mTeamId && mShowBadges)
@@ -3800,22 +3811,35 @@ void Being::showBadges(const bool show)
updateBadgesCount();
}
+void Being::showBadges(const bool show)
+{
+ showTeamBadge(show);
+ showGuildBadge(show);
+ showGmBadge(show);
+ showPartyBadge(show);
+}
+
+void Being::showPartyBadge(const bool show)
+{
+ delete2(mPartyBadge);
+ if (show && !mPartyName.empty() && mShowBadges)
+ {
+ const std::string badge = BadgesDB::getPartyBadge(mPartyName);
+ if (!badge.empty())
+ {
+ mPartyBadge = AnimatedSprite::load(
+ paths.getStringValue("badges") + badge);
+ }
+ }
+ updateBadgesCount();
+}
+
void Being::setPartyName(const std::string &name)
{
if (mPartyName != name)
{
- delete2(mPartyBadge);
mPartyName = name;
- if (!mPartyName.empty() && mShowBadges)
- {
- const std::string badge = BadgesDB::getPartyBadge(mPartyName);
- if (!badge.empty())
- {
- mPartyBadge = AnimatedSprite::load(
- paths.getStringValue("badges") + badge);
- }
- }
- updateBadgesCount();
+ showPartyBadge(!mPartyName.empty());
}
}
diff --git a/src/being/being.h b/src/being/being.h
index cd56f5626..6850b2169 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -931,6 +931,14 @@ class Being notfinal : public ActorSprite,
void setTeamId(const uint16_t teamId);
+ void showTeamBadge(const bool show);
+
+ void showGuildBadge(const bool show);
+
+ void showGmBadge(const bool show);
+
+ void showPartyBadge(const bool show);
+
void showBadges(const bool show);
uint16_t getTeamId() const