diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/game.cpp | 6 | ||||
-rw-r--r-- | src/gui/theme.cpp | 6 | ||||
-rw-r--r-- | src/gui/theme.h | 6 | ||||
-rw-r--r-- | src/gui/widgets/chattab.h | 3 | ||||
-rw-r--r-- | src/localplayer.cpp | 6 | ||||
-rw-r--r-- | src/net/ea/chathandler.cpp | 20 |
8 files changed, 48 insertions, 3 deletions
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); + } } } |