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/chat.cpp | |
parent | 8606e95b5c8a5fadde99a253de91a661454460db (diff) | |
download | mana-fc4a12470adde2502f37f22b86f58560e416f3e4.tar.gz mana-fc4a12470adde2502f37f22b86f58560e416f3e4.tar.bz2 mana-fc4a12470adde2502f37f22b86f58560e416f3e4.tar.xz mana-fc4a12470adde2502f37f22b86f58560e416f3e4.zip |
Make whisper tabs optional
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 45 |
1 files changed, 37 insertions, 8 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; } |