From 55dd2a721ec7dfb0966c1e93536096984d78e2e5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 12 Feb 2012 18:50:24 +0300 Subject: Add option to enable/disable grouping friends in online list. --- src/defaults.cpp | 1 + src/gui/setup_players.cpp | 3 +++ src/gui/whoisonline.cpp | 18 +++++++++++++++--- src/gui/whoisonline.h | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/defaults.cpp b/src/defaults.cpp index 18b00dfb7..f5fb40881 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -225,6 +225,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "testInfo", ""); AddDEF(configData, "enableresize", true); AddDEF(configData, "noframe", false); + AddDEF(configData, "groupFriends", true); return configData; } diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index f0bf4c0ea..a08517fae 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -84,6 +84,9 @@ Setup_Players::Setup_Players() new SetupItemCheckBox(_("Allow self heal with mouse click"), "", "selfMouseHeal", this, "selfMouseHealEvent"); + new SetupItemCheckBox(_("Group friends in who is online window"), "", + "groupFriends", this, "groupFriendsEvent"); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 7c620bdf1..1efa9c22d 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -85,7 +85,8 @@ WhoIsOnline::WhoIsOnline(): mMemoryBuffer(nullptr), mCurlError(new char[CURL_ERROR_SIZE]), mAllowUpdate(true), - mShowLevel(false) + mShowLevel(false), + mGroupFriends(true) { mCurlError[0] = 0; setWindowName("WhoIsOnline"); @@ -124,12 +125,15 @@ WhoIsOnline::WhoIsOnline(): download(); config.addListener("updateOnlineList", this); + config.addListener("groupFriends", this); mUpdateOnlineList = config.getBoolValue("updateOnlineList"); + mGroupFriends = config.getBoolValue("groupFriends"); } WhoIsOnline::~WhoIsOnline() { config.removeListener("updateOnlineList", this); + config.removeListener("groupFriends", this); if (mThread && SDL_GetThreadID(mThread)) SDL_WaitThread(mThread, nullptr); @@ -282,7 +286,10 @@ void WhoIsOnline::loadList(std::vector &list) case PlayerRelation::FRIEND: player->setText("2"); - friends.push_back(player); + if (mGroupFriends) + friends.push_back(player); + else + neutral.push_back(player); break; case PlayerRelation::DISREGARDED: @@ -425,7 +432,10 @@ void WhoIsOnline::loadWebList() case PlayerRelation::FRIEND: player->setText("2"); - friends.push_back(player); + if (mGroupFriends) + friends.push_back(player); + else + neutral.push_back(player); break; case PlayerRelation::DISREGARDED: @@ -716,6 +726,8 @@ void WhoIsOnline::optionChanged(const std::string &name) { if (name == "updateOnlineList") mUpdateOnlineList = config.getBoolValue("updateOnlineList"); + else if (name == "groupFriends") + mGroupFriends = config.getBoolValue("groupFriends"); } void OnlinePlayer::setText(std::string color) diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index dad51e857..1607286a9 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -201,6 +201,7 @@ private: bool mAllowUpdate; bool mShowLevel; bool mUpdateOnlineList; + bool mGroupFriends; }; extern WhoIsOnline *whoIsOnline; -- cgit v1.2.3-70-g09d2