GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/socialguildtab2.h Lines: 0 32 0.0 %
Date: 2017-11-29 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-2017  The ManaPlus Developers
5
 *
6
 *  This file is part of The ManaPlus Client.
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  any later version.
12
 *
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU General Public License for more details.
17
 *
18
 *  You should have received a copy of the GNU General Public License
19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
#ifndef GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H
23
#define GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H
24
25
#include "gui/widgets/tabs/socialtab.h"
26
27
#include "guild.h"
28
29
#include "being/localplayer.h"
30
31
#include "utils/delete2.h"
32
#include "utils/foreach.h"
33
#include "utils/gettext.h"
34
#include "utils/stringutils.h"
35
36
#include "localconsts.h"
37
38
class SocialGuildTab2 final : public SocialTab,
39
                              public ActionListener
40
{
41
    public:
42
        SocialGuildTab2(const Widget2 *const widget,
43
                        Guild *const guild,
44
                        const Opaque showBackground) :
45
            SocialTab(widget),
46
            ActionListener()
47
        {
48
            // TRANSLATORS: tab in social window
49
            setCaption(_("Guild"));
50
51
            setTabColor(&getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB),
52
                &getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB_OUTLINE));
53
            setHighlightedTabColor(&getThemeColor(
54
                ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED),
55
                &getThemeColor(
56
                ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE));
57
            setSelectedTabColor(&getThemeColor(
58
                ThemeColorId::GUILD_SOCIAL_TAB_SELECTED),
59
                &getThemeColor(
60
                ThemeColorId::GUILD_SOCIAL_TAB_SELECTED_OUTLINE));
61
62
            createControls(guild, showBackground);
63
            mMenuAction = "guild";
64
        }
65
66
        A_DELETE_COPY(SocialGuildTab2)
67
68
        ~SocialGuildTab2()
69
        {
70
            delete2(mList)
71
            delete2(mScroll)
72
        }
73
74
        void action(const ActionEvent &event A_UNUSED) override final
75
        {
76
        }
77
78
        void buildCounter(const int online0 A_UNUSED,
79
                          const int total0 A_UNUSED) override final
80
        {
81
            if (localPlayer == nullptr)
82
                return;
83
84
            const Guild *const guild = localPlayer->getGuild();
85
            if (guild == nullptr)
86
                return;
87
88
            const Guild::MemberList *const members = guild->getMembers();
89
            int online = 0;
90
            int total = 0;
91
            FOR_EACHP (Guild::MemberList::const_iterator, it, members)
92
            {
93
                if ((*it)->getOnline())
94
                    online ++;
95
                total ++;
96
            }
97
98
            // TRANSLATORS: social window label
99
            mCounterString = strprintf(_("Players: %u/%u"),
100
                CAST_U32(online),
101
                CAST_U32(total));
102
            updateCounter();
103
        }
104
};
105
106
#endif  // GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H