GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_players.cpp Lines: 64 70 91.4 %
Date: 2017-11-29 Branches: 156 320 48.8 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  Andrei Karas
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
#include "gui/widgets/tabs/setup_players.h"
24
25
#include "configuration.h"
26
#include "settings.h"
27
28
#include "gui/models/namesmodel.h"
29
30
#include "gui/widgets/containerplacer.h"
31
#include "gui/widgets/layouthelper.h"
32
#include "gui/widgets/scrollarea.h"
33
#include "gui/widgets/setupitem.h"
34
35
#include "utils/delete2.h"
36
#include "utils/gettext.h"
37
38
#include "debug.h"
39
40
static const int badgesListSize = 4;
41
42
static const char *const badgesList[] =
43
{
44
    // TRANSLATORS: screen badges type
45
    N_("hide"),
46
    // TRANSLATORS: screen badges type
47
    N_("show at top"),
48
    // TRANSLATORS: screen badges type
49
    N_("show at right"),
50
    // TRANSLATORS: screen badges type
51
    N_("show at bottom"),
52
};
53
54
static const int visibleNamesListSize = 3;
55
56
static const char *const visibleNamesList[] =
57
{
58
    // TRANSLATORS: visible name type
59
    N_("hide"),
60
    // TRANSLATORS: visible name type
61
    N_("show"),
62
    // TRANSLATORS: visible name type
63
    N_("show on selection")
64
};
65
66
static const int topDownListSize = 2;
67
68
static const char *const topDownList[] =
69
{
70
    // TRANSLATORS: show on top or down
71
    N_("top"),
72
    // TRANSLATORS: show on top or down
73
    N_("bottom")
74
};
75
76
4
Setup_Players::Setup_Players(const Widget2 *const widget) :
77
    SetupTabScroll(widget),
78

4
    mBadgesList(new NamesModel),
79

4
    mVisibleNamesList(new NamesModel),
80

12
    mVisibleNamesPosList(new NamesModel)
81
{
82
    // TRANSLATORS: settings tab name
83
20
    setName(_("Players"));
84
85
8
    LayoutHelper h(this);
86
4
    ContainerPlacer place = h.getPlacer(0, 0);
87
4
    place(0, 0, mScroll, 10, 10);
88
89
    // TRANSLATORS: settings option
90


52
    new SetupItemCheckBox(_("Show gender"), "",
91

4
        "showgender", this, "showgenderEvent");
92
93
    // TRANSLATORS: settings option
94


52
    new SetupItemCheckBox(_("Show level"), "",
95

4
        "showlevel", this, "showlevelEvent");
96
97
    // TRANSLATORS: settings option
98


52
    new SetupItemCheckBox(_("Show own name"), "",
99

4
        "showownname", this, "showownnameEvent");
100
101
    // TRANSLATORS: settings option
102


52
    new SetupItemCheckBox(_("Enable extended mouse targeting"), "",
103

4
        "extMouseTargeting", this, "extMouseTargetingEvent");
104
105
    // TRANSLATORS: settings option
106


52
    new SetupItemCheckBox(_("Target dead players"), "",
107

4
        "targetDeadPlayers", this, "targetDeadPlayersEvent");
108
109
4
    mVisibleNamesList->fillFromArray(&visibleNamesList[0],
110
        visibleNamesListSize);
111
    // TRANSLATORS: settings option
112


52
    new SetupItemDropDown(_("Show player names"), "",
113
        "visiblenames", this, "visiblenamesEvent",
114

4
        mVisibleNamesList, 150);
115
116
4
    mVisibleNamesPosList->fillFromArray(&topDownList[0],
117
        topDownListSize);
118
    // TRANSLATORS: settings option
119


52
    new SetupItemDropDown(_("Show player names at"), "",
120
        "visiblenamespos", this, "visiblenamesposEvent",
121

4
        mVisibleNamesPosList, 150);
122
123
    // TRANSLATORS: settings option
124


52
    new SetupItemCheckBox(_("Auto move names"), "",
125

4
        "moveNames", this, "moveNamesEvent");
126
127
4
    mBadgesList->fillFromArray(&badgesList[0], badgesListSize);
128
    // TRANSLATORS: settings option
129


52
    new SetupItemDropDown(_("Badges"), "",
130

4
        "showBadges", this, "showBadgesEvent", mBadgesList, 150);
131
132
    // TRANSLATORS: settings option
133


52
    new SetupItemCheckBox(_("Secure trades"), "",
134

4
        "securetrades", this, "securetradesEvent");
135
136
    // TRANSLATORS: settings option
137


52
    new SetupItemTextField(_("Unsecure chars in names"), "",
138

4
        "unsecureChars", this, "unsecureCharsEvent");
139
140
    // TRANSLATORS: settings option
141


52
    new SetupItemCheckBox(_("Show statuses"), "",
142

4
        "showPlayersStatus", this, "showPlayersStatusEvent");
143
144
    // TRANSLATORS: settings option
145


52
    new SetupItemCheckBox(_("Show ip addresses on screenshots"), "",
146

4
        "showip", this, "showipEvent");
147
148
    // TRANSLATORS: settings option
149


52
    new SetupItemCheckBox(_("Allow self heal with mouse click"), "",
150

4
        "selfMouseHeal", this, "selfMouseHealEvent");
151
152
    // TRANSLATORS: settings option
153


52
    new SetupItemCheckBox(_("Group friends in who is online window"), "",
154

4
        "groupFriends", this, "groupFriendsEvent");
155
156
    // TRANSLATORS: settings option
157


52
    new SetupItemCheckBox(_("Hide erased players nicks"), "",
158

4
        "hideErased", this, "hideErasedEvent");
159
160
    // TRANSLATORS: settings option
161


52
    new SetupItemCheckBox(_("Collect players id and seen log"),
162

4
        "", "enableIdCollecting", this, "enableIdCollectingEvent");
163
164
    // TRANSLATORS: settings option
165


52
    new SetupItemCheckBox(_("Use special diagonal speed in players moving"),
166

4
        "", "useDiagonalSpeed", this, "useDiagonalSpeedEvent");
167
168
    // TRANSLATORS: settings option
169


52
    new SetupItemCheckBox(_("Log players actions (for GM)"),
170

4
        "", "logPlayerActions", this, "logPlayerActionsEvent");
171
172
    // TRANSLATORS: settings option
173


52
    new SetupItemCheckBox(_("Create screenshots for each complete trades"),
174

4
        "", "tradescreenshot", this, "tradescreenshotEvent");
175
176
    // TRANSLATORS: settings option
177


52
    new SetupItemCheckBox(_("Emulate right mouse button by long mouse click"
178
        " (useful for touch interfaces)"),
179

4
        "", "longmouseclick", this, "longmouseclickEvent");
180
181
    // TRANSLATORS: settings option
182


64
    new SetupItemCheckBox(_("Enable remote commands"),
183
        "", "enableRemoteCommands", this, "enableRemoteCommandsEvent",
184
        "1",
185

4
        MainConfig_false);
186
187
    // TRANSLATORS: settings option
188


52
    new SetupItemCheckBox(_("Allow move character by mouse"),
189

4
        "", "allowMoveByMouse", this, "allowMoveByMouseEvent");
190
191
8
    setDimension(Rect(0, 0, 550, 350));
192
4
}
193
194
12
Setup_Players::~Setup_Players()
195
{
196
4
    delete2(mBadgesList);
197
4
    delete2(mVisibleNamesList);
198
4
    delete2(mVisibleNamesPosList);
199
8
}
200
201
void Setup_Players::externalUpdated()
202
{
203
    reread("enableRemoteCommands");
204
}
205
206
void Setup_Players::apply()
207
{
208
    SetupTabScroll::apply();
209
    settings.enableRemoteCommands = (serverConfig.getValue(
210
        "enableRemoteCommands", 1) != 0);
211
}