ManaPlus
emulateguildtab.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 
24 #ifdef TMWA_SUPPORT
25 
27 
28 #include "configuration.h"
29 #include "soundmanager.h"
30 
31 #include "const/sound.h"
32 
33 #include "gui/windows/chatwindow.h"
34 
35 #include "utils/gettext.h"
36 
37 #include "net/tmwa/guildmanager.h"
38 
39 #include "debug.h"
40 
42  // TRANSLATORS: guild chat tab name
43  ChatTab(widget, _("Guild"), "", "#Guild", ChatTabType::GUILD),
45 {
46  setTabColors(ThemeColorId::GUILD_CHAT_TAB);
47  mShowOnline = config.getBoolValue("showGuildOnline");
48  config.addListener("showGuildOnline", this);
49 }
50 
52 {
53  config.removeListeners(this);
55 }
56 
57 bool EmulateGuildTab::handleCommand(const std::string &restrict type,
58  const std::string &restrict args)
59 {
60  if (type == "invite")
62  else if (type == "leave")
64  else if (type == "kick")
65  GuildManager::kick(args);
66  else if (type == "notice")
68  else
69  return false;
70 
71  return true;
72 }
73 
74 void EmulateGuildTab::handleInput(const std::string &msg)
75 {
76  if (guildManager == nullptr)
77  return;
79 }
80 
82 {
83  if (guildManager == nullptr)
84  return;
85 
87 }
88 
90 {
91  names.push_back("/help");
92  names.push_back("/invite ");
93  names.push_back("/leave");
94  names.push_back("/kick ");
95  names.push_back("/notice ");
96 }
97 
99 {
101 }
102 
103 void EmulateGuildTab::optionChanged(const std::string &value)
104 {
105  if (value == "showGuildOnline")
106  mShowOnline = config.getBoolValue("showGuildOnline");
107 }
108 
109 #endif // TMWA_SUPPORT
#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)
void getAutoCompleteList(StringVect &names) const
void getAutoCompleteCommands(StringVect &names) const
void playNewMessageSound() const
bool handleCommand(const std::string &type, const std::string &args)
EmulateGuildTab(const Widget2 *const widget)
void handleInput(const std::string &msg)
static void notice(const std::string &msg)
void chat(const std::string &msg)
static void leave()
static void kick(const std::string &msg)
static void invite(const std::string &msg)
static void getNames(StringVect &names)
void playGuiSound(const std::string &name)
Configuration config
#define _(s)
Definition: gettext.h:35
GuildManager * guildManager
#define restrict
Definition: localconsts.h:165
#define CHECKLISTENERS
Definition: localconsts.h:277
bool msg(InputEvent &event)
Definition: chat.cpp:39
static const std::string SOUND_GUILD
Definition: sound.h:34
SoundManager soundManager
std::vector< std::string > StringVect
Definition: stringvector.h:29