summaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-23 13:09:30 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-23 13:09:30 +0300
commit07012a81f523b7f6bd095325ddd2675a3ce06d09 (patch)
tree839921e0f2b3143ef0f5dcdf4cfc6969e1e32154 /src/input
parent028638516b8a19edfe512309708012003e68b5c5 (diff)
downloadplus-07012a81f523b7f6bd095325ddd2675a3ce06d09.tar.gz
plus-07012a81f523b7f6bd095325ddd2675a3ce06d09.tar.bz2
plus-07012a81f523b7f6bd095325ddd2675a3ce06d09.tar.xz
plus-07012a81f523b7f6bd095325ddd2675a3ce06d09.zip
If chat command not found, try find it in input actions.
Diffstat (limited to 'src/input')
-rw-r--r--src/input/inputmanager.cpp23
-rw-r--r--src/input/inputmanager.h4
2 files changed, 25 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,
diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h
index 1635bf03c..ab8f3d2f0 100644
--- a/src/input/inputmanager.h
+++ b/src/input/inputmanager.h
@@ -118,6 +118,10 @@ class InputManager final
void executeAction(const int keyNum);
+ bool executeChatCommand(const std::string &cmd,
+ const std::string &args,
+ ChatTab *const tab);
+
protected:
void resetKey(const int i);