ManaPlus
setup_misc.cpp
Go to the documentation of this file.
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 
24 
25 #include "configuration.h"
26 
28 
29 #include "gui/models/namesmodel.h"
30 
34 #include "gui/widgets/scrollarea.h"
35 
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 Setup_Misc::Setup_Misc(const Widget2 *const widget) :
117  SetupTabScroll(widget),
118  mProxyTypeList(new NamesModel),
119  mShortcutsList(new NamesModel),
120 #ifdef USE_SDL2
121  mSdlLogList(new NamesModel),
122 #endif // USE_SDL2
123  mDensityList(new NamesModel)
124 {
125  // TRANSLATORS: misc tab in settings
126  setName(_("Misc"));
127 
128  LayoutHelper h(this);
129  ContainerPlacer place = h.getPlacer(0, 0);
130  place(0, 0, mScroll, 10, 10);
131 
132  // TRANSLATORS: settings option
133  new SetupItemLabel(_("Monsters"), "", this,
135 
136  // TRANSLATORS: settings option
137  new SetupItemCheckBox(_("Show damage inflicted to monsters"), "",
138  "showMonstersTakedDamage", this, "showMonstersTakedDamageEvent",
140 
141  // TRANSLATORS: settings option
142  new SetupItemCheckBox(_("Auto target only reachable monsters"), "",
143  "targetOnlyReachable", this, "targetOnlyReachableEvent",
145 
146  // TRANSLATORS: settings option
147  new SetupItemCheckBox(_("Select auto target for attack skills"), "",
148  "skillAutotarget", this, "skillAutotargetEvent",
150 
151  // TRANSLATORS: settings option
152  new SetupItemCheckBox(_("Highlight monster attack range"), "",
153  "highlightMonsterAttackRange", this,
154  "highlightMonsterAttackRangeEvent",
156 
157  // TRANSLATORS: settings option
158  new SetupItemCheckBox(_("Show monster hp bar"), "",
159  "showMobHP", this, "showMobHPEvent",
161 
162  // TRANSLATORS: settings option
163  new SetupItemCheckBox(_("Cycle monster targets"), "",
164  "cycleMonsters", this, "cycleMonstersEvent",
166 
167 
168  // TRANSLATORS: settings group
169  new SetupItemLabel(_("Map"), "", this,
171 
172  // TRANSLATORS: settings option
173  new SetupItemCheckBox(_("Show warps particles"), "",
174  "warpParticle", this, "warpParticleEvent",
176 
177  // TRANSLATORS: settings option
178  new SetupItemCheckBox(_("Highlight map portals"), "",
179  "highlightMapPortals", this, "highlightMapPortalsEvent",
181 
182  // TRANSLATORS: settings option
183  new SetupItemCheckBox(_("Highlight floor items"), "",
184  "floorItemsHighlight", this, "floorItemsHighlightEvent",
186 
187  // TRANSLATORS: settings option
188  new SetupItemCheckBox(_("Highlight player attack range"), "",
189  "highlightAttackRange", this, "highlightAttackRangeEvent",
191 
192  // TRANSLATORS: settings option
193  new SetupItemCheckBox(_("Show extended minimaps"), "",
194  "showExtMinimaps", this, "showExtMinimapsEvent",
196 
197  // TRANSLATORS: settings option
198  new SetupItemCheckBox(_("Draw path"), "", "drawPath",
199  this, "drawPathEvent",
201 
202  // TRANSLATORS: settings option
203  new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys",
204  this, "drawHotKeysEvent",
206 
207  // TRANSLATORS: settings option
208  new SetupItemCheckBox(_("Enable lazy scrolling"), "",
209  "enableLazyScrolling", this, "enableLazyScrollingEvent",
211 
212  // TRANSLATORS: settings option
213  new SetupItemIntTextField(_("Scroll laziness"), "", "ScrollLaziness",
214  this, "ScrollLazinessEvent", 1, 160,
216 
217  // TRANSLATORS: settings option
218  new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius",
219  this, "ScrollRadiusEvent", 0, mapTileSize,
221 
222  // TRANSLATORS: settings option
223  new SetupItemCheckBox(_("Auto resize minimaps"), "", "autoresizeminimaps",
224  this, "autoresizeminimapsEvent",
226 
227  // TRANSLATORS: settings option
228  new SetupItemCheckBox(_("Play map animations"), "", "playMapAnimations",
229  this, "playMapAnimationsEvent",
231 
232 
233  // TRANSLATORS: settings group
234  new SetupItemLabel(_("Moving"), "", this,
236 
237  // TRANSLATORS: settings option
238  new SetupItemCheckBox(_("Auto fix position"), "",
239  "autofixPos", this, "autofixPosEvent",
241 
242  // TRANSLATORS: settings option
243  new SetupItemCheckBox(_("Show server side position"), "",
244  "showserverpos", this, "showserverposEvent",
246 
247  // TRANSLATORS: settings option
248  new SetupItemCheckBox(_("Attack while moving"), "",
249  "attackMoving", this, "attackMovingEvent",
251 
252  // TRANSLATORS: settings option
253  new SetupItemCheckBox(_("Attack next target"), "",
254  "attackNext", this, "attackNextEvent",
256 
257  // TRANSLATORS: settings option
258  new SetupItemCheckBox(_("Sync player move"), "", "syncPlayerMove",
259  this, "syncPlayerMoveEvent",
261 
262  // TRANSLATORS: settings option
263  new SetupItemIntTextField(_("Sync player move distance"), "",
264  "syncPlayerMoveDistance",
265  this, "syncPlayerMoveDistanceEvent", 1, 30,
267 
268  // TRANSLATORS: settings option
269  new SetupItemIntTextField(_("Sync player move distance on legacy servers"),
270  "",
271  "syncPlayerMoveDistanceLegacy",
272  this, "syncPlayerMoveDistanceLegacyEvent", 1, 30,
274 
275  // TRANSLATORS: settings option
276  new SetupItemTextField(_("Crazy move A program"), "",
277  "crazyMoveProgram", this, "crazyMoveProgramEvent",
279 
280  // TRANSLATORS: settings option
281  new SetupItemCheckBox(_("Mouse relative moves "
282  "(good for touch interfaces)"), "", "mouseDirectionMove",
283  this, "mouseDirectionMoveEvent",
285 
286  // TRANSLATORS: settings group
287  new SetupItemLabel(_("Player"), "", this,
289 
290  // TRANSLATORS: settings option
291  new SetupItemCheckBox(_("Show own hp bar"), "",
292  "showOwnHP", this, "showOwnHPEvent",
294 
295  // TRANSLATORS: settings option
296  new SetupItemCheckBox(_("Enable quick stats"), "",
297  "quickStats", this, "quickStatsEvent",
299 
300  // TRANSLATORS: settings option
301  new SetupItemCheckBox(_("Cycle player targets"), "",
302  "cyclePlayers", this, "cyclePlayersEvent",
304 
305  // TRANSLATORS: settings option
306  new SetupItemCheckBox(_("Show job exp messages"), "",
307  "showJobExp", this, "showJobExpEvent",
309 
310  // TRANSLATORS: settings option
311  new SetupItemCheckBox(_("Show players popups"), "",
312  "showBeingPopup", this, "showBeingPopupEvent",
314 
315  // TRANSLATORS: settings option
316  new SetupItemTextField(_("Afk message"), "",
317  "afkMessage", this, "afkMessageEvent",
319 
320  // TRANSLATORS: settings option
321  new SetupItemCheckBox(_("Show job"), "", "showJob",
322  this, "showJobEvent",
324 
325  // TRANSLATORS: settings option
326  new SetupItemCheckBox(_("Enable attack filter"), "",
327  "enableAttackFilter", this, "enableAttackFilterEvent",
329 
330  // TRANSLATORS: settings option
331  new SetupItemCheckBox(_("Enable pickup filter"), "",
332  "enablePickupFilter", this, "enablePickupFilterEvent",
334 
335  // TRANSLATORS: settings option
336  new SetupItemCheckBox(_("Enable advert protocol"), "",
337  "enableAdvert", this, "enableAdvertEvent",
339 
340  // TRANSLATORS: settings option
341  new SetupItemCheckBox(_("Enabled pets support"),
342  "", "usepets", this, "usepetsEvent",
344 
345  // TRANSLATORS: settings option
346  new SetupItemCheckBox(_("Enable weight notifications"), "",
347  "weightMsg", this, "weightMsgEvent",
349 
350  // TRANSLATORS: settings group
351  new SetupItemLabel(_("Shop"), "", this,
353 
354  // TRANSLATORS: settings option
355  new SetupItemCheckBox(_("Accept sell/buy requests"), "",
356  "autoShop", this, "autoShopEvent",
358 
359  // TRANSLATORS: settings option
360  new SetupItemCheckBox(_("Enable shop mode"), "",
361  "tradebot", this, "tradebotEvent",
363 
364 
365  // TRANSLATORS: settings group
366  new SetupItemLabel(_("NPC"), "", this,
368 
369  // TRANSLATORS: settings option
370  new SetupItemCheckBox(_("Cycle npc targets"), "",
371  "cycleNPC", this, "cycleNPCEvent",
373 
374  // TRANSLATORS: settings option
375  new SetupItemCheckBox(_("Log NPC dialogue"), "", "logNpcInGui",
376  this, "logNpcInGuiEvent",
378 
379 
380  // TRANSLATORS: settings group
381  new SetupItemLabel(_("Bots support"), "", this,
383 
384  // TRANSLATORS: settings option
385  new SetupItemCheckBox(_("Enable guild bot support and disable native "
386  "guild support"), "", "enableGuildBot", this,
387  "enableGuildBotEvent",
388  "0",
390 
391  // TRANSLATORS: settings option
392  new SetupItemCheckBox(_("Enable manamarket bot support"),
393  "", "enableManaMarketBot", this,
394  "enableManaMarketBotEvent",
395  "0",
397 
398 
399  // TRANSLATORS: settings group
400  new SetupItemLabel(_("Keyboard"), "", this,
402 
403  // TRANSLATORS: settings option
404  new SetupItemIntTextField(_("Repeat delay"), "",
405  "repeateDelay", this, "repeateDelayEvent", 0, 10000,
407 
408  // TRANSLATORS: settings option
409  new SetupItemIntTextField(_("Repeat interval"), "",
410  "repeateInterval", this, "repeateIntervalEvent", 0, 10000,
412 
413  // TRANSLATORS: settings option
414  new SetupItemIntTextField(_("Custom repeat interval"), "",
415  "repeateInterval2", this, "repeateInterval2Event", 0, 10000,
417 
418 #ifdef USE_SDL2
419  // TRANSLATORS: settings option
420  new SetupItemCheckBox(_("Enable alt-tab workaround"), "",
421  "blockAltTab", this, "blockAltTabEvent",
423 #endif // USE_SDL2
424 
425 
426  // TRANSLATORS: settings group
427  new SetupItemLabel(_("Windows"), "", this,
429 
431  // TRANSLATORS: settings option
432  new SetupItemDropDown(_("Shortcut buttons"), "", "autohideButtons", this,
433  "autohideButtonsEvent", mShortcutsList, 200,
435 
436  // TRANSLATORS: settings option
437  new SetupItemCheckBox(_("Show icons on shortcut buttons"), "",
438  "showButtonIcons", this, "showButtonIconsEvent",
440 
441 
442  // TRANSLATORS: settings group
443  new SetupItemLabel(_("Proxy server"), "", this,
445 
447  // TRANSLATORS: settings option
448  new SetupItemDropDown(_("Proxy type"), "", "downloadProxyType", this,
449  "downloadProxyTypeEvent", mProxyTypeList, 200,
451 
452  // TRANSLATORS: settings option
453  new SetupItemTextField(_("Proxy address:port"), "",
454  "downloadProxy", this, "downloadProxyEvent",
456 
457  // TRANSLATORS: settings option
458  new SetupItemCheckBox(_("Tunnel through HTTP proxy"), "",
459  "downloadProxyTunnel", this, "downloadProxyTunnelEvent",
461 
462 
463  // TRANSLATORS: settings group
464  new SetupItemLabel(_("Logging"), "", this,
466 
467  // TRANSLATORS: settings option
468  new SetupItemCheckBox(_("Enable OpenGL version check "
469  "(do not disable)"), "", "checkOpenGLVersion", this,
470  "checkOpenGLVersionEvent",
472 
473  // TRANSLATORS: settings option
474  new SetupItemCheckBox(_("Enable debug log"), "",
475  "debugLog", this, "debugLogEvent",
477 
478  // TRANSLATORS: settings option
479  new SetupItemTextField(_("Ignore logging packets"), "",
480  "ignorelogpackets", this, "ignorelogpacketsEvent",
482 
483  // TRANSLATORS: settings option
484  new SetupItemCheckBox(_("Log unimplemented packets"), "",
485  "unimplimentedLog", this, "unimplimentedLogEvent",
487 
488  // TRANSLATORS: settings option
489  new SetupItemCheckBox(_("Enable OpenGL log"), "",
490  "debugOpenGL", this, "debugOpenGLEvent",
492 
493  // TRANSLATORS: settings option
494  new SetupItemCheckBox(_("Enable input log"), "",
495  "logInput", this, "logInputEvent",
497 
498 #ifdef USE_SDL2
499  mSdlLogList->fillFromArray(&sdlLogList[0], sdlLogListSize);
500  // TRANSLATORS: settings option
501  new SetupItemDropDown(_("SDL logging level"), "",
502  "sdlLogLevel", this, "sdlLogLevelEvent", mSdlLogList, 100,
504 #endif // USE_SDL2
505 
506  // TRANSLATORS: settings option
507  new SetupButtonItem(_("Upload log file"), "", "upload",
508  this, "uploadLog", &uploadListener);
509 
510 
511  // TRANSLATORS: settings group
512  new SetupItemLabel(_("Other"), "", this,
514 
515  // TRANSLATORS: settings option
516  new SetupItemCheckBox(_("Enable server side attack"), "",
517  "serverAttack", this, "serverAttackEvent",
519 
520  // TRANSLATORS: settings option
521  new SetupItemCheckBox(_("Hide support page link on error"), "",
522  "hidesupport", this, "hidesupportEvent",
524 
525  // TRANSLATORS: settings option
526  new SetupItemCheckBox(_("Enable double clicks"), "",
527  "doubleClick", this, "doubleClickEvent",
529 
530  // TRANSLATORS: settings option
531  new SetupItemCheckBox(_("Enable bot checker"), "",
532  "enableBotCheker", this, "enableBotChekerEvent",
534 
535  // TRANSLATORS: settings option
536  new SetupItemCheckBox(_("Enable buggy servers protection "
537  "(do not disable)"), "", "enableBuggyServers", this,
538  "enableBuggyServersEvent",
540 
541  // TRANSLATORS: settings option
542  new SetupItemCheckBox(_("Low traffic mode"), "", "lowTraffic",
543  this, "lowTrafficEvent",
545 
546 #ifndef ANDROID
547  // TRANSLATORS: settings option
548  new SetupItemCheckBox(_("Use FBO for screenshots (only for opengl)"),
549  "", "usefbo", this, "usefboEvent",
551 #endif // ANDROID
552 
553 #ifndef WIN32
554  // TRANSLATORS: settings option
555  new SetupItemTextField(_("Screenshot directory"), "",
556  "screenshotDirectory3", this, "screenshotDirectory3Event",
559 #endif // WIN32
560 
561  // TRANSLATORS: settings option
562  new SetupItemIntTextField(_("Network delay between sub servers"),
563  "", "networksleep", this, "networksleepEvent", 0, 10000,
565 
566  // TRANSLATORS: settings option
567  new SetupItemCheckBox(_("Show background"), "", "showBackground",
568  this, "showBackgroundEvent",
570 
572  // TRANSLATORS: settings option
573  new SetupItemDropDown(_("Screen density override"), "",
574  "screenDensity", this, "screenDensityEvent", mDensityList, 100,
576 
577  setDimension(Rect(0, 0, 550, 350));
578 }
579 
581 {
585 #ifdef USE_SDL2
586  delete2(mSdlLogList)
587 #endif // USE_SDL2
588 }
589 
591 {
593 
594  logger->setDebugLog(config.getBoolValue("debugLog"));
595  logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog"));
597 }
598 
600 {
601  reread("showJob");
602  reread("enableGuildBot");
603  reread("enableManaMarketBot");
604  reread("enableBuggyServers");
605  reread("afkMessage");
606 }
bool getBoolValue(const std::string &key) const
ContainerPlacer getPlacer(const int x, const int y)
void setReportUnimplemented(const bool n)
Definition: logger.h:184
void setDebugLog(const bool n)
Definition: logger.h:181
void fillFromArray(const char *const *const arr, const std::size_t size)
Definition: namesmodel.cpp:52
Definition: rect.h:74
void reread(const std::string &name)
ScrollArea * mScroll
void setName(const std::string &name)
Definition: setuptab.h:68
void externalUpdated()
Definition: setup_misc.cpp:599
NamesModel * mDensityList
Definition: setup_misc.h:49
NamesModel * mProxyTypeList
Definition: setup_misc.h:44
NamesModel * mShortcutsList
Definition: setup_misc.h:45
void apply()
Definition: setup_misc.cpp:590
Setup_Misc(const Widget2 *const widget)
Definition: setup_misc.cpp:116
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
Configuration config
static const int mapTileSize
Definition: map.h:27
#define new
Definition: debug_new.h:147
#define delete2(var)
Definition: delete2.h:25
#define N_(s)
Definition: gettext.h:36
#define _(s)
Definition: gettext.h:35
Logger * logger
Definition: logger.cpp:89
const bool MainConfig_true
Definition: mainconfig.h:30
const bool MainConfig_false
Definition: mainconfig.h:30
void loadIgnorePackets()
Definition: net.cpp:194
const bool Separator_true
Definition: separator.h:30
static const char *const proxyTypeList[]
Definition: setup_misc.cpp:59
static const char *const densityList[]
Definition: setup_misc.cpp:76
static const int shortcutsListSize
Definition: setup_misc.cpp:45
static const int proxyTypeListSize
Definition: setup_misc.cpp:57
static const int densityListSize
Definition: setup_misc.cpp:74
static const char *const shortcutsList[]
Definition: setup_misc.cpp:47
UploadListener uploadListener
const bool UseBase64_false
Definition: usebase64.h:30
const bool UseBase64_true
Definition: usebase64.h:30