GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_misc.cpp Lines: 195 206 94.7 %
Date: 2021-03-17 Branches: 509 1032 49.3 %

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_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
2
Setup_Misc::Setup_Misc(const Widget2 *const widget) :
117
    SetupTabScroll(widget),
118

2
    mProxyTypeList(new NamesModel),
119

2
    mShortcutsList(new NamesModel),
120
#ifdef USE_SDL2
121

2
    mSdlLogList(new NamesModel),
122
#endif  // USE_SDL2
123

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


12
        Separator_true);
135
136
    // TRANSLATORS: settings option
137
2
    new SetupItemCheckBox(_("Show damage inflicted to monsters"), "",
138
        "showMonstersTakedDamage", this, "showMonstersTakedDamageEvent",
139



16
        MainConfig_true);
140
141
    // TRANSLATORS: settings option
142
2
    new SetupItemCheckBox(_("Auto target only reachable monsters"), "",
143
        "targetOnlyReachable", this, "targetOnlyReachableEvent",
144



24
        MainConfig_true);
145
146
    // TRANSLATORS: settings option
147
2
    new SetupItemCheckBox(_("Select auto target for attack skills"), "",
148
        "skillAutotarget", this, "skillAutotargetEvent",
149



24
        MainConfig_true);
150
151
    // TRANSLATORS: settings option
152
2
    new SetupItemCheckBox(_("Highlight monster attack range"), "",
153
        "highlightMonsterAttackRange", this,
154
        "highlightMonsterAttackRangeEvent",
155



24
        MainConfig_true);
156
157
    // TRANSLATORS: settings option
158
2
    new SetupItemCheckBox(_("Show monster hp bar"), "",
159
        "showMobHP", this, "showMobHPEvent",
160



24
        MainConfig_true);
161
162
    // TRANSLATORS: settings option
163
2
    new SetupItemCheckBox(_("Cycle monster targets"), "",
164
        "cycleMonsters", this, "cycleMonstersEvent",
165



24
        MainConfig_true);
166
167
168
    // TRANSLATORS: settings group
169
2
    new SetupItemLabel(_("Map"), "", this,
170


12
        Separator_true);
171
172
    // TRANSLATORS: settings option
173
2
    new SetupItemCheckBox(_("Show warps particles"), "",
174
        "warpParticle", this, "warpParticleEvent",
175



24
        MainConfig_true);
176
177
    // TRANSLATORS: settings option
178
2
    new SetupItemCheckBox(_("Highlight map portals"), "",
179
        "highlightMapPortals", this, "highlightMapPortalsEvent",
180



24
        MainConfig_true);
181
182
    // TRANSLATORS: settings option
183
2
    new SetupItemCheckBox(_("Highlight floor items"), "",
184
        "floorItemsHighlight", this, "floorItemsHighlightEvent",
185



24
        MainConfig_true);
186
187
    // TRANSLATORS: settings option
188
2
    new SetupItemCheckBox(_("Highlight player attack range"), "",
189
        "highlightAttackRange", this, "highlightAttackRangeEvent",
190



24
        MainConfig_true);
191
192
    // TRANSLATORS: settings option
193
2
    new SetupItemCheckBox(_("Show extended minimaps"), "",
194
        "showExtMinimaps", this, "showExtMinimapsEvent",
195



24
        MainConfig_true);
196
197
    // TRANSLATORS: settings option
198
2
    new SetupItemCheckBox(_("Draw path"), "", "drawPath",
199
        this, "drawPathEvent",
200



24
        MainConfig_true);
201
202
    // TRANSLATORS: settings option
203
2
    new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys",
204
        this, "drawHotKeysEvent",
205



24
        MainConfig_true);
206
207
    // TRANSLATORS: settings option
208
2
    new SetupItemCheckBox(_("Enable lazy scrolling"), "",
209
        "enableLazyScrolling", this, "enableLazyScrollingEvent",
210



24
        MainConfig_true);
211
212
    // TRANSLATORS: settings option
213
2
    new SetupItemIntTextField(_("Scroll laziness"), "", "ScrollLaziness",
214
        this, "ScrollLazinessEvent", 1, 160,
215



24
        MainConfig_true);
216
217
    // TRANSLATORS: settings option
218
2
    new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius",
219
        this, "ScrollRadiusEvent", 0, mapTileSize,
220



24
        MainConfig_true);
221
222
    // TRANSLATORS: settings option
223
2
    new SetupItemCheckBox(_("Auto resize minimaps"), "", "autoresizeminimaps",
224
        this, "autoresizeminimapsEvent",
225



24
        MainConfig_true);
226
227
    // TRANSLATORS: settings option
228
2
    new SetupItemCheckBox(_("Play map animations"), "", "playMapAnimations",
229
        this, "playMapAnimationsEvent",
230



24
        MainConfig_true);
231
232
233
    // TRANSLATORS: settings group
234
2
    new SetupItemLabel(_("Moving"), "", this,
235


12
        Separator_true);
236
237
    // TRANSLATORS: settings option
238
2
    new SetupItemCheckBox(_("Auto fix position"), "",
239
        "autofixPos", this, "autofixPosEvent",
240



24
        MainConfig_true);
241
242
    // TRANSLATORS: settings option
243
2
    new SetupItemCheckBox(_("Show server side position"), "",
244
        "showserverpos", this, "showserverposEvent",
245



24
        MainConfig_true);
246
247
    // TRANSLATORS: settings option
248
2
    new SetupItemCheckBox(_("Attack while moving"), "",
249
        "attackMoving", this, "attackMovingEvent",
250



24
        MainConfig_true);
251
252
    // TRANSLATORS: settings option
253
2
    new SetupItemCheckBox(_("Attack next target"), "",
254
        "attackNext", this, "attackNextEvent",
255



24
        MainConfig_true);
256
257
    // TRANSLATORS: settings option
258
2
    new SetupItemCheckBox(_("Sync player move"), "", "syncPlayerMove",
259
        this, "syncPlayerMoveEvent",
260



24
        MainConfig_true);
261
262
    // TRANSLATORS: settings option
263
2
    new SetupItemIntTextField(_("Sync player move distance"), "",
264
        "syncPlayerMoveDistance",
265
        this, "syncPlayerMoveDistanceEvent", 1, 30,
266



24
        MainConfig_true);
267
268
    // TRANSLATORS: settings option
269
2
    new SetupItemIntTextField(_("Sync player move distance on legacy servers"),
270
        "",
271
        "syncPlayerMoveDistanceLegacy",
272
        this, "syncPlayerMoveDistanceLegacyEvent", 1, 30,
273



24
        MainConfig_true);
274
275
    // TRANSLATORS: settings option
276
2
    new SetupItemTextField(_("Crazy move A program"), "",
277
        "crazyMoveProgram", this, "crazyMoveProgramEvent",
278



24
        MainConfig_true, UseBase64_false);
279
280
    // TRANSLATORS: settings option
281
2
    new SetupItemCheckBox(_("Mouse relative moves "
282
        "(good for touch interfaces)"), "", "mouseDirectionMove",
283
        this, "mouseDirectionMoveEvent",
284



24
        MainConfig_true);
285
286
    // TRANSLATORS: settings group
287
2
    new SetupItemLabel(_("Player"), "", this,
288


12
        Separator_true);
289
290
    // TRANSLATORS: settings option
291
2
    new SetupItemCheckBox(_("Show own hp bar"), "",
292
        "showOwnHP", this, "showOwnHPEvent",
293



24
        MainConfig_true);
294
295
    // TRANSLATORS: settings option
296
2
    new SetupItemCheckBox(_("Enable quick stats"), "",
297
        "quickStats", this, "quickStatsEvent",
298



24
        MainConfig_true);
299
300
    // TRANSLATORS: settings option
301
2
    new SetupItemCheckBox(_("Cycle player targets"), "",
302
        "cyclePlayers", this, "cyclePlayersEvent",
303



24
        MainConfig_true);
304
305
    // TRANSLATORS: settings option
306
2
    new SetupItemCheckBox(_("Show job exp messages"), "",
307
        "showJobExp", this, "showJobExpEvent",
308



24
        MainConfig_true);
309
310
    // TRANSLATORS: settings option
311
2
    new SetupItemCheckBox(_("Show players popups"), "",
312
        "showBeingPopup", this, "showBeingPopupEvent",
313



24
        MainConfig_true);
314
315
    // TRANSLATORS: settings option
316
2
    new SetupItemTextField(_("Afk message"), "",
317
        "afkMessage", this, "afkMessageEvent",
318



24
        MainConfig_false, UseBase64_false);
319
320
    // TRANSLATORS: settings option
321
2
    new SetupItemCheckBox(_("Show job"), "", "showJob",
322
        this, "showJobEvent",
323



24
        MainConfig_false);
324
325
    // TRANSLATORS: settings option
326
2
    new SetupItemCheckBox(_("Enable attack filter"), "",
327
        "enableAttackFilter", this, "enableAttackFilterEvent",
328



24
        MainConfig_true);
329
330
    // TRANSLATORS: settings option
331
2
    new SetupItemCheckBox(_("Enable pickup filter"), "",
332
        "enablePickupFilter", this, "enablePickupFilterEvent",
333



24
        MainConfig_true);
334
335
    // TRANSLATORS: settings option
336
2
    new SetupItemCheckBox(_("Enable advert protocol"), "",
337
        "enableAdvert", this, "enableAdvertEvent",
338



24
        MainConfig_true);
339
340
    // TRANSLATORS: settings option
341
2
    new SetupItemCheckBox(_("Enabled pets support"),
342
        "", "usepets", this, "usepetsEvent",
343



24
        MainConfig_true);
344
345
    // TRANSLATORS: settings option
346
2
    new SetupItemCheckBox(_("Enable weight notifications"), "",
347
        "weightMsg", this, "weightMsgEvent",
348



24
        MainConfig_true);
349
350
    // TRANSLATORS: settings group
351
2
    new SetupItemLabel(_("Shop"), "", this,
352


12
        Separator_true);
353
354
    // TRANSLATORS: settings option
355
2
    new SetupItemCheckBox(_("Accept sell/buy requests"), "",
356
        "autoShop", this, "autoShopEvent",
357



24
        MainConfig_true);
358
359
    // TRANSLATORS: settings option
360
2
    new SetupItemCheckBox(_("Enable shop mode"), "",
361
        "tradebot", this, "tradebotEvent",
362



24
        MainConfig_true);
363
364
365
    // TRANSLATORS: settings group
366
2
    new SetupItemLabel(_("NPC"), "", this,
367


12
        Separator_true);
368
369
    // TRANSLATORS: settings option
370
2
    new SetupItemCheckBox(_("Cycle npc targets"), "",
371
        "cycleNPC", this, "cycleNPCEvent",
372



24
        MainConfig_true);
373
374
    // TRANSLATORS: settings option
375
2
    new SetupItemCheckBox(_("Log NPC dialogue"), "", "logNpcInGui",
376
        this, "logNpcInGuiEvent",
377



24
        MainConfig_true);
378
379
380
    // TRANSLATORS: settings group
381
2
    new SetupItemLabel(_("Bots support"), "", this,
382


12
        Separator_true);
383
384
    // TRANSLATORS: settings option
385
2
    new SetupItemCheckBox(_("Enable guild bot support and disable native "
386
        "guild support"), "", "enableGuildBot", this,
387
        "enableGuildBotEvent",
388
        "0",
389



30
        MainConfig_false);
390
391
    // TRANSLATORS: settings option
392
2
    new SetupItemCheckBox(_("Enable manamarket bot support"),
393
        "", "enableManaMarketBot", this,
394
        "enableManaMarketBotEvent",
395
        "0",
396



30
        MainConfig_false);
397
398
399
    // TRANSLATORS: settings group
400
2
    new SetupItemLabel(_("Keyboard"), "", this,
401


12
        Separator_true);
402
403
    // TRANSLATORS: settings option
404
2
    new SetupItemIntTextField(_("Repeat delay"), "",
405
        "repeateDelay", this, "repeateDelayEvent", 0, 10000,
406



24
        MainConfig_true);
407
408
    // TRANSLATORS: settings option
409
2
    new SetupItemIntTextField(_("Repeat interval"), "",
410
        "repeateInterval", this, "repeateIntervalEvent", 0, 10000,
411



24
        MainConfig_true);
412
413
    // TRANSLATORS: settings option
414
2
    new SetupItemIntTextField(_("Custom repeat interval"), "",
415
        "repeateInterval2", this, "repeateInterval2Event", 0, 10000,
416



24
        MainConfig_true);
417
418
#ifdef USE_SDL2
419
    // TRANSLATORS: settings option
420
2
    new SetupItemCheckBox(_("Enable alt-tab workaround"), "",
421
        "blockAltTab", this, "blockAltTabEvent",
422



24
        MainConfig_true);
423
#endif  // USE_SDL2
424
425
426
    // TRANSLATORS: settings group
427
2
    new SetupItemLabel(_("Windows"), "", this,
428


12
        Separator_true);
429
430
2
    mShortcutsList->fillFromArray(&shortcutsList[0], shortcutsListSize);
431
    // TRANSLATORS: settings option
432
2
    new SetupItemDropDown(_("Shortcut buttons"), "", "autohideButtons", this,
433
2
        "autohideButtonsEvent", mShortcutsList, 200,
434



26
        MainConfig_true);
435
436
    // TRANSLATORS: settings option
437
2
    new SetupItemCheckBox(_("Show icons on shortcut buttons"), "",
438
        "showButtonIcons", this, "showButtonIconsEvent",
439



24
        MainConfig_true);
440
441
442
    // TRANSLATORS: settings group
443
2
    new SetupItemLabel(_("Proxy server"), "", this,
444


12
        Separator_true);
445
446
2
    mProxyTypeList->fillFromArray(&proxyTypeList[0], proxyTypeListSize);
447
    // TRANSLATORS: settings option
448
2
    new SetupItemDropDown(_("Proxy type"), "", "downloadProxyType", this,
449
2
        "downloadProxyTypeEvent", mProxyTypeList, 200,
450



26
        MainConfig_true);
451
452
    // TRANSLATORS: settings option
453
2
    new SetupItemTextField(_("Proxy address:port"), "",
454
        "downloadProxy", this, "downloadProxyEvent",
455



24
        MainConfig_true, UseBase64_false);
456
457
    // TRANSLATORS: settings option
458
2
    new SetupItemCheckBox(_("Tunnel through HTTP proxy"), "",
459
        "downloadProxyTunnel", this, "downloadProxyTunnelEvent",
460



24
        MainConfig_true);
461
462
463
    // TRANSLATORS: settings group
464
2
    new SetupItemLabel(_("Logging"), "", this,
465


12
        Separator_true);
466
467
    // TRANSLATORS: settings option
468
2
    new SetupItemCheckBox(_("Enable OpenGL version check "
469
        "(do not disable)"), "", "checkOpenGLVersion", this,
470
        "checkOpenGLVersionEvent",
471



24
        MainConfig_true);
472
473
    // TRANSLATORS: settings option
474
2
    new SetupItemCheckBox(_("Enable debug log"), "",
475
        "debugLog", this, "debugLogEvent",
476



24
        MainConfig_true);
477
478
    // TRANSLATORS: settings option
479
2
    new SetupItemTextField(_("Ignore logging packets"), "",
480
        "ignorelogpackets", this, "ignorelogpacketsEvent",
481



24
        MainConfig_true, UseBase64_false);
482
483
    // TRANSLATORS: settings option
484
2
    new SetupItemCheckBox(_("Log unimplemented packets"), "",
485
        "unimplimentedLog", this, "unimplimentedLogEvent",
486



24
        MainConfig_true);
487
488
    // TRANSLATORS: settings option
489
2
    new SetupItemCheckBox(_("Enable OpenGL log"), "",
490
        "debugOpenGL", this, "debugOpenGLEvent",
491



24
        MainConfig_true);
492
493
    // TRANSLATORS: settings option
494
2
    new SetupItemCheckBox(_("Enable input log"), "",
495
        "logInput", this, "logInputEvent",
496



24
        MainConfig_true);
497
498
#ifdef USE_SDL2
499
2
    mSdlLogList->fillFromArray(&sdlLogList[0], sdlLogListSize);
500
    // TRANSLATORS: settings option
501
2
    new SetupItemDropDown(_("SDL logging level"), "",
502
2
        "sdlLogLevel", this, "sdlLogLevelEvent", mSdlLogList, 100,
503



26
        MainConfig_true);
504
#endif  // USE_SDL2
505
506
    // TRANSLATORS: settings option
507
2
    new SetupButtonItem(_("Upload log file"), "", "upload",
508



24
        this, "uploadLog", &uploadListener);
509
510
511
    // TRANSLATORS: settings group
512
2
    new SetupItemLabel(_("Other"), "", this,
513


12
        Separator_true);
514
515
    // TRANSLATORS: settings option
516
2
    new SetupItemCheckBox(_("Enable server side attack"), "",
517
        "serverAttack", this, "serverAttackEvent",
518



24
        MainConfig_true);
519
520
    // TRANSLATORS: settings option
521
2
    new SetupItemCheckBox(_("Hide support page link on error"), "",
522
        "hidesupport", this, "hidesupportEvent",
523



24
        MainConfig_true);
524
525
    // TRANSLATORS: settings option
526
2
    new SetupItemCheckBox(_("Enable double clicks"), "",
527
        "doubleClick", this, "doubleClickEvent",
528



24
        MainConfig_true);
529
530
    // TRANSLATORS: settings option
531
2
    new SetupItemCheckBox(_("Enable bot checker"), "",
532
        "enableBotCheker", this, "enableBotChekerEvent",
533



24
        MainConfig_true);
534
535
    // TRANSLATORS: settings option
536
2
    new SetupItemCheckBox(_("Enable buggy servers protection "
537
        "(do not disable)"), "", "enableBuggyServers", this,
538
        "enableBuggyServersEvent",
539



24
        MainConfig_false);
540
541
    // TRANSLATORS: settings option
542
2
    new SetupItemCheckBox(_("Low traffic mode"), "", "lowTraffic",
543
        this, "lowTrafficEvent",
544



24
        MainConfig_true);
545
546
#ifndef ANDROID
547
    // TRANSLATORS: settings option
548
2
    new SetupItemCheckBox(_("Use FBO for screenshots (only for opengl)"),
549
        "", "usefbo", this, "usefboEvent",
550



24
        MainConfig_true);
551
#endif  // ANDROID
552
553
#ifndef WIN32
554
    // TRANSLATORS: settings option
555
2
    new SetupItemTextField(_("Screenshot directory"), "",
556
        "screenshotDirectory3", this, "screenshotDirectory3Event",
557
        MainConfig_true,
558



16
        UseBase64_true);
559
#endif  // WIN32
560
561
    // TRANSLATORS: settings option
562
2
    new SetupItemIntTextField(_("Network delay between sub servers"),
563
        "", "networksleep", this, "networksleepEvent", 0, 10000,
564



24
        MainConfig_true);
565
566
    // TRANSLATORS: settings option
567
2
    new SetupItemCheckBox(_("Show background"), "", "showBackground",
568
        this, "showBackgroundEvent",
569



24
        MainConfig_true);
570
571
2
    mDensityList->fillFromArray(&densityList[0], densityListSize);
572
    // TRANSLATORS: settings option
573
2
    new SetupItemDropDown(_("Screen density override"), "",
574
2
        "screenDensity", this, "screenDensityEvent", mDensityList, 100,
575



28
        MainConfig_true);
576
577
2
    setDimension(Rect(0, 0, 550, 350));
578
2
}
579
580
6
Setup_Misc::~Setup_Misc()
581
{
582
2
    delete2(mProxyTypeList)
583
2
    delete2(mShortcutsList)
584
2
    delete2(mDensityList)
585
#ifdef USE_SDL2
586
2
    delete2(mSdlLogList)
587
#endif  // USE_SDL2
588
4
}
589
590
void Setup_Misc::apply()
591
{
592
    SetupTabScroll::apply();
593
594
    logger->setDebugLog(config.getBoolValue("debugLog"));
595
    logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog"));
596
    Net::loadIgnorePackets();
597
}
598
599
void Setup_Misc::externalUpdated()
600
{
601
    reread("showJob");
602
    reread("enableGuildBot");
603
    reread("enableManaMarketBot");
604
    reread("enableBuggyServers");
605
    reread("afkMessage");
606
}