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