-
-
Notifications
You must be signed in to change notification settings - Fork 991
/
general.cpp
1079 lines (876 loc) · 21.6 KB
/
general.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
/**
* @file
* Get and set user-preferences.
*/
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "preferences/general.hpp"
#include "config.hpp"
#include "credentials.hpp"
#include "filesystem.hpp"
#include "game_config.hpp"
#include "hotkey/hotkey_item.hpp"
#include "lexical_cast.hpp"
#include "log.hpp"
#include "sdl/point.hpp"
#include "serialization/parser.hpp"
#include "sound.hpp"
#include "utils/general.hpp"
#include "video.hpp" // non_interactive()
#include <sys/stat.h> // for setting the permissions of the preferences file
#ifndef _WIN32
#include <unistd.h>
#endif
static lg::log_domain log_config("config");
#define ERR_CFG LOG_STREAM(err , log_config)
static lg::log_domain log_filesystem("filesystem");
#define ERR_FS LOG_STREAM(err, log_filesystem)
namespace {
bool no_preferences_save = false;
bool fps = false;
int draw_delay_ = 0;
config prefs;
}
namespace preferences {
/*
* Stores all the static, default values for certain game preferences. The values
* are kept here for easy modification without a lengthy rebuild.
*
* Add any variables of similar type here.
*/
const int min_window_width = 800;
const int min_window_height = 600;
const int def_window_width = 1280;
const int def_window_height = 720;
const int min_font_scaling = 80;
const int max_font_scaling = 150;
const SCALING_ALGORITHM default_scaling_algorithm = SCALING_ALGORITHM::XBRZ_NN;
class prefs_event_handler : public events::sdl_handler {
public:
virtual void handle_event(const SDL_Event &) {}
virtual void handle_window_event(const SDL_Event &event);
prefs_event_handler() : sdl_handler(false) {}
};
prefs_event_handler event_handler_;
base_manager::base_manager()
{
event_handler_.join_global();
try{
#ifdef DEFAULT_PREFS_PATH
filesystem::scoped_istream stream = filesystem::istream_file(filesystem::get_default_prefs_file(),false);
read(prefs, *stream);
config user_prefs;
stream = filesystem::istream_file(filesystem::get_prefs_file());
read(user_prefs, *stream);
prefs.merge_with(user_prefs);
#else
filesystem::scoped_istream stream = filesystem::istream_file(filesystem::get_prefs_file(),false);
read(prefs, *stream);
#endif
} catch(const config::error& e) {
ERR_CFG << "Error loading preference, message: "
<< e.what()
<< std::endl;
}
preferences::load_credentials();
}
base_manager::~base_manager()
{
event_handler_.leave_global();
try {
if (no_preferences_save) return;
// Set the 'hidden' preferences.
prefs["scroll_threshold"] = mouse_scroll_threshold();
write_preferences();
} catch (...) {}
}
/*
* Hook for setting window state variables on window resize and maximize
* events. Since there is no fullscreen window event, that setter is called
* from the CVideo function instead.
*/
void prefs_event_handler::handle_window_event(const SDL_Event& event)
{
// Safety check to make sure this is a window event
if (event.type != SDL_WINDOWEVENT) return;
switch(event.window.event) {
case SDL_WINDOWEVENT_RESIZED:
_set_resolution(point(event.window.data1,event.window.data2));
break;
case SDL_WINDOWEVENT_MAXIMIZED:
_set_maximized(true);
break;
case SDL_WINDOWEVENT_RESTORED:
_set_maximized(fullscreen() || false);
break;
}
}
void write_preferences()
{
#ifndef _WIN32
bool prefs_file_existed = access(filesystem::get_prefs_file().c_str(), F_OK) == 0;
#endif
try {
filesystem::scoped_ostream prefs_file = filesystem::ostream_file(filesystem::get_prefs_file());
write(*prefs_file, prefs);
} catch(filesystem::io_exception&) {
ERR_FS << "error writing to preferences file '" << filesystem::get_prefs_file() << "'" << std::endl;
}
preferences::save_credentials();
#ifndef _WIN32
if(!prefs_file_existed) {
if(chmod(filesystem::get_prefs_file().c_str(), 0600) == -1) {
ERR_FS << "error setting permissions of preferences file '" << filesystem::get_prefs_file() << "'" << std::endl;
}
}
#endif
}
void set(const std::string &key, bool value)
{
prefs[key] = value;
}
void set(const std::string &key, int value)
{
prefs[key] = value;
}
void set(const std::string &key, char const *value)
{
prefs[key] = value;
}
void set(const std::string &key, const std::string &value)
{
prefs[key] = value;
}
void set(const std::string &key, const config::attribute_value &value)
{
prefs[key] = value;
}
void clear(const std::string& key)
{
prefs.recursive_clear_value(key);
}
void set_child(const std::string& key, const config& val) {
prefs.clear_children(key);
prefs.add_child(key, val);
}
const config &get_child(const std::string& key)
{
return prefs.child(key);
}
void erase(const std::string& key) {
prefs.remove_attribute(key);
}
bool have_setting(const std::string& key) {
return prefs.has_attribute(key);
}
std::string get(const std::string& key) {
return prefs[key];
}
std::string get(const std::string& key, const std::string& def) {
return prefs[key].empty() ? def : prefs[key];
}
bool get(const std::string &key, bool def)
{
return prefs[key].to_bool(def);
}
config::attribute_value get_as_attribute(const std::string &key)
{
return prefs[key];
}
void disable_preferences_save() {
no_preferences_save = true;
}
config* get_prefs(){
config* pointer = &prefs;
return pointer;
}
bool show_allied_orb() {
return get("show_ally_orb", game_config::show_ally_orb);
}
void set_show_allied_orb(bool show_orb) {
prefs["show_ally_orb"] = show_orb;
}
bool show_enemy_orb() {
return get("show_enemy_orb", game_config::show_enemy_orb);
}
void set_show_enemy_orb(bool show_orb) {
prefs["show_enemy_orb"] = show_orb;
}
bool show_moved_orb() {
return get("show_moved_orb", game_config::show_moved_orb);
}
void set_show_moved_orb(bool show_orb) {
prefs["show_moved_orb"] = show_orb;
}
bool show_unmoved_orb() {
return get("show_unmoved_orb", game_config::show_unmoved_orb);
}
void set_show_unmoved_orb(bool show_orb) {
prefs["show_unmoved_orb"] = show_orb;
}
bool show_partial_orb() {
return get("show_partial_orb", game_config::show_partial_orb);
}
void set_show_partial_orb(bool show_orb) {
prefs["show_partial_orb"] = show_orb;
}
static std::string fix_orb_color_name(const std::string& color) {
if (color.substr(0,4) == "orb_") {
if(color[4] >= '0' && color[4] <= '9') {
return color.substr(5);
} else {
return color.substr(4);
}
}
return color;
}
std::string allied_color() {
std::string ally_color = get("ally_orb_color");
if (ally_color.empty())
return game_config::colors::ally_orb_color;
return fix_orb_color_name(ally_color);
}
void set_allied_color(const std::string& color_id) {
prefs["ally_orb_color"] = color_id;
}
std::string core_id() {
std::string core_id = get("core");
if (core_id.empty())
return "default";
return core_id;
}
void set_core_id(const std::string& core_id) {
prefs["core"] = core_id;
}
std::string enemy_color() {
std::string enemy_color = get("enemy_orb_color");
if (enemy_color.empty())
return game_config::colors::enemy_orb_color;
return fix_orb_color_name(enemy_color);
}
void set_enemy_color(const std::string& color_id) {
prefs["enemy_orb_color"] = color_id;
}
std::string moved_color() {
std::string moved_color = get("moved_orb_color");
if (moved_color.empty())
return game_config::colors::moved_orb_color;
return fix_orb_color_name(moved_color);
}
void set_moved_color(const std::string& color_id) {
prefs["moved_orb_color"] = color_id;
}
std::string unmoved_color() {
std::string unmoved_color = get("unmoved_orb_color");
if (unmoved_color.empty())
return game_config::colors::unmoved_orb_color;
return fix_orb_color_name(unmoved_color);
}
void set_unmoved_color(const std::string& color_id) {
prefs["unmoved_orb_color"] = color_id;
}
std::string partial_color() {
std::string partmoved_color = get("partial_orb_color");
if (partmoved_color.empty())
return game_config::colors::partial_orb_color;
return fix_orb_color_name(partmoved_color);
}
void set_partial_color(const std::string& color_id) {
prefs["partial_orb_color"] = color_id;
}
bool scroll_to_action()
{
return get("scroll_to_action", true);
}
void set_scroll_to_action(bool ison)
{
prefs["scroll_to_action"] = ison;
}
point resolution()
{
const unsigned x_res = prefs["xresolution"].to_unsigned();
const unsigned y_res = prefs["yresolution"].to_unsigned();
// Either resolution was unspecified, return default.
if(x_res == 0 || y_res == 0) {
return point(def_window_width, def_window_height);
}
return point(
std::max<unsigned>(x_res, min_window_width),
std::max<unsigned>(y_res, min_window_height)
);
}
bool maximized()
{
return get("maximized", !fullscreen());
}
bool fullscreen()
{
return get("fullscreen", true);
}
void _set_resolution(const point& res)
{
preferences::set("xresolution", std::to_string(res.x));
preferences::set("yresolution", std::to_string(res.y));
}
void _set_maximized(bool ison)
{
prefs["maximized"] = ison;
}
void _set_fullscreen(bool ison)
{
prefs["fullscreen"] = ison;
}
bool turbo()
{
if(CVideo::get_singleton().non_interactive()) {
return true;
}
return get("turbo", false);
}
void _set_turbo(bool ison)
{
prefs["turbo"] = ison;
}
double turbo_speed()
{
return prefs["turbo_speed"].to_double(2.0);
}
void save_turbo_speed(const double speed)
{
prefs["turbo_speed"] = speed;
}
int font_scaling()
{
// Clip at 80 because if it's too low it'll cause crashes
return std::max<int>(std::min<int>(prefs["font_scale"].to_int(100), max_font_scaling), min_font_scaling);
}
void set_font_scaling(int scale)
{
prefs["font_scale"] = utils::clamp(scale, min_font_scaling, max_font_scaling);
}
int font_scaled(int size)
{
return (size * font_scaling()) / 100;
}
bool idle_anim()
{
return get("idle_anim", true);
}
void _set_idle_anim(const bool ison)
{
prefs["idle_anim"] = ison;
}
int idle_anim_rate()
{
return prefs["idle_anim_rate"];
}
void _set_idle_anim_rate(const int rate)
{
prefs["idle_anim_rate"] = rate;
}
std::string language()
{
return prefs["locale"];
}
void set_language(const std::string& s)
{
preferences::set("locale", s);
}
std::string gui_theme()
{
return prefs["gui2_theme"];
}
void set_gui_theme(const std::string& s)
{
preferences::set("gui2_theme", s);
}
bool ellipses()
{
return get("show_side_colors", false);
}
void set_ellipses(bool ison)
{
preferences::set("show_side_colors", ison);
}
bool grid()
{
return get("grid", false);
}
void _set_grid(bool ison)
{
preferences::set("grid", ison);
}
size_t sound_buffer_size()
{
// Sounds don't sound good on Windows unless the buffer size is 4k,
// but this seems to cause crashes on other systems...
#ifdef _WIN32
const size_t buf_size = 4096;
#else
const size_t buf_size = 1024;
#endif
return prefs["sound_buffer_size"].to_int(buf_size);
}
void save_sound_buffer_size(const size_t size)
{
#ifdef _WIN32
const char* buf_size = "4096";
#else
const char* buf_size = "1024";
#endif
const std::string new_size = lexical_cast_default<std::string>(size, buf_size);
if (get("sound_buffer_size") == new_size)
return;
preferences::set("sound_buffer_size", new_size);
sound::reset_sound();
}
int music_volume()
{
return prefs["music_volume"].to_int(100);
}
void set_music_volume(int vol)
{
if(music_volume() == vol) {
return;
}
prefs["music_volume"] = vol;
sound::set_music_volume(music_volume());
}
int sound_volume()
{
return prefs["sound_volume"].to_int(100);
}
void set_sound_volume(int vol)
{
if(sound_volume() == vol) {
return;
}
prefs["sound_volume"] = vol;
sound::set_sound_volume(sound_volume());
}
int bell_volume()
{
return prefs["bell_volume"].to_int(100);
}
void set_bell_volume(int vol)
{
if(bell_volume() == vol) {
return;
}
prefs["bell_volume"] = vol;
sound::set_bell_volume(bell_volume());
}
int UI_volume()
{
return prefs["UI_volume"].to_int(100);
}
void set_UI_volume(int vol)
{
if(UI_volume() == vol) {
return;
}
prefs["UI_volume"] = vol;
sound::set_UI_volume(UI_volume());
}
bool turn_bell()
{
return get("turn_bell", true);
}
bool set_turn_bell(bool ison)
{
if(!turn_bell() && ison) {
preferences::set("turn_bell", true);
if(!music_on() && !sound_on() && !UI_sound_on()) {
if(!sound::init_sound()) {
preferences::set("turn_bell", false);
return false;
}
}
} else if(turn_bell() && !ison) {
preferences::set("turn_bell", false);
sound::stop_bell();
if(!music_on() && !sound_on() && !UI_sound_on())
sound::close_sound();
}
return true;
}
bool UI_sound_on()
{
return get("UI_sound", true);
}
bool set_UI_sound(bool ison)
{
if(!UI_sound_on() && ison) {
preferences::set("UI_sound", true);
if(!music_on() && !sound_on() && !turn_bell()) {
if(!sound::init_sound()) {
preferences::set("UI_sound", false);
return false;
}
}
} else if(UI_sound_on() && !ison) {
preferences::set("UI_sound", false);
sound::stop_UI_sound();
if(!music_on() && !sound_on() && !turn_bell())
sound::close_sound();
}
return true;
}
bool message_bell()
{
return get("message_bell", true);
}
bool sound_on()
{
return get("sound", true);
}
bool set_sound(bool ison) {
if(!sound_on() && ison) {
preferences::set("sound", true);
if(!music_on() && !turn_bell() && !UI_sound_on()) {
if(!sound::init_sound()) {
preferences::set("sound", false);
return false;
}
}
} else if(sound_on() && !ison) {
preferences::set("sound", false);
sound::stop_sound();
if(!music_on() && !turn_bell() && !UI_sound_on())
sound::close_sound();
}
return true;
}
bool music_on()
{
return get("music", true);
}
bool set_music(bool ison) {
if(!music_on() && ison) {
preferences::set("music", true);
if(!sound_on() && !turn_bell() && !UI_sound_on()) {
if(!sound::init_sound()) {
preferences::set("music", false);
return false;
}
}
else
sound::play_music();
} else if(music_on() && !ison) {
preferences::set("music", false);
if(!sound_on() && !turn_bell() && !UI_sound_on())
sound::close_sound();
else
sound::stop_music();
}
return true;
}
bool stop_music_in_background()
{
return get("stop_music_in_background", false);
}
void set_stop_music_in_background(bool ison)
{
preferences::set("stop_music_in_background", ison);
}
namespace {
double scroll = 0.2;
}
bool joystick_support_enabled()
{
return get("joystick_support_enabled", false);
}
int joystick_mouse_deadzone()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_scroll_deadzone"), 1500), 0, 16000);
return value;
}
int joystick_num_mouse_xaxis()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_num_scroll_xaxis"), 0), -1, 3);
return value;
}
int joystick_mouse_xaxis_num()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_scroll_xaxis_num"), 0), 0, 7);
return value;
}
int joystick_num_mouse_yaxis()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_num_scroll_yaxis"), 0), -1, 3);
return value;
}
int joystick_mouse_yaxis_num()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_scroll_yaxis_num"), 1), 0, 7);
return value;
}
int joystick_scroll_deadzone()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_scroll_deadzone"), 1500), 0, 16000);
return value;
}
int joystick_cursor_deadzone()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_cursor_deadzone"), 1500), 0, 16000);
return value;
}
int joystick_thrusta_deadzone()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_thrusta_deadzone"), 1500), 0, 16000);
return value;
}
int joystick_thrustb_deadzone()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_thrustb_deadzone"), 1500), 0, 16000);
return value;
}
int joystick_cursor_threshold()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_cursor_threshold"), 10000), 0, 16000);
return value;
}
int joystick_num_scroll_xaxis()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_num_scroll_xaxis"), 0), -1, 3);
return value;
}
int joystick_scroll_xaxis_num()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_scroll_xaxis_num"), 0), 0, 7);
return value;
}
int joystick_num_scroll_yaxis()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_num_scroll_yaxis"), 0), -1, 3);
return value;
}
int joystick_scroll_yaxis_num()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_scroll_yaxis_num"), 1), 0, 7);
return value;
}
int joystick_num_cursor_xaxis()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_num_cursor_xaxis"), 0), -1, 3);
return value;
}
int joystick_cursor_xaxis_num()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_cursor_xaxis_num"), 3), 0, 7);
return value;
}
int joystick_num_cursor_yaxis()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_num_cursor_yaxis"), 0), -1, 3);
return value;
}
int joystick_cursor_yaxis_num()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_cursor_yaxis_num"), 4), 0, 7);
return value;
}
int joystick_num_thrusta_axis()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_num_thrusta_axis"), 0), -1, 3);
return value;
}
int joystick_thrusta_axis_num()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_thrusta_axis_num"), 2), 0, 7);
return value;
}
int joystick_num_thrustb_axis()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_num_thrustb_axis"), 0), -1, 3);
return value;
}
int joystick_thrustb_axis_num()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("joystick_thrustb_axis_num"), 2), 0, 7);
return value;
}
int scroll_speed()
{
const int value = utils::clamp<int>(lexical_cast_default<int>(get("scroll"), 50), 1, 100);
scroll = value/100.0;
return value;
}
void set_scroll_speed(const int new_speed)
{
prefs["scroll"] = new_speed;
scroll = new_speed / 100.0;
}
bool middle_click_scrolls()
{
return get("middle_click_scrolls", true);
}
bool mouse_scroll_enabled()
{
return get("mouse_scrolling", true);
}
void enable_mouse_scroll(bool value)
{
set("mouse_scrolling", value);
}
int mouse_scroll_threshold()
{
return prefs["scroll_threshold"].to_int(10);
}
bool animate_map()
{
return preferences::get("animate_map", true);
}
bool animate_water()
{
return preferences::get("animate_water", true);
}
bool minimap_movement_coding()
{
return preferences::get("minimap_movement_coding", true);
}
void toggle_minimap_movement_coding()
{
set("minimap_movement_coding", !minimap_movement_coding());
}
bool minimap_terrain_coding()
{
return preferences::get("minimap_terrain_coding", true);
}
void toggle_minimap_terrain_coding()
{
set("minimap_terrain_coding", !minimap_terrain_coding());
}
bool minimap_draw_units()
{
return preferences::get("minimap_draw_units", true);
}
void toggle_minimap_draw_units()
{
set("minimap_draw_units", !minimap_draw_units());
}
bool minimap_draw_villages()
{
return preferences::get("minimap_draw_villages", true);
}
void toggle_minimap_draw_villages()
{
set("minimap_draw_villages", !minimap_draw_villages());
}
bool minimap_draw_terrain()
{
return preferences::get("minimap_draw_terrain", true);
}
void toggle_minimap_draw_terrain()
{
set("minimap_draw_terrain", !minimap_draw_terrain());
}
void set_animate_map(bool value)
{
set("animate_map", value);
}
void set_animate_water(bool value)
{
set("animate_water", value);
}
bool show_fps()
{
return fps;
}
void set_show_fps(bool value)
{
fps = value;
}
int draw_delay()
{
return draw_delay_;
}
void set_draw_delay(int value)
{
draw_delay_ = value;
}
bool use_color_cursors()
{
return get("color_cursors", true);
}
void _set_color_cursors(bool value)
{
preferences::set("color_cursors", value);
}
void load_hotkeys()
{
hotkey::load_hotkeys(prefs, false);
}
void save_hotkeys()