ManaPlus
guildtab.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2008-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
25 
26 #include "configuration.h"
27 #include "soundmanager.h"
28 
29 #include "const/sound.h"
30 
31 #include "gui/windows/chatwindow.h"
32 
33 #include "input/inputmanager.h"
34 
35 #include "net/guildhandler.h"
36 
37 #include "utils/gettext.h"
38 
39 #include "debug.h"
40 
41 namespace EAthena
42 {
43  extern Guild *taGuild;
44 } // namespace EAthena
45 
46 GuildTab::GuildTab(const Widget2 *const widget) :
47  // TRANSLATORS: guild chat tab name
48  ChatTab(widget, _("Guild"), "", "#Guild", ChatTabType::GUILD)
49 {
50  setTabColors(ThemeColorId::GUILD_CHAT_TAB);
51  mShowOnline = config.getBoolValue("showGuildOnline");
52  config.addListener("showGuildOnline", this);
53 }
54 
56 {
57  config.removeListeners(this);
59 }
60 
61 bool GuildTab::handleCommand(const std::string &restrict type,
62  const std::string &restrict args)
63 {
64  if (type == "invite" && (EAthena::taGuild != nullptr))
65  {
66  guildHandler->invite(args);
67  }
68  else if (type == "leave" && (EAthena::taGuild != nullptr))
69  {
71  std::string(),
72  this);
73  }
74  else if (type == "kick" && (EAthena::taGuild != nullptr))
75  {
77  args,
78  this);
79  }
80  else if (type == "notice" && (EAthena::taGuild != nullptr))
81  {
83  args,
84  this);
85  }
86  else
87  {
88  return false;
89  }
90 
91  return true;
92 }
93 
94 void GuildTab::handleInput(const std::string &msg)
95 {
96  if (EAthena::taGuild == nullptr)
97  return;
98 
100 }
101 
103 {
104  if (EAthena::taGuild != nullptr)
105  EAthena::taGuild->getNames(names);
106 }
107 
109 {
110  names.push_back("/help");
111  names.push_back("/invite ");
112  names.push_back("/kick ");
113  names.push_back("/notice ");
114  names.push_back("/leave");
115 }
116 
118 {
120 }
121 
122 void GuildTab::optionChanged(const std::string &value)
123 {
124  if (value == "showGuildOnline")
125  mShowOnline = config.getBoolValue("showGuildOnline");
126 }
#define setTabColors(name)
Definition: chattab.h:51
bool mShowOnline
Definition: chattab.h:215
static std::string doReplace(const std::string &msg)
bool getBoolValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
void removeListeners(ConfigListener *const listener)
void optionChanged(const std::string &value)
Definition: guildtab.cpp:122
void handleInput(const std::string &msg)
Definition: guildtab.cpp:94
void getAutoCompleteCommands(StringVect &names) const
Definition: guildtab.cpp:108
void getAutoCompleteList(StringVect &names) const
Definition: guildtab.cpp:102
bool handleCommand(const std::string &type, const std::string &args)
Definition: guildtab.cpp:61
~GuildTab()
Definition: guildtab.cpp:55
GuildTab(const Widget2 *const widget)
Definition: guildtab.cpp:46
void playNewMessageSound() const
Definition: guildtab.cpp:117
Definition: guild.h:70
void getNames(StringVect &names) const
Definition: guild.cpp:355
bool executeChatCommand(const std::string &cmd, const std::string &args, ChatTab *const tab)
virtual void chat(const std::string &text) const =0
virtual void invite(const std::string &name) const =0
void playGuiSound(const std::string &name)
Configuration config
#define _(s)
Definition: gettext.h:35
Net::GuildHandler * guildHandler
Definition: net.cpp:92
InputManager inputManager
#define restrict
Definition: localconsts.h:165
#define CHECKLISTENERS
Definition: localconsts.h:277
bool msg(InputEvent &event)
Definition: chat.cpp:39
Guild * taGuild
Definition: guildhandler.h:99
static const std::string SOUND_GUILD
Definition: sound.h:34
SoundManager soundManager
std::vector< std::string > StringVect
Definition: stringvector.h:29