summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-25 13:26:14 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-25 13:26:14 +0300
commita7c2351c708c38bf020e8e1250b6a78cb2b6f89e (patch)
treebe67051942049a004b2cfaa0535931aa5d4f169b
parent4bb530a447cc08fbe176cface478898e0b35f5d1 (diff)
downloadplus-a7c2351c708c38bf020e8e1250b6a78cb2b6f89e.tar.gz
plus-a7c2351c708c38bf020e8e1250b6a78cb2b6f89e.tar.bz2
plus-a7c2351c708c38bf020e8e1250b6a78cb2b6f89e.tar.xz
plus-a7c2351c708c38bf020e8e1250b6a78cb2b6f89e.zip
Move chat command /me into actions.
-rw-r--r--src/actions/chat.cpp53
-rw-r--r--src/actions/chat.h1
-rw-r--r--src/commands.cpp6
-rw-r--r--src/commands.h5
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h9
6 files changed, 65 insertions, 10 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
diff --git a/src/actions/chat.h b/src/actions/chat.h
index c575827fd..78a3743e6 100644
--- a/src/actions/chat.h
+++ b/src/actions/chat.h
@@ -41,6 +41,7 @@ namespace Actions
decHandler(createParty);
decHandler(createGuild);
decHandler(party);
+ decHandler(me);
} // namespace Actions
#undef decHandler
diff --git a/src/commands.cpp b/src/commands.cpp
index f709e4a91..41c828840 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -251,12 +251,6 @@ static void outStringNormal(ChatTab *const tab,
}
}
-impHandler(me)
-{
- outString(event.tab, strprintf("*%s*", event.args.c_str()), event.args);
- return true;
-}
-
impHandler(toggle)
{
if (event.args.empty())
diff --git a/src/commands.h b/src/commands.h
index c448ca4d3..89f3f52fe 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -51,7 +51,6 @@ struct CommandInfo final
namespace Commands
{
- decHandler(me);
decHandler(toggle);
decHandler(present);
decHandler(quit);
@@ -121,8 +120,7 @@ namespace Commands
enum
{
- COMMAND_ME = 0,
- COMMAND_TOGGLE,
+ COMMAND_TOGGLE = 0,
COMMAND_PRESENT,
COMMAND_QUIT,
COMMAND_ALL,
@@ -191,7 +189,6 @@ enum
static const CommandInfo commands[] =
{
- {"me", &Commands::me, -1, true},
{"toggle", &Commands::toggle, -1, false},
{"present", &Commands::present, -1, false},
{"quit", &Commands::quit, -1, false},
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index 47414e0db..2eb05dac6 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -363,6 +363,7 @@ namespace InputAction
CREATE_PARTY,
CREATE_GUILD,
PARTY,
+ ME,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index d01e870fb..368518afc 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -3036,6 +3036,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
InputAction::NO_VALUE, 50,
InputCondition::INGAME,
"party",
+ true},
+ {"keyMe",
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ Input::GRP_DEFAULT,
+ &Actions::me,
+ InputAction::NO_VALUE, 50,
+ InputCondition::INGAME,
+ "me",
true}
};