The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
preferences.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://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 #include "global.hpp"
21 
22 #define GETTEXT_DOMAIN "wesnoth-lib"
23 
24 #include "config.hpp"
25 #include "filesystem.hpp"
26 #include "game_config.hpp"
27 #include "hotkey/hotkey_item.hpp"
28 #include "log.hpp"
29 #include "preferences.hpp"
30 #include "sound.hpp"
31 #include "video.hpp" // non_interactive()
32 #include "serialization/parser.hpp"
33 #include "util.hpp"
34 
35 #include <sys/stat.h> // for setting the permissions of the preferences file
36 #include <boost/concept_check.hpp>
37 #ifndef _WIN32
38 #include <unistd.h>
39 #endif
40 
41 static lg::log_domain log_config("config");
42 #define ERR_CFG LOG_STREAM(err , log_config)
43 
44 static lg::log_domain log_filesystem("filesystem");
45 #define ERR_FS LOG_STREAM(err, log_filesystem)
46 
47 namespace {
48 
49 bool no_preferences_save = false;
50 
51 bool fps = false;
52 
53 int draw_delay_ = 20;
54 
55 config prefs;
56 }
57 
58 namespace preferences {
59 
61 public:
62  virtual void handle_event(const SDL_Event &) {}
63  virtual void handle_window_event(const SDL_Event &event);
65 };
66 
68 
70 {
71  event_handler_.join_global();
72 
73  try{
74 #ifdef DEFAULT_PREFS_PATH
76  read(prefs, *stream);
77 
78  config user_prefs;
80  read(user_prefs, *stream);
81 
82  prefs.merge_with(user_prefs);
83 #else
85  read(prefs, *stream);
86 #endif
87  } catch(const config::error& e) {
88  ERR_CFG << "Error loading preference, message: "
89  << e.what()
90  << std::endl;
91  }
92 }
93 
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  */
112 {
113 
114  // Saftey 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(std::make_pair(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 
139  bool prefs_file_existed = access(filesystem::get_prefs_file().c_str(), F_OK) == 0;
140 
141 #endif
142 
143  try {
145  write(*prefs_file, prefs);
146  } catch(filesystem::io_exception&) {
147  ERR_FS << "error writing to preferences file '" << filesystem::get_prefs_file() << "'" << std::endl;
148  }
149 
150 
151 #ifndef _WIN32
152 
153  if(!prefs_file_existed) {
154 
155  if(chmod(filesystem::get_prefs_file().c_str(), 0600) == -1) {
156  ERR_FS << "error setting permissions of preferences file '" << filesystem::get_prefs_file() << "'" << std::endl;
157  }
158 
159  }
160 
161 #endif
162 
163 
164 }
165 
166 void set(const std::string &key, bool value)
167 {
168  prefs[key] = value;
169 }
170 
171 void set(const std::string &key, int value)
172 {
173  prefs[key] = value;
174 }
175 
176 void set(const std::string &key, char const *value)
177 {
178  prefs[key] = value;
179 }
180 
181 void set(const std::string &key, const std::string &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  no_preferences_save = true;
224 }
225 
227  config* pointer = &prefs;
228  return pointer;
229 }
230 
231 
233  return get("show_ally_orb", game_config::show_ally_orb);
234 }
235 void set_show_allied_orb(bool show_orb) {
236  prefs["show_ally_orb"] = show_orb;
237 }
238 
240  return get("show_enemy_orb", game_config::show_enemy_orb);
241 }
242 void set_show_enemy_orb(bool show_orb) {
243  prefs["show_enemy_orb"] = show_orb;
244 }
245 
247  return get("show_moved_orb", game_config::show_moved_orb);
248 }
249 void set_show_moved_orb(bool show_orb) {
250  prefs["show_moved_orb"] = show_orb;
251 }
252 
254  return get("show_unmoved_orb", game_config::show_unmoved_orb);
255 }
256 void set_show_unmoved_orb(bool show_orb) {
257  prefs["show_unmoved_orb"] = show_orb;
258 }
259 
261  return get("show_partial_orb", game_config::show_partial_orb);
262 }
263 void set_show_partial_orb(bool show_orb) {
264  prefs["show_partial_orb"] = show_orb;
265 }
266 
267 
269  if (color.substr(0,4) == "orb_") {
270  if(color[4] >= '0' && color[4] <= '9') {
271  return color.substr(5);
272  } else {
273  return color.substr(4);
274  }
275  }
276  return color;
277 }
278 
280  std::string ally_color = get("ally_orb_color");
281  if (ally_color.empty())
283  return fix_orb_color_name(ally_color);
284 }
285 void set_allied_color(const std::string& color_id) {
286  prefs["ally_orb_color"] = color_id;
287 }
288 
290  std::string core_id = get("core");
291  if (core_id.empty())
292  return "default";
293  return core_id;
294 }
296  prefs["core"] = core_id;
297 }
298 
300  std::string enemy_color = get("enemy_orb_color");
301  if (enemy_color.empty())
303  return fix_orb_color_name(enemy_color);
304 }
305 void set_enemy_color(const std::string& color_id) {
306  prefs["enemy_orb_color"] = color_id;
307 }
308 
310  std::string moved_color = get("moved_orb_color");
311  if (moved_color.empty())
313  return fix_orb_color_name(moved_color);
314 }
315 void set_moved_color(const std::string& color_id) {
316  prefs["moved_orb_color"] = color_id;
317 }
318 
320  std::string unmoved_color = get("unmoved_orb_color");
321  if (unmoved_color.empty())
323  return fix_orb_color_name(unmoved_color);
324 }
325 void set_unmoved_color(const std::string& color_id) {
326  prefs["unmoved_orb_color"] = color_id;
327 }
328 
330  std::string partmoved_color = get("partial_orb_color");
331  if (partmoved_color.empty())
333  return fix_orb_color_name(partmoved_color);
334 }
335 void set_partial_color(const std::string& color_id) {
336  prefs["partial_orb_color"] = color_id;
337 }
338 
340 {
341  return get("scroll_to_action", true);
342 }
343 
344 void set_scroll_to_action(bool ison)
345 {
346  prefs["scroll_to_action"] = ison;
347 }
348 
350 {
351  return 800;
352 }
353 
355 {
356  return 600;
357 }
358 
359 std::pair<int,int> resolution()
360 {
361  const std::string& x = prefs["xresolution"], y = prefs["yresolution"];
362 
363  if (!x.empty() && !y.empty()) {
364  return std::make_pair(
365  std::max(std::stoi(x), min_allowed_width()),
366  std::max(std::stoi(y), min_allowed_height()));
367  } else {
368  return std::pair<int,int>(1024,768);
369  }
370 }
371 
372 bool maximized()
373 {
374  return get("maximized", !fullscreen());
375 }
376 
378 {
379  return get("fullscreen", false);
380 }
381 
382 void _set_resolution(const std::pair<int, int>& res)
383 {
384  preferences::set("xresolution", std::to_string(res.first));
385  preferences::set("yresolution", std::to_string(res.second));
386 }
387 
388 void _set_maximized(bool ison)
389 {
390  prefs["maximized"] = ison;
391 }
392 
393 void _set_fullscreen(bool ison)
394 {
395  prefs["fullscreen"] = ison;
396 }
397 
398 bool turbo()
399 {
400  if(CVideo::get_singleton().non_interactive()) {
401  return true;
402  }
403 
404  return get("turbo", false);
405 }
406 
407 void _set_turbo(bool ison)
408 {
409  prefs["turbo"] = ison;
410 }
411 
412 double turbo_speed()
413 {
414  return prefs["turbo_speed"].to_double(2.0);
415 }
416 
417 void save_turbo_speed(const double speed)
418 {
419  prefs["turbo_speed"] = speed;
420 }
421 
423 {
424  // Clip at 50 because if it's too low it'll cause crashes
425  return std::max<int>(50, prefs["font_scale"].to_int(100));
426 }
427 
429 {
430  prefs["font_scale"] = scale;
431 }
432 
434 {
435  return (size * font_scaling()) / 100;
436 }
437 
438 bool idle_anim()
439 {
440  return get("idle_anim", true);
441 }
442 
443 void _set_idle_anim(const bool ison)
444 {
445  prefs["idle_anim"] = ison;
446 }
447 
449 {
450  return prefs["idle_anim_rate"];
451 }
452 
453 void _set_idle_anim_rate(const int rate)
454 {
455  prefs["idle_anim_rate"] = rate;
456 }
457 
459 {
460  return prefs["locale"];
461 }
462 
464 {
465  preferences::set("locale", s);
466 }
467 
468 bool ellipses()
469 {
470  return get("show_side_colors", false);
471 }
472 
473 void set_ellipses(bool ison)
474 {
475  preferences::set("show_side_colors", ison);
476 }
477 
478 bool grid()
479 {
480  return get("grid", false);
481 }
482 
483 void _set_grid(bool ison)
484 {
485  preferences::set("grid", ison);
486 }
487 
489 {
490  // Sounds don't sound good on Windows unless the buffer size is 4k,
491  // but this seems to cause crashes on other systems...
492  #ifdef _WIN32
493  const size_t buf_size = 4096;
494  #else
495  const size_t buf_size = 1024;
496  #endif
497 
498  return prefs["sound_buffer_size"].to_int(buf_size);
499 }
500 
501 void save_sound_buffer_size(const size_t size)
502 {
503  #ifdef _WIN32
504  const char* buf_size = "4096";
505  #else
506  const char* buf_size = "1024";
507  #endif
508 
509  const std::string new_size = lexical_cast_default<std::string>(size, buf_size);
510  if (get("sound_buffer_size") == new_size)
511  return;
512 
513  preferences::set("sound_buffer_size", new_size);
514 
516 }
517 
519 {
520  return prefs["music_volume"].to_int(100);
521 }
522 
523 void set_music_volume(int vol)
524 {
525  if(music_volume() == vol) {
526  return;
527  }
528 
529  prefs["music_volume"] = vol;
531 }
532 
534 {
535  return prefs["sound_volume"].to_int(100);
536 }
537 
538 void set_sound_volume(int vol)
539 {
540  if(sound_volume() == vol) {
541  return;
542  }
543 
544  prefs["sound_volume"] = vol;
546 }
547 
549 {
550  return prefs["bell_volume"].to_int(100);
551 }
552 
553 void set_bell_volume(int vol)
554 {
555  if(bell_volume() == vol) {
556  return;
557  }
558 
559  prefs["bell_volume"] = vol;
561 }
562 
564 {
565  return prefs["UI_volume"].to_int(100);
566 }
567 
568 void set_UI_volume(int vol)
569 {
570  if(UI_volume() == vol) {
571  return;
572  }
573 
574  prefs["UI_volume"] = vol;
576 }
577 
578 bool turn_bell()
579 {
580  return get("turn_bell", true);
581 }
582 
583 bool set_turn_bell(bool ison)
584 {
585  if(!turn_bell() && ison) {
586  preferences::set("turn_bell", true);
587  if(!music_on() && !sound_on() && !UI_sound_on()) {
588  if(!sound::init_sound()) {
589  preferences::set("turn_bell", false);
590  return false;
591  }
592  }
593  } else if(turn_bell() && !ison) {
594  preferences::set("turn_bell", false);
596  if(!music_on() && !sound_on() && !UI_sound_on())
598  }
599  return true;
600 }
601 
603 {
604  return get("UI_sound", true);
605 }
606 
607 bool set_UI_sound(bool ison)
608 {
609  if(!UI_sound_on() && ison) {
610  preferences::set("UI_sound", true);
611  if(!music_on() && !sound_on() && !turn_bell()) {
612  if(!sound::init_sound()) {
613  preferences::set("UI_sound", false);
614  return false;
615  }
616  }
617  } else if(UI_sound_on() && !ison) {
618  preferences::set("UI_sound", false);
620  if(!music_on() && !sound_on() && !turn_bell())
622  }
623  return true;
624 }
625 
627 {
628  return get("message_bell", true);
629 }
630 
631 bool sound_on()
632 {
633  return get("sound", true);
634 }
635 
636 bool set_sound(bool ison) {
637  if(!sound_on() && ison) {
638  preferences::set("sound", true);
639  if(!music_on() && !turn_bell() && !UI_sound_on()) {
640  if(!sound::init_sound()) {
641  preferences::set("sound", false);
642  return false;
643  }
644  }
645  } else if(sound_on() && !ison) {
646  preferences::set("sound", false);
648  if(!music_on() && !turn_bell() && !UI_sound_on())
650  }
651  return true;
652 }
653 
654 bool music_on()
655 {
656  return get("music", true);
657 }
658 
659 bool set_music(bool ison) {
660  if(!music_on() && ison) {
661  preferences::set("music", true);
662  if(!sound_on() && !turn_bell() && !UI_sound_on()) {
663  if(!sound::init_sound()) {
664  preferences::set("music", false);
665  return false;
666  }
667  }
668  else
670  } else if(music_on() && !ison) {
671  preferences::set("music", false);
672  if(!sound_on() && !turn_bell() && !UI_sound_on())
674  else
676  }
677  return true;
678 }
679 
680 namespace {
681  double scroll = 0.2;
682 }
683 
685 {
686  return get("joystick_support_enabled", false);
687 }
688 
690 {
691  const int value = lexical_cast_in_range<int>(get("joystick_scroll_deadzone"), 1500, 0, 16000);
692  return value;
693 }
694 
696 {
697  const int value = lexical_cast_in_range<int>(get("joystick_num_scroll_xaxis"), 0, -1, 3);
698  return value;
699 }
700 
702 {
703  const int value = lexical_cast_in_range<int>(get("joystick_scroll_xaxis_num"), 0, 0, 7);
704  return value;
705 }
706 
708 {
709  const int value = lexical_cast_in_range<int>(get("joystick_num_scroll_yaxis"), 0, -1, 3);
710  return value;
711 }
712 
714 {
715  const int value = lexical_cast_in_range<int>(get("joystick_scroll_yaxis_num"), 1, 0, 7);
716  return value;
717 }
718 
720 {
721  const int value = lexical_cast_in_range<int>(get("joystick_scroll_deadzone"), 1500, 0, 16000);
722  return value;
723 }
724 
726 {
727  const int value = lexical_cast_in_range<int>(get("joystick_cursor_deadzone"), 1500, 0, 16000);
728  return value;
729 }
730 
732 {
733  const int value = lexical_cast_in_range<int>(get("joystick_thrusta_deadzone"), 1500, 0, 16000);
734  return value;
735 }
736 
738 {
739  const int value = lexical_cast_in_range<int>(get("joystick_thrustb_deadzone"), 1500, 0, 16000);
740  return value;
741 }
742 
744 {
745  const int value = lexical_cast_in_range<int>(get("joystick_cursor_threshold"), 10000, 0, 16000);
746  return value;
747 }
748 
750 {
751  const int value = lexical_cast_in_range<int>(get("joystick_num_scroll_xaxis"), 0, -1, 3);
752  return value;
753 }
754 
756 {
757  const int value = lexical_cast_in_range<int>(get("joystick_scroll_xaxis_num"), 0, 0, 7);
758  return value;
759 }
760 
762 {
763  const int value = lexical_cast_in_range<int>(get("joystick_num_scroll_yaxis"), 0, -1, 3);
764  return value;
765 }
766 
768 {
769  const int value = lexical_cast_in_range<int>(get("joystick_scroll_yaxis_num"), 1, 0, 7);
770  return value;
771 }
772 
774 {
775  const int value = lexical_cast_in_range<int>(get("joystick_num_cursor_xaxis"), 0, -1, 3);
776  return value;
777 }
778 
780 {
781  const int value = lexical_cast_in_range<int>(get("joystick_cursor_xaxis_num"), 3, 0, 7);
782  return value;
783 }
784 
786 {
787  const int value = lexical_cast_in_range<int>(get("joystick_num_cursor_yaxis"), 0, -1, 3);
788  return value;
789 }
790 
792 {
793  const int value = lexical_cast_in_range<int>(get("joystick_cursor_yaxis_num"), 4, 0, 7);
794  return value;
795 }
796 
798 {
799  const int value = lexical_cast_in_range<int>(get("joystick_num_thrusta_axis"), 0, -1, 3);
800  return value;
801 }
802 
804 {
805  const int value = lexical_cast_in_range<int>(get("joystick_thrusta_axis_num"), 2, 0, 7);
806  return value;
807 }
808 
810 {
811  const int value = lexical_cast_in_range<int>(get("joystick_num_thrustb_axis"), 0, -1, 3);
812  return value;
813 }
814 
816 {
817  const int value = lexical_cast_in_range<int>(get("joystick_thrustb_axis_num"), 2, 0, 7);
818  return value;
819 }
820 
821 
823 {
824  const int value = lexical_cast_in_range<int>(get("scroll"), 50, 1, 100);
825  scroll = value/100.0;
826 
827  return value;
828 }
829 
830 void set_scroll_speed(const int new_speed)
831 {
832  prefs["scroll"] = new_speed;
833  scroll = new_speed / 100.0;
834 }
835 
837 {
838  return get("middle_click_scrolls", true);
839 }
840 
842 {
843  return get("mouse_scrolling", true);
844 }
845 
847 {
848  set("mouse_scrolling", value);
849 }
850 
852 {
853  return prefs["scroll_threshold"].to_int(10);
854 }
855 
857 {
858  return preferences::get("animate_map", true);
859 }
860 
862 {
863  return preferences::get("animate_water", true);
864 }
865 
867 {
868  return preferences::get("minimap_movement_coding", true);
869 }
870 
872 {
873  set("minimap_movement_coding", !minimap_movement_coding());
874 }
875 
877 {
878  return preferences::get("minimap_terrain_coding", true);
879 }
880 
882 {
883  set("minimap_terrain_coding", !minimap_terrain_coding());
884 }
885 
887 {
888  return preferences::get("minimap_draw_units", true);
889 }
890 
892 {
893  set("minimap_draw_units", !minimap_draw_units());
894 }
895 
897 {
898  return preferences::get("minimap_draw_villages", true);
899 }
900 
902 {
903  set("minimap_draw_villages", !minimap_draw_villages());
904 }
905 
907 {
908  return preferences::get("minimap_draw_terrain", true);
909 }
910 
912 {
913  set("minimap_draw_terrain", !minimap_draw_terrain());
914 }
915 
917 {
918  set("animate_map", value);
919 }
920 
922 {
923  set("animate_water", value);
924 }
925 
927 {
928  return preferences::get("unit_standing_animations", true);
929 }
930 
932 {
933  set("unit_standing_animations", value);
934 }
935 
936 bool show_fps()
937 {
938  return fps;
939 }
940 
941 void set_show_fps(bool value)
942 {
943  fps = value;
944 }
945 
947 {
948  return draw_delay_;
949 }
950 
952 {
953  draw_delay_ = value;
954 }
955 
957 {
958  return get("color_cursors", true);
959 }
960 
962 {
963  preferences::set("color_cursors", value);
964 }
965 
967 {
968  hotkey::load_hotkeys(prefs, false);
969 }
970 
972 {
973  hotkey::save_hotkeys(prefs);
974 }
975 
977 {
979  prefs.clear_children("hotkey");
980 }
981 
982 void add_alias(const std::string &alias, const std::string &command)
983 {
984  config &alias_list = prefs.child_or_add("alias");
985  alias_list[alias] = command;
986 }
987 
988 
990 {
991  return get_child("alias");
992 }
993 
994 unsigned int sample_rate()
995 {
996  return prefs["sample_rate"].to_int(44100);
997 }
998 
999 void save_sample_rate(const unsigned int rate)
1000 {
1001  if (sample_rate() == rate)
1002  return;
1003 
1004  prefs["sample_rate"] = int(rate);
1005 
1006  // If audio is open, we have to re set sample rate
1008 }
1009 
1011 {
1012  return get("confirm_load_save_from_different_version", true);
1013 }
1014 
1016 {
1017  return get("use_twelve_hour_clock_format", false);
1018 }
1019 
1021 {
1022  return get("disable_auto_moves", false);
1023 }
1024 
1026 {
1027  preferences::set("disable_auto_moves", value);
1028 }
1029 
1031 {
1032  return get("disable_loadingscreen_animation", false);
1033 }
1034 
1036 {
1037  set("disable_loadingscreen_animation", value);
1038 }
1039 
1040 } // end namespace preferences
1041 
int joystick_mouse_xaxis_num()
bool disable_auto_moves()
void _set_turbo(bool ison)
int joystick_thrustb_axis_num()
bool set_sound(bool ison)
void set_show_enemy_orb(bool show_orb)
std::string unmoved_color()
void close_sound()
Definition: sound.cpp:362
void _set_fullscreen(bool ison)
int bell_volume()
bool turn_bell()
int joystick_mouse_yaxis_num()
void _set_grid(bool ison)
void _set_resolution(const std::pair< int, int > &res)
bool show_unmoved_orb
Definition: game_config.cpp:81
void set_moved_color(const std::string &color_id)
int joystick_num_mouse_xaxis()
void save_hotkeys()
bool minimap_draw_units()
void set_allied_color(const std::string &color_id)
bool show_fps()
void set_unmoved_color(const std::string &color_id)
void set_show_standing_animations(bool value)
void stop_music()
Definition: sound.cpp:411
void write_preferences()
GLenum GLenum GLenum GLenum GLenum scale
Definition: glew.h:10669
void _set_maximized(bool ison)
int mouse_scroll_threshold()
Gets the threshold for when to scroll.
void disable_preferences_save()
void save_hotkeys(config &cfg)
Save the non-default hotkeys to the config.
const char * what() const
Definition: exceptions.hpp:35
void set_show_unmoved_orb(bool show_orb)
int joystick_thrusta_axis_num()
void _set_color_cursors(bool value)
void set_disable_loadingscreen_animation(bool value)
int draw_delay()
config & child_or_add(const std::string &key)
Returns a reference to the first child with the given key.
Definition: config.cpp:734
void set_scroll_speed(const int new_speed)
bool minimap_movement_coding()
int joystick_num_cursor_yaxis()
void set_UI_volume(int vol)
Definition: sound.cpp:890
bool show_enemy_orb()
#define ERR_FS
Definition: preferences.cpp:45
int scroll_speed()
void save_turbo_speed(const double speed)
prefs_event_handler event_handler_
Definition: preferences.cpp:67
void enable_mouse_scroll(bool value)
bool show_allied_orb()
void clear(const std::string &key)
int joystick_thrustb_deadzone()
bool idle_anim()
GLuint const GLfloat * val
Definition: glew.h:2614
bool message_bell()
int joystick_num_mouse_yaxis()
void stop_sound()
Definition: sound.cpp:422
static CVideo & get_singleton()
Definition: video.hpp:75
void set(const std::string &key, bool value)
int joystick_num_thrustb_axis()
unsigned int sample_rate()
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1220
double turbo_speed()
bool confirm_load_save_from_different_version()
bool animate_water()
std::string enemy_orb_color
Definition: game_config.cpp:74
void set_sound_volume(int vol)
int joystick_num_scroll_xaxis()
bool show_enemy_orb
Definition: game_config.cpp:81
-file util.hpp
Definitions for the interface to Wesnoth Markup Language (WML).
int joystick_num_cursor_xaxis()
bool ellipses()
bool sound_on()
bool show_ally_orb
Definition: game_config.cpp:81
void save_sound_buffer_size(const size_t size)
bool maximized()
bool init_sound()
Definition: sound.cpp:314
int joystick_cursor_yaxis_num()
GLuint GLuint stream
Definition: glew.h:5239
void reset_sound()
Definition: sound.cpp:389
bool minimap_draw_villages()
int joystick_thrusta_deadzone()
std::string ally_orb_color
Definition: game_config.cpp:74
bool joystick_support_enabled()
void set_bell_volume(int vol)
Definition: sound.cpp:879
std::string get(const std::string &key)
void set_enemy_color(const std::string &color_id)
void load_hotkeys()
void toggle_minimap_draw_units()
int joystick_scroll_yaxis_num()
virtual void handle_window_event(const SDL_Event &event)
void stop_UI_sound()
Definition: sound.cpp:457
bool fullscreen()
GLsizei const GLfloat * value
Definition: glew.h:1817
void set_font_scaling(int scale)
std::istream * istream_file(const std::string &fname, bool treat_failure_as_error=true)
void set_music_volume(int vol)
void play_music()
Definition: sound.cpp:485
int font_scaled(int size)
void set_show_fps(bool value)
std::ostream * ostream_file(std::string const &fname, bool create_directory=true)
void set_partial_color(const std::string &color_id)
void erase(const std::string &key)
std::pair< int, int > resolution()
void set_show_partial_orb(bool show_orb)
void set_core_id(const std::string &core_id)
Modify, read and display user preferences.
void toggle_minimap_draw_terrain()
#define ERR_CFG
Definition: preferences.cpp:42
bool UI_sound_on()
void set_bell_volume(int vol)
bool animate_map()
bool show_standing_animations()
void set_animate_map(bool value)
std::string moved_orb_color
Definition: game_config.cpp:74
int joystick_scroll_xaxis_num()
void _set_idle_anim(const bool ison)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
Templates and utility-routines for strings and numbers.
void set_sound_volume(int vol)
Definition: sound.cpp:859
std::string get_default_prefs_file()
GLsizei const GLvoid * pointer
Definition: glew.h:1491
GLuint color
Definition: glew.h:5801
void set_show_moved_orb(bool show_orb)
bool show_moved_orb()
void set_music_volume(int vol)
Definition: sound.cpp:849
void set_draw_delay(int value)
void toggle_minimap_draw_villages()
int idle_anim_rate()
int joystick_num_thrusta_axis()
void set_UI_volume(int vol)
void set_child(const std::string &key, const config &val)
static std::string fix_orb_color_name(const std::string &color)
GLuint GLint GLboolean GLint GLenum access
Definition: glew.h:8305
GLuint res
Definition: glew.h:9258
void save_sample_rate(const unsigned int rate)
static lg::log_domain log_filesystem("filesystem")
size_t sound_buffer_size()
std::string allied_color()
void add_alias(const std::string &alias, const std::string &command)
std::string unmoved_orb_color
Definition: game_config.cpp:74
void clear_hotkeys()
std::string moved_color()
void toggle_minimap_terrain_coding()
bool middle_click_scrolls()
An exception object used when an IO error occurs.
Definition: filesystem.hpp:40
bool music_on()
bool use_color_cursors()
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
void toggle_minimap_movement_coding()
bool set_UI_sound(bool ison)
std::string language()
config * get_prefs()
bool show_moved_orb
Definition: game_config.cpp:81
Declarations for File-IO.
void read(config &cfg, std::istream &in, abstract_validator *validator)
Definition: parser.cpp:400
void stop_bell()
Definition: sound.cpp:441
void set_scroll_to_action(bool ison)
void set_ellipses(bool ison)
const config & get_child(const std::string &key)
void reset_default_hotkeys()
Reset all hotkeys to the defaults.
int joystick_cursor_xaxis_num()
int joystick_cursor_threshold()
std::string core_id()
void set_language(const std::string &s)
GLsizeiptr size
Definition: glew.h:1649
sdl_handler(const bool auto_join=true)
Definition: events.cpp:151
bool mouse_scroll_enabled()
bool disable_loadingscreen_animation()
std::string partial_color()
int sound_volume()
int min_allowed_width()
bool have_setting(const std::string &key)
int font_scaling()
bool minimap_draw_terrain()
cl_event event
Definition: glew.h:3070
void load_hotkeys(const config &cfg, bool set_as_default)
Iterates through all hotkeys present in the config struct and creates and adds them to the hotkey lis...
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Definition: config.cpp:658
bool set_music(bool ison)
Standard logging facilities (interface).
int joystick_scroll_deadzone()
bool set_turn_bell(bool ison)
bool scroll_to_action()
virtual void handle_event(const SDL_Event &)
Definition: preferences.cpp:62
int min_allowed_height()
#define e
int joystick_mouse_deadzone()
bool show_partial_orb
Definition: game_config.cpp:81
int joystick_cursor_deadzone()
bool show_unmoved_orb()
std::string partial_orb_color
Definition: game_config.cpp:74
std::string get_prefs_file()
bool show_partial_orb()
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
const config & get_alias()
GLdouble s
Definition: glew.h:1358
int joystick_num_scroll_yaxis()
void set_animate_water(bool value)
void write(std::ostream &out, configr_of const &cfg, unsigned int level)
Definition: parser.cpp:621
static lg::log_domain log_config("config")
void _set_idle_anim_rate(const int rate)
GLsizei const GLcharARB ** string
Definition: glew.h:4503
virtual void join_global()
Definition: events.cpp:230
bool use_twelve_hour_clock_format()
void set_show_allied_orb(bool show_orb)
std::string enemy_color()
int music_volume()
bool minimap_terrain_coding()
void set_disable_auto_moves(bool value)