diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-05-09 18:21:14 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-06-29 15:48:52 -0600 |
commit | f1cab9c5ab1d36586ae1e0d1dae3f3d1483522b5 (patch) | |
tree | a0146a49c90bd15bb65e8bbae94883b189037a40 | |
parent | a2bb244ea72fefdb60d8ef5b037dfbc5b6ac842d (diff) | |
download | mana-client-f1cab9c5ab1d36586ae1e0d1dae3f3d1483522b5.tar.gz mana-client-f1cab9c5ab1d36586ae1e0d1dae3f3d1483522b5.tar.bz2 mana-client-f1cab9c5ab1d36586ae1e0d1dae3f3d1483522b5.tar.xz mana-client-f1cab9c5ab1d36586ae1e0d1dae3f3d1483522b5.zip |
Make whisper responses from tmwAthena show up in correct tabs
Reviewed-by: Bertram
-rw-r--r-- | src/commandhandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/chat.cpp | 8 | ||||
-rw-r--r-- | src/gui/chat.h | 18 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/chattab.h | 15 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 23 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.h | 6 |
7 files changed, 48 insertions, 26 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index dab51c8f..2567b3b4 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -389,7 +389,7 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) if (tempNick.compare(playerName) == 0 || args.empty()) return; - chatWindow->whisper(recvnick, msg, true); + chatWindow->whisper(recvnick, msg, BY_PLAYER); } else tab->chatLog(_("Cannot send empty whispers!"), BY_SERVER); diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index da1bd600..9842e1f4 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -431,7 +431,7 @@ void ChatWindow::setRecordingFile(const std::string &msg) } void ChatWindow::whisper(const std::string &nick, - const std::string &mes, bool own) + const std::string &mes, Own own) { if (mes.empty()) return; @@ -455,10 +455,14 @@ void ChatWindow::whisper(const std::string &nick, if (tab) { - if (own) + if (own == BY_PLAYER) { tab->chatInput(mes); } + else if (own == BY_SERVER) + { + tab->chatLog(mes); + } else { tab->chatLog(nick, mes); diff --git a/src/gui/chat.h b/src/gui/chat.h index 3de2b146..aeba2ece 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -35,8 +35,8 @@ #include <vector> class BrowserBox; -class Channel; class ChatTab; +class Channel; class ChatInput; class Recorder; class ScrollArea; @@ -47,12 +47,24 @@ class WhisperTab; #define DEFAULT_CHAT_WINDOW_SCROLL 7 // 1 means `1/8th of the window size'. +enum Own +{ + BY_GM, + BY_PLAYER, + BY_OTHER, + BY_SERVER, + BY_CHANNEL, + ACT_WHISPER, // getting whispered at + ACT_IS, // equivalent to "/me" on IRC + BY_LOGGER +}; + /** One item in the chat log */ struct CHATLOG { std::string nick; std::string text; - int own; + Own own; }; /** @@ -170,7 +182,7 @@ class ChatWindow : public Window, void doPresent(); void whisper(const std::string &nick, const std::string &mes, - bool own = false); + Own own = BY_OTHER); ChatTab *addWhisperTab(const std::string &nick, bool switchTo = false); diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 8c300eca..03ff79d9 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -72,7 +72,7 @@ ChatTab::~ChatTab() delete mScrollArea; } -void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) +void ChatTab::chatLog(std::string line, Own own, bool ignoreRecord) { // Trim whitespace trim(line); diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 2189a780..f5682668 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -30,18 +30,6 @@ class BrowserBox; class Recorder; class ScrollArea; -enum -{ - BY_GM, - BY_PLAYER, - BY_OTHER, - BY_SERVER, - BY_CHANNEL, - ACT_WHISPER, // getting whispered at - ACT_IS, // equivalent to "/me" on IRC - BY_LOGGER -}; - /** * A tab for the chat window. This is special to ease chat handling. */ @@ -62,7 +50,8 @@ class ChatTab : public Tab * @param channelName which channel to send the message to. * @param ignoreRecord should this not be recorded? */ - void chatLog(std::string line, int own = BY_SERVER, bool ignoreRecord = false); + void chatLog(std::string line, Own own = BY_SERVER, + bool ignoreRecord = false); /** * Adds the text to the message list diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 493df0e5..53af2e6b 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -70,19 +70,28 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) switch (msg.getId()) { case SMSG_WHISPER_RESPONSE: + if (mSentWhispers.empty()) + nick = "user"; + else + { + nick = mSentWhispers.front(); + mSentWhispers.pop(); + } + switch (msg.readInt8()) { case 0x00: - // comment out since we'll local echo in chat.cpp instead, then only report failures - //localChatTab->chatLog("Whisper sent", BY_SERVER); + // Success (don't need to report) break; case 0x01: - localChatTab->chatLog(_("Whisper could not be sent, user " - "is offline."), BY_SERVER); + chatWindow->whisper(nick, strprintf(_("Whisper could not " + "be sent, %s is offline."), nick.c_str()), + BY_SERVER); break; case 0x02: - localChatTab->chatLog(_("Whisper could not be sent, " - "ignored by user."), BY_SERVER); + chatWindow->whisper(nick, strprintf(_("Whisper could not " + "be sent, ignored by %s."), nick.c_str()), + BY_SERVER); break; } break; @@ -197,6 +206,8 @@ void ChatHandler::privateMessage(const std::string &recipient, outMsg.writeInt16(text.length() + 28); outMsg.writeString(recipient, 24); outMsg.writeString(text, text.length()); + + mSentWhispers.push(recipient); } void ChatHandler::channelList() diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index 3e035f7e..6426a71e 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -27,6 +27,8 @@ #include "net/tmwa/messagehandler.h" +#include <queue> + namespace TmwAthena { class ChatHandler : public MessageHandler, public Net::ChatHandler @@ -61,6 +63,10 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler void kickUser(int channelId, const std::string &name); void who(); + + private: + typedef std::queue<std::string> WhisperQueue; + WhisperQueue mSentWhispers; }; } // namespace TmwAthena |