diff options
-rw-r--r-- | src/gui/chatwindow.cpp | 25 | ||||
-rw-r--r-- | src/gui/chatwindow.h | 7 | ||||
-rw-r--r-- | src/gui/widgets/chattab.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/langtab.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/chathandler.cpp | 32 |
5 files changed, 45 insertions, 23 deletions
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 + " ") { } diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 3a2c6ec2e..0118e5071 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -268,12 +268,13 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg, const bool channels) if (!being) return; + std::string channel; if (channels) { chatMsgLength -= 3; - msg.readInt8(); // channel - msg.readInt8(); // channel - msg.readInt8(); // channel + channel = msg.readInt8(); + channel += msg.readInt8(); + channel += msg.readInt8(); } if (chatMsgLength <= 0) @@ -307,7 +308,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg, const bool channels) PlayerRelation::SPEECH_LOG) && chatWindow) { chatWindow->resortChatLog(removeColors(sender_name) - .append(" : ").append(chatMsg), BY_OTHER); + .append(" : ").append(chatMsg), BY_OTHER, channel, false, true); } if (player_relations.hasPermission(sender_name, @@ -321,12 +322,13 @@ void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat, bool channels) { int chatMsgLength = msg.readInt16() - 4; + std::string channel; if (channels) { chatMsgLength -= 3; - msg.readInt8(); // channel - msg.readInt8(); // channel - msg.readInt8(); // channel + channel = msg.readInt8(); + channel += msg.readInt8(); + channel += msg.readInt8(); } if (chatMsgLength <= 0) return; @@ -337,13 +339,19 @@ void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat, if (normalChat) { if (chatWindow) - chatWindow->resortChatLog(chatMsg, BY_PLAYER); + { + chatWindow->resortChatLog(chatMsg, BY_PLAYER, + channel, false, true); + } - const std::string senseStr = "You sense the following: "; - if (actorSpriteManager && !chatMsg.find(senseStr)) + if (channel.empty()) { - actorSpriteManager->parseLevels( - chatMsg.substr(senseStr.size())); + const std::string senseStr = "You sense the following: "; + if (actorSpriteManager && !chatMsg.find(senseStr)) + { + actorSpriteManager->parseLevels( + chatMsg.substr(senseStr.size())); + } } if (pos != std::string::npos) |