The Battle for Wesnoth  1.15.12+dev
general.hpp
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 #pragma once
16 
17 #include "config.hpp"
18 #include "terrain/translation.hpp"
19 #include "utils/make_enum.hpp"
20 
21 #include <utility>
22 
23 struct point;
24 
25 namespace hotkey {
26  class hotkey_item;
27 }
28 
29 namespace preferences {
30 
31  struct base_manager
32  {
33  base_manager();
34  ~base_manager();
35  };
36 
37  extern const int min_window_width;
38  extern const int min_window_height;
39 
40  extern const int def_window_width;
41  extern const int def_window_height;
42 
43  extern const int min_font_scaling;
44  extern const int max_font_scaling;
45 
46  void write_preferences();
47 
48  void set(const std::string& key, const std::string &value);
49  void set(const std::string& key, char const *value);
50  void set(const std::string& key, bool value);
51  void set(const std::string& key, int value);
52  void set(const std::string& key, const config::attribute_value& value);
53  void clear(const std::string& key);
54  void set_child(const std::string& key, const config& val);
55  const config &get_child(const std::string &key);
56  std::string get(const std::string& key);
57  std::string get(const std::string& key, const std::string& def);
58  bool get(const std::string& key, bool def);
59  config::attribute_value get_as_attribute(const std::string& key);
60  void erase(const std::string& key);
61  bool have_setting(const std::string& key);
62 
64 
65  config* get_prefs();
66 
67  std::string core_id();
68  void set_core_id(const std::string& root);
69 
70  bool scroll_to_action();
71  void set_scroll_to_action(bool ison);
72 
73  point resolution();
74  void _set_resolution(const point& res);
75 
76  bool maximized();
77  void _set_maximized(bool ison);
78 
79  bool fullscreen();
80  void _set_fullscreen(bool ison);
81 
82  bool turbo();
83  void _set_turbo(bool ison);
84 
85  double turbo_speed();
86  void save_turbo_speed(const double speed);
87 
88  int font_scaling();
89  void set_font_scaling(int scale);
90  int font_scaled(int size);
91 
92  bool idle_anim();
93  void _set_idle_anim(const bool ison);
94 
95  int idle_anim_rate();
96  void _set_idle_anim_rate(const int rate);
97 
98  std::string language();
99  void set_language(const std::string& s);
100 
101  std::string gui_theme();
102  void set_gui_theme(const std::string& s);
103 
104  // Don't rename it to sound() because of a gcc-3.3 branch bug,
105  // which will cause it to conflict with the sound namespace.
106  bool sound_on();
107  bool set_sound(bool ison);
108 
109  unsigned int sample_rate();
110  void save_sample_rate(const unsigned int rate);
111 
112  std::size_t sound_buffer_size();
113  void save_sound_buffer_size(const std::size_t size);
114 
115  int sound_volume();
116  void set_sound_volume(int vol);
117 
118  int bell_volume();
119  void set_bell_volume(int vol);
120 
121  int UI_volume();
122  void set_UI_volume(int vol);
123 
124  bool music_on();
125  bool set_music(bool ison);
126 
127  int music_volume();
128  void set_music_volume(int vol);
129 
131  void set_stop_music_in_background(bool ison);
132 
133  unsigned int tile_size();
134  void set_tile_size(const unsigned int size);
135 
136  bool turn_bell();
137  bool set_turn_bell(bool ison);
138 
139  bool UI_sound_on();
140  bool set_UI_sound(bool ison);
141 
142  bool message_bell();
143 
144  // Proxies for preferences_dialog
145  void load_hotkeys();
146  void save_hotkeys();
147  void clear_hotkeys();
148 
149  void add_alias(const std::string& alias, const std::string& command);
150  const config &get_alias();
151 
152 
153  std::string allied_color();
154  void set_allied_color(const std::string& color_id);
155 
156  std::string enemy_color();
157  void set_enemy_color(const std::string& color_id);
158 
159  std::string unmoved_color();
160  void set_unmoved_color(const std::string& color_id);
161 
162  std::string partial_color();
163  void set_partial_color(const std::string& color_id);
164 
165  std::string moved_color();
166  void set_moved_color(const std::string& color_id);
167 
168  std::string disengaged_color();
169  void set_disengaged_color(const std::string& color_id);
170 
171  bool show_allied_orb();
172  void set_show_allied_orb(bool show_orb);
173 
174  bool show_enemy_orb();
175  void set_show_enemy_orb(bool show_orb);
176 
177  bool show_moved_orb();
178  void set_show_moved_orb(bool show_orb);
179 
180  bool show_unmoved_orb();
181  void set_show_unmoved_orb(bool show_orb);
182 
183  bool show_partial_orb();
184  void set_show_partial_orb(bool show_orb);
185 
186  bool show_disengaged_orb();
187  void set_show_disengaged_orb(bool show_orb);
188 
189  bool use_color_cursors();
190  void _set_color_cursors(bool value);
191 
192  int scroll_speed();
193  void set_scroll_speed(const int scroll);
194 
195  bool middle_click_scrolls();
196  bool mouse_scroll_enabled();
197  void enable_mouse_scroll(bool value);
198 
199  /**
200  * Gets the threshold for when to scroll.
201  *
202  * This scrolling happens when the mouse is in the application and near
203  * the border.
204  */
206 
207  int draw_delay();
208  void set_draw_delay(int value);
209 
210  bool animate_map();
211  void set_animate_map(bool value);
212 
213  bool animate_water();
214  void set_animate_water(bool value);
215 
218 
219  bool minimap_terrain_coding();
221 
222  bool minimap_draw_units();
224 
225  bool minimap_draw_villages();
227 
228  bool minimap_draw_terrain();
230 
231  bool show_fps();
232  void set_show_fps(bool value);
233 
234  bool ellipses();
235  void set_ellipses(bool ison);
236 
237  bool grid();
238  void _set_grid(bool ison);
239 
241 
243  void set_use_twelve_hour_clock_format(bool value);
244 
245  bool disable_auto_moves();
246  void set_disable_auto_moves(bool value);
247 
250 
251  std::string addon_manager_saved_order_name();
252  void set_addon_manager_saved_order_name(const std::string& value);
253 
254  // Sorting for GUI2 listboxes
256  (NONE, "none")
257  (ASCENDING, "ascending")
258  (DESCENDING, "descending")
259  )
262 
263 } // 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 _set_fullscreen(bool ison)
Definition: general.cpp:424
int bell_volume()
Definition: general.cpp:589
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
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 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
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
int scroll_speed()
Definition: general.cpp:745
void save_turbo_speed(const double speed)
Definition: general.cpp:448
void _set_resolution(const point &res)
Definition: general.cpp:413
void set_language(const std::string &language, const std::vector< std::string > *)
Definition: gettext.cpp:447
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
void clear_hotkeys(const std::string &command)
Unset the command bindings for all hotkeys matching the command.
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
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
void set_sound_volume(int vol)
Definition: general.cpp:579
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
Keyboard shortcuts for game actions.
bool maximized()
Definition: general.cpp:403
void set_use_twelve_hour_clock_format(bool value)
std::string turn_bell
bool minimap_draw_villages()
Definition: general.cpp:819
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 toggle_minimap_draw_units()
Definition: general.cpp:814
const int min_font_scaling
Definition: general.cpp:71
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
int font_scaled(int size)
Definition: general.cpp:464
void set_show_fps(bool value)
Definition: general.cpp:854
MAKE_ENUM(SORT_ORDER,(NONE, "none")(ASCENDING, "ascending")(DESCENDING, "descending")) SORT_ORDER addon_manager_saved_order_direction()
void set_partial_color(const std::string &color_id)
Definition: general.cpp:363
void erase(const std::string &key)
Definition: general.cpp:218
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
void _set_idle_anim(const bool ison)
Definition: general.cpp:474
void set_show_moved_orb(bool show_orb)
Definition: general.cpp:271
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
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
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
Default, unset return value.
Definition: retval.hpp:31
std::string moved_color()
Definition: general.cpp:337
void toggle_minimap_terrain_coding()
Definition: general.cpp:804
bool middle_click_scrolls()
Definition: general.cpp:759
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
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
std::size_t sound_buffer_size()
Definition: general.cpp:529
std::string core_id()
Definition: general.cpp:317
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
unsigned int tile_size
Definition: game_config.cpp:67
void set_show_disengaged_orb(bool show_orb)
Definition: general.cpp:292
bool set_music(bool ison)
Definition: general.cpp:710
bool set_turn_bell(bool ison)
Definition: general.cpp:634
bool turbo()
Definition: general.cpp:429
bool scroll_to_action()
Definition: general.cpp:377
point resolution()
Definition: general.cpp:387
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
void set_damage_prediction_allow_monte_carlo_simulation(bool value)
Definition: general.cpp:948
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
void _set_idle_anim_rate(const int rate)
Definition: general.cpp:484
Defines the MAKE_ENUM macro.
void set_addon_manager_saved_order_name(const std::string &value)
Definition: general.cpp:958
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