GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_misc.cpp Lines: 183 194 94.3 %
Date: 2018-05-19 03:07:18 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-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_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

4
        Separator_true);
135
136
    // TRANSLATORS: settings option
137


52
    new SetupItemCheckBox(_("Show damage inflicted to monsters"), "",
138
        "showMonstersTakedDamage", this, "showMonstersTakedDamageEvent",
139

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


52
    new SetupItemCheckBox(_("Auto target only reachable monsters"), "",
143
        "targetOnlyReachable", this, "targetOnlyReachableEvent",
144

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


52
    new SetupItemCheckBox(_("Select auto target for attack skills"), "",
148
        "skillAutotarget", this, "skillAutotargetEvent",
149

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


52
    new SetupItemCheckBox(_("Highlight monster attack range"), "",
153
        "highlightMonsterAttackRange", this,
154
        "highlightMonsterAttackRangeEvent",
155

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


52
    new SetupItemCheckBox(_("Show monster hp bar"), "",
159
        "showMobHP", this, "showMobHPEvent",
160

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


52
    new SetupItemCheckBox(_("Cycle monster targets"), "",
164
        "cycleMonsters", this, "cycleMonstersEvent",
165

4
        MainConfig_true);
166
167
168
    // TRANSLATORS: settings group
169

28
    new SetupItemLabel(_("Map"), "", this,
170

4
        Separator_true);
171
172
    // TRANSLATORS: settings option
173


52
    new SetupItemCheckBox(_("Show warps particles"), "",
174
        "warpParticle", this, "warpParticleEvent",
175

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


52
    new SetupItemCheckBox(_("Highlight map portals"), "",
179
        "highlightMapPortals", this, "highlightMapPortalsEvent",
180

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


52
    new SetupItemCheckBox(_("Highlight floor items"), "",
184
        "floorItemsHighlight", this, "floorItemsHighlightEvent",
185

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


52
    new SetupItemCheckBox(_("Highlight player attack range"), "",
189
        "highlightAttackRange", this, "highlightAttackRangeEvent",
190

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


52
    new SetupItemCheckBox(_("Show extended minimaps"), "",
194
        "showExtMinimaps", this, "showExtMinimapsEvent",
195

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


52
    new SetupItemCheckBox(_("Draw path"), "", "drawPath",
199
        this, "drawPathEvent",
200

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


52
    new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys",
204
        this, "drawHotKeysEvent",
205

4
        MainConfig_true);
206
207
    // TRANSLATORS: settings option
208


52
    new SetupItemCheckBox(_("Enable lazy scrolling"), "",
209
        "enableLazyScrolling", this, "enableLazyScrollingEvent",
210

4
        MainConfig_true);
211
212
    // TRANSLATORS: settings option
213


52
    new SetupItemIntTextField(_("Scroll laziness"), "", "ScrollLaziness",
214
        this, "ScrollLazinessEvent", 1, 160,
215

4
        MainConfig_true);
216
217
    // TRANSLATORS: settings option
218


52
    new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius",
219
        this, "ScrollRadiusEvent", 0, mapTileSize,
220

4
        MainConfig_true);
221
222
    // TRANSLATORS: settings option
223


52
    new SetupItemCheckBox(_("Auto resize minimaps"), "", "autoresizeminimaps",
224
        this, "autoresizeminimapsEvent",
225

4
        MainConfig_true);
226
227
    // TRANSLATORS: settings option
228


52
    new SetupItemCheckBox(_("Play map animations"), "", "playMapAnimations",
229
        this, "playMapAnimationsEvent",
230

4
        MainConfig_true);
231
232
233
    // TRANSLATORS: settings group
234

28
    new SetupItemLabel(_("Moving"), "", this,
235

4
        Separator_true);
236
237
    // TRANSLATORS: settings option
238


52
    new SetupItemCheckBox(_("Auto fix position"), "",
239
        "autofixPos", this, "autofixPosEvent",
240

4
        MainConfig_true);
241
242
    // TRANSLATORS: settings option
243


52
    new SetupItemCheckBox(_("Show server side position"), "",
244
        "showserverpos", this, "showserverposEvent",
245

4
        MainConfig_true);
246
247
    // TRANSLATORS: settings option
248


52
    new SetupItemCheckBox(_("Attack while moving"), "",
249
        "attackMoving", this, "attackMovingEvent",
250

4
        MainConfig_true);
251
252
    // TRANSLATORS: settings option
253


52
    new SetupItemCheckBox(_("Attack next target"), "",
254
        "attackNext", this, "attackNextEvent",
255

4
        MainConfig_true);
256
257
    // TRANSLATORS: settings option
258


52
    new SetupItemCheckBox(_("Sync player move"), "", "syncPlayerMove",
259
        this, "syncPlayerMoveEvent",
260

4
        MainConfig_true);
261
262
    // TRANSLATORS: settings option
263


52
    new SetupItemIntTextField(_("Sync player move distance"), "",
264
        "syncPlayerMoveDistance",
265
        this, "syncPlayerMoveDistanceEvent", 1, 30,
266

4
        MainConfig_true);
267
268
    // TRANSLATORS: settings option
269


52
    new SetupItemTextField(_("Crazy move A program"), "",
270
        "crazyMoveProgram", this, "crazyMoveProgramEvent",
271

4
        MainConfig_true, UseBase64_false);
272
273
    // TRANSLATORS: settings option
274


52
    new SetupItemCheckBox(_("Mouse relative moves "
275
        "(good for touch interfaces)"), "", "mouseDirectionMove",
276
        this, "mouseDirectionMoveEvent",
277

4
        MainConfig_true);
278
279
    // TRANSLATORS: settings group
280

28
    new SetupItemLabel(_("Player"), "", this,
281

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


52
    new SetupItemCheckBox(_("Show own hp bar"), "",
285
        "showOwnHP", this, "showOwnHPEvent",
286

4
        MainConfig_true);
287
288
    // TRANSLATORS: settings option
289


52
    new SetupItemCheckBox(_("Enable quick stats"), "",
290
        "quickStats", this, "quickStatsEvent",
291

4
        MainConfig_true);
292
293
    // TRANSLATORS: settings option
294


52
    new SetupItemCheckBox(_("Cycle player targets"), "",
295
        "cyclePlayers", this, "cyclePlayersEvent",
296

4
        MainConfig_true);
297
298
    // TRANSLATORS: settings option
299


52
    new SetupItemCheckBox(_("Show job exp messages"), "",
300
        "showJobExp", this, "showJobExpEvent",
301

4
        MainConfig_true);
302
303
    // TRANSLATORS: settings option
304


52
    new SetupItemCheckBox(_("Show players popups"), "",
305
        "showBeingPopup", this, "showBeingPopupEvent",
306

4
        MainConfig_true);
307
308
    // TRANSLATORS: settings option
309


52
    new SetupItemTextField(_("Afk message"), "",
310
        "afkMessage", this, "afkMessageEvent",
311

4
        MainConfig_false, UseBase64_false);
312
313
    // TRANSLATORS: settings option
314


52
    new SetupItemCheckBox(_("Show job"), "", "showJob",
315
        this, "showJobEvent",
316

4
        MainConfig_false);
317
318
    // TRANSLATORS: settings option
319


52
    new SetupItemCheckBox(_("Enable attack filter"), "",
320
        "enableAttackFilter", this, "enableAttackFilterEvent",
321

4
        MainConfig_true);
322
323
    // TRANSLATORS: settings option
324


52
    new SetupItemCheckBox(_("Enable pickup filter"), "",
325
        "enablePickupFilter", this, "enablePickupFilterEvent",
326

4
        MainConfig_true);
327
328
    // TRANSLATORS: settings option
329


52
    new SetupItemCheckBox(_("Enable advert protocol"), "",
330
        "enableAdvert", this, "enableAdvertEvent",
331

4
        MainConfig_true);
332
333
    // TRANSLATORS: settings option
334


52
    new SetupItemCheckBox(_("Enabled pets support"),
335
        "", "usepets", this, "usepetsEvent",
336

4
        MainConfig_true);
337
338
    // TRANSLATORS: settings option
339


52
    new SetupItemCheckBox(_("Enable weight notifications"), "",
340
        "weightMsg", this, "weightMsgEvent",
341

4
        MainConfig_true);
342
343
    // TRANSLATORS: settings group
344

28
    new SetupItemLabel(_("Shop"), "", this,
345

4
        Separator_true);
346
347
    // TRANSLATORS: settings option
348


52
    new SetupItemCheckBox(_("Accept sell/buy requests"), "",
349
        "autoShop", this, "autoShopEvent",
350

4
        MainConfig_true);
351
352
    // TRANSLATORS: settings option
353


52
    new SetupItemCheckBox(_("Enable shop mode"), "",
354
        "tradebot", this, "tradebotEvent",
355

4
        MainConfig_true);
356
357
358
    // TRANSLATORS: settings group
359

28
    new SetupItemLabel(_("NPC"), "", this,
360

4
        Separator_true);
361
362
    // TRANSLATORS: settings option
363


52
    new SetupItemCheckBox(_("Cycle npc targets"), "",
364
        "cycleNPC", this, "cycleNPCEvent",
365

4
        MainConfig_true);
366
367
    // TRANSLATORS: settings option
368


52
    new SetupItemCheckBox(_("Log NPC dialogue"), "", "logNpcInGui",
369
        this, "logNpcInGuiEvent",
370

4
        MainConfig_true);
371
372
373
    // TRANSLATORS: settings group
374

28
    new SetupItemLabel(_("Bots support"), "", this,
375

4
        Separator_true);
376
377
    // TRANSLATORS: settings option
378


64
    new SetupItemCheckBox(_("Enable guild bot support and disable native "
379
        "guild support"), "", "enableGuildBot", this,
380
        "enableGuildBotEvent",
381
        "0",
382

4
        MainConfig_false);
383
384
    // TRANSLATORS: settings option
385


64
    new SetupItemCheckBox(_("Enable manamarket bot support"),
386
        "", "enableManaMarketBot", this,
387
        "enableManaMarketBotEvent",
388
        "0",
389

4
        MainConfig_false);
390
391
392
    // TRANSLATORS: settings group
393

28
    new SetupItemLabel(_("Keyboard"), "", this,
394

4
        Separator_true);
395
396
    // TRANSLATORS: settings option
397


52
    new SetupItemIntTextField(_("Repeat delay"), "",
398
        "repeateDelay", this, "repeateDelayEvent", 0, 10000,
399

4
        MainConfig_true);
400
401
    // TRANSLATORS: settings option
402


52
    new SetupItemIntTextField(_("Repeat interval"), "",
403
        "repeateInterval", this, "repeateIntervalEvent", 0, 10000,
404

4
        MainConfig_true);
405
406
    // TRANSLATORS: settings option
407


52
    new SetupItemIntTextField(_("Custom repeat interval"), "",
408
        "repeateInterval2", this, "repeateInterval2Event", 0, 10000,
409

4
        MainConfig_true);
410
411
#ifdef USE_SDL2
412
    // TRANSLATORS: settings option
413
    new SetupItemCheckBox(_("Enable alt-tab workaround"), "",
414
        "blockAltTab", this, "blockAltTabEvent",
415
        MainConfig_true);
416
#endif  // USE_SDL2
417
418
419
    // TRANSLATORS: settings group
420

28
    new SetupItemLabel(_("Windows"), "", this,
421

4
        Separator_true);
422
423
4
    mShortcutsList->fillFromArray(&shortcutsList[0], shortcutsListSize);
424
    // TRANSLATORS: settings option
425


52
    new SetupItemDropDown(_("Shortcut buttons"), "", "autohideButtons", this,
426
4
        "autohideButtonsEvent", mShortcutsList, 200,
427

8
        MainConfig_true);
428
429
430
    // TRANSLATORS: settings group
431

28
    new SetupItemLabel(_("Proxy server"), "", this,
432

4
        Separator_true);
433
434
4
    mProxyTypeList->fillFromArray(&proxyTypeList[0], proxyTypeListSize);
435
    // TRANSLATORS: settings option
436


52
    new SetupItemDropDown(_("Proxy type"), "", "downloadProxyType", this,
437
4
        "downloadProxyTypeEvent", mProxyTypeList, 200,
438

8
        MainConfig_true);
439
440
    // TRANSLATORS: settings option
441


52
    new SetupItemTextField(_("Proxy address:port"), "",
442
        "downloadProxy", this, "downloadProxyEvent",
443

4
        MainConfig_true, UseBase64_false);
444
445
    // TRANSLATORS: settings option
446


52
    new SetupItemCheckBox(_("Tunnel through HTTP proxy"), "",
447
        "downloadProxyTunnel", this, "downloadProxyTunnelEvent",
448

4
        MainConfig_true);
449
450
451
    // TRANSLATORS: settings group
452

28
    new SetupItemLabel(_("Logging"), "", this,
453

4
        Separator_true);
454
455
    // TRANSLATORS: settings option
456


52
    new SetupItemCheckBox(_("Enable OpenGL version check "
457
        "(do not disable)"), "", "checkOpenGLVersion", this,
458
        "checkOpenGLVersionEvent",
459

4
        MainConfig_true);
460
461
    // TRANSLATORS: settings option
462


52
    new SetupItemCheckBox(_("Enable debug log"), "",
463
        "debugLog", this, "debugLogEvent",
464

4
        MainConfig_true);
465
466
    // TRANSLATORS: settings option
467


52
    new SetupItemTextField(_("Ignore logging packets"), "",
468
        "ignorelogpackets", this, "ignorelogpacketsEvent",
469

4
        MainConfig_true, UseBase64_false);
470
471
    // TRANSLATORS: settings option
472


52
    new SetupItemCheckBox(_("Log unimplemented packets"), "",
473
        "unimplimentedLog", this, "unimplimentedLogEvent",
474

4
        MainConfig_true);
475
476
    // TRANSLATORS: settings option
477


52
    new SetupItemCheckBox(_("Enable OpenGL log"), "",
478
        "debugOpenGL", this, "debugOpenGLEvent",
479

4
        MainConfig_true);
480
481
    // TRANSLATORS: settings option
482


52
    new SetupItemCheckBox(_("Enable input log"), "",
483
        "logInput", this, "logInputEvent",
484

4
        MainConfig_true);
485
486
#ifdef USE_SDL2
487
    mSdlLogList->fillFromArray(&sdlLogList[0], sdlLogListSize);
488
    // TRANSLATORS: settings option
489
    new SetupItemDropDown(_("SDL logging level"), "",
490
        "sdlLogLevel", this, "sdlLogLevelEvent", mSdlLogList, 100,
491
        MainConfig_true);
492
#endif  // USE_SDL2
493
494
    // TRANSLATORS: settings option
495


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

4
        this, "uploadLog", &uploadListener);
497
498
499
    // TRANSLATORS: settings group
500

28
    new SetupItemLabel(_("Other"), "", this,
501

4
        Separator_true);
502
503
    // TRANSLATORS: settings option
504


52
    new SetupItemCheckBox(_("Enable server side attack"), "",
505
        "serverAttack", this, "serverAttackEvent",
506

4
        MainConfig_true);
507
508
    // TRANSLATORS: settings option
509


52
    new SetupItemCheckBox(_("Hide support page link on error"), "",
510
        "hidesupport", this, "hidesupportEvent",
511

4
        MainConfig_true);
512
513
    // TRANSLATORS: settings option
514


52
    new SetupItemCheckBox(_("Enable double clicks"), "",
515
        "doubleClick", this, "doubleClickEvent",
516

4
        MainConfig_true);
517
518
    // TRANSLATORS: settings option
519


52
    new SetupItemCheckBox(_("Enable bot checker"), "",
520
        "enableBotCheker", this, "enableBotChekerEvent",
521

4
        MainConfig_true);
522
523
    // TRANSLATORS: settings option
524


52
    new SetupItemCheckBox(_("Enable buggy servers protection "
525
        "(do not disable)"), "", "enableBuggyServers", this,
526
        "enableBuggyServersEvent",
527

4
        MainConfig_false);
528
529
    // TRANSLATORS: settings option
530


52
    new SetupItemCheckBox(_("Low traffic mode"), "", "lowTraffic",
531
        this, "lowTrafficEvent",
532

4
        MainConfig_true);
533
534
#ifndef ANDROID
535
    // TRANSLATORS: settings option
536


52
    new SetupItemCheckBox(_("Use FBO for screenshots (only for opengl)"),
537
        "", "usefbo", this, "usefboEvent",
538

4
        MainConfig_true);
539
#endif  // ANDROID
540
541
#ifndef WIN32
542
    // TRANSLATORS: settings option
543


52
    new SetupItemTextField(_("Screenshot directory"), "",
544
        "screenshotDirectory3", this, "screenshotDirectory3Event",
545
        MainConfig_true,
546

4
        UseBase64_true);
547
#endif  // WIN32
548
549
    // TRANSLATORS: settings option
550


52
    new SetupItemIntTextField(_("Network delay between sub servers"),
551
        "", "networksleep", this, "networksleepEvent", 0, 10000,
552

4
        MainConfig_true);
553
554
    // TRANSLATORS: settings option
555


52
    new SetupItemCheckBox(_("Show background"), "", "showBackground",
556
        this, "showBackgroundEvent",
557

4
        MainConfig_true);
558
559
4
    mDensityList->fillFromArray(&densityList[0], densityListSize);
560
    // TRANSLATORS: settings option
561


52
    new SetupItemDropDown(_("Screen density override"), "",
562
4
        "screenDensity", this, "screenDensityEvent", mDensityList, 100,
563

8
        MainConfig_true);
564
565
8
    setDimension(Rect(0, 0, 550, 350));
566
4
}
567
568
12
Setup_Misc::~Setup_Misc()
569
{
570
4
    delete2(mProxyTypeList);
571
4
    delete2(mShortcutsList);
572
4
    delete2(mDensityList);
573
#ifdef USE_SDL2
574
    delete2(mSdlLogList);
575
#endif  // USE_SDL2
576
8
}
577
578
void Setup_Misc::apply()
579
{
580
    SetupTabScroll::apply();
581
582
    logger->setDebugLog(config.getBoolValue("debugLog"));
583
    logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog"));
584
    Net::loadIgnorePackets();
585
}
586
587
void Setup_Misc::externalUpdated()
588
{
589
    reread("showJob");
590
    reread("enableGuildBot");
591
    reread("enableManaMarketBot");
592
    reread("enableBuggyServers");
593
    reread("afkMessage");
594
}