From 6494df1ca2a1c00b85828deb3b62f371338536fb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 22 May 2012 22:21:21 +0300 Subject: Add option to hide nick for erased players relation. --- src/being.cpp | 17 +++++++++++++---- src/being.h | 1 + src/defaults.cpp | 1 + src/gui/popupmenu.cpp | 4 ++-- src/gui/setup_players.cpp | 3 +++ 5 files changed, 20 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 69dfb9046..c58cc4696 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -203,6 +203,7 @@ bool Being::mShowGender = false; bool Being::mShowLevel = false; bool Being::mShowPlayersStatus = false; bool Being::mEnableReorderSprites = true; +bool Being::mHideErased = false; std::list beingInfoCache; @@ -279,7 +280,7 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): config.addListener("visiblenames", this); - mEnableReorderSprites = config.getBoolValue("enableReorderSprites"); + reReadConfig(); if (mType == NPC) setShowName(true); @@ -1602,8 +1603,18 @@ std::string Being::getGenderSign() const void Being::showName() { + if (mName.empty()) + return; + delete mDispName; mDispName = nullptr; + + if (mHideErased && player_relations.getRelation(mName) == + PlayerRelation::ERASED) + { + return; + } + std::string mDisplayName(mName); if (mType != MONSTER && (mShowGender || mShowLevel)) @@ -1632,9 +1643,6 @@ void Being::showName() font = gui->getSecureFont(); } - if (mDisplayName.empty()) - return; - mDispName = new FlashText(mDisplayName, getPixelX(), getPixelY(), gcn::Graphics::CENTER, mNameColor, font); @@ -1837,6 +1845,7 @@ void Being::reReadConfig() mShowLevel = config.getBoolValue("showlevel"); mShowPlayersStatus = config.getBoolValue("showPlayersStatus"); mEnableReorderSprites = config.getBoolValue("enableReorderSprites"); + mHideErased = config.getBoolValue("hideErased"); mUpdateConfigTime = cur_time; } diff --git a/src/being.h b/src/being.h index 250073faa..ee4efef0f 100644 --- a/src/being.h +++ b/src/being.h @@ -905,6 +905,7 @@ class Being : public ActorSprite, public ConfigListener static bool mShowLevel; static bool mShowPlayersStatus; static bool mEnableReorderSprites; + static bool mHideErased; unsigned int mMoveTime; unsigned int mAttackTime; diff --git a/src/defaults.cpp b/src/defaults.cpp index 264914ba4..e8f421216 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -258,6 +258,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "networksleep", 0); AddDEF(configData, "newtextures", true); AddDEF(configData, "videodetected", false); + AddDEF(configData, "hideErased", false); return configData; } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 436fd93b1..318de81b0 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -730,8 +730,7 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "unignore" && !mNick.empty()) { - player_relations.setRelation(mNick, - PlayerRelation::NEUTRAL); + player_relations.setRelation(mNick, PlayerRelation::NEUTRAL); } else if (link == "ignore" && being && being->getType() == ActorSprite::PLAYER) @@ -768,6 +767,7 @@ void PopupMenu::handleLink(const std::string &link, being->getType() == ActorSprite::PLAYER) { player_relations.setRelation(being->getName(), PlayerRelation::ERASED); + being->updateName(); } else if (link == "erase" && !mNick.empty()) { diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index b2cd7847d..0f5fb9615 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -86,6 +86,9 @@ Setup_Players::Setup_Players() new SetupItemCheckBox(_("Group friends in who is online window"), "", "groupFriends", this, "groupFriendsEvent"); + new SetupItemCheckBox(_("Hide erased players nicks"), "", + "hideErased", this, "hideErasedEvent"); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } -- cgit v1.2.3-60-g2f50