summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-09-06 00:20:01 +0300
committerAndrei Karas <akaras@inbox.ru>2013-09-06 01:02:51 +0300
commiteb6a0f8af34d0f8de808d474381c232716a7534d (patch)
tree01849b726376d9ebe58a13d99a09dc31a29eaf1e /src
parent5413a9e7c761dc80cf33dbee8593b8721c1539b6 (diff)
downloadplus-eb6a0f8af34d0f8de808d474381c232716a7534d.tar.gz
plus-eb6a0f8af34d0f8de808d474381c232716a7534d.tar.bz2
plus-eb6a0f8af34d0f8de808d474381c232716a7534d.tar.xz
plus-eb6a0f8af34d0f8de808d474381c232716a7534d.zip
add globals filter.
It can move some global messages into debug window. This mean it prevent from spam in chat message and spam sounds. By default filter configured to ignore globals from Sagatha.
Diffstat (limited to 'src')
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/chatwindow.cpp25
-rw-r--r--src/gui/chatwindow.h5
-rw-r--r--src/gui/setup_chat.cpp4
-rw-r--r--src/net/ea/chathandler.cpp3
5 files changed, 37 insertions, 1 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 06e67d6ed..4c8183f39 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -299,6 +299,7 @@ DefaultsData* getConfigDefaults()
#endif
AddDEF("logInput", false);
AddDEF("highlightWords", "");
+ AddDEF("globalsFilter", "Sagatha");
AddDEF("selfMouseHeal", true);
AddDEF("serverslistupdate", "");
AddDEF("fadeoutmusic", true);
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 1065501b7..f5618a279 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -215,6 +215,7 @@ ChatWindow::ChatWindow():
mChatHistoryIndex(0),
mAwayLog(),
mHighlights(),
+ mGlobalsFilter(),
mGMLoaded(false),
mHaveMouse(false),
mAutoHide(config.getBoolValue("autohideChat")),
@@ -291,9 +292,11 @@ ChatWindow::ChatWindow():
initTradeFilter();
loadCustomList();
parseHighlights();
+ parseGlobalsFilter();
config.addListener("autohideChat", this);
config.addListener("showBattleEvents", this);
+ config.addListener("globalsFilter", this);
enableVisibleSound(true);
}
@@ -1683,6 +1686,18 @@ void ChatWindow::parseHighlights()
mHighlights.push_back(player_node->getName());
}
+void ChatWindow::parseGlobalsFilter()
+{
+ mGlobalsFilter.clear();
+ if (!player_node)
+ return;
+
+ splitToStringVector(mGlobalsFilter, config.getStringValue(
+ "globalsFilter"), ',');
+
+ mHighlights.push_back(player_node->getName());
+}
+
bool ChatWindow::findHighlight(const std::string &str)
{
return findI(str, mHighlights) != std::string::npos;
@@ -1708,6 +1723,8 @@ void ChatWindow::optionChanged(const std::string &name)
mAutoHide = config.getBoolValue("autohideChat");
else if (name == "showBattleEvents")
mShowBattleEvents = config.getBoolValue("showBattleEvents");
+ else if (name == "globalsFilter")
+ parseGlobalsFilter();
}
void ChatWindow::mouseMoved(gcn::MouseEvent &event)
@@ -1768,3 +1785,11 @@ void ChatWindow::logicChildren()
BLOCK_END("ChatWindow::logicChildren")
}
#endif
+
+void ChatWindow::addGlobalMessage(const std::string &line)
+{
+ if (debugChatTab && findI(line, mGlobalsFilter) != std::string::npos)
+ debugChatTab->chatLog(line, BY_OTHER);
+ else
+ localChatTab->chatLog(line, BY_GM);
+}
diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h
index 67f87be1a..80b59b8d7 100644
--- a/src/gui/chatwindow.h
+++ b/src/gui/chatwindow.h
@@ -273,6 +273,8 @@ class ChatWindow final : public Window,
void parseHighlights();
+ void parseGlobalsFilter();
+
bool findHighlight(const std::string &str) A_WARN_UNUSED;
void copyToClipboard(const int x, const int y) const;
@@ -293,6 +295,8 @@ class ChatWindow final : public Window,
void widgetResized(const gcn::Event &event) override;
+ void addGlobalMessage(const std::string &line);
+
#ifdef USE_PROFILER
void logicChildren();
#endif
@@ -367,6 +371,7 @@ class ChatWindow final : public Window,
unsigned int mChatHistoryIndex;
std::list<std::string> mAwayLog;
StringVect mHighlights;
+ StringVect mGlobalsFilter;
bool mGMLoaded;
bool mHaveMouse;
bool mAutoHide;
diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp
index 91a9dd859..3a81119ba 100644
--- a/src/gui/setup_chat.cpp
+++ b/src/gui/setup_chat.cpp
@@ -186,6 +186,10 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) :
"highlightWords", this, "highlightWordsEvent");
// TRANSLATORS: settings option
+ new SetupItemTextField(_("Globals ignore names (separated by comma)"), "",
+ "globalsFilter", this, "globalsFilterEvent");
+
+ // TRANSLATORS: settings option
new SetupItemCheckBox(_("Show MVP messages"), "",
"showMVP", this, "showMVPEvent");
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index c8259bc91..a7879f6fc 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -356,7 +356,8 @@ void ChatHandler::processChat(Net::MessageIn &msg, const bool normalChat,
}
else if (localChatTab)
{
- localChatTab->chatLog(chatMsg, BY_GM);
+ if (chatWindow)
+ chatWindow->addGlobalMessage(chatMsg);
}
BLOCK_END("ChatHandler::processChat")
}