diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-08-25 13:26:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-08-25 13:26:14 +0300 |
commit | a7c2351c708c38bf020e8e1250b6a78cb2b6f89e (patch) | |
tree | be67051942049a004b2cfaa0535931aa5d4f169b /src/actions/chat.cpp | |
parent | 4bb530a447cc08fbe176cface478898e0b35f5d1 (diff) | |
download | mv-a7c2351c708c38bf020e8e1250b6a78cb2b6f89e.tar.gz mv-a7c2351c708c38bf020e8e1250b6a78cb2b6f89e.tar.bz2 mv-a7c2351c708c38bf020e8e1250b6a78cb2b6f89e.tar.xz mv-a7c2351c708c38bf020e8e1250b6a78cb2b6f89e.zip |
Move chat command /me into actions.
Diffstat (limited to 'src/actions/chat.cpp')
-rw-r--r-- | src/actions/chat.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index be6c88bbe..4396d438a 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -24,6 +24,7 @@ #include "dropshortcut.h" #include "emoteshortcut.h" #include "game.h" +#include "guildmanager.h" #include "itemshortcut.h" #include "soundmanager.h" @@ -34,6 +35,7 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" +#include "gui/chatconsts.h" #include "gui/dialogsmanager.h" #include "gui/gui.h" #include "gui/popupmanager.h" @@ -67,7 +69,9 @@ #include "gui/windows/updaterwindow.h" #include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/chattabtype.h" +#include "net/chathandler.h" #include "net/guildhandler.h" #include "net/net.h" #include "net/partyhandler.h" @@ -85,6 +89,49 @@ extern unsigned int tmwServerVersion; namespace Actions { +static void outString(const ChatTab *const tab, + const std::string &str, + const std::string &def) +{ + if (!tab) + { + Net::getChatHandler()->me(def, GENERAL_CHANNEL); + return; + } + + switch (tab->getType()) + { + case ChatTabType::PARTY: + { + Net::getPartyHandler()->chat(str); + break; + } + case ChatTabType::GUILD: + { + if (!localPlayer) + return; + const Guild *const guild = localPlayer->getGuild(); + if (guild) + { + if (guild->getServerGuild()) + { + if (tmwServerVersion > 0) + return; + Net::getGuildHandler()->chat(guild->getId(), str); + } + else if (guildManager) + { + guildManager->chat(str); + } + } + break; + } + default: + Net::getChatHandler()->me(def, GENERAL_CHANNEL); + break; + } +} + impHandler0(toggleChat) { return chatWindow ? chatWindow->requestChatFocus() : false; @@ -298,4 +345,10 @@ impHandler(party) return true; } +impHandler(me) +{ + outString(event.tab, strprintf("*%s*", event.args.c_str()), event.args); + return true; +} + } // namespace Actions |