diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-18 21:33:21 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-18 21:33:21 +0300 |
commit | 25907c03212110f10c910b0ef90a416dff450ca7 (patch) | |
tree | fa409f004887619041e19f06f289d5ecb1c89e59 /src | |
parent | 772daf48072915d598014c25a33ff3dc96e43bce (diff) | |
download | mv-25907c03212110f10c910b0ef90a416dff450ca7.tar.gz mv-25907c03212110f10c910b0ef90a416dff450ca7.tar.bz2 mv-25907c03212110f10c910b0ef90a416dff450ca7.tar.xz mv-25907c03212110f10c910b0ef90a416dff450ca7.zip |
Add option to show/hide guild online messages.
Disabled by default.
Diffstat (limited to 'src')
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/gui/setup_chat.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 15 | ||||
-rw-r--r-- | src/gui/widgets/chattab.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/guildchattab.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/guildchattab.h | 4 | ||||
-rw-r--r-- | src/guildmanager.cpp | 4 | ||||
-rw-r--r-- | src/net/ea/gui/guildtab.cpp | 10 | ||||
-rw-r--r-- | src/net/ea/gui/guildtab.h | 4 | ||||
-rw-r--r-- | src/net/ea/guildhandler.cpp | 4 |
10 files changed, 56 insertions, 3 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index fe5762a6f..4c71b36bc 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -305,6 +305,7 @@ DefaultsData* getConfigDefaults() AddDEF("screenActionButton3", Input::KEY_PATHFIND); AddDEF("screenButtonsFormat", 0); AddDEF("autoresizeminimaps", false); + AddDEF("showGuildOnline", false); return configData; } diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp index c57160d7f..bb0ab0096 100644 --- a/src/gui/setup_chat.cpp +++ b/src/gui/setup_chat.cpp @@ -92,6 +92,9 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) : new SetupItemCheckBox(_("Show chat history"), "", "showChatHistory", this, "showChatHistoryEvent"); + new SetupItemCheckBox(_("Show guild online messages"), "", + "showGuildOnline", this, "showGuildOnlineEvent"); + new SetupItemLabel(_("Messages"), "", this); diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 0742e0ae2..fd336e116 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -55,7 +55,8 @@ ChatTab::ChatTab(const Widget2 *const widget, const std::string &name) : mScrollArea(new ScrollArea(mTextOutput, false)), mAllowHightlight(true), mRemoveNames(false), - mNoAway(false) + mNoAway(false), + mShowOnline(false) { setCaption(name); @@ -506,3 +507,15 @@ void ChatTab::playNewMessageSound() { sound.playGuiSound(SOUND_WHISPER); } + +void ChatTab::showOnline(const std::string &nick, + const bool isOnline) +{ + if (!mShowOnline) + return; + + if (isOnline) + chatLog(strprintf(_("%s is now Online."), nick.c_str())); + else + chatLog(strprintf(_("%s is now Offline."), nick.c_str())); +} diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index ae4ac3f01..0b3469458 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -165,6 +165,9 @@ class ChatTab : public Tab void addNewRow(std::string &line); + void showOnline(const std::string &nick, + const bool isOnline); + virtual void playNewMessageSound(); protected: @@ -190,6 +193,7 @@ class ChatTab : public Tab bool mAllowHightlight; bool mRemoveNames; bool mNoAway; + bool mShowOnline; }; extern ChatTab *localChatTab; diff --git a/src/gui/widgets/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp index 79907b4c3..c960b4798 100644 --- a/src/gui/widgets/guildchattab.cpp +++ b/src/gui/widgets/guildchattab.cpp @@ -23,6 +23,7 @@ #include "gui/widgets/guildchattab.h" #include "chatlogger.h" +#include "configuration.h" #include "guild.h" #include "guildmanager.h" #include "localplayer.h" @@ -44,10 +45,13 @@ GuildChatTab::GuildChatTab(const Widget2 *const widget) : &getThemeColor(Theme::GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE)); setSelectedTabColor(&getThemeColor(Theme::GUILD_CHAT_TAB_SELECTED), &getThemeColor(Theme::GUILD_CHAT_TAB_SELECTED_OUTLINE)); + mShowOnline = config.getBoolValue("showGuildOnline"); + config.addListener("showGuildOnline", this); } GuildChatTab::~GuildChatTab() { + config.removeListeners(this); } bool GuildChatTab::handleCommand(const std::string &type, @@ -132,3 +136,9 @@ void GuildChatTab::playNewMessageSound() { sound.playGuiSound(SOUND_GUILD); } + +void GuildChatTab::optionChanged(const std::string &value) +{ + if (value == "showGuildOnline") + mShowOnline = config.getBoolValue("showGuildOnline"); +} diff --git a/src/gui/widgets/guildchattab.h b/src/gui/widgets/guildchattab.h index 91baf6973..c1605495d 100644 --- a/src/gui/widgets/guildchattab.h +++ b/src/gui/widgets/guildchattab.h @@ -28,7 +28,7 @@ /** * A tab for a guild chat channel. */ -class GuildChatTab final : public ChatTab +class GuildChatTab final : public ChatTab, public ConfigListener { public: GuildChatTab(const Widget2 *const widget); @@ -49,6 +49,8 @@ class GuildChatTab final : public ChatTab void playNewMessageSound() override; + void optionChanged(const std::string &value) override; + protected: void handleInput(const std::string &msg) override; diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 7ec8ae95b..4359d2659 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -270,6 +270,8 @@ bool GuildManager::process(std::string msg) m->setOnline(false); guild->sort(); mRequest = false; + if (mTab) + mTab->showOnline(msg, false); return true; } else if (!haveNick && findCutLast(msg, " is now Online.")) @@ -286,6 +288,8 @@ bool GuildManager::process(std::string msg) m->setOnline(true); guild->sort(); mRequest = false; + if (mTab) + mTab->showOnline(msg, true); return true; } else if (findCutFirst(msg, "Welcome to the ")) diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index ff433f606..b764a9f85 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -23,6 +23,7 @@ #include "net/ea/gui/guildtab.h" #include "chatlogger.h" +#include "configuration.h" #include "guild.h" #include "localplayer.h" #include "soundmanager.h" @@ -51,10 +52,13 @@ GuildTab::GuildTab(const Widget2 *const widget) : &getThemeColor(Theme::GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE)); setSelectedTabColor(&getThemeColor(Theme::GUILD_CHAT_TAB_SELECTED), &getThemeColor(Theme::GUILD_CHAT_TAB_SELECTED_OUTLINE)); + mShowOnline = config.getBoolValue("showGuildOnline"); + config.addListener("showGuildOnline", this); } GuildTab::~GuildTab() { + config.removeListeners(this); } bool GuildTab::handleCommand(const std::string &type, const std::string &args) @@ -155,4 +159,10 @@ void GuildTab::playNewMessageSound() sound.playGuiSound(SOUND_GUILD); } +void GuildTab::optionChanged(const std::string &value) +{ + if (value == "showGuildOnline") + mShowOnline = config.getBoolValue("showGuildOnline"); +} + } // namespace Ea diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h index 020c6d7c9..d7b48f09f 100644 --- a/src/net/ea/gui/guildtab.h +++ b/src/net/ea/gui/guildtab.h @@ -31,7 +31,7 @@ namespace Ea /** * A tab for a guild chat channel. */ -class GuildTab : public ChatTab +class GuildTab : public ChatTab, public ConfigListener { public: GuildTab(const Widget2 *const widget); @@ -52,6 +52,8 @@ class GuildTab : public ChatTab void playNewMessageSound() override; + void optionChanged(const std::string &value) override; + protected: void handleInput(const std::string &msg) override; diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 7c2592617..e9ec8c97d 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -149,7 +149,11 @@ void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) { GuildMember *const m = taGuild->getMember(accountId, charId); if (m) + { m->setOnline(online); + if (guildTab) + guildTab->showOnline(m->getName(), online); + } } } |