From eef58035c1848a8cffbcb17373b6afbe43be1440 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 9 May 2017 00:29:58 +0300 Subject: Add chat command for send any gui key. New chat command: guikey. --- src/actions/chat.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/actions/chat.cpp') 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 -- cgit v1.2.3-60-g2f50