diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-04-15 09:12:07 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-04-15 09:12:07 -0600 |
commit | fc4a12470adde2502f37f22b86f58560e416f3e4 (patch) | |
tree | db745342789cf54de216a8597f483f3609cebe9b /src/gui | |
parent | 8606e95b5c8a5fadde99a253de91a661454460db (diff) | |
download | mana-client-fc4a12470adde2502f37f22b86f58560e416f3e4.tar.gz mana-client-fc4a12470adde2502f37f22b86f58560e416f3e4.tar.bz2 mana-client-fc4a12470adde2502f37f22b86f58560e416f3e4.tar.xz mana-client-fc4a12470adde2502f37f22b86f58560e416f3e4.zip |
Make whisper tabs optional
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 45 | ||||
-rw-r--r-- | src/gui/chat.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 6 |
3 files changed, 42 insertions, 11 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 48acefee..30511ef9 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -35,8 +35,12 @@ #include "configuration.h" #include "localplayer.h" +#include "net/chathandler.h" +#include "net/net.h" + #include "utils/dtor.h" #include "utils/stringutils.h" +#include "utils/strprintf.h" #include <guichan/focushandler.hpp> #include <guichan/focuslistener.hpp> @@ -417,19 +421,44 @@ void ChatWindow::whisper(std::string nick, std::string mes, bool own) toLower(playerName); toLower(tempNick); - if (!own && tempNick.compare(playerName) == 0) + if (tempNick.compare(playerName) == 0) return; ChatTab *tab = mWhispers[tempNick]; - if (!tab) + if (tab) { - tab = new WhisperTab(tempNick); - mWhispers[tempNick] = tab; + if (own) + tab->chatInput(mes); + else + tab->chatLog(nick, mes); } - - if (own) - tab->chatInput(mes); else - tab->chatLog(nick, mes); + { + if (own) + { + Net::getChatHandler()->privateMessage(nick, mes); + + localChatTab->chatLog(strprintf(_("Whispering to %s: %s"), + nick.c_str(), mes.c_str()), BY_PLAYER); + } + else + localChatTab->chatLog(nick + " : " + mes, ACT_WHISPER, false); + } +} + +bool ChatWindow::addWhisperTab(std::string nick) +{ + std::string playerName = player_node->getName(); + std::string tempNick = nick; + + toLower(playerName); + toLower(tempNick); + + if (mWhispers[tempNick] || tempNick.compare(playerName) == 0) + return false; + + mWhispers[tempNick] = new WhisperTab(nick); + + return true; } diff --git a/src/gui/chat.h b/src/gui/chat.h index 65281c37..f5af7558 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -173,6 +173,8 @@ class ChatWindow : public Window, void whisper(std::string nick, std::string mes, bool own = false); + bool addWhisperTab(std::string nick); + protected: friend class ChatTab; friend class WhisperTab; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 1879a918..0e3ae423 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -144,9 +144,9 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) lineColor = "##2"; // Equiv. to BrowserBox::GREEN break; case ACT_WHISPER: - // Resend whisper through normal mechanism - chatWindow->whisper(tmp.nick, tmp.text); - return; + tmp.nick = strprintf(_("%s whispers: "), tmp.nick.c_str()); + lineColor = "##W"; + break; case ACT_IS: tmp.nick += CAT_IS; lineColor = "##I"; |