summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/perserver/default/chatcommands.txt2
-rw-r--r--src/commandhandler.cpp15
-rw-r--r--src/commandhandler.h5
-rw-r--r--src/commands.cpp20
-rw-r--r--src/commands.h4
-rw-r--r--src/gui/popupmenu.cpp14
6 files changed, 51 insertions, 9 deletions
diff --git a/data/perserver/default/chatcommands.txt b/data/perserver/default/chatcommands.txt
index e33134e6a..6fed60596 100644
--- a/data/perserver/default/chatcommands.txt
+++ b/data/perserver/default/chatcommands.txt
@@ -79,3 +79,5 @@
/setdrop
/url
/open
+/enablehighlight
+/disablehighlight
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)
{