From eb6a0f8af34d0f8de808d474381c232716a7534d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 6 Sep 2013 00:20:01 +0300 Subject: 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. --- src/gui/chatwindow.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/gui/chatwindow.cpp') 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); +} -- cgit v1.2.3-60-g2f50