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 void _set_resolution(const point& res)
420 {
421  preferences::set("xresolution", std::to_string(res.x));
422  preferences::set("yresolution", std::to_string(res.y));
423 }
424 
425 void _set_maximized(bool ison)
426 {
427  prefs["maximized"] = ison;
428 }
429 
430 void _set_fullscreen(bool ison)
431 {
432  prefs["fullscreen"] = ison;
433 }
434 
435 bool turbo()
436 {
437  if(CVideo::get_singleton().non_interactive()) {
438  return true;
439  }
440 
441  return get("turbo", false);
442 }
443 
444 void _set_turbo(bool ison)
445 {
446  prefs["turbo"] = ison;
447 }
448 
449 double turbo_speed()
450 {
451  return prefs["turbo_speed"].to_double(2.0);
452 }
453 
454 void save_turbo_speed(const double speed)
455 {
456  prefs["turbo_speed"] = speed;
457 }
458 
460 {
461  // Clip at 80 because if it's too low it'll cause crashes
462  return std::max<int>(std::min<int>(prefs["font_scale"].to_int(100), max_font_scaling), min_font_scaling);
463 }
464 
466 {
467  prefs["font_scale"] = std::clamp(scale, min_font_scaling, max_font_scaling);
468 }
469 
471 {
472  return (size * font_scaling()) / 100;
473 }
474 
475 bool idle_anim()
476 {
477  return get("idle_anim", true);
478 }
479 
480 void _set_idle_anim(const bool ison)
481 {
482  prefs["idle_anim"] = ison;
483 }
484 
486 {
487  return prefs["idle_anim_rate"];
488 }
489 
490 void _set_idle_anim_rate(const int rate)
491 {
492  prefs["idle_anim_rate"] = rate;
493 }
494 
495 std::string language()
496 {
497  return prefs["locale"];
498 }
499 
500 void set_language(const std::string& s)
501 {
502  preferences::set("locale", s);
503 }
504 
505 std::string gui_theme()
506 {
507  return prefs["gui2_theme"];
508 }
509 
510 void set_gui_theme(const std::string& s)
511 {
512  preferences::set("gui2_theme", s);
513 }
514 
515 bool ellipses()
516 {
517  return get("show_side_colors", false);
518 }
519 
520 void set_ellipses(bool ison)
521 {
522  preferences::set("show_side_colors", ison);
523 }
524 
525 bool grid()
526 {
527  return get("grid", false);
528 }
529 
530 void _set_grid(bool ison)
531 {
532  preferences::set("grid", ison);
533 }
534 
535 std::size_t sound_buffer_size()
536 {
537  // Sounds don't sound good on Windows unless the buffer size is 4k,
538  // but this seems to cause crashes on other systems...
539  #ifdef _WIN32
540  const std::size_t buf_size = 4096;
541  #else
542  const std::size_t buf_size = 1024;
543  #endif
544 
545  return prefs["sound_buffer_size"].to_int(buf_size);
546 }
547 
548 void save_sound_buffer_size(const std::size_t size)
549 {
550  #ifdef _WIN32
551  const char* buf_size = "4096";
552  #else
553  const char* buf_size = "1024";
554  #endif
555 
556  const std::string new_size = lexical_cast_default<std::string>(size, buf_size);
557  if (get("sound_buffer_size") == new_size)
558  return;
559 
560  preferences::set("sound_buffer_size", new_size);
561 
563 }
564 
566 {
567  return prefs["music_volume"].to_int(100);
568 }
569 
570 void set_music_volume(int vol)
571 {
572  if(music_volume() == vol) {
573  return;
574  }
575 
576  prefs["music_volume"] = vol;
578 }
579 
581 {
582  return prefs["sound_volume"].to_int(100);
583 }
584 
585 void set_sound_volume(int vol)
586 {
587  if(sound_volume() == vol) {
588  return;
589  }
590 
591  prefs["sound_volume"] = vol;
593 }
594 
596 {
597  return prefs["bell_volume"].to_int(100);
598 }
599 
600 void set_bell_volume(int vol)
601 {
602  if(bell_volume() == vol) {
603  return;
604  }
605 
606  prefs["bell_volume"] = vol;
608 }
609 
611 {
612  return prefs["UI_volume"].to_int(100);
613 }
614 
615 void set_UI_volume(int vol)
616 {
617  if(UI_volume() == vol) {
618  return;
619  }
620 
621  prefs["UI_volume"] = vol;
623 }
624 
625 unsigned int tile_size()
626 {
627  return prefs["tile_size"].to_unsigned();
628 }
629 
630 void set_tile_size(const unsigned int size)
631 {
632  prefs["tile_size"] = size;
633 }
634 
635 bool turn_bell()
636 {
637  return get("turn_bell", true);
638 }
639 
640 bool set_turn_bell(bool ison)
641 {
642  if(!turn_bell() && ison) {
643  preferences::set("turn_bell", true);
644  if(!music_on() && !sound_on() && !UI_sound_on()) {
645  if(!sound::init_sound()) {
646  preferences::set("turn_bell", false);
647  return false;
648  }
649  }
650  } else if(turn_bell() && !ison) {
651  preferences::set("turn_bell", false);
653  if(!music_on() && !sound_on() && !UI_sound_on())
655  }
656  return true;
657 }
658 
660 {
661  return get("UI_sound", true);
662 }
663 
664 bool set_UI_sound(bool ison)
665 {
666  if(!UI_sound_on() && ison) {
667  preferences::set("UI_sound", true);
668  if(!music_on() && !sound_on() && !turn_bell()) {
669  if(!sound::init_sound()) {
670  preferences::set("UI_sound", false);
671  return false;
672  }
673  }
674  } else if(UI_sound_on() && !ison) {
675  preferences::set("UI_sound", false);
677  if(!music_on() && !sound_on() && !turn_bell())
679  }
680  return true;
681 }
682 
684 {
685  return get("message_bell", true);
686 }
687 
688 bool sound_on()
689 {
690  return get("sound", true);
691 }
692 
693 bool set_sound(bool ison) {
694  if(!sound_on() && ison) {
695  preferences::set("sound", true);
696  if(!music_on() && !turn_bell() && !UI_sound_on()) {
697  if(!sound::init_sound()) {
698  preferences::set("sound", false);
699  return false;
700  }
701  }
702  } else if(sound_on() && !ison) {
703  preferences::set("sound", false);
705  if(!music_on() && !turn_bell() && !UI_sound_on())
707  }
708  return true;
709 }
710 
711 bool music_on()
712 {
713  return get("music", true);
714 }
715 
716 bool set_music(bool ison) {
717  if(!music_on() && ison) {
718  preferences::set("music", true);
719  if(!sound_on() && !turn_bell() && !UI_sound_on()) {
720  if(!sound::init_sound()) {
721  preferences::set("music", false);
722  return false;
723  }
724  }
725  else
727  } else if(music_on() && !ison) {
728  preferences::set("music", false);
729  if(!sound_on() && !turn_bell() && !UI_sound_on())
731  else
733  }
734  return true;
735 }
736 
738 {
739  return get("stop_music_in_background", false);
740 }
741 
743 {
744  preferences::set("stop_music_in_background", ison);
745 }
746 
747 namespace {
748  double scroll = 0.2;
749 }
750 
752 {
753  const int value = std::clamp<int>(lexical_cast_default<int>(get("scroll"), 50), 1, 100);
754  scroll = value/100.0;
755 
756  return value;
757 }
758 
759 void set_scroll_speed(const int new_speed)
760 {
761  prefs["scroll"] = new_speed;
762  scroll = new_speed / 100.0;
763 }
764 
766 {
767  return get("middle_click_scrolls", true);
768 }
769 
771 {
772  return get("mouse_scrolling", true);
773 }
774 
775 void enable_mouse_scroll(bool value)
776 {
777  set("mouse_scrolling", value);
778 }
779 
781 {
782  return prefs["scroll_threshold"].to_int(10);
783 }
784 
786 {
787  return preferences::get("animate_map", true);
788 }
789 
791 {
792  return preferences::get("animate_water", true);
793 }
794 
796 {
797  return preferences::get("minimap_movement_coding", true);
798 }
799 
801 {
802  set("minimap_movement_coding", !minimap_movement_coding());
803 }
804 
806 {
807  return preferences::get("minimap_terrain_coding", true);
808 }
809 
811 {
812  set("minimap_terrain_coding", !minimap_terrain_coding());
813 }
814 
816 {
817  return preferences::get("minimap_draw_units", true);
818 }
819 
821 {
822  set("minimap_draw_units", !minimap_draw_units());
823 }
824 
826 {
827  return preferences::get("minimap_draw_villages", true);
828 }
829 
831 {
832  set("minimap_draw_villages", !minimap_draw_villages());
833 }
834 
836 {
837  return preferences::get("minimap_draw_terrain", true);
838 }
839 
841 {
842  set("minimap_draw_terrain", !minimap_draw_terrain());
843 }
844 
845 void set_animate_map(bool value)
846 {
847  set("animate_map", value);
848 }
849 
850 void set_animate_water(bool value)
851 {
852  set("animate_water", value);
853 }
854 
855 bool show_fps()
856 {
857  return fps;
858 }
859 
860 void set_show_fps(bool value)
861 {
862  fps = value;
863 }
864 
866 {
867  return prefs["draw_delay"].to_int(-1);
868 }
869 
870 void set_draw_delay(int value)
871 {
872  prefs["draw_delay"] = value;
873 }
874 
876 {
877  return get("color_cursors", true);
878 }
879 
880 void _set_color_cursors(bool value)
881 {
882  preferences::set("color_cursors", value);
883 }
884 
886 {
888 }
889 
891 {
893 }
894 
896 {
898  prefs.clear_children("hotkey");
899 }
900 
901 void add_alias(const std::string &alias, const std::string &command)
902 {
903  config &alias_list = prefs.child_or_add("alias");
904  alias_list[alias] = command;
905 }
906 
907 
909 {
910  return get_child("alias");
911 }
912 
913 unsigned int sample_rate()
914 {
915  return prefs["sample_rate"].to_int(44100);
916 }
917 
918 void save_sample_rate(const unsigned int rate)
919 {
920  if (sample_rate() == rate)
921  return;
922 
923  prefs["sample_rate"] = static_cast<int>(rate);
924 
925  // If audio is open, we have to re set sample rate
927 }
928 
930 {
931  return get("confirm_load_save_from_different_version", true);
932 }
933 
935 {
936  return get("use_twelve_hour_clock_format", false);
937 }
938 
940 {
941  return get("disable_auto_moves", false);
942 }
943 
944 void set_disable_auto_moves(bool value)
945 {
946  preferences::set("disable_auto_moves", value);
947 }
948 
950 {
951  return get("damage_prediction_allow_monte_carlo_simulation", true);
952 }
953 
955 {
956  set("damage_prediction_allow_monte_carlo_simulation", value);
957 }
958 
960 {
961  return get("addon_manager_saved_order_name");
962 }
963 
964 void set_addon_manager_saved_order_name(const std::string& value)
965 {
966  set("addon_manager_saved_order_name", value);
967 }
968 
970 {
971  return SORT_ORDER::string_to_enum(get("addon_manager_saved_order_direction"), SORT_ORDER::NONE);
972 }
973 
975 {
976  set("addon_manager_saved_order_direction", SORT_ORDER::enum_to_string(value));
977 }
978 
979 
980 } // end namespace preferences
bool disable_auto_moves()
Definition: general.cpp:939
void _set_turbo(bool ison)
Definition: general.cpp:444
bool set_sound(bool ison)
Definition: general.cpp:693
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:430
int bell_volume()
Definition: general.cpp:595
bool turn_bell()
Definition: general.cpp:635
void _set_grid(bool ison)
Definition: general.cpp:530
std::string addon_manager_saved_order_name()
Definition: general.cpp:959
bool show_unmoved_orb
void set_moved_color(const std::string &color_id)
Definition: general.cpp:349
void save_hotkeys()
Definition: general.cpp:890
bool minimap_draw_units()
Definition: general.cpp:815
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:855
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:425
int mouse_scroll_threshold()
Gets the threshold for when to scroll.
Definition: general.cpp:780
void disable_preferences_save()
Definition: general.cpp:227
void set_addon_manager_saved_order_direction(SORT_ORDER value)
Definition: general.cpp:974
void save_hotkeys(config &cfg)
Save the non-default hotkeys to the config.
SORT_ORDER addon_manager_saved_order_direction()
Definition: general.cpp:969
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:880
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:865
void set_scroll_speed(const int new_speed)
Definition: general.cpp:759
bool minimap_movement_coding()
Definition: general.cpp:795
void set_UI_volume(int vol)
Definition: sound.cpp:1120
bool show_enemy_orb()
Definition: general.cpp:267
int scroll_speed()
Definition: general.cpp:751
void save_turbo_speed(const double speed)
Definition: general.cpp:454
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:419
void enable_mouse_scroll(bool value)
Definition: general.cpp:775
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:475
bool message_bell()
Definition: general.cpp:683
std::string gui_theme()
Definition: general.cpp:505
void set_tile_size(const unsigned int size)
Definition: general.cpp:630
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:913
double turbo_speed()
Definition: general.cpp:449
bool confirm_load_save_from_different_version()
Definition: general.cpp:929
bool animate_water()
Definition: general.cpp:790
std::string enemy_orb_color
void set_sound_volume(int vol)
Definition: general.cpp:585
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:515
void load_base_prefs()
Definition: general.cpp:236
bool sound_on()
Definition: general.cpp:688
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:825
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:885
void toggle_minimap_draw_units()
Definition: general.cpp:820
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:465
void set_music_volume(int vol)
Definition: general.cpp:570
void play_music()
Definition: sound.cpp:617
int font_scaled(int size)
Definition: general.cpp:470
void set_show_fps(bool value)
Definition: general.cpp:860
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:840
bool UI_sound_on()
Definition: general.cpp:659
void set_bell_volume(int vol)
Definition: general.cpp:600
void set_stop_music_in_background(bool ison)
Definition: general.cpp:742
bool animate_map()
Definition: general.cpp:785
bool damage_prediction_allow_monte_carlo_simulation()
Definition: general.cpp:949
void set_animate_map(bool value)
Definition: general.cpp:845
const char * what() const noexcept
Definition: exceptions.hpp:36
std::string moved_orb_color
void _set_idle_anim(const bool ison)
Definition: general.cpp:480
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:870
void toggle_minimap_draw_villages()
Definition: general.cpp:830
int idle_anim_rate()
Definition: general.cpp:485
#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:615
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:918
std::string allied_color()
Definition: general.cpp:313
void add_alias(const std::string &alias, const std::string &command)
Definition: general.cpp:901
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:895
std::string moved_color()
Definition: general.cpp:343
unsigned int tile_size()
Definition: general.cpp:625
void toggle_minimap_terrain_coding()
Definition: general.cpp:810
bool middle_click_scrolls()
Definition: general.cpp:765
An exception object used when an IO error occurs.
Definition: filesystem.hpp:48
bool stop_music_in_background()
Definition: general.cpp:737
static map_location::DIRECTION s
bool music_on()
Definition: general.cpp:711
bool use_color_cursors()
Definition: general.cpp:875
void toggle_minimap_movement_coding()
Definition: general.cpp:800
Holds a 2D point.
Definition: point.hpp:24
bool set_UI_sound(bool ison)
Definition: general.cpp:664
std::string language()
Definition: general.cpp:495
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:520
void save_sound_buffer_size(const std::size_t size)
Definition: general.cpp:548
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:535
std::string core_id()
Definition: general.cpp:323
void set_language(const std::string &s)
Definition: general.cpp:500
bool grid()
Definition: general.cpp:525
const int def_window_height
Definition: general.cpp:70
bool mouse_scroll_enabled()
Definition: general.cpp:770
std::string partial_color()
Definition: general.cpp:363
int sound_volume()
Definition: general.cpp:580
bool have_setting(const std::string &key)
Definition: general.cpp:205
int font_scaling()
Definition: general.cpp:459
bool minimap_draw_terrain()
Definition: general.cpp:835
void set_show_disengaged_orb(bool show_orb)
Definition: general.cpp:298
void load_credentials()
bool set_music(bool ison)
Definition: general.cpp:716
Standard logging facilities (interface).
bool set_turn_bell(bool ison)
Definition: general.cpp:640
bool turbo()
Definition: general.cpp:435
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:610
bool show_unmoved_orb()
Definition: general.cpp:281
void set_damage_prediction_allow_monte_carlo_simulation(bool value)
Definition: general.cpp:954
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:908
void set_disengaged_color(const std::string &color_id)
Definition: general.cpp:379
void set_animate_water(bool value)
Definition: general.cpp:850
bool show_disengaged_orb
int y
y coordinate.
Definition: point.hpp:48
void _set_idle_anim_rate(const int rate)
Definition: general.cpp:490
void set_addon_manager_saved_order_name(const std::string &value)
Definition: general.cpp:964
virtual void join_global()
Definition: events.cpp:363
bool use_twelve_hour_clock_format()
Definition: general.cpp:934
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:565
void set_gui_theme(const std::string &s)
Definition: general.cpp:510
bool minimap_terrain_coding()
Definition: general.cpp:805
void set_disable_auto_moves(bool value)
Definition: general.cpp:944