Mana
Loading...
Searching...
No Matches
partytab.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2008-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
23
24#include "chatlogger.h"
25#include "commandhandler.h"
26#include "localplayer.h"
27#include "party.h"
28
29#include "net/net.h"
30#include "net/partyhandler.h"
31
32#include "resources/theme.h"
33
34#include "utils/gettext.h"
35
36namespace TmwAthena {
37
43
44void PartyTab::handleInput(const std::string &msg)
45{
47}
48
50{
51 chatLog(_("/help > Display this help."));
52 chatLog(_("/invite > Invite a player to your party"));
53 chatLog(_("/leave > Leave the party you are in"));
54 chatLog(_("/kick > Kick someone from the party you are in"));
55 chatLog(_("/item > Show/change party item sharing options"));
56 chatLog(_("/exp > Show/change party experience sharing options"));
57}
58
59bool PartyTab::handleCommand(const std::string &type, const std::string &args)
60{
61 if (type == "help")
62 {
63 if (args == "invite")
64 {
65 chatLog(_("Command: /invite <nick>"));
66 chatLog(_("This command invites <nick> to party with you."));
67 chatLog(_("If the <nick> has spaces in it, enclose it in "
68 "double quotes (\")."));
69 }
70 else if (args == "leave")
71 {
72 chatLog(_("Command: /leave"));
73 chatLog(_("This command causes the player to leave the party."));
74 }
75 else if (args == "item")
76 {
77 chatLog(_("Command: /item <policy>"));
78 chatLog(_("This command changes the party's item sharing policy."));
79 chatLog(_("<policy> can be one of \"1\", \"yes\", \"true\" to "
80 "enable item sharing, or \"0\", \"no\", \"false\" to "
81 "disable item sharing."));
82 chatLog(_("Command: /item"));
83 chatLog(_("This command displays the party's current item sharing policy."));
84 }
85 else if (args == "exp")
86 {
87 chatLog(_("Command: /exp <policy>"));
88 chatLog(_("This command changes the party's experience sharing policy."));
89 chatLog(_("<policy> can be one of \"1\", \"yes\", \"true\" to "
90 "enable experience sharing, or \"0\", \"no\", \"false\" to "
91 "disable experience sharing."));
92 chatLog(_("Command: /exp"));
93 chatLog(_("This command displays the party's current experience sharing policy."));
94 }
95 else
96 return false;
97 }
98 else if (type == "create" || type == "new")
99 {
100 if (args.empty())
101 chatLog(_("Party name is missing."), BY_SERVER);
102 else
104 }
105 else if (type == "invite")
106 {
108 }
109 else if (type == "leave")
110 {
112 }
113 else if (type == "kick")
114 {
115 Net::getPartyHandler()->kick(args);
116 }
117 else if (type == "item")
118 {
119 if (args.empty())
120 {
121 switch (Net::getPartyHandler()->getShareItems())
122 {
123 case PARTY_SHARE:
124 chatLog(_("Item sharing enabled."), BY_SERVER);
125 return true;
126 case PARTY_SHARE_NO:
127 chatLog(_("Item sharing disabled."), BY_SERVER);
128 return true;
130 chatLog(_("Item sharing not possible."), BY_SERVER);
131 return true;
133 chatLog(_("Item sharing unknown."), BY_SERVER);
134 return true;
135 }
136 }
137
138 char opt = CommandHandler::parseBoolean(args);
139
140 switch (opt)
141 {
142 case 1:
144 break;
145 case 0:
147 break;
148 case -1:
150 }
151 }
152 else if (type == "exp")
153 {
154 if (args.empty())
155 {
156 switch (Net::getPartyHandler()->getShareExperience())
157 {
158 case PARTY_SHARE:
159 chatLog(_("Experience sharing enabled."), BY_SERVER);
160 return true;
161 case PARTY_SHARE_NO:
162 chatLog(_("Experience sharing disabled."), BY_SERVER);
163 return true;
165 chatLog(_("Experience sharing not possible."), BY_SERVER);
166 return true;
168 chatLog(_("Experience sharing unknown."), BY_SERVER);
169 return true;
170 }
171 }
172
173 char opt = CommandHandler::parseBoolean(args);
174
175 switch (opt)
176 {
177 case 1:
179 break;
180 case 0:
182 break;
183 case -1:
185 }
186 }
187 else
188 return false;
189
190 return true;
191}
192
193void PartyTab::getAutoCompleteList(std::vector<std::string> &names) const
194{
195 if (Party *p = local_player->getParty())
196 p->getNames(names);
197}
198
199void PartyTab::saveToLogFile(std::string &msg)
200{
201 if (chatLogger)
202 chatLogger->log("#Party", msg);
203}
204
205} // namespace TmwAthena
ChatLogger * chatLogger
Chat log object.
Definition client.cpp:100
@ BY_SERVER
Definition chatwindow.h:50
Party * getParty() const
Definition being.h:262
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
static char parseBoolean(const std::string &value)
virtual void leave()=0
virtual void setShareExperience(PartyShare share)=0
virtual void create(const std::string &name=std::string())=0
virtual void kick(Being *player)=0
virtual void chat(const std::string &text)=0
virtual void setShareItems(PartyShare share)=0
virtual void invite(Being *player)=0
Definition party.h:59
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
@ PARTY_TAB
Definition theme.h:228
void getAutoCompleteList(std::vector< std::string > &) const override
Definition partytab.cpp:193
bool handleCommand(const std::string &type, const std::string &args) override
Handle special commands.
Definition partytab.cpp:59
void handleInput(const std::string &msg) override
Definition partytab.cpp:44
void saveToLogFile(std::string &msg) override
Definition partytab.cpp:199
void showHelp() override
Add any extra help text to the output.
Definition partytab.cpp:49
std::string booleanOptionInstructions(const char *command)
#define _(s)
Definition gettext.h:38
LocalPlayer * local_player
PartyHandler * getPartyHandler()
Definition net.cpp:105
Warning: buffers and other variables are shared, so there can be only one connection active at a time...
@ PARTY_SHARE
@ PARTY_SHARE_NO
@ PARTY_SHARE_UNKNOWN
@ PARTY_SHARE_NOT_POSSIBLE