From 4d5746331c6e4beee730e4b67df26e65bbc1001e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 22 Jan 2013 20:57:37 +0300 Subject: Show in online list colored party and guild members. --- src/gui/whoisonline.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++----- src/gui/whoisonline.h | 2 ++ 2 files changed, 65 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 73dcf008a..893b27a46 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -22,10 +22,8 @@ #include "gui/whoisonline.h" -#include -#include -#include -#include +#include "guild.h" +#include "party.h" #include "gui/socialwindow.h" #include "gui/viewport.h" @@ -49,6 +47,11 @@ #include "utils/dtor.h" #include "utils/gettext.h" +#include +#include +#include +#include + // Curl should be included after Guichan to avoid Windows redefinitions #include @@ -263,7 +266,7 @@ void WhoIsOnline::loadList(std::vector &list) { case PlayerRelation::NEUTRAL: default: - player->setText("0"); + setNeutralColor(player); neutral.push_back(player); break; @@ -411,7 +414,7 @@ void WhoIsOnline::loadWebList() { case PlayerRelation::NEUTRAL: default: - player->setText("0"); + setNeutralColor(player); neutral.push_back(player); break; @@ -722,6 +725,60 @@ void WhoIsOnline::optionChanged(const std::string &name) mGroupFriends = config.getBoolValue("groupFriends"); } +void WhoIsOnline::setNeutralColor(OnlinePlayer *const player) +{ + if (!player) + return; + + if (actorSpriteManager && player_node) + { + const std::string &nick = player->getNick(); + if (player_node->isInParty()) + { + const Party *const party = player_node->getParty(); + if (party) + { + if (party->getMember(nick)) + { + player->setText("P"); + return; + } + } + } + + const Being *const being = actorSpriteManager->findBeingByName(nick); + if (being) + { + const Guild *const guild2 = player_node->getGuild(); + if (guild2) + { + const Guild *const guild1 = being->getGuild(); + if (guild1) + { + if (guild1->getId() == guild2->getId() + || guild2->getMember(nick)) + { + player->setText("U"); + return; + } + } + else if (guild2->isMember(nick)) + { + player->setText("U"); + return; + } + } + } + const Guild *const guild3 = Guild::getGuild(1); + if (guild3 && guild3->isMember(nick)) + { + player->setText("U"); + return; + } + } + player->setText("0"); +} + void OnlinePlayer::setText(std::string color) { mText.clear(); diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index fa2955e40..6ee9a9c9d 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -152,6 +152,8 @@ public: void readFromWeb(); + void setNeutralColor(OnlinePlayer *const player); + private: void download(); -- cgit v1.2.3-70-g09d2