summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-09-18 13:20:13 +0300
committerAndrei Karas <akaras@inbox.ru>2013-09-18 13:20:13 +0300
commit3c7d4f339c20bc665efa6f6666171f0ca610203b (patch)
tree7c6479877911619696fd481698987e2f83491666
parent64b82129075e7608e94f8e27ee6c446213032cfb (diff)
downloadmv-3c7d4f339c20bc665efa6f6666171f0ca610203b.tar.gz
mv-3c7d4f339c20bc665efa6f6666171f0ca610203b.tar.bz2
mv-3c7d4f339c20bc665efa6f6666171f0ca610203b.tar.xz
mv-3c7d4f339c20bc665efa6f6666171f0ca610203b.zip
show online messages in party tab.
by default disabled.
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/setup_chat.cpp4
-rw-r--r--src/net/ea/gui/partytab.cpp11
-rw-r--r--src/net/ea/gui/partytab.h4
-rw-r--r--src/net/ea/partyhandler.cpp46
5 files changed, 57 insertions, 9 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 9a3313320..68cc4eb6e 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -307,6 +307,7 @@ DefaultsData* getConfigDefaults()
AddDEF("screenButtonsFormat", 0);
AddDEF("autoresizeminimaps", false);
AddDEF("showGuildOnline", false);
+ AddDEF("showPartyOnline", false);
AddDEF("enableGmTab", true);
AddDEF("gamecount", 0);
AddDEF("rated", false);
diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp
index 283ed8a95..cf2958e4d 100644
--- a/src/gui/setup_chat.cpp
+++ b/src/gui/setup_chat.cpp
@@ -105,6 +105,10 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) :
"showChatHistory", this, "showChatHistoryEvent");
// TRANSLATORS: settings option
+ new SetupItemCheckBox(_("Show party online messages"), "",
+ "showPartyOnline", this, "showPartyOnlineEvent");
+
+ // TRANSLATORS: settings option
new SetupItemCheckBox(_("Show guild online messages"), "",
"showGuildOnline", this, "showGuildOnlineEvent");
diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp
index eb4801cbf..5cca1d54a 100644
--- a/src/net/ea/gui/partytab.cpp
+++ b/src/net/ea/gui/partytab.cpp
@@ -24,6 +24,7 @@
#include "chatlogger.h"
#include "commands.h"
+#include "configuration.h"
#include "party.h"
#include "soundconsts.h"
#include "soundmanager.h"
@@ -50,6 +51,9 @@ PartyTab::PartyTab(const Widget2 *const widget) :
&getThemeColor(Theme::PARTY_CHAT_TAB_HIGHLIGHTED_OUTLINE));
setSelectedTabColor(&getThemeColor(Theme::PARTY_CHAT_TAB_SELECTED),
&getThemeColor(Theme::PARTY_CHAT_TAB_SELECTED_OUTLINE));
+
+ mShowOnline = config.getBoolValue("showPartyOnline");
+ config.addListener("showPartyOnline", this);
}
PartyTab::~PartyTab()
@@ -281,4 +285,11 @@ void PartyTab::playNewMessageSound() const
{
soundManager.playGuiSound(SOUND_GUILD);
}
+
+void PartyTab::optionChanged(const std::string &value)
+{
+ if (value == "showPartyOnline")
+ mShowOnline = config.getBoolValue("showPartyOnline");
+}
+
} // namespace Ea
diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h
index 16c9e8a3f..1988df4e8 100644
--- a/src/net/ea/gui/partytab.h
+++ b/src/net/ea/gui/partytab.h
@@ -31,7 +31,7 @@ namespace Ea
/**
* A tab for a party chat channel.
*/
-class PartyTab : public ChatTab
+class PartyTab : public ChatTab, public ConfigListener
{
public:
explicit PartyTab(const Widget2 *const widget);
@@ -52,6 +52,8 @@ class PartyTab : public ChatTab
void playNewMessageSound() const override;
+ void optionChanged(const std::string &value);
+
protected:
void handleInput(const std::string &msg) override;
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index cd0c3cdfc..8bb8b6a8a 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -75,8 +75,9 @@ void PartyHandler::processPartyCreate(Net::MessageIn &msg) const
void PartyHandler::processPartyInfo(Net::MessageIn &msg) const
{
- bool oldParty = false;
+ bool isOldParty = false;
std::set<std::string> names;
+ std::set<std::string> onlineNames;
if (!Ea::taParty)
{
logger->log1("error: party empty in SMSG_PARTY_INFO");
@@ -86,9 +87,15 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) const
{
if (Ea::taParty->getNumberOfElements() > 1)
{
- oldParty = true;
-
+ isOldParty = true;
Ea::taParty->getNamesSet(names);
+ const Party::MemberList *const members = Ea::taParty->getMembers();
+ FOR_EACHP (Party::MemberList::const_iterator, it, members)
+ {
+ if ((*it)->getOnline())
+ onlineNames.insert((*it)->getName());
+ }
+ onlineNames.insert(player_node->getName());
}
}
@@ -119,20 +126,40 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) const
if (Ea::taParty)
{
- if (oldParty)
+ bool joined(false);
+
+ if (isOldParty)
{
if (names.find(nick) == names.end())
{
NotifyManager::notify(NotifyManager::PARTY_USER_JOINED,
nick);
+ joined = true;
}
}
PartyMember *const member = Ea::taParty->addMember(id, nick);
if (member)
{
- member->setLeader(leader);
- member->setOnline(online);
- member->setMap(map);
+ if (!joined && Ea::partyTab)
+ {
+ if (!names.empty() && ((onlineNames.find(nick)
+ == onlineNames.end() && online)
+ || (onlineNames.find(nick) != onlineNames.end()
+ && !online)))
+ {
+ Ea::partyTab->showOnline(nick, online);
+ }
+
+ member->setLeader(leader);
+ member->setOnline(online);
+ member->setMap(map);
+ }
+ else
+ {
+ member->setLeader(leader);
+ member->setOnline(online);
+ member->setMap(map);
+ }
}
}
}
@@ -279,7 +306,10 @@ void PartyHandler::processPartyMove(Net::MessageIn &msg) const
msg.skip(4); // 0
m->setX(msg.readInt16()); // x
m->setY(msg.readInt16()); // y
- m->setOnline(msg.readInt8()); // online (if 0)
+ const int online = msg.readInt8();
+ if (m->getOnline() != online)
+ Ea::partyTab->showOnline(m->getName(), online);
+ m->setOnline(online); // online (if 0)
msg.readString(24); // party
msg.readString(24); // nick
m->setMap(msg.readString(16)); // map