Mana
Loading...
Searching...
No Matches
whispertab.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "whispertab.h"
23
24#include "chatlogger.h"
25#include "commandhandler.h"
26#include "localplayer.h"
27
28#include "net/chathandler.h"
29#include "net/net.h"
30
31#include "resources/theme.h"
32
33#include "utils/gettext.h"
34
35WhisperTab::WhisperTab(const std::string &nick) :
36 ChatTab(nick),
37 mNick(nick)
38{
40}
41
47
48void WhisperTab::handleInput(const std::string &msg)
49{
50 if (msg.empty())
51 {
52 chatLog(_("Cannot send empty chat!"), BY_SERVER, false);
53 return;
54 }
55
57
59}
60
61void WhisperTab::handleCommand(const std::string &msg)
62{
63 if (msg == "close")
64 delete this;
65 else
67}
68
70{
71 chatLog(_("/ignore > Ignore the other player"));
72 chatLog(_("/unignore > Stop ignoring the other player"));
73 chatLog(_("/close > Close the whisper tab"));
74}
75
76bool WhisperTab::handleCommand(const std::string &type,
77 const std::string &args)
78{
79 if (type == "help")
80 {
81 if (args == "close")
82 {
83 chatLog(_("Command: /close"));
84 chatLog(_("This command closes the current whisper tab."));
85 }
86 else if (args == "ignore")
87 {
88 chatLog(_("Command: /ignore"));
89 chatLog(_("This command ignores the other player regardless of "
90 "current relations."));
91 }
92 else if (args == "unignore")
93 {
94 chatLog(_("Command: /unignore <player>"));
95 chatLog(_("This command stops ignoring the other player if they "
96 "are being ignored."));
97 }
98 else
99 return false;
100 }
101 else if (type == "close")
102 {
103 delete this;
104 }
105 else if (type == "ignore")
106 {
108 }
109 else if (type == "unignore")
110 {
112 }
113 else
114 return false;
115
116 return true;
117}
118
119void WhisperTab::saveToLogFile(std::string &msg)
120{
121 if (chatLogger)
122 chatLogger->log(getNick(), msg);
123}
ChatLogger * chatLogger
Chat log object.
Definition client.cpp:100
@ BY_SERVER
Definition chatwindow.h:50
const std::string & getName() const
Returns the name of the being.
Definition being.h:190
void log(std::string str)
Enters a message in the log.
A tab for the chat window.
Definition chattab.h:36
void chatLog(std::string line, Own own=BY_SERVER, bool ignoreRecord=false)
Adds a line of text to our message list.
Definition chattab.cpp:111
virtual bool handleCommand(const std::string &type, const std::string &args)
Handle special commands.
Definition chattab.h:94
void removeWhisper(const std::string &nick)
void handleIgnore(const std::string &args, ChatTab *tab)
Handle an ignore command.
void handleUnignore(const std::string &args, ChatTab *tab)
Handle an unignore command.
virtual void privateMessage(const std::string &recipient, const std::string &text)=0
void setTabColor(const gcn::Color *color)
Set the normal color fo the tab's text.
Definition tab.cpp:117
static const gcn::Color & getThemeColor(int type)
Gets the color associated with the type in the default palette (0).
Definition theme.cpp:313
@ WHISPER_TAB
Definition theme.h:229
~WhisperTab() override
const std::string & getNick() const
Definition whispertab.h:34
void showHelp() override
Add any extra help text to the output.
void handleInput(const std::string &msg) override
void saveToLogFile(std::string &msg) override
std::string mNick
Definition whispertab.h:63
WhisperTab(const std::string &nick)
Constructor.
bool handleCommand(const std::string &type, const std::string &args) override
Handle special commands.
CommandHandler * commandHandler
Definition game.cpp:112
ChatWindow * chatWindow
Definition game.cpp:93
#define _(s)
Definition gettext.h:38
LocalPlayer * local_player
ChatHandler * getChatHandler()
Definition net.cpp:70