From 0384e13f0faf26e4b2716c3a16d2518bb23fba42 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 22 Mar 2013 13:43:19 +0300 Subject: Show channel messages in language tab. --- src/gui/chatwindow.cpp | 25 +++++++++++++++++++------ src/gui/chatwindow.h | 7 ++++--- src/gui/widgets/chattab.h | 2 +- src/gui/widgets/langtab.cpp | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) (limited to 'src/gui') diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 9d8739ddb..074ce2b81 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -45,6 +45,7 @@ #include "gui/widgets/battletab.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/itemlinkhandler.h" +#include "gui/widgets/langtab.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/textfield.h" @@ -1422,18 +1423,23 @@ std::string ChatWindow::autoCompleteHistory(std::string partName) } void ChatWindow::resortChatLog(std::string line, Own own, + const std::string &channel, const bool ignoreRecord, const bool tryRemoveColors) { if (own == -1) own = BY_SERVER; + std::string prefix; + if (!channel.empty()) + prefix = std::string("##3").append(channel).append("##0"); + if (tradeChatTab) { if (findI(line, mTradeFilter) != std::string::npos) { -// logger->log("trade: " + line); - tradeChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors); + tradeChatTab->chatLog(prefix + line, own, + ignoreRecord, tryRemoveColors); return; } @@ -1447,7 +1453,7 @@ void ChatWindow::resortChatLog(std::string line, Own own, if (line.find(": \302\202\302") != std::string::npos) return; line = line.erase(idx + 2, 2); - tradeChatTab->chatLog(line, own, ignoreRecord, + tradeChatTab->chatLog(prefix + line, own, ignoreRecord, tryRemoveColors); return; } @@ -1464,8 +1470,8 @@ void ChatWindow::resortChatLog(std::string line, Own own, { if (line.find("http", idx1) != idx1 + 2) { - tradeChatTab->chatLog(line, own, ignoreRecord, - tryRemoveColors); + tradeChatTab->chatLog(prefix + line, own, + ignoreRecord, tryRemoveColors); return; } } @@ -1473,8 +1479,15 @@ void ChatWindow::resortChatLog(std::string line, Own own, } } - if (localChatTab) + if (langChatTab && !channel.empty() + && langChatTab->getChannelName() == channel) + { + langChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors); + } + else if (localChatTab && channel.empty()) + { localChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors); + } } void ChatWindow::battleChatLog(std::string line, Own own, diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index 1e9274466..7e2426467 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -235,9 +235,10 @@ class ChatWindow final : public Window, void ignoreAllWhispers(); - void resortChatLog(std::string line, Own own = BY_UNKNOWN, - const bool ignoreRecord = false, - const bool tryRemoveColors = true); + void resortChatLog(std::string line, Own own, + const std::string &channel, + const bool ignoreRecord, + const bool tryRemoveColors); void battleChatLog(std::string line, Own own = BY_UNKNOWN, const bool ignoreRecord = false, diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index e85dac74a..7105f3fc4 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -176,7 +176,7 @@ class ChatTab : public Tab virtual void playNewMessageSound(); - std::string getChannelName() + const std::string &getChannelName() const { return mChannelName; } protected: diff --git a/src/gui/widgets/langtab.cpp b/src/gui/widgets/langtab.cpp index edef9e178..f9ae12ebd 100644 --- a/src/gui/widgets/langtab.cpp +++ b/src/gui/widgets/langtab.cpp @@ -27,7 +27,7 @@ #include "debug.h" LangTab::LangTab(const Widget2 *const widget, const std::string &lang) : - ChatTab(widget, _("Lang"), " " + lang) + ChatTab(widget, _("Lang"), lang + " ") { } -- cgit v1.2.3-60-g2f50