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 |
|
|
#include "gui/widgets/tabs/chat/guildtab.h" |
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 |
|
|
|
55 |
|
|
GuildTab::~GuildTab() |
56 |
|
|
{ |
57 |
|
|
config.removeListeners(this); |
58 |
|
|
CHECKLISTENERS |
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 |
|
|
{ |
70 |
|
|
inputManager.executeChatCommand(InputAction::LEAVE_GUILD, |
71 |
|
|
std::string(), |
72 |
|
|
this); |
73 |
|
|
} |
74 |
|
|
else if (type == "kick" && (EAthena::taGuild != nullptr)) |
75 |
|
|
{ |
76 |
|
|
inputManager.executeChatCommand(InputAction::KICK_GUILD, |
77 |
|
|
args, |
78 |
|
|
this); |
79 |
|
|
} |
80 |
|
|
else if (type == "notice" && (EAthena::taGuild != nullptr)) |
81 |
|
|
{ |
82 |
|
|
inputManager.executeChatCommand(InputAction::GUILD_NOTICE, |
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 |
|
|
|
99 |
|
|
guildHandler->chat(ChatWindow::doReplace(msg)); |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
void GuildTab::getAutoCompleteList(StringVect &names) const |
103 |
|
|
{ |
104 |
|
|
if (EAthena::taGuild != nullptr) |
105 |
|
|
EAthena::taGuild->getNames(names); |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
void GuildTab::getAutoCompleteCommands(StringVect &names) const |
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 |
|
|
|
117 |
|
|
void GuildTab::playNewMessageSound() const |
118 |
|
|
{ |
119 |
|
|
soundManager.playGuiSound(SOUND_GUILD); |
120 |
|
|
} |
121 |
|
|
|
122 |
|
|
void GuildTab::optionChanged(const std::string &value) |
123 |
|
|
{ |
124 |
|
|
if (value == "showGuildOnline") |
125 |
|
|
mShowOnline = config.getBoolValue("showGuildOnline"); |
126 |
✓✗✓✗
|
3 |
} |