GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/chat/emulateguildtab.cpp Lines: 1 35 2.9 %
Date: 2021-03-17 Branches: 2 38 5.3 %

Line Branch Exec Source
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
26
#include "gui/widgets/tabs/chat/emulateguildtab.h"
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
41
EmulateGuildTab::EmulateGuildTab(const Widget2 *const widget) :
42
    // TRANSLATORS: guild chat tab name
43
    ChatTab(widget, _("Guild"), "", "#Guild", ChatTabType::GUILD),
44
    ConfigListener()
45
{
46
    setTabColors(ThemeColorId::GUILD_CHAT_TAB);
47
    mShowOnline = config.getBoolValue("showGuildOnline");
48
    config.addListener("showGuildOnline", this);
49
}
50
51
EmulateGuildTab::~EmulateGuildTab()
52
{
53
    config.removeListeners(this);
54
    CHECKLISTENERS
55
}
56
57
bool EmulateGuildTab::handleCommand(const std::string &restrict type,
58
                                    const std::string &restrict args)
59
{
60
    if (type == "invite")
61
        GuildManager::invite(args);
62
    else if (type == "leave")
63
        GuildManager::leave();
64
    else if (type == "kick")
65
        GuildManager::kick(args);
66
    else if (type == "notice")
67
        GuildManager::notice(args);
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;
78
    guildManager->chat(ChatWindow::doReplace(msg));
79
}
80
81
void EmulateGuildTab::getAutoCompleteList(StringVect &names) const
82
{
83
    if (guildManager == nullptr)
84
        return;
85
86
    GuildManager::getNames(names);
87
}
88
89
void EmulateGuildTab::getAutoCompleteCommands(StringVect &names) const
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
98
void EmulateGuildTab::playNewMessageSound() const
99
{
100
    soundManager.playGuiSound(SOUND_GUILD);
101
}
102
103
void EmulateGuildTab::optionChanged(const std::string &value)
104
{
105
    if (value == "showGuildOnline")
106
        mShowOnline = config.getBoolValue("showGuildOnline");
107

3
}
108
109
#endif  // TMWA_SUPPORT