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/gui/widgets | |
parent | 772daf48072915d598014c25a33ff3dc96e43bce (diff) | |
download | manaplus-25907c03212110f10c910b0ef90a416dff450ca7.tar.gz manaplus-25907c03212110f10c910b0ef90a416dff450ca7.tar.bz2 manaplus-25907c03212110f10c910b0ef90a416dff450ca7.tar.xz manaplus-25907c03212110f10c910b0ef90a416dff450ca7.zip |
Add option to show/hide guild online messages.
Disabled by default.
Diffstat (limited to 'src/gui/widgets')
-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 |
4 files changed, 31 insertions, 2 deletions
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; |