summaryrefslogtreecommitdiff
path: root/src/actions
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-09 00:29:58 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-09 00:29:58 +0300
commiteef58035c1848a8cffbcb17373b6afbe43be1440 (patch)
treeec8ff687c1c15c6b3f8448e596f51de066a5717b /src/actions
parent1f0070646425aeb23f01d769f5b1cf071d1d3d15 (diff)
downloadplus-eef58035c1848a8cffbcb17373b6afbe43be1440.tar.gz
plus-eef58035c1848a8cffbcb17373b6afbe43be1440.tar.bz2
plus-eef58035c1848a8cffbcb17373b6afbe43be1440.tar.xz
plus-eef58035c1848a8cffbcb17373b6afbe43be1440.zip
Add chat command for send any gui key.
New chat command: guikey.
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/chat.cpp37
-rw-r--r--src/actions/chat.h1
2 files changed, 38 insertions, 0 deletions
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp
index 6e6f3cae1..266f610b8 100644
--- a/src/actions/chat.cpp
+++ b/src/actions/chat.cpp
@@ -28,6 +28,8 @@
#include "being/localplayer.h"
+#include "gui/sdlinput.h"
+
#include "gui/windows/chatwindow.h"
#include "listeners/inputactionreplaylistener.h"
@@ -48,6 +50,7 @@
#include "utils/booleanoptions.h"
#include "utils/chatutils.h"
+#include "utils/parameters.h"
#include "utils/translation/podict.h"
@@ -716,4 +719,38 @@ impHandler(translate)
return true;
}
+impHandler0(sendGuiKey)
+{
+ if (!guiInput)
+ return false;
+
+ const std::string args = event.args;
+ if (args.empty())
+ return false;
+ StringVect pars;
+ if (!splitParameters(pars, args, " ,", '\"'))
+ return false;
+ const int sz = CAST_S32(pars.size());
+ if (sz < 1)
+ return false;
+
+ int keyValue = atoi(pars[0].c_str());
+ if (keyValue == 0 &&
+ pars[0].size() == 1)
+ {
+ keyValue = CAST_S32(pars[0][0]);
+ }
+ if (sz == 2)
+ {
+ const InputActionT actionId = inputManager.getActionByConfigField(
+ pars[1]);
+ guiInput->simulateKey(keyValue, actionId);
+ }
+ else
+ {
+ guiInput->simulateKey(keyValue, InputAction::NO_VALUE);
+ }
+ return true;
+}
+
} // namespace Actions
diff --git a/src/actions/chat.h b/src/actions/chat.h
index ba33806a3..3815e53e7 100644
--- a/src/actions/chat.h
+++ b/src/actions/chat.h
@@ -62,6 +62,7 @@ namespace Actions
decHandler(chatClipboard);
decHandler(guildNotice);
decHandler(translate);
+ decHandler(sendGuiKey);
} // namespace Actions
#undef decHandler