summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-15 09:12:07 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-15 09:12:07 -0600
commitfc4a12470adde2502f37f22b86f58560e416f3e4 (patch)
treedb745342789cf54de216a8597f483f3609cebe9b
parent8606e95b5c8a5fadde99a253de91a661454460db (diff)
downloadMana-fc4a12470adde2502f37f22b86f58560e416f3e4.tar.gz
Mana-fc4a12470adde2502f37f22b86f58560e416f3e4.tar.bz2
Mana-fc4a12470adde2502f37f22b86f58560e416f3e4.tar.xz
Mana-fc4a12470adde2502f37f22b86f58560e416f3e4.zip
Make whisper tabs optional
-rw-r--r--src/commandhandler.cpp25
-rw-r--r--src/commandhandler.h5
-rw-r--r--src/gui/chat.cpp45
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/gui/widgets/chattab.cpp6
5 files changed, 71 insertions, 12 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 586a62cd..9b8c037b 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -68,6 +68,10 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab)
{
handleMsg(args, tab);
}
+ else if (type == "msgtab" || type == "whispertab" || type == "wt")
+ {
+ handleMsgTab(args, tab);
+ }
else if (type == "join")
{
handleJoin(args, tab);
@@ -145,6 +149,9 @@ void CommandHandler::handleHelp(const std::string &args, ChatTab *tab)
tab->chatLog(_("/msg > Send a private message to a user"));
tab->chatLog(_("/whisper > Alias of msg"));
tab->chatLog(_("/w > Alias of msg"));
+ tab->chatLog(_("/msgtab > Makes a tab for private messages with another user"));
+ tab->chatLog(_("/whispertab > Alias of msgtab"));
+ tab->chatLog(_("/wt > Alias of msgtab"));
tab->chatLog(_("/close > Close the whisper tab (only works in whisper tabs)"));
#ifdef TMWSERV_SUPPORT
@@ -219,6 +226,14 @@ void CommandHandler::handleHelp(const std::string &args, ChatTab *tab)
tab->chatLog(_("If the <nick> has spaces in it, enclose it in "
"double quotes (\")."));
}
+ else if (args == "msgtab" || args == "whispertab" || args == "wt")
+ {
+ tab->chatLog(_("Command: /msgtab <nick>"));
+ tab->chatLog(_("Command: /whispertab <nick>"));
+ tab->chatLog(_("Command: /wtab <nick>"));
+ tab->chatLog(_("This command tries to make a tab for whispers between"
+ "you and <nick>."));
+ }
else if (args == "op")
{
tab->chatLog(_("Command: /op <nick>"));
@@ -353,7 +368,15 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab)
chatWindow->whisper(recvnick, msg, true);
}
else
- tab->chatLog("Cannont send empty whispers!");
+ tab->chatLog(_("Cannont send empty whispers!"), BY_SERVER);
+}
+
+void CommandHandler::handleMsgTab(const std::string &args, ChatTab *tab) {
+ if (chatWindow->addWhisperTab(args))
+ return;
+
+ tab->chatLog(strprintf(_("Cannont create a whisper tab for nick '%s'!"
+ "It either already exists, or is you."), args.c_str()), BY_SERVER);
}
void CommandHandler::handleClear(const std::string &args, ChatTab *tab)
diff --git a/src/commandhandler.h b/src/commandhandler.h
index b9b61647..458c82c0 100644
--- a/src/commandhandler.h
+++ b/src/commandhandler.h
@@ -76,6 +76,11 @@ class CommandHandler
void handleMsg(const std::string &args, ChatTab *tab);
/**
+ * Handle a msg tab request.
+ */
+ void handleMsgTab(const std::string &args, ChatTab *tab);
+
+ /**
* Handle a join command.
*/
void handleJoin(const std::string &args, ChatTab *tab);
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";