diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-18 17:02:13 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-18 17:02:13 +0300 |
commit | dd828df46a661fbd0a24fbe540a4a585360be005 (patch) | |
tree | 7963e4739a4f6ace5d5c847edd4e679cc6c9bf87 /src/commandhandler.cpp | |
parent | ea28a76cfbace0ccc8d25e523b410f2dea339423 (diff) | |
download | manaverse-dd828df46a661fbd0a24fbe540a4a585360be005.tar.gz manaverse-dd828df46a661fbd0a24fbe540a4a585360be005.tar.bz2 manaverse-dd828df46a661fbd0a24fbe540a4a585360be005.tar.xz manaverse-dd828df46a661fbd0a24fbe540a4a585360be005.zip |
add named commands with enum.
use some named commands from popupmenu.
Diffstat (limited to 'src/commandhandler.cpp')
-rw-r--r-- | src/commandhandler.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index fc7d6dff8..a9b5672ee 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -34,7 +34,11 @@ CommandHandler::CommandHandler() : { const int sz = sizeof(commands) / sizeof(CommandInfo); for (int f = 0; f < sz; f ++) - mCommands[commands[f].name] = commands[f].func; + { + const std::string name = commands[f].name; + if (!name.empty()) + mCommands[name] = commands[f].func; + } } void CommandHandler::handleCommands(const std::string &command, @@ -75,3 +79,39 @@ void CommandHandler::invokeCommand(const std::string &type, } } } + +void CommandHandler::invokeCommand(const int type, + const bool warn) +{ + if (type < 0 || type >= END_COMMANDS) + return; + (commands[type].func)("", nullptr); +} + +void CommandHandler::invokeCommand(const int type, + ChatTab *const tab, + const bool warn) +{ + if (type < 0 || type >= END_COMMANDS) + return; + (commands[type].func)("", tab); +} + +void CommandHandler::invokeCommand(const int type, + const std::string &args, + const bool warn) +{ + if (type < 0 || type >= END_COMMANDS) + return; + (commands[type].func)(args, nullptr); +} + +void CommandHandler::invokeCommand(const int type, + const std::string &args, + ChatTab *const tab, + const bool warn) +{ + if (type < 0 || type >= END_COMMANDS) + return; + (commands[type].func)(args, tab); +} |