GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/socialguildtab2.h Lines: 0 32 0.0 %
Date: 2021-03-17 Branches: 0 18 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2010  The Mana Developers
4
 *  Copyright (C) 2011-2019  The ManaPlus Developers
5
 *  Copyright (C) 2019-2021  Andrei Karas
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
#ifndef GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H
24
#define GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H
25
26
#include "gui/widgets/tabs/socialtab.h"
27
28
#include "guild.h"
29
30
#include "being/localplayer.h"
31
32
#include "utils/delete2.h"
33
#include "utils/foreach.h"
34
#include "utils/gettext.h"
35
#include "utils/stringutils.h"
36
37
#include "localconsts.h"
38
39
class SocialGuildTab2 final : public SocialTab,
40
                              public ActionListener
41
{
42
    public:
43
        SocialGuildTab2(const Widget2 *const widget,
44
                        Guild *const guild,
45
                        const Opaque showBackground) :
46
            SocialTab(widget),
47
            ActionListener()
48
        {
49
            // TRANSLATORS: tab in social window
50
            setCaption(_("Guild"));
51
52
            setTabColor(&getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB, 255U),
53
                &getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB_OUTLINE, 255U));
54
            setHighlightedTabColor(&getThemeColor(
55
                ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED, 255U),
56
                &getThemeColor(
57
                ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE, 255U));
58
            setSelectedTabColor(&getThemeColor(
59
                ThemeColorId::GUILD_SOCIAL_TAB_SELECTED, 255U),
60
                &getThemeColor(
61
                ThemeColorId::GUILD_SOCIAL_TAB_SELECTED_OUTLINE, 255U));
62
63
            createControls(guild, showBackground);
64
            mMenuAction = "guild";
65
        }
66
67
        A_DELETE_COPY(SocialGuildTab2)
68
69
        ~SocialGuildTab2() override final
70
        {
71
            delete2(mList)
72
            delete2(mScroll)
73
        }
74
75
        void action(const ActionEvent &event A_UNUSED) override final
76
        {
77
        }
78
79
        void buildCounter(const int online0 A_UNUSED,
80
                          const int total0 A_UNUSED) override final
81
        {
82
            if (localPlayer == nullptr)
83
                return;
84
85
            const Guild *const guild = localPlayer->getGuild();
86
            if (guild == nullptr)
87
                return;
88
89
            const Guild::MemberList *const members = guild->getMembers();
90
            int online = 0;
91
            int total = 0;
92
            FOR_EACHP (Guild::MemberList::const_iterator, it, members)
93
            {
94
                if ((*it)->getOnline())
95
                    online ++;
96
                total ++;
97
            }
98
99
            // TRANSLATORS: social window label
100
            mCounterString = strprintf(_("Players: %u/%u"),
101
                CAST_U32(online),
102
                CAST_U32(total));
103
            updateCounter();
104
        }
105
};
106
107
#endif  // GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H