diff options
Diffstat (limited to 'src/input/inputmanager.cpp')
-rw-r--r-- | src/input/inputmanager.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 2cbd100e2..c74544432 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -157,8 +157,9 @@ void InputManager::retrieve() } } } - if (!inputActionData[i].chatCommand.empty()) - mChatMap[i] = i; + const std::string &cmd = inputActionData[i].chatCommand; + if (!cmd.empty()) + mChatMap[cmd] = i; } } @@ -728,6 +729,24 @@ void InputManager::executeAction(const int keyNum) func(evt); } +bool InputManager::executeChatCommand(const std::string &cmd, + const std::string &args, + ChatTab *const tab) +{ + const std::map<std::string, int>::const_iterator it = mChatMap.find(cmd); + if (it != mChatMap.end()) + { + ActionFuncPtr func = *(inputActionData[(*it).second].action); + if (func) + { + InputEvent evt(args, tab); + func(evt); + return true; + } + } + return false; +} + void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, KeyToIdMap &idMap, KeyTimeMap &keyTimeMap, |