From fbf45af162f9a2eecd3c27c8729bd9c811dbe793 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 Aug 2014 15:14:59 +0300 Subject: Move chat command /enablehightlight into actions. --- src/input/inputaction.h | 1 + src/input/inputactionmap.h | 11 ++++++++++- src/input/inputmanager.cpp | 16 ++++++++++++++++ src/input/inputmanager.h | 4 ++++ 4 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src/input') diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 48508b0fb..09f753117 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -408,6 +408,7 @@ namespace InputAction OPEN_URL, EXECUTE, TEST_SDL_FONT, + ENABLE_HIGHLIGHT, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index e2d123b73..4a7f76c6b 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -3449,7 +3449,16 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { #else "", #endif - false} + false}, + {"keyEnableHightlight", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::enableHighlight, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "enablehighlight", + true} }; #endif // INPUT_INPUTACTIONMAP_H diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 099e2b7fb..3a7f1be9c 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -752,6 +752,22 @@ bool InputManager::executeChatCommand(const std::string &cmd, return false; } +bool InputManager::executeChatCommand(const int keyNum, + const std::string &args, + ChatTab *const tab) +{ + if (keyNum < 0 || keyNum >= InputAction::TOTAL) + return false; + ActionFuncPtr func = *(inputActionData[keyNum].action); + if (func) + { + InputEvent evt(args, tab, mMask); + func(evt); + return true; + } + return false; +} + void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, KeyToIdMap &idMap, KeyTimeMap &keyTimeMap, diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h index 6bb4e65a2..b91af8882 100644 --- a/src/input/inputmanager.h +++ b/src/input/inputmanager.h @@ -123,6 +123,10 @@ class InputManager final const std::string &args, ChatTab *const tab); + bool executeChatCommand(const int keyNum, + const std::string &args, + ChatTab *const tab); + void addChatCommands(std::list &arr); protected: -- cgit v1.2.3-70-g09d2