GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/chat/emulateguildtab.cpp Lines: 1 35 2.9 %
Date: 2017-11-29 Branches: 2 50 4.0 %

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-2017  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#ifdef TMWA_SUPPORT
24
25
#include "gui/widgets/tabs/chat/emulateguildtab.h"
26
27
#include "configuration.h"
28
#include "soundmanager.h"
29
30
#include "const/sound.h"
31
32
#include "gui/windows/chatwindow.h"
33
34
#include "utils/gettext.h"
35
36
#include "net/tmwa/guildmanager.h"
37
38
#include "debug.h"
39
40
EmulateGuildTab::EmulateGuildTab(const Widget2 *const widget) :
41
    // TRANSLATORS: guild chat tab name
42
    ChatTab(widget, _("Guild"), "", "#Guild", ChatTabType::GUILD),
43
    ConfigListener()
44
{
45
    setTabColors(ThemeColorId::GUILD_CHAT_TAB);
46
    mShowOnline = config.getBoolValue("showGuildOnline");
47
    config.addListener("showGuildOnline", this);
48
}
49
50
EmulateGuildTab::~EmulateGuildTab()
51
{
52
    config.removeListeners(this);
53
    CHECKLISTENERS
54
}
55
56
bool EmulateGuildTab::handleCommand(const std::string &restrict type,
57
                                    const std::string &restrict args)
58
{
59
    if (type == "invite")
60
        GuildManager::invite(args);
61
    else if (type == "leave")
62
        GuildManager::leave();
63
    else if (type == "kick")
64
        GuildManager::kick(args);
65
    else if (type == "notice")
66
        GuildManager::notice(args);
67
    else
68
        return false;
69
70
    return true;
71
}
72
73
void EmulateGuildTab::handleInput(const std::string &msg)
74
{
75
    if (guildManager == nullptr)
76
        return;
77
    guildManager->chat(ChatWindow::doReplace(msg));
78
}
79
80
void EmulateGuildTab::getAutoCompleteList(StringVect &names) const
81
{
82
    if (guildManager == nullptr)
83
        return;
84
85
    guildManager->getNames(names);
86
}
87
88
void EmulateGuildTab::getAutoCompleteCommands(StringVect &names) const
89
{
90
    names.push_back("/help");
91
    names.push_back("/invite ");
92
    names.push_back("/leave");
93
    names.push_back("/kick ");
94
    names.push_back("/notice ");
95
}
96
97
void EmulateGuildTab::playNewMessageSound() const
98
{
99
    soundManager.playGuiSound(SOUND_GUILD);
100
}
101
102
void EmulateGuildTab::optionChanged(const std::string &value)
103
{
104
    if (value == "showGuildOnline")
105
        mShowOnline = config.getBoolValue("showGuildOnline");
106

6
}
107
108
#endif  // TMWA_SUPPORT