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