From e63b10c3a63d93b9a6dfa144624fea8610d7768c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 19 Feb 2013 00:30:24 +0300 Subject: Add support for GM tab. This tab visible all messages from @wgm chat command and local messages in this tab. --- data/graphics/gui/colors.xml | 3 +++ data/themes/blacknblack/colors.xml | 3 +++ data/themes/blackwood/colors.xml | 3 +++ data/themes/enchilado/colors.xml | 3 +++ data/themes/jewelry/colors.xml | 9 +++++++++ data/themes/mana/colors.xml | 3 +++ data/themes/pink/colors.xml | 3 +++ data/themes/unity/colors.xml | 3 +++ data/themes/wood/colors.xml | 3 +++ src/CMakeLists.txt | 2 ++ src/Makefile.am | 2 ++ src/game.cpp | 6 ++++++ src/gui/theme.cpp | 6 ++++++ src/gui/theme.h | 6 ++++++ src/gui/widgets/chattab.h | 3 ++- src/localplayer.cpp | 6 +++++- src/net/ea/chathandler.cpp | 20 +++++++++++++++++++- 17 files changed, 81 insertions(+), 3 deletions(-) diff --git a/data/graphics/gui/colors.xml b/data/graphics/gui/colors.xml index 1efa2a6a4..95f1e66a3 100644 --- a/data/graphics/gui/colors.xml +++ b/data/graphics/gui/colors.xml @@ -30,14 +30,17 @@ + + + diff --git a/data/themes/blacknblack/colors.xml b/data/themes/blacknblack/colors.xml index cc41030bb..d31f1f519 100644 --- a/data/themes/blacknblack/colors.xml +++ b/data/themes/blacknblack/colors.xml @@ -30,14 +30,17 @@ + + + diff --git a/data/themes/blackwood/colors.xml b/data/themes/blackwood/colors.xml index 28bbd9f4f..b56f7e021 100644 --- a/data/themes/blackwood/colors.xml +++ b/data/themes/blackwood/colors.xml @@ -30,14 +30,17 @@ + + + diff --git a/data/themes/enchilado/colors.xml b/data/themes/enchilado/colors.xml index a24e3516b..60b701306 100644 --- a/data/themes/enchilado/colors.xml +++ b/data/themes/enchilado/colors.xml @@ -30,14 +30,17 @@ + + + diff --git a/data/themes/jewelry/colors.xml b/data/themes/jewelry/colors.xml index 444ad8c96..d8a36b990 100644 --- a/data/themes/jewelry/colors.xml +++ b/data/themes/jewelry/colors.xml @@ -31,14 +31,17 @@ + + + @@ -123,14 +126,17 @@ + + + @@ -216,14 +222,17 @@ + + + diff --git a/data/themes/mana/colors.xml b/data/themes/mana/colors.xml index c15ca9141..520c874c5 100644 --- a/data/themes/mana/colors.xml +++ b/data/themes/mana/colors.xml @@ -30,14 +30,17 @@ + + + diff --git a/data/themes/pink/colors.xml b/data/themes/pink/colors.xml index 37823138f..33c226654 100644 --- a/data/themes/pink/colors.xml +++ b/data/themes/pink/colors.xml @@ -30,14 +30,17 @@ + + + diff --git a/data/themes/unity/colors.xml b/data/themes/unity/colors.xml index eab87aca2..c7398e045 100644 --- a/data/themes/unity/colors.xml +++ b/data/themes/unity/colors.xml @@ -29,14 +29,17 @@ + + + diff --git a/data/themes/wood/colors.xml b/data/themes/wood/colors.xml index 3a7a0ea4d..3517e79e1 100644 --- a/data/themes/wood/colors.xml +++ b/data/themes/wood/colors.xml @@ -30,14 +30,17 @@ + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 349a0a12c..dc8c83047 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,6 +130,8 @@ SET(SRCS gui/widgets/extendednamesmodel.h gui/widgets/flowcontainer.cpp gui/widgets/flowcontainer.h + gui/widgets/gmtab.cpp + gui/widgets/gmtab.h gui/widgets/guildchattab.cpp gui/widgets/guildchattab.h gui/widgets/horizontcontainer.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 6a70ab4d5..63e3247f6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -132,6 +132,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/extendednamesmodel.h \ gui/widgets/flowcontainer.cpp \ gui/widgets/flowcontainer.h \ + gui/widgets/gmtab.cpp \ + gui/widgets/gmtab.h \ gui/widgets/guildchattab.cpp \ gui/widgets/guildchattab.h \ gui/widgets/guitable.cpp \ diff --git a/src/game.cpp b/src/game.cpp index d5cebe6a1..798d6010b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -73,6 +73,7 @@ #include "gui/widgets/battletab.h" #include "gui/widgets/dropshortcutcontainer.h" #include "gui/widgets/emoteshortcutcontainer.h" +#include "gui/widgets/gmtab.h" #include "gui/widgets/itemshortcutcontainer.h" #include "gui/widgets/spellshortcutcontainer.h" #include "gui/widgets/tradetab.h" @@ -153,6 +154,7 @@ ChatTab *localChatTab = nullptr; ChatTab *debugChatTab = nullptr; TradeTab *tradeChatTab = nullptr; BattleTab *battleChatTab = nullptr; +GmTab *gmChatTab = nullptr; const unsigned adjustDelay = 10; @@ -278,6 +280,9 @@ static void createGuiWindows() battleChatTab = nullptr; } + if (player_node && !gmChatTab && player_node->getGMLevel() > 0) + gmChatTab = new GmTab(chatWindow); + if (config.getBoolValue("logToChat")) logger->setChatWindow(chatWindow); @@ -316,6 +321,7 @@ static void destroyGuiWindows() del_0(debugChatTab) del_0(tradeChatTab) del_0(battleChatTab) + del_0(gmChatTab); logger->log("start deleting"); del_0(chatWindow) logger->log("end deleting"); diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index acd188031..202bfed20 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -757,6 +757,8 @@ static int readColorType(const std::string &type) "GUILD_CHAT_TAB_OUTLINE", "GUILD_SOCIAL_TAB", "GUILD_SOCIAL_TAB_OUTLINE", + "GM_CHAT_TAB", + "GM_CHAT_TAB_OUTLINE", "PARTY_CHAT_TAB_HIGHLIGHTED", "PARTY_CHAT_TAB_HIGHLIGHTED_OUTLINE", "PARTY_SOCIAL_TAB_HIGHLIGHTED", @@ -765,6 +767,8 @@ static int readColorType(const std::string &type) "GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE", "GUILD_SOCIAL_TAB_HIGHLIGHTED", "GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE", + "GM_CHAT_TAB_HIGHLIGHTED", + "GM_CHAT_TAB_HIGHLIGHTED_OUTLINE", "PARTY_CHAT_TAB_SELECTED", "PARTY_CHAT_TAB_SELECTED_OUTLINE", "PARTY_SOCIAL_TAB_SELECTED", @@ -773,6 +777,8 @@ static int readColorType(const std::string &type) "GUILD_CHAT_TAB_SELECTED_OUTLINE", "GUILD_SOCIAL_TAB_SELECTED", "GUILD_SOCIAL_TAB_SELECTED_OUTLINE", + "GM_CHAT_TAB_SELECTED", + "GM_CHAT_TAB_SELECTED_OUTLINE", "BACKGROUND", "BACKGROUND_GRAY", "SCROLLBAR_GRAY", diff --git a/src/gui/theme.h b/src/gui/theme.h index 213799788..223716057 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -228,6 +228,8 @@ class Theme final : public Palette, public ConfigListener GUILD_CHAT_TAB_OUTLINE, GUILD_SOCIAL_TAB, GUILD_SOCIAL_TAB_OUTLINE, + GM_CHAT_TAB, + GM_CHAT_TAB_OUTLINE, PARTY_CHAT_TAB_HIGHLIGHTED, PARTY_CHAT_TAB_HIGHLIGHTED_OUTLINE, PARTY_SOCIAL_TAB_HIGHLIGHTED, @@ -236,6 +238,8 @@ class Theme final : public Palette, public ConfigListener GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE, GUILD_SOCIAL_TAB_HIGHLIGHTED, GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE, + GM_CHAT_TAB_HIGHLIGHTED, + GM_CHAT_TAB_HIGHLIGHTED_OUTLINE, PARTY_CHAT_TAB_SELECTED, PARTY_CHAT_TAB_SELECTED_OUTLINE, PARTY_SOCIAL_TAB_SELECTED, @@ -244,6 +248,8 @@ class Theme final : public Palette, public ConfigListener GUILD_CHAT_TAB_SELECTED_OUTLINE, GUILD_SOCIAL_TAB_SELECTED, GUILD_SOCIAL_TAB_SELECTED_OUTLINE, + GM_CHAT_TAB_SELECTED, + GM_CHAT_TAB_SELECTED_OUTLINE, BACKGROUND, BACKGROUND_GRAY, SCROLLBAR_GRAY, diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 0b3469458..24afffc0f 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -47,7 +47,8 @@ class ChatTab : public Tab TAB_GUILD, TAB_DEBUG, TAB_TRADE, - TAB_BATTLE + TAB_BATTLE, + TAB_GM }; /** diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 99ef5a242..43c15428a 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -51,6 +51,7 @@ #include "gui/socialwindow.h" #include "gui/viewport.h" +#include "gui/widgets/gmtab.h" #include "gui/widgets/whispertab.h" #include "net/beinghandler.h" @@ -392,11 +393,14 @@ void LocalPlayer::setGMLevel(const int level) { setGM(true); if (chatWindow) + { chatWindow->loadGMCommands(); + if (!gmChatTab) + gmChatTab = new GmTab(chatWindow); + } } } - Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const { // Compute where the next tile will be set. diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index d133178b3..61ae2eee7 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -32,6 +32,7 @@ #include "gui/shopwindow.h" #include "gui/widgets/chattab.h" +#include "gui/widgets/gmtab.h" #include "utils/gettext.h" @@ -246,7 +247,24 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) } else if (localChatTab) { - localChatTab->chatLog(chatMsg, BY_SERVER); + if (gmChatTab && strStartWith(chatMsg, "[GM] ")) + { + chatMsg = chatMsg.substr(5); + const size_t pos = chatMsg.find(": ", 0); + if (pos == std::string::npos) + { + gmChatTab->chatLog(chatMsg); + } + else + { + gmChatTab->chatLog(chatMsg.substr(0, pos), + chatMsg.substr(pos + 2)); + } + } + else + { + localChatTab->chatLog(chatMsg, BY_SERVER); + } } } -- cgit v1.2.3-60-g2f50