diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-15 12:59:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-15 12:59:29 +0300 |
commit | ab92ecc43d1b4d62e2ef3ac95c337dcee5f5fcc6 (patch) | |
tree | 1fc12b7dbe75471b4262483c36c13cc89f45facf /src | |
parent | 324a3df386950a6f262f2382caa33177f085c03f (diff) | |
download | manaverse-ab92ecc43d1b4d62e2ef3ac95c337dcee5f5fcc6.tar.gz manaverse-ab92ecc43d1b4d62e2ef3ac95c337dcee5f5fcc6.tar.bz2 manaverse-ab92ecc43d1b4d62e2ef3ac95c337dcee5f5fcc6.tar.xz manaverse-ab92ecc43d1b4d62e2ef3ac95c337dcee5f5fcc6.zip |
Move chat tab types into separate file.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/commands.cpp | 20 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/tabs/battletab.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chattab.cpp | 16 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chattab.h | 14 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chattabtype.h | 41 | ||||
-rw-r--r-- | src/gui/widgets/tabs/gmtab.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/tabs/guildchattab.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/tabs/langtab.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/tabs/tradetab.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/tabs/whispertab.h | 3 | ||||
-rw-r--r-- | src/net/ea/gui/guildtab.h | 3 | ||||
-rw-r--r-- | src/net/ea/gui/partytab.h | 3 |
15 files changed, 81 insertions, 42 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34084e026..63e763db6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,6 +125,7 @@ SET(SRCS gui/widgets/characterviewsmall.h gui/widgets/tabs/chattab.cpp gui/widgets/tabs/chattab.h + gui/widgets/tabs/chattabtype.h gui/widgets/checkbox.cpp gui/widgets/checkbox.h gui/models/colormodel.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 7961a343f..69f87a2fe 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -216,6 +216,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/characterviewsmall.h \ gui/widgets/tabs/chattab.cpp \ gui/widgets/tabs/chattab.h \ + gui/widgets/tabs/chattabtype.h \ gui/widgets/checkbox.cpp \ gui/widgets/checkbox.h \ gui/models/colormodel.cpp \ diff --git a/src/commands.cpp b/src/commands.cpp index 25b34fc81..737095480 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -111,12 +111,12 @@ static void outString(const ChatTab *const tab, switch (tab->getType()) { - case ChatTab::TAB_PARTY: + case ChatTabType::PARTY: { Net::getPartyHandler()->chat(str); break; } - case ChatTab::TAB_GUILD: + case ChatTabType::GUILD: { if (!player_node) return; @@ -214,12 +214,12 @@ static void outStringNormal(ChatTab *const tab, switch (tab->getType()) { - case ChatTab::TAB_PARTY: + case ChatTabType::PARTY: { Net::getPartyHandler()->chat(str); break; } - case ChatTab::TAB_GUILD: + case ChatTabType::GUILD: { const Guild *const guild = player_node->getGuild(); if (guild) @@ -237,7 +237,7 @@ static void outStringNormal(ChatTab *const tab, } break; } - case ChatTab::TAB_WHISPER: + case ChatTabType::WHISPER: { const WhisperTab *const whisper = static_cast<const WhisperTab *const>(tab); @@ -270,12 +270,12 @@ impHandler2(help) } switch (tab->getType()) { - case ChatTab::TAB_PARTY: + case ChatTabType::PARTY: { helpWindow->loadHelp("chatparty"); break; } - case ChatTab::TAB_GUILD: + case ChatTabType::GUILD: { helpWindow->loadHelp("chatguild"); break; @@ -759,7 +759,7 @@ impHandler(follow) if (!args.empty()) player_node->setFollow(args); - else if (tab && tab->getType() == ChatTab::TAB_WHISPER) + else if (tab && tab->getType() == ChatTabType::WHISPER) player_node->setFollow(static_cast<WhisperTab*>(tab)->getNick()); } @@ -770,7 +770,7 @@ impHandler(imitation) if (!args.empty()) player_node->setImitate(args); - else if (tab && tab->getType() == ChatTab::TAB_WHISPER) + else if (tab && tab->getType() == ChatTabType::WHISPER) player_node->setImitate(static_cast<WhisperTab*>(tab)->getNick()); else player_node->setImitate(""); @@ -881,7 +881,7 @@ impHandler2(info) switch (tab->getType()) { - case ChatTab::TAB_GUILD: + case ChatTabType::GUILD: { const Guild *const guild = player_node->getGuild(); if (guild) diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 7629bf9ed..3ecd0f333 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -615,7 +615,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab) mBrowserBox->clearRows(); - if (tab->getType() == static_cast<int>(ChatTab::TAB_WHISPER)) + if (tab->getType() == static_cast<int>(ChatTabType::WHISPER)) { // TRANSLATORS: popup menu item // TRANSLATORS: close chat tab @@ -664,7 +664,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab) mBrowserBox->addRow("disable away", _("Disable away")); } mBrowserBox->addRow("##3---"); - if (tab->getType() == static_cast<int>(ChatTab::TAB_PARTY)) + if (tab->getType() == static_cast<int>(ChatTabType::PARTY)) { // TRANSLATORS: popup menu item // TRANSLATORS: enable away messages in chat tab @@ -676,7 +676,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab) mBrowserBox->addRow("chat clipboard", _("Copy to clipboard")); mBrowserBox->addRow("##3---"); - if (tab->getType() == static_cast<int>(ChatTab::TAB_WHISPER)) + if (tab->getType() == static_cast<int>(ChatTabType::WHISPER)) { const WhisperTab *const wTab = static_cast<WhisperTab*>(tab); std::string name = wTab->getNick(); diff --git a/src/gui/widgets/tabs/battletab.h b/src/gui/widgets/tabs/battletab.h index 52f44cf40..0f9a80609 100644 --- a/src/gui/widgets/tabs/battletab.h +++ b/src/gui/widgets/tabs/battletab.h @@ -24,6 +24,7 @@ #define GUI_WIDGETS_TABS_BATTLETAB_H #include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/chattabtype.h" /** * A tab for a party chat channel. @@ -38,7 +39,7 @@ class BattleTab final : public ChatTab ~BattleTab(); int getType() const override final A_WARN_UNUSED - { return ChatTab::TAB_BATTLE; } + { return ChatTabType::BATTLE; } void saveToLogFile(const std::string &msg) const override final; }; diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index e52f935b3..fccc421ae 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -38,6 +38,8 @@ #include "gui/widgets/itemlinkhandler.h" #include "gui/widgets/tabbedarea.h" +#include "gui/widgets/tabs/chattabtype.h" + #include "net/chathandler.h" #include "net/net.h" @@ -276,8 +278,8 @@ void ChatTab::chatLog(std::string line, Own own, mScrollArea->logic(); if (own != BY_PLAYER) { - if (own == BY_SERVER && (getType() == TAB_PARTY - || getType() == TAB_GUILD)) + if (own == BY_SERVER && (getType() == ChatTabType::PARTY + || getType() == ChatTabType::GUILD)) { return; } @@ -446,11 +448,11 @@ void ChatTab::saveToLogFile(const std::string &msg) const { if (chatLogger) { - if (getType() == TAB_INPUT) + if (getType() == ChatTabType::INPUT) { chatLogger->log(msg); } - else if (getType() == TAB_DEBUG + else if (getType() == ChatTabType::DEBUG && config.getBoolValue("enableDebugLog")) { chatLogger->log("#Debug", msg); @@ -461,11 +463,11 @@ void ChatTab::saveToLogFile(const std::string &msg) const int ChatTab::getType() const { if (getCaption() == "General" || getCaption() == _("General")) - return TAB_INPUT; + return ChatTabType::INPUT; else if (getCaption() == "Debug" || getCaption() == _("Debug")) - return TAB_DEBUG; + return ChatTabType::DEBUG; else - return TAB_UNKNOWN; + return ChatTabType::UNKNOWN; } void ChatTab::addRow(std::string &line) diff --git a/src/gui/widgets/tabs/chattab.h b/src/gui/widgets/tabs/chattab.h index 84c00fdfc..da17f1501 100644 --- a/src/gui/widgets/tabs/chattab.h +++ b/src/gui/widgets/tabs/chattab.h @@ -38,20 +38,6 @@ class ScrollArea; class ChatTab : public Tab { public: - enum Type - { - TAB_UNKNOWN = 0, - TAB_INPUT, - TAB_WHISPER, - TAB_PARTY, - TAB_GUILD, - TAB_DEBUG, - TAB_TRADE, - TAB_BATTLE, - TAB_LANG, - TAB_GM - }; - /** * Constructor. */ diff --git a/src/gui/widgets/tabs/chattabtype.h b/src/gui/widgets/tabs/chattabtype.h new file mode 100644 index 000000000..802b33a43 --- /dev/null +++ b/src/gui/widgets/tabs/chattabtype.h @@ -0,0 +1,41 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GUI_WIDGETS_TABS_CHATTABTYPE_H +#define GUI_WIDGETS_TABS_CHATTABTYPE_H + +namespace ChatTabType +{ + enum Type + { + UNKNOWN = 0, + INPUT, + WHISPER, + PARTY, + GUILD, + DEBUG, + TRADE, + BATTLE, + LANG, + GM + }; +} // namespace ChatTabType + +#endif // GUI_WIDGETS_TABS_CHATTABTYPE_H diff --git a/src/gui/widgets/tabs/gmtab.h b/src/gui/widgets/tabs/gmtab.h index 0685c3808..ffe738523 100644 --- a/src/gui/widgets/tabs/gmtab.h +++ b/src/gui/widgets/tabs/gmtab.h @@ -22,6 +22,7 @@ #define GUI_WIDGETS_TABS_GMTAB_H #include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/chattabtype.h" /** * A tab for whispers from a single player. @@ -36,7 +37,7 @@ class GmTab final : public ChatTab ~GmTab(); int getType() const override final A_WARN_UNUSED - { return ChatTab::TAB_GM; } + { return ChatTabType::GM; } void saveToLogFile(const std::string &msg) const override final; diff --git a/src/gui/widgets/tabs/guildchattab.h b/src/gui/widgets/tabs/guildchattab.h index cfcf901ca..41c06636c 100644 --- a/src/gui/widgets/tabs/guildchattab.h +++ b/src/gui/widgets/tabs/guildchattab.h @@ -24,6 +24,7 @@ #define GUI_WIDGETS_TABS_GUILDCHATTAB_H #include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/chattabtype.h" /** * A tab for a guild chat channel. @@ -44,7 +45,7 @@ class GuildChatTab final : public ChatTab, void saveToLogFile(const std::string &msg) const override final; int getType() const override A_WARN_UNUSED - { return ChatTab::TAB_GUILD; } + { return ChatTabType::GUILD; } void playNewMessageSound() const override final; diff --git a/src/gui/widgets/tabs/langtab.h b/src/gui/widgets/tabs/langtab.h index e036e4dd8..49c9c68a0 100644 --- a/src/gui/widgets/tabs/langtab.h +++ b/src/gui/widgets/tabs/langtab.h @@ -22,6 +22,7 @@ #define GUI_WIDGETS_TABS_LANGTAB_H #include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/chattabtype.h" class LangTab final : public ChatTab { @@ -34,7 +35,7 @@ class LangTab final : public ChatTab ~LangTab(); int getType() const override final A_WARN_UNUSED - { return ChatTab::TAB_LANG; } + { return ChatTabType::LANG; } void saveToLogFile(const std::string &msg) const override final; }; diff --git a/src/gui/widgets/tabs/tradetab.h b/src/gui/widgets/tabs/tradetab.h index 07d95844e..9bcaa6275 100644 --- a/src/gui/widgets/tabs/tradetab.h +++ b/src/gui/widgets/tabs/tradetab.h @@ -24,6 +24,7 @@ #define GUI_WIDGETS_TABS_TRADETAB_H #include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/chattabtype.h" /** * A tab for a party chat channel. @@ -38,7 +39,7 @@ class TradeTab final : public ChatTab ~TradeTab(); int getType() const override final A_WARN_UNUSED - { return ChatTab::TAB_TRADE; } + { return ChatTabType::TRADE; } void saveToLogFile(const std::string &msg) const override final; diff --git a/src/gui/widgets/tabs/whispertab.h b/src/gui/widgets/tabs/whispertab.h index 84b55ae58..8a315a7c3 100644 --- a/src/gui/widgets/tabs/whispertab.h +++ b/src/gui/widgets/tabs/whispertab.h @@ -24,6 +24,7 @@ #define GUI_WIDGETS_TABS_WHISPERTAB_H #include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/chattabtype.h" /** * A tab for whispers from a single player. @@ -40,7 +41,7 @@ class WhisperTab final : public ChatTab const std::string &restrict args) override final; int getType() const override final A_WARN_UNUSED - { return ChatTab::TAB_WHISPER; } + { return ChatTabType::WHISPER; } void saveToLogFile(const std::string &msg) const override final; diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h index 931b53397..c3936f348 100644 --- a/src/net/ea/gui/guildtab.h +++ b/src/net/ea/gui/guildtab.h @@ -24,6 +24,7 @@ #define NET_EA_GUI_GUILDTAB_H #include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/chattabtype.h" namespace Ea { @@ -47,7 +48,7 @@ class GuildTab : public ChatTab, void saveToLogFile(const std::string &msg) const override final; int getType() const override final A_WARN_UNUSED - { return ChatTab::TAB_GUILD; } + { return ChatTabType::GUILD; } void playNewMessageSound() const override final; diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h index 6c61990dd..1a08d0954 100644 --- a/src/net/ea/gui/partytab.h +++ b/src/net/ea/gui/partytab.h @@ -24,6 +24,7 @@ #define NET_EA_GUI_PARTYTAB_H #include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/chattabtype.h" namespace Ea { @@ -45,7 +46,7 @@ class PartyTab : public ChatTab, const std::string &restrict args) override final; int getType() const override final A_WARN_UNUSED - { return ChatTab::TAB_PARTY; } + { return ChatTabType::PARTY; } void saveToLogFile(const std::string &msg) const override final; |