GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_misc.cpp Lines: 168 179 93.9 %
Date: 2017-11-29 Branches: 481 990 48.6 %

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_misc.h"
24
25
#include "configuration.h"
26
27
#include "const/resources/map/map.h"
28
29
#include "gui/models/namesmodel.h"
30
31
#include "gui/widgets/containerplacer.h"
32
#include "gui/widgets/layouthelper.h"
33
#include "gui/widgets/setupbuttonitem.h"
34
#include "gui/widgets/scrollarea.h"
35
36
#include "listeners/uploadlistener.h"
37
38
#include "net/net.h"
39
40
#include "utils/delete2.h"
41
#include "utils/gettext.h"
42
43
#include "debug.h"
44
45
static const int shortcutsListSize = 3;
46
47
static const char *const shortcutsList[] =
48
{
49
    // TRANSLATORS: show buttons at top right corner type
50
    N_("Always show"),
51
    // TRANSLATORS: show buttons at top right corner type
52
    N_("Auto hide in small resolution"),
53
    // TRANSLATORS: show buttons at top right corner type
54
    N_("Always auto hide")
55
};
56
57
static const int proxyTypeListSize = 8;
58
59
static const char *const proxyTypeList[] =
60
{
61
    // TRANSLATORS: Proxy type selection
62
    N_("System proxy"),
63
    // TRANSLATORS: Proxy type selection
64
    N_("Direct connection"),
65
    "HTTP",
66
    "HTTP 1.0",
67
    "SOCKS4",
68
    "SOCKS4A",
69
    "SOCKS5",
70
    // TRANSLATORS: Proxy type selection
71
    N_("SOCKS5 hostname")
72
};
73
74
static const int densityListSize = 7;
75
76
static const char *const densityList[] =
77
{
78
    // TRANSLATORS: screen density type
79
    N_("default"),
80
    // TRANSLATORS: screen density type
81
    N_("low"),
82
    // TRANSLATORS: screen density type
83
    N_("medium"),
84
    // TRANSLATORS: screen density type
85
    N_("tv"),
86
    // TRANSLATORS: screen density type
87
    N_("high"),
88
    // TRANSLATORS: screen density type
89
    N_("xhigh"),
90
    // TRANSLATORS: screen density type
91
    N_("xxhigh")
92
};
93
94
#ifdef USE_SDL2
95
static const int sdlLogListSize = 7;
96
97
static const char *const sdlLogList[] =
98
{
99
    // TRANSLATORS: sdl2 log level
100
    N_("default"),
101
    // TRANSLATORS: sdl2 log level
102
    N_("verbose"),
103
    // TRANSLATORS: sdl2 log level
104
    N_("debug"),
105
    // TRANSLATORS: sdl2 log level
106
    N_("info"),
107
    // TRANSLATORS: sdl2 log level
108
    N_("warn"),
109
    // TRANSLATORS: sdl2 log level
110
    N_("error"),
111
    // TRANSLATORS: sdl2 log level
112
    N_("critical")
113
};
114
#endif  // USE_SDL2
115
116
4
Setup_Misc::Setup_Misc(const Widget2 *const widget) :
117
    SetupTabScroll(widget),
118

4
    mProxyTypeList(new NamesModel),
119

4
    mShortcutsList(new NamesModel),
120
#ifdef USE_SDL2
121
    mSdlLogList(new NamesModel),
122
#endif  // USE_SDL2
123

12
    mDensityList(new NamesModel)
124
{
125
    // TRANSLATORS: misc tab in settings
126
20
    setName(_("Misc"));
127
128
8
    LayoutHelper h(this);
129
4
    ContainerPlacer place = h.getPlacer(0, 0);
130
4
    place(0, 0, mScroll, 10, 10);
131
132
    // TRANSLATORS: settings option
133


28
    new SetupItemLabel(_("Monsters"), "", this);
134
135
    // TRANSLATORS: settings option
136


52
    new SetupItemCheckBox(_("Show damage inflicted to monsters"), "",
137

4
        "showMonstersTakedDamage", this, "showMonstersTakedDamageEvent");
138
139
    // TRANSLATORS: settings option
140


52
    new SetupItemCheckBox(_("Auto target only reachable monsters"), "",
141

4
        "targetOnlyReachable", this, "targetOnlyReachableEvent");
142
143
    // TRANSLATORS: settings option
144


52
    new SetupItemCheckBox(_("Select auto target for attack skills"), "",
145

4
        "skillAutotarget", this, "skillAutotargetEvent");
146
147
    // TRANSLATORS: settings option
148


52
    new SetupItemCheckBox(_("Highlight monster attack range"), "",
149
        "highlightMonsterAttackRange", this,
150

4
        "highlightMonsterAttackRangeEvent");
151
152
    // TRANSLATORS: settings option
153


52
    new SetupItemCheckBox(_("Show monster hp bar"), "",
154

4
        "showMobHP", this, "showMobHPEvent");
155
156
    // TRANSLATORS: settings option
157


52
    new SetupItemCheckBox(_("Cycle monster targets"), "",
158

4
        "cycleMonsters", this, "cycleMonstersEvent");
159
160
161
    // TRANSLATORS: settings group
162


28
    new SetupItemLabel(_("Map"), "", this);
163
164
    // TRANSLATORS: settings option
165


52
    new SetupItemCheckBox(_("Show warps particles"), "",
166

4
        "warpParticle", this, "warpParticleEvent");
167
168
    // TRANSLATORS: settings option
169


52
    new SetupItemCheckBox(_("Highlight map portals"), "",
170

4
        "highlightMapPortals", this, "highlightMapPortalsEvent");
171
172
    // TRANSLATORS: settings option
173


52
    new SetupItemCheckBox(_("Highlight floor items"), "",
174

4
        "floorItemsHighlight", this, "floorItemsHighlightEvent");
175
176
    // TRANSLATORS: settings option
177


52
    new SetupItemCheckBox(_("Highlight player attack range"), "",
178

4
        "highlightAttackRange", this, "highlightAttackRangeEvent");
179
180
    // TRANSLATORS: settings option
181


52
    new SetupItemCheckBox(_("Show extended minimaps"), "",
182

4
        "showExtMinimaps", this, "showExtMinimapsEvent");
183
184
    // TRANSLATORS: settings option
185


52
    new SetupItemCheckBox(_("Draw path"), "", "drawPath",
186

4
        this, "drawPathEvent");
187
188
    // TRANSLATORS: settings option
189


52
    new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys",
190

4
        this, "drawHotKeysEvent");
191
192
    // TRANSLATORS: settings option
193


52
    new SetupItemCheckBox(_("Enable lazy scrolling"), "",
194

4
        "enableLazyScrolling", this, "enableLazyScrollingEvent");
195
196
    // TRANSLATORS: settings option
197


52
    new SetupItemIntTextField(_("Scroll laziness"), "", "ScrollLaziness",
198

4
        this, "ScrollLazinessEvent", 1, 160);
199
200
    // TRANSLATORS: settings option
201


52
    new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius",
202

4
        this, "ScrollRadiusEvent", 0, mapTileSize);
203
204
    // TRANSLATORS: settings option
205


52
    new SetupItemCheckBox(_("Auto resize minimaps"), "", "autoresizeminimaps",
206

4
        this, "autoresizeminimapsEvent");
207
208
    // TRANSLATORS: settings option
209


52
    new SetupItemCheckBox(_("Play map animations"), "", "playMapAnimations",
210

4
        this, "playMapAnimationsEvent");
211
212
213
    // TRANSLATORS: settings group
214


28
    new SetupItemLabel(_("Moving"), "", this);
215
216
    // TRANSLATORS: settings option
217


52
    new SetupItemCheckBox(_("Auto fix position"), "",
218

4
        "autofixPos", this, "autofixPosEvent");
219
220
    // TRANSLATORS: settings option
221


52
    new SetupItemCheckBox(_("Show server side position"), "",
222

4
        "showserverpos", this, "showserverposEvent");
223
224
    // TRANSLATORS: settings option
225


52
    new SetupItemCheckBox(_("Attack while moving"), "",
226

4
        "attackMoving", this, "attackMovingEvent");
227
228
    // TRANSLATORS: settings option
229


52
    new SetupItemCheckBox(_("Attack next target"), "",
230

4
        "attackNext", this, "attackNextEvent");
231
232
    // TRANSLATORS: settings option
233


52
    new SetupItemCheckBox(_("Sync player move"), "", "syncPlayerMove",
234

4
        this, "syncPlayerMoveEvent");
235
236
    // TRANSLATORS: settings option
237


52
    new SetupItemIntTextField(_("Sync player move distance"), "",
238
        "syncPlayerMoveDistance",
239

4
        this, "syncPlayerMoveDistanceEvent", 1, 30);
240
241
    // TRANSLATORS: settings option
242


52
    new SetupItemTextField(_("Crazy move A program"), "",
243

4
        "crazyMoveProgram", this, "crazyMoveProgramEvent");
244
245
    // TRANSLATORS: settings option
246


52
    new SetupItemCheckBox(_("Mouse relative moves "
247
        "(good for touch interfaces)"), "", "mouseDirectionMove",
248

4
        this, "mouseDirectionMoveEvent");
249
250
    // TRANSLATORS: settings group
251


28
    new SetupItemLabel(_("Player"), "", this);
252
253
    // TRANSLATORS: settings option
254


52
    new SetupItemCheckBox(_("Show own hp bar"), "",
255

4
        "showOwnHP", this, "showOwnHPEvent");
256
257
    // TRANSLATORS: settings option
258


52
    new SetupItemCheckBox(_("Enable quick stats"), "",
259

4
        "quickStats", this, "quickStatsEvent");
260
261
    // TRANSLATORS: settings option
262


52
    new SetupItemCheckBox(_("Cycle player targets"), "",
263

4
        "cyclePlayers", this, "cyclePlayersEvent");
264
265
    // TRANSLATORS: settings option
266


52
    new SetupItemCheckBox(_("Show job exp messages"), "",
267

4
        "showJobExp", this, "showJobExpEvent");
268
269
    // TRANSLATORS: settings option
270


52
    new SetupItemCheckBox(_("Show players popups"), "",
271

4
        "showBeingPopup", this, "showBeingPopupEvent");
272
273
    // TRANSLATORS: settings option
274


52
    new SetupItemTextField(_("Afk message"), "",
275
        "afkMessage", this, "afkMessageEvent",
276

4
        MainConfig_false);
277
278
    // TRANSLATORS: settings option
279


52
    new SetupItemCheckBox(_("Show job"), "", "showJob",
280
        this, "showJobEvent",
281

4
        MainConfig_false);
282
283
    // TRANSLATORS: settings option
284


52
    new SetupItemCheckBox(_("Enable attack filter"), "",
285

4
        "enableAttackFilter", this, "enableAttackFilterEvent");
286
287
    // TRANSLATORS: settings option
288


52
    new SetupItemCheckBox(_("Enable pickup filter"), "",
289

4
        "enablePickupFilter", this, "enablePickupFilterEvent");
290
291
    // TRANSLATORS: settings option
292


52
    new SetupItemCheckBox(_("Enable advert protocol"), "",
293

4
        "enableAdvert", this, "enableAdvertEvent");
294
295
    // TRANSLATORS: settings option
296


52
    new SetupItemCheckBox(_("Enabled pets support"),
297

4
        "", "usepets", this, "usepetsEvent");
298
299
    // TRANSLATORS: settings option
300


52
    new SetupItemCheckBox(_("Enable weight notifications"), "",
301

4
        "weightMsg", this, "weightMsgEvent");
302
303
    // TRANSLATORS: settings group
304


28
    new SetupItemLabel(_("Shop"), "", this);
305
306
    // TRANSLATORS: settings option
307


52
    new SetupItemCheckBox(_("Accept sell/buy requests"), "",
308

4
        "autoShop", this, "autoShopEvent");
309
310
    // TRANSLATORS: settings option
311


52
    new SetupItemCheckBox(_("Enable shop mode"), "",
312

4
        "tradebot", this, "tradebotEvent");
313
314
315
    // TRANSLATORS: settings group
316


28
    new SetupItemLabel(_("NPC"), "", this);
317
318
    // TRANSLATORS: settings option
319


52
    new SetupItemCheckBox(_("Cycle npc targets"), "",
320

4
        "cycleNPC", this, "cycleNPCEvent");
321
322
    // TRANSLATORS: settings option
323


52
    new SetupItemCheckBox(_("Log NPC dialogue"), "", "logNpcInGui",
324

4
        this, "logNpcInGuiEvent");
325
326
327
    // TRANSLATORS: settings group
328


28
    new SetupItemLabel(_("Bots support"), "", this);
329
330
    // TRANSLATORS: settings option
331


64
    new SetupItemCheckBox(_("Enable guild bot support and disable native "
332
        "guild support"), "", "enableGuildBot", this,
333
        "enableGuildBotEvent",
334
        "0",
335

4
        MainConfig_false);
336
337
    // TRANSLATORS: settings option
338


64
    new SetupItemCheckBox(_("Enable manamarket bot support"),
339
        "", "enableManaMarketBot", this,
340
        "enableManaMarketBotEvent",
341
        "0",
342

4
        MainConfig_false);
343
344
345
    // TRANSLATORS: settings group
346


28
    new SetupItemLabel(_("Keyboard"), "", this);
347
348
    // TRANSLATORS: settings option
349


52
    new SetupItemIntTextField(_("Repeat delay"), "",
350

4
        "repeateDelay", this, "repeateDelayEvent", 0, 10000);
351
352
    // TRANSLATORS: settings option
353


52
    new SetupItemIntTextField(_("Repeat interval"), "",
354

4
        "repeateInterval", this, "repeateIntervalEvent", 0, 10000);
355
356
    // TRANSLATORS: settings option
357


52
    new SetupItemIntTextField(_("Custom repeat interval"), "",
358

4
        "repeateInterval2", this, "repeateInterval2Event", 0, 10000);
359
360
#ifdef USE_SDL2
361
    // TRANSLATORS: settings option
362
    new SetupItemCheckBox(_("Enable alt-tab workaround"), "",
363
        "blockAltTab", this, "blockAltTabEvent");
364
#endif  // USE_SDL2
365
366
367
    // TRANSLATORS: settings group
368


28
    new SetupItemLabel(_("Windows"), "", this);
369
370
4
    mShortcutsList->fillFromArray(&shortcutsList[0], shortcutsListSize);
371
    // TRANSLATORS: settings option
372


52
    new SetupItemDropDown(_("Shortcut buttons"), "", "autohideButtons", this,
373

4
        "autohideButtonsEvent", mShortcutsList, 200);
374
375
376
    // TRANSLATORS: settings group
377


28
    new SetupItemLabel(_("Proxy server"), "", this);
378
379
4
    mProxyTypeList->fillFromArray(&proxyTypeList[0], proxyTypeListSize);
380
    // TRANSLATORS: settings option
381


52
    new SetupItemDropDown(_("Proxy type"), "", "downloadProxyType", this,
382

4
        "downloadProxyTypeEvent", mProxyTypeList, 200);
383
384
    // TRANSLATORS: settings option
385


52
    new SetupItemTextField(_("Proxy address:port"), "",
386

4
        "downloadProxy", this, "downloadProxyEvent");
387
388
    // TRANSLATORS: settings option
389


52
    new SetupItemCheckBox(_("Tunnel through HTTP proxy"), "",
390

4
        "downloadProxyTunnel", this, "downloadProxyTunnelEvent");
391
392
393
    // TRANSLATORS: settings group
394


28
    new SetupItemLabel(_("Logging"), "", this);
395
396
    // TRANSLATORS: settings option
397


52
    new SetupItemCheckBox(_("Enable OpenGL version check "
398
        "(do not disable)"), "", "checkOpenGLVersion", this,
399

4
        "checkOpenGLVersionEvent");
400
401
    // TRANSLATORS: settings option
402


52
    new SetupItemCheckBox(_("Enable debug log"), "",
403

4
        "debugLog", this, "debugLogEvent");
404
405
    // TRANSLATORS: settings option
406


52
    new SetupItemTextField(_("Ignore logging packets"), "",
407

4
        "ignorelogpackets", this, "ignorelogpacketsEvent");
408
409
    // TRANSLATORS: settings option
410


52
    new SetupItemCheckBox(_("Log unimplemented packets"), "",
411

4
        "unimplimentedLog", this, "unimplimentedLogEvent");
412
413
    // TRANSLATORS: settings option
414


52
    new SetupItemCheckBox(_("Enable OpenGL log"), "",
415

4
        "debugOpenGL", this, "debugOpenGLEvent");
416
417
    // TRANSLATORS: settings option
418


52
    new SetupItemCheckBox(_("Enable input log"), "",
419

4
        "logInput", this, "logInputEvent");
420
421
#ifdef USE_SDL2
422
    mSdlLogList->fillFromArray(&sdlLogList[0], sdlLogListSize);
423
    // TRANSLATORS: settings option
424
    new SetupItemDropDown(_("SDL logging level"), "",
425
        "sdlLogLevel", this, "sdlLogLevelEvent", mSdlLogList, 100);
426
#endif  // USE_SDL2
427
428
    // TRANSLATORS: settings option
429


52
    new SetupButtonItem(_("Upload log file"), "", "upload",
430

4
        this, "uploadLog", &uploadListener);
431
432
433
    // TRANSLATORS: settings group
434


28
    new SetupItemLabel(_("Other"), "", this);
435
436
    // TRANSLATORS: settings option
437


52
    new SetupItemCheckBox(_("Enable server side attack"), "",
438

4
        "serverAttack", this, "serverAttackEvent");
439
440
    // TRANSLATORS: settings option
441


52
    new SetupItemCheckBox(_("Hide support page link on error"), "",
442

4
        "hidesupport", this, "hidesupportEvent");
443
444
    // TRANSLATORS: settings option
445


52
    new SetupItemCheckBox(_("Enable double clicks"), "",
446

4
        "doubleClick", this, "doubleClickEvent");
447
448
    // TRANSLATORS: settings option
449


52
    new SetupItemCheckBox(_("Enable bot checker"), "",
450

4
        "enableBotCheker", this, "enableBotChekerEvent");
451
452
    // TRANSLATORS: settings option
453


52
    new SetupItemCheckBox(_("Enable buggy servers protection "
454
        "(do not disable)"), "", "enableBuggyServers", this,
455
        "enableBuggyServersEvent",
456

4
        MainConfig_false);
457
458
    // TRANSLATORS: settings option
459


52
    new SetupItemCheckBox(_("Low traffic mode"), "", "lowTraffic",
460

4
        this, "lowTrafficEvent");
461
462
#ifndef ANDROID
463
    // TRANSLATORS: settings option
464


52
    new SetupItemCheckBox(_("Use FBO for screenshots (only for opengl)"),
465

4
        "", "usefbo", this, "usefboEvent");
466
#endif  // ANDROID
467
468
#ifndef WIN32
469
    // TRANSLATORS: settings option
470


52
    new SetupItemTextField(_("Screenshot directory"), "",
471
        "screenshotDirectory3", this, "screenshotDirectory3Event",
472
        MainConfig_true,
473

4
        UseBase64_true);
474
#endif  // WIN32
475
476
    // TRANSLATORS: settings option
477


52
    new SetupItemIntTextField(_("Network delay between sub servers"),
478

4
        "", "networksleep", this, "networksleepEvent", 0, 10000);
479
480
    // TRANSLATORS: settings option
481


52
    new SetupItemCheckBox(_("Show background"), "", "showBackground",
482

4
        this, "showBackgroundEvent");
483
484
4
    mDensityList->fillFromArray(&densityList[0], densityListSize);
485
    // TRANSLATORS: settings option
486


52
    new SetupItemDropDown(_("Screen density override"), "",
487

4
        "screenDensity", this, "screenDensityEvent", mDensityList, 100);
488
489
8
    setDimension(Rect(0, 0, 550, 350));
490
4
}
491
492
12
Setup_Misc::~Setup_Misc()
493
{
494
4
    delete2(mProxyTypeList);
495
4
    delete2(mShortcutsList);
496
4
    delete2(mDensityList);
497
#ifdef USE_SDL2
498
    delete2(mSdlLogList);
499
#endif  // USE_SDL2
500
8
}
501
502
void Setup_Misc::apply()
503
{
504
    SetupTabScroll::apply();
505
506
    logger->setDebugLog(config.getBoolValue("debugLog"));
507
    logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog"));
508
    Net::loadIgnorePackets();
509
}
510
511
void Setup_Misc::externalUpdated()
512
{
513
    reread("showJob");
514
    reread("enableGuildBot");
515
    reread("enableManaMarketBot");
516
    reread("enableBuggyServers");
517
    reread("afkMessage");
518
}