summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-23 21:48:59 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-23 21:48:59 +0300
commit475aa157df7400ce40ef9a5cc4cb441291d45df9 (patch)
tree6990e349c853115820caaf1f34e96c35a5186c8d
parent2efe6bad2044f12d842466e149f512aba9b7fc86 (diff)
downloadmv-475aa157df7400ce40ef9a5cc4cb441291d45df9.tar.gz
mv-475aa157df7400ce40ef9a5cc4cb441291d45df9.tar.bz2
mv-475aa157df7400ce40ef9a5cc4cb441291d45df9.tar.xz
mv-475aa157df7400ce40ef9a5cc4cb441291d45df9.zip
Move chat command /whisper into actions.
-rw-r--r--src/actions/chat.cpp57
-rw-r--r--src/actions/chat.h1
-rw-r--r--src/commands.cpp54
-rw-r--r--src/commands.h7
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h11
6 files changed, 70 insertions, 61 deletions
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp
index d69895af3..08b3e0014 100644
--- a/src/actions/chat.cpp
+++ b/src/actions/chat.cpp
@@ -68,6 +68,9 @@
#include "gui/widgets/tabs/chattab.h"
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
#include "debug.h"
extern ShortcutWindow *spellShortcutWindow;
@@ -154,4 +157,58 @@ impHandler0(scrollChatDown)
return false;
}
+impHandler(msg)
+{
+ std::string recvnick;
+ std::string msg;
+
+ if (event.args.substr(0, 1) == "\"")
+ {
+ const size_t pos = event.args.find('"', 1);
+ if (pos != std::string::npos)
+ {
+ recvnick = event.args.substr(1, pos - 1);
+ if (pos + 2 < event.args.length())
+ msg = event.args.substr(pos + 2, event.args.length());
+ }
+ }
+ else
+ {
+ const size_t pos = event.args.find(" ");
+ if (pos != std::string::npos)
+ {
+ recvnick = event.args.substr(0, pos);
+ if (pos + 1 < event.args.length())
+ msg = event.args.substr(pos + 1, event.args.length());
+ }
+ else
+ {
+ recvnick = std::string(event.args);
+ msg.clear();
+ }
+ }
+
+ trim(msg);
+
+ if (msg.length() > 0)
+ {
+ std::string playerName = localPlayer->getName();
+ std::string tempNick = recvnick;
+
+ toLower(playerName);
+ toLower(tempNick);
+
+ if (tempNick.compare(playerName) == 0 || event.args.empty())
+ return true;
+
+ chatWindow->addWhisper(recvnick, msg, ChatMsgType::BY_PLAYER);
+ }
+ else
+ {
+ // TRANSLATORS: whisper send
+ event.tab->chatLog(_("Cannot send empty whispers!"), ChatMsgType::BY_SERVER);
+ }
+ return true;
+}
+
} // namespace Actions
diff --git a/src/actions/chat.h b/src/actions/chat.h
index 8d0003e73..b653e6efb 100644
--- a/src/actions/chat.h
+++ b/src/actions/chat.h
@@ -35,6 +35,7 @@ namespace Actions
decHandler(ignoreAllWhispers);
decHandler(scrollChatUp);
decHandler(scrollChatDown);
+ decHandler(msg);
} // namespace Actions
#undef decHandler
diff --git a/src/commands.cpp b/src/commands.cpp
index 270a781ab..c80c2cf3f 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -251,60 +251,6 @@ static void outStringNormal(ChatTab *const tab,
}
}
-impHandler(msg)
-{
- std::string recvnick;
- std::string msg;
-
- if (event.args.substr(0, 1) == "\"")
- {
- const size_t pos = event.args.find('"', 1);
- if (pos != std::string::npos)
- {
- recvnick = event.args.substr(1, pos - 1);
- if (pos + 2 < event.args.length())
- msg = event.args.substr(pos + 2, event.args.length());
- }
- }
- else
- {
- const size_t pos = event.args.find(" ");
- if (pos != std::string::npos)
- {
- recvnick = event.args.substr(0, pos);
- if (pos + 1 < event.args.length())
- msg = event.args.substr(pos + 1, event.args.length());
- }
- else
- {
- recvnick = std::string(event.args);
- msg.clear();
- }
- }
-
- trim(msg);
-
- if (msg.length() > 0)
- {
- std::string playerName = localPlayer->getName();
- std::string tempNick = recvnick;
-
- toLower(playerName);
- toLower(tempNick);
-
- if (tempNick.compare(playerName) == 0 || event.args.empty())
- return true;
-
- chatWindow->addWhisper(recvnick, msg, ChatMsgType::BY_PLAYER);
- }
- else
- {
- // TRANSLATORS: whisper send
- event.tab->chatLog(_("Cannot send empty whispers!"), ChatMsgType::BY_SERVER);
- }
- return true;
-}
-
impHandler(query)
{
if (chatWindow)
diff --git a/src/commands.h b/src/commands.h
index 5844cac08..c5731e459 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -51,7 +51,6 @@ struct CommandInfo final
namespace Commands
{
- decHandler(msg);
decHandler(query);
decHandler(clear);
decHandler(cleanGraphics);
@@ -137,8 +136,7 @@ namespace Commands
enum
{
- COMMAND_MSG = 0,
- COMMAND_WHISPER,
+ COMMAND_WHISPER = 0,
COMMAND_W,
COMMAND_QUERY,
COMMAND_Q,
@@ -227,9 +225,6 @@ enum
static const CommandInfo commands[] =
{
- {"msg", Commands::msg, -1, true},
- {"whisper", Commands::msg, -1, true},
- {"w", &Commands::msg, -1, true},
{"query", Commands::query, -1, true},
{"q", &Commands::query, -1, true},
{"ignore", &Commands::ignore, -1, true},
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index 8d4051fc0..852529934 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -347,6 +347,7 @@ namespace InputAction
IPC_TOGGLE,
WHERE,
WHO,
+ WHISPER,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index b7a7fcff7..165457b27 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -2892,7 +2892,16 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
InputAction::NO_VALUE, 50,
InputCondition::INGAME,
"who",
- false}
+ false},
+ {"keyWhisper",
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ Input::GRP_DEFAULT,
+ &Actions::msg,
+ InputAction::NO_VALUE, 50,
+ InputCondition::INGAME,
+ "w|whisper|msg",
+ true}
};
#endif // INPUT_INPUTACTIONMAP_H