GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_players.cpp Lines: 67 73 91.8 %
Date: 2018-06-18 21:15:20 Branches: 153 314 48.7 %

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-2018  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
        "showgender", this, "showgenderEvent",
92

4
        MainConfig_true);
93
94
    // TRANSLATORS: settings option
95


52
    new SetupItemCheckBox(_("Show level"), "",
96
        "showlevel", this, "showlevelEvent",
97

4
        MainConfig_true);
98
99
    // TRANSLATORS: settings option
100


52
    new SetupItemCheckBox(_("Show own name"), "",
101
        "showownname", this, "showownnameEvent",
102

4
        MainConfig_true);
103
104
    // TRANSLATORS: settings option
105


52
    new SetupItemCheckBox(_("Enable extended mouse targeting"), "",
106
        "extMouseTargeting", this, "extMouseTargetingEvent",
107

4
        MainConfig_true);
108
109
    // TRANSLATORS: settings option
110


52
    new SetupItemCheckBox(_("Target dead players"), "",
111
        "targetDeadPlayers", this, "targetDeadPlayersEvent",
112

4
        MainConfig_true);
113
114
4
    mVisibleNamesList->fillFromArray(&visibleNamesList[0],
115
        visibleNamesListSize);
116
    // TRANSLATORS: settings option
117


52
    new SetupItemDropDown(_("Show player names"), "",
118
        "visiblenames", this, "visiblenamesEvent",
119
4
        mVisibleNamesList, 150,
120

8
        MainConfig_true);
121
122
4
    mVisibleNamesPosList->fillFromArray(&topDownList[0],
123
        topDownListSize);
124
    // TRANSLATORS: settings option
125


52
    new SetupItemDropDown(_("Show player names at"), "",
126
        "visiblenamespos", this, "visiblenamesposEvent",
127
4
        mVisibleNamesPosList, 150,
128

8
        MainConfig_true);
129
130
    // TRANSLATORS: settings option
131
36
    new SetupItemCheckBox(_("Auto move names"), "",
132
        "moveNames", this, "moveNamesEvent",
133

4
        MainConfig_true);
134
135
4
    mBadgesList->fillFromArray(&badgesList[0], badgesListSize);
136
    // TRANSLATORS: settings option
137


52
    new SetupItemDropDown(_("Badges"), "",
138
4
        "showBadges", this, "showBadgesEvent", mBadgesList, 150,
139

8
        MainConfig_true);
140
141
    // TRANSLATORS: settings option
142


52
    new SetupItemCheckBox(_("Secure trades"), "",
143
        "securetrades", this, "securetradesEvent",
144

4
        MainConfig_true);
145
146
    // TRANSLATORS: settings option
147


52
    new SetupItemTextField(_("Unsecure chars in names"), "",
148
        "unsecureChars", this, "unsecureCharsEvent",
149

4
        MainConfig_true, UseBase64_false);
150
151
    // TRANSLATORS: settings option
152


52
    new SetupItemCheckBox(_("Show statuses"), "",
153
        "showPlayersStatus", this, "showPlayersStatusEvent",
154

4
        MainConfig_true);
155
156
    // TRANSLATORS: settings option
157


52
    new SetupItemCheckBox(_("Show ip addresses on screenshots"), "",
158
        "showip", this, "showipEvent",
159

4
        MainConfig_true);
160
161
    // TRANSLATORS: settings option
162


52
    new SetupItemCheckBox(_("Allow self heal with mouse click"), "",
163
        "selfMouseHeal", this, "selfMouseHealEvent",
164

4
        MainConfig_true);
165
166
    // TRANSLATORS: settings option
167


52
    new SetupItemCheckBox(_("Group friends in who is online window"), "",
168
        "groupFriends", this, "groupFriendsEvent",
169

4
        MainConfig_true);
170
171
    // TRANSLATORS: settings option
172


52
    new SetupItemCheckBox(_("Hide erased players nicks"), "",
173
        "hideErased", this, "hideErasedEvent",
174

4
        MainConfig_true);
175
176
    // TRANSLATORS: settings option
177


52
    new SetupItemCheckBox(_("Collect players id and seen log"),
178
        "", "enableIdCollecting", this, "enableIdCollectingEvent",
179

4
        MainConfig_true);
180
181
    // TRANSLATORS: settings option
182


52
    new SetupItemCheckBox(_("Use special diagonal speed in players moving"),
183
        "", "useDiagonalSpeed", this, "useDiagonalSpeedEvent",
184

4
        MainConfig_true);
185
186
    // TRANSLATORS: settings option
187


52
    new SetupItemCheckBox(_("Log players actions (for GM)"),
188
        "", "logPlayerActions", this, "logPlayerActionsEvent",
189

4
        MainConfig_true);
190
191
    // TRANSLATORS: settings option
192


52
    new SetupItemCheckBox(_("Create screenshots for each complete trades"),
193
        "", "tradescreenshot", this, "tradescreenshotEvent",
194

4
        MainConfig_true);
195
196
    // TRANSLATORS: settings option
197


52
    new SetupItemCheckBox(_("Emulate right mouse button by long mouse click"
198
        " (useful for touch interfaces)"),
199
        "", "longmouseclick", this, "longmouseclickEvent",
200

4
        MainConfig_true);
201
202
    // TRANSLATORS: settings option
203


64
    new SetupItemCheckBox(_("Enable remote commands"),
204
        "", "enableRemoteCommands", this, "enableRemoteCommandsEvent",
205
        "1",
206

4
        MainConfig_false);
207
208
    // TRANSLATORS: settings option
209


52
    new SetupItemCheckBox(_("Allow move character by mouse"),
210
        "", "allowMoveByMouse", this, "allowMoveByMouseEvent",
211

4
        MainConfig_true);
212
213
8
    setDimension(Rect(0, 0, 550, 350));
214
4
}
215
216
12
Setup_Players::~Setup_Players()
217
{
218
4
    delete2(mBadgesList);
219
4
    delete2(mVisibleNamesList);
220
4
    delete2(mVisibleNamesPosList);
221
8
}
222
223
void Setup_Players::externalUpdated()
224
{
225
    reread("enableRemoteCommands");
226
}
227
228
void Setup_Players::apply()
229
{
230
    SetupTabScroll::apply();
231
    settings.enableRemoteCommands = (serverConfig.getValue(
232
        "enableRemoteCommands", 1) != 0);
233
}