diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-05-09 00:29:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-05-09 00:29:58 +0300 |
commit | eef58035c1848a8cffbcb17373b6afbe43be1440 (patch) | |
tree | ec8ff687c1c15c6b3f8448e596f51de066a5717b /src/actions/chat.cpp | |
parent | 1f0070646425aeb23f01d769f5b1cf071d1d3d15 (diff) | |
download | manaverse-eef58035c1848a8cffbcb17373b6afbe43be1440.tar.gz manaverse-eef58035c1848a8cffbcb17373b6afbe43be1440.tar.bz2 manaverse-eef58035c1848a8cffbcb17373b6afbe43be1440.tar.xz manaverse-eef58035c1848a8cffbcb17373b6afbe43be1440.zip |
Add chat command for send any gui key.
New chat command: guikey.
Diffstat (limited to 'src/actions/chat.cpp')
-rw-r--r-- | src/actions/chat.cpp | 37 |
1 files changed, 37 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 |