diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-18 16:17:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-18 16:17:08 +0300 |
commit | ea28a76cfbace0ccc8d25e523b410f2dea339423 (patch) | |
tree | c5582fe4d9b26dc381ef90ed7a155ea050514243 /src | |
parent | 8fdbbe936fc0bb99b0c3d851b7a5b522514ba2b9 (diff) | |
download | plus-ea28a76cfbace0ccc8d25e523b410f2dea339423.tar.gz plus-ea28a76cfbace0ccc8d25e523b410f2dea339423.tar.bz2 plus-ea28a76cfbace0ccc8d25e523b410f2dea339423.tar.xz plus-ea28a76cfbace0ccc8d25e523b410f2dea339423.zip |
add new chat commands.
/enablehighlight - enable sound hightlight in chat tab
/disablehighlight - disable sound hightlight in chat tab
Diffstat (limited to 'src')
-rw-r--r-- | src/commandhandler.cpp | 15 | ||||
-rw-r--r-- | src/commandhandler.h | 5 | ||||
-rw-r--r-- | src/commands.cpp | 20 | ||||
-rw-r--r-- | src/commands.h | 4 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 14 |
5 files changed, 49 insertions, 9 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 4675ddd22..fc7d6dff8 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -53,6 +53,14 @@ void CommandHandler::handleCommand(const std::string &command, ? command.size() : pos + 1); args = trim(args); + invokeCommand(type, args, tab, true); +} + +void CommandHandler::invokeCommand(const std::string &type, + const std::string &args, + ChatTab *const tab, + const bool warn) +{ const CommandsMapIter it = mCommands.find(type); if (it != mCommands.end()) { @@ -60,7 +68,10 @@ void CommandHandler::handleCommand(const std::string &command, } else if (!tab->handleCommand(type, args)) { - // TRANSLATORS: chat commands handling message - tab->chatLog(_("Unknown command.")); + if (warn) + { + // TRANSLATORS: chat commands handling message + tab->chatLog(_("Unknown command.")); + } } } diff --git a/src/commandhandler.h b/src/commandhandler.h index cd265beb5..58fe78bf5 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -61,6 +61,11 @@ class CommandHandler final void handleCommand(const std::string &command, ChatTab *const tab = localChatTab); + void invokeCommand(const std::string &type, + const std::string &args, + ChatTab *const tab, + const bool warn = false); + void handleCommands(const std::string &command, ChatTab *const tab = localChatTab); diff --git a/src/commands.cpp b/src/commands.cpp index ab2558e2c..e6d0e9eb6 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1144,6 +1144,26 @@ impHandler1(execute) execFile(name, name, params, ""); } +impHandler1(enableHighlight) +{ + if (tab) + { + tab->setAllowHighlight(true); + if (chatWindow) + chatWindow->saveState(); + } +} + +impHandler1(disableHighlight) +{ + if (tab) + { + tab->setAllowHighlight(false); + if (chatWindow) + chatWindow->saveState(); + } +} + impHandler0(testsdlfont) { #if defined USE_OPENGL && defined DEBUG_SDLFONT diff --git a/src/commands.h b/src/commands.h index bc45bf837..96423d748 100644 --- a/src/commands.h +++ b/src/commands.h @@ -114,6 +114,8 @@ namespace Commands decHandler(cacheInfo); decHandler(execute); decHandler(testsdlfont); + decHandler(enableHighlight); + decHandler(disableHighlight); void replaceVars(std::string &str); } // namespace Commands @@ -192,6 +194,8 @@ static const CommandInfo commands[] = {"open", &Commands::open}, {"execute", &Commands::execute}, {"testsdlfont", &Commands::testsdlfont}, + {"enablehighlight", &Commands::enableHighlight}, + {"disablehighlight", &Commands::disableHighlight}, {"hack", &Commands::hack} }; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 4aaa0cf01..53a8a11f7 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -23,6 +23,7 @@ #include "gui/popupmenu.h" #include "actorspritemanager.h" +#include "commandhandler.h" #include "dropshortcut.h" #include "game.h" #include "guild.h" @@ -1198,7 +1199,8 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "chat close" && mTab) { - mTab->handleCommand("close", ""); + if (commandHandler) + commandHandler->invokeCommand("close", "", mTab); } else if (link == "leave party" && mTab) { @@ -1316,15 +1318,13 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "enable highlight" && mTab) { - mTab->setAllowHighlight(true); - if (chatWindow) - chatWindow->saveState(); + if (commandHandler) + commandHandler->invokeCommand("enablehighlight", "", mTab); } else if (link == "disable highlight" && mTab) { - mTab->setAllowHighlight(false); - if (chatWindow) - chatWindow->saveState(); + if (commandHandler) + commandHandler->invokeCommand("disablehighlight", "", mTab); } else if (link == "dont remove name" && mTab) { |