GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_players.cpp Lines: 68 74 91.9 %
Date: 2021-03-17 Branches: 156 316 49.4 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009  The Mana World Development Team
4
 *  Copyright (C) 2011-2019  The ManaPlus Developers
5
 *  Copyright (C) 2009-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
#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
2
Setup_Players::Setup_Players(const Widget2 *const widget) :
77
    SetupTabScroll(widget),
78

2
    mBadgesList(new NamesModel),
79

2
    mVisibleNamesList(new NamesModel),
80

6
    mVisibleNamesPosList(new NamesModel)
81
{
82
    // TRANSLATORS: settings tab name
83
8
    setName(_("Players"));
84
85
4
    LayoutHelper h(this);
86
2
    ContainerPlacer place = h.getPlacer(0, 0);
87
2
    place(0, 0, mScroll, 10, 10);
88
89
    // TRANSLATORS: settings option
90
2
    new SetupItemCheckBox(_("Show gender"), "",
91
        "showgender", this, "showgenderEvent",
92



24
        MainConfig_true);
93
94
    // TRANSLATORS: settings option
95
2
    new SetupItemCheckBox(_("Show level"), "",
96
        "showlevel", this, "showlevelEvent",
97



24
        MainConfig_true);
98
99
    // TRANSLATORS: settings option
100
2
    new SetupItemCheckBox(_("Show own name"), "",
101
        "showownname", this, "showownnameEvent",
102



24
        MainConfig_true);
103
104
    // TRANSLATORS: settings option
105
2
    new SetupItemCheckBox(_("Enable extended mouse targeting"), "",
106
        "extMouseTargeting", this, "extMouseTargetingEvent",
107



24
        MainConfig_true);
108
109
    // TRANSLATORS: settings option
110
2
    new SetupItemCheckBox(_("Target dead players"), "",
111
        "targetDeadPlayers", this, "targetDeadPlayersEvent",
112



24
        MainConfig_true);
113
114
2
    mVisibleNamesList->fillFromArray(&visibleNamesList[0],
115
2
        visibleNamesListSize);
116
    // TRANSLATORS: settings option
117
2
    new SetupItemDropDown(_("Show player names"), "",
118
        "visiblenames", this, "visiblenamesEvent",
119
2
        mVisibleNamesList, 150,
120



26
        MainConfig_true);
121
122
2
    mVisibleNamesPosList->fillFromArray(&topDownList[0],
123
2
        topDownListSize);
124
    // TRANSLATORS: settings option
125
2
    new SetupItemDropDown(_("Show player names at"), "",
126
        "visiblenamespos", this, "visiblenamesposEvent",
127
2
        mVisibleNamesPosList, 150,
128



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



24
        MainConfig_true);
134
135
2
    mBadgesList->fillFromArray(&badgesList[0], badgesListSize);
136
    // TRANSLATORS: settings option
137
2
    new SetupItemDropDown(_("Badges"), "",
138
2
        "showBadges", this, "showBadgesEvent", mBadgesList, 150,
139



20
        MainConfig_true);
140
141
    // TRANSLATORS: settings option
142
2
    new SetupItemCheckBox(_("Secure trades"), "",
143
        "securetrades", this, "securetradesEvent",
144



24
        MainConfig_true);
145
146
    // TRANSLATORS: settings option
147
2
    new SetupItemTextField(_("Unsecure chars in names"), "",
148
        "unsecureChars", this, "unsecureCharsEvent",
149



24
        MainConfig_true, UseBase64_false);
150
151
    // TRANSLATORS: settings option
152
2
    new SetupItemCheckBox(_("Show statuses"), "",
153
        "showPlayersStatus", this, "showPlayersStatusEvent",
154



24
        MainConfig_true);
155
156
    // TRANSLATORS: settings option
157
2
    new SetupItemCheckBox(_("Show ip addresses on screenshots"), "",
158
        "showip", this, "showipEvent",
159



24
        MainConfig_true);
160
161
    // TRANSLATORS: settings option
162
2
    new SetupItemCheckBox(_("Allow self heal with mouse click"), "",
163
        "selfMouseHeal", this, "selfMouseHealEvent",
164



24
        MainConfig_true);
165
166
    // TRANSLATORS: settings option
167
2
    new SetupItemCheckBox(_("Group friends in who is online window"), "",
168
        "groupFriends", this, "groupFriendsEvent",
169



24
        MainConfig_true);
170
171
    // TRANSLATORS: settings option
172
2
    new SetupItemCheckBox(_("Hide erased players nicks"), "",
173
        "hideErased", this, "hideErasedEvent",
174



24
        MainConfig_true);
175
176
    // TRANSLATORS: settings option
177
2
    new SetupItemCheckBox(_("Collect players id and seen log"),
178
        "", "enableIdCollecting", this, "enableIdCollectingEvent",
179



24
        MainConfig_true);
180
181
    // TRANSLATORS: settings option
182
2
    new SetupItemCheckBox(_("Use special diagonal speed in players moving"),
183
        "", "useDiagonalSpeed", this, "useDiagonalSpeedEvent",
184



24
        MainConfig_true);
185
186
    // TRANSLATORS: settings option
187
2
    new SetupItemCheckBox(_("Log players actions (for GM)"),
188
        "", "logPlayerActions", this, "logPlayerActionsEvent",
189



24
        MainConfig_true);
190
191
    // TRANSLATORS: settings option
192
2
    new SetupItemCheckBox(_("Create screenshots for each complete trades"),
193
        "", "tradescreenshot", this, "tradescreenshotEvent",
194



24
        MainConfig_true);
195
196
    // TRANSLATORS: settings option
197
2
    new SetupItemCheckBox(_("Emulate right mouse button by long mouse click"
198
        " (useful for touch interfaces)"),
199
        "", "longmouseclick", this, "longmouseclickEvent",
200



24
        MainConfig_true);
201
202
    // TRANSLATORS: settings option
203
2
    new SetupItemCheckBox(_("Enable remote commands"),
204
        "", "enableRemoteCommands", this, "enableRemoteCommandsEvent",
205
        "1",
206



30
        MainConfig_false);
207
208
    // TRANSLATORS: settings option
209
2
    new SetupItemCheckBox(_("Allow move character by mouse"),
210
        "", "allowMoveByMouse", this, "allowMoveByMouseEvent",
211



26
        MainConfig_true);
212
213
2
    setDimension(Rect(0, 0, 550, 350));
214
2
}
215
216
6
Setup_Players::~Setup_Players()
217
{
218
2
    delete2(mBadgesList)
219
2
    delete2(mVisibleNamesList)
220
2
    delete2(mVisibleNamesPosList)
221
4
}
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
}