The Battle for Wesnoth  1.15.1+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 /** @file */
16 
17 #pragma once
18 
19 #include "config.hpp"
20 #include "terrain/translation.hpp"
21 #include "utils/make_enum.hpp"
22 
23 #include <utility>
24 
25 struct point;
26 
27 namespace hotkey {
28  class hotkey_item;
29 }
30 
31 namespace preferences {
32 
33  struct base_manager
34  {
35  base_manager();
36  ~base_manager();
37  };
38 
39  extern const int min_window_width;
40  extern const int min_window_height;
41 
42  extern const int def_window_width;
43  extern const int def_window_height;
44 
45  extern const int min_font_scaling;
46  extern const int max_font_scaling;
47 
49  (LINEAR, "linear")
50  (NEAREST_NEIGHBOR, "nn")
51  (XBRZ_LIN, "xbrzlin")
52  (XBRZ_NN, "xbrznn")
53  )
54 
56 
57  void write_preferences();
58 
59  void set(const std::string& key, const std::string &value);
60  void set(const std::string& key, char const *value);
61  void set(const std::string& key, bool value);
62  void set(const std::string& key, int value);
63  void set(const std::string& key, const config::attribute_value& value);
64  void clear(const std::string& key);
65  void set_child(const std::string& key, const config& val);
66  const config &get_child(const std::string &key);
67  std::string get(const std::string& key);
68  std::string get(const std::string& key, const std::string& def);
69  bool get(const std::string& key, bool def);
70  config::attribute_value get_as_attribute(const std::string& key);
71  void erase(const std::string& key);
72  bool have_setting(const std::string& key);
73 
75 
76  config* get_prefs();
77 
78  std::string core_id();
79  void set_core_id(const std::string& root);
80 
81  bool scroll_to_action();
82  void set_scroll_to_action(bool ison);
83 
84  point resolution();
85  void _set_resolution(const point& res);
86 
87  bool maximized();
88  void _set_maximized(bool ison);
89 
90  bool fullscreen();
91  void _set_fullscreen(bool ison);
92 
93  bool turbo();
94  void _set_turbo(bool ison);
95 
96  double turbo_speed();
97  void save_turbo_speed(const double speed);
98 
99  int font_scaling();
100  void set_font_scaling(int scale);
101  int font_scaled(int size);
102 
103  bool idle_anim();
104  void _set_idle_anim(const bool ison);
105 
106  int idle_anim_rate();
107  void _set_idle_anim_rate(const int rate);
108 
109  std::string language();
110  void set_language(const std::string& s);
111 
112  std::string gui_theme();
113  void set_gui_theme(const std::string& s);
114 
115  // Don't rename it to sound() because of a gcc-3.3 branch bug,
116  // which will cause it to conflict with the sound namespace.
117  bool sound_on();
118  bool set_sound(bool ison);
119 
120  unsigned int sample_rate();
121  void save_sample_rate(const unsigned int rate);
122 
123  std::size_t sound_buffer_size();
124  void save_sound_buffer_size(const std::size_t size);
125 
126  int sound_volume();
127  void set_sound_volume(int vol);
128 
129  int bell_volume();
130  void set_bell_volume(int vol);
131 
132  int UI_volume();
133  void set_UI_volume(int vol);
134 
135  bool music_on();
136  bool set_music(bool ison);
137 
138  int music_volume();
139  void set_music_volume(int vol);
140 
142  void set_stop_music_in_background(bool ison);
143 
144  bool turn_bell();
145  bool set_turn_bell(bool ison);
146 
147  bool UI_sound_on();
148  bool set_UI_sound(bool ison);
149 
150  bool message_bell();
151 
152  // Proxies for preferences_dialog
153  void load_hotkeys();
154  void save_hotkeys();
155  void clear_hotkeys();
156 
157  void add_alias(const std::string& alias, const std::string& command);
158  const config &get_alias();
159 
160 
161  std::string allied_color();
162  void set_allied_color(const std::string& color_id);
163 
164  std::string enemy_color();
165  void set_enemy_color(const std::string& color_id);
166 
167  std::string unmoved_color();
168  void set_unmoved_color(const std::string& color_id);
169 
170  std::string partial_color();
171  void set_partial_color(const std::string& color_id);
172 
173  std::string moved_color();
174  void set_moved_color(const std::string& color_id);
175 
176 
177  bool show_allied_orb();
178  void set_show_allied_orb(bool show_orb);
179 
180  bool show_enemy_orb();
181  void set_show_enemy_orb(bool show_orb);
182 
183  bool show_moved_orb();
184  void set_show_moved_orb(bool show_orb);
185 
186  bool show_unmoved_orb();
187  void set_show_unmoved_orb(bool show_orb);
188 
189  bool show_partial_orb();
190  void set_show_partial_orb(bool show_orb);
191 
192 
193  bool use_color_cursors();
194  void _set_color_cursors(bool value);
195 
202 
208 
215 
219 
223 
224  int scroll_speed();
225  void set_scroll_speed(const int scroll);
226 
227  bool middle_click_scrolls();
228  bool mouse_scroll_enabled();
229  void enable_mouse_scroll(bool value);
230 
231  /**
232  * Gets the threshold for when to scroll.
233  *
234  * This scrolling happens when the mouse is in the application and near
235  * the border.
236  */
238 
239  int draw_delay();
240  void set_draw_delay(int value);
241 
242  bool animate_map();
243  void set_animate_map(bool value);
244 
245  bool animate_water();
246  void set_animate_water(bool value);
247 
250 
251  bool minimap_terrain_coding();
253 
254  bool minimap_draw_units();
256 
257  bool minimap_draw_villages();
259 
260  bool minimap_draw_terrain();
262 
263  bool show_fps();
264  void set_show_fps(bool value);
265 
266  bool ellipses();
267  void set_ellipses(bool ison);
268 
269  bool grid();
270  void _set_grid(bool ison);
271 
273 
275  void set_use_twelve_hour_clock_format(bool value);
276 
277  bool disable_auto_moves();
278  void set_disable_auto_moves(bool value);
279 
281  void set_disable_loadingscreen_animation(bool value);
282 
285 
286 } // end namespace preferences
int joystick_mouse_xaxis_num()
Definition: general.cpp:738
bool disable_auto_moves()
Definition: general.cpp:1047
void _set_turbo(bool ison)
Definition: general.cpp:424
int joystick_thrustb_axis_num()
Definition: general.cpp:852
preferences::SCALING_ALGORITHM SCALING_ALGORITHM
Definition: picture.cpp:757
bool set_sound(bool ison)
Definition: general.cpp:663
void set_show_enemy_orb(bool show_orb)
Definition: general.cpp:266
std::string unmoved_color()
Definition: general.cpp:343
void _set_fullscreen(bool ison)
Definition: general.cpp:410
int bell_volume()
Definition: general.cpp:575
int joystick_mouse_yaxis_num()
Definition: general.cpp:750
void _set_grid(bool ison)
Definition: general.cpp:510
bool show_unmoved_orb
void set_moved_color(const std::string &color_id)
Definition: general.cpp:339
int joystick_num_mouse_xaxis()
Definition: general.cpp:732
bool minimap_draw_units()
Definition: general.cpp:923
const int min_window_height
Definition: general.cpp:66
void set_allied_color(const std::string &color_id)
Definition: general.cpp:309
bool show_fps()
Definition: general.cpp:963
void set_unmoved_color(const std::string &color_id)
Definition: general.cpp:349
void write_preferences()
Definition: general.cpp:154
void _set_maximized(bool ison)
Definition: general.cpp:405
int mouse_scroll_threshold()
Gets the threshold for when to scroll.
Definition: general.cpp:888
void disable_preferences_save()
Definition: general.cpp:246
const SCALING_ALGORITHM default_scaling_algorithm
Definition: general.cpp:74
void save_hotkeys(config &cfg)
Save the non-default hotkeys to the config.
void set_show_unmoved_orb(bool show_orb)
Definition: general.cpp:280
int joystick_thrusta_axis_num()
Definition: general.cpp:840
Variant for storing WML attributes.
void _set_color_cursors(bool value)
Definition: general.cpp:988
const int min_window_width
Definition: general.cpp:65
void set_disable_loadingscreen_animation(bool value)
Definition: general.cpp:1062
int draw_delay()
Definition: general.cpp:973
void set_scroll_speed(const int new_speed)
Definition: general.cpp:867
bool minimap_movement_coding()
Definition: general.cpp:903
int joystick_num_cursor_yaxis()
Definition: general.cpp:822
int scroll_speed()
Definition: general.cpp:859
void save_turbo_speed(const double speed)
Definition: general.cpp:434
void _set_resolution(const point &res)
Definition: general.cpp:399
void set_language(const std::string &language, const std::vector< std::string > *)
Definition: gettext.cpp:449
void enable_mouse_scroll(bool value)
Definition: general.cpp:883
bool show_allied_orb()
Definition: general.cpp:256
void clear(const std::string &key)
Definition: general.cpp:205
void clear_hotkeys(const std::string &command)
Unset the command bindings for all hotkeys matching the command.
int joystick_thrustb_deadzone()
Definition: general.cpp:774
bool idle_anim()
Definition: general.cpp:455
bool message_bell()
Definition: general.cpp:653
int joystick_num_mouse_yaxis()
Definition: general.cpp:744
std::string gui_theme()
Definition: general.cpp:485
int joystick_num_thrustb_axis()
Definition: general.cpp:846
unsigned int sample_rate()
Definition: general.cpp:1021
double turbo_speed()
Definition: general.cpp:429
bool confirm_load_save_from_different_version()
Definition: general.cpp:1037
bool animate_water()
Definition: general.cpp:898
void set_sound_volume(int vol)
Definition: general.cpp:565
int joystick_num_scroll_xaxis()
Definition: general.cpp:786
bool show_enemy_orb
Definitions for the interface to Wesnoth Markup Language (WML).
int joystick_num_cursor_xaxis()
Definition: general.cpp:810
bool ellipses()
Definition: general.cpp:495
bool sound_on()
Definition: general.cpp:658
Keyboard shortcuts for game actions.
bool maximized()
Definition: general.cpp:389
void set_use_twelve_hour_clock_format(bool value)
int joystick_cursor_yaxis_num()
Definition: general.cpp:828
std::string turn_bell
bool minimap_draw_villages()
Definition: general.cpp:933
int joystick_thrusta_deadzone()
Definition: general.cpp:768
bool joystick_support_enabled()
Definition: general.cpp:721
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:329
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:928
int joystick_scroll_yaxis_num()
Definition: general.cpp:804
const int min_font_scaling
Definition: general.cpp:71
bool fullscreen()
Definition: general.cpp:394
void set_font_scaling(int scale)
Definition: general.cpp:445
void set_music_volume(int vol)
Definition: general.cpp:550
int font_scaled(int size)
Definition: general.cpp:450
void set_show_fps(bool value)
Definition: general.cpp:968
void set_partial_color(const std::string &color_id)
Definition: general.cpp:359
void erase(const std::string &key)
Definition: general.cpp:220
void set_show_partial_orb(bool show_orb)
Definition: general.cpp:287
void set_core_id(const std::string &core_id)
Definition: general.cpp:319
config::attribute_value get_as_attribute(const std::string &key)
Definition: general.cpp:241
Modify, read and display user preferences.
void toggle_minimap_draw_terrain()
Definition: general.cpp:948
bool UI_sound_on()
Definition: general.cpp:629
void set_bell_volume(int vol)
Definition: general.cpp:580
void set_stop_music_in_background(bool ison)
Definition: general.cpp:712
bool animate_map()
Definition: general.cpp:893
bool damage_prediction_allow_monte_carlo_simulation()
Definition: general.cpp:1067
void set_animate_map(bool value)
Definition: general.cpp:953
int joystick_scroll_xaxis_num()
Definition: general.cpp:792
void _set_idle_anim(const bool ison)
Definition: general.cpp:460
void set_show_moved_orb(bool show_orb)
Definition: general.cpp:273
void set_draw_delay(int value)
Definition: general.cpp:978
void toggle_minimap_draw_villages()
Definition: general.cpp:938
int idle_anim_rate()
Definition: general.cpp:465
int joystick_num_thrusta_axis()
Definition: general.cpp:834
const int max_font_scaling
Definition: general.cpp:72
void set_UI_volume(int vol)
Definition: general.cpp:595
void set_child(const std::string &key, const config &val)
Definition: general.cpp:210
const int def_window_width
Definition: general.cpp:68
void save_sample_rate(const unsigned int rate)
Definition: general.cpp:1026
std::string allied_color()
Definition: general.cpp:303
void add_alias(const std::string &alias, const std::string &command)
Definition: general.cpp:1009
std::string moved_color()
Definition: general.cpp:333
void toggle_minimap_terrain_coding()
Definition: general.cpp:918
bool middle_click_scrolls()
Definition: general.cpp:873
bool stop_music_in_background()
Definition: general.cpp:707
static map_location::DIRECTION s
bool music_on()
Definition: general.cpp:681
bool use_color_cursors()
Definition: general.cpp:983
void toggle_minimap_movement_coding()
Definition: general.cpp:908
Holds a 2D point.
Definition: point.hpp:23
bool set_UI_sound(bool ison)
Definition: general.cpp:634
std::string language()
Definition: general.cpp:475
config * get_prefs()
Definition: general.cpp:250
bool show_moved_orb
void set_scroll_to_action(bool ison)
Definition: general.cpp:368
void set_ellipses(bool ison)
Definition: general.cpp:500
void save_sound_buffer_size(const std::size_t size)
Definition: general.cpp:528
const config & get_child(const std::string &key)
Definition: general.cpp:215
std::size_t sound_buffer_size()
Definition: general.cpp:515
int joystick_cursor_xaxis_num()
Definition: general.cpp:816
int joystick_cursor_threshold()
Definition: general.cpp:780
std::string core_id()
Definition: general.cpp:313
bool grid()
Definition: general.cpp:505
const int def_window_height
Definition: general.cpp:69
bool mouse_scroll_enabled()
Definition: general.cpp:878
bool disable_loadingscreen_animation()
Definition: general.cpp:1057
std::string partial_color()
Definition: general.cpp:353
int sound_volume()
Definition: general.cpp:560
MAKE_ENUM(ALIGNMENT_FEMALE_VARIATION,(LAWFUL, N_("female^lawful"))(FEMALE_NEUTRAL, N_("female^neutral"))(CHAOTIC, N_("female^chaotic"))(LIMINAL, N_("female^liminal"))) std
Implementation detail of unit_type::alignment_description.
Definition: types.cpp:909
bool have_setting(const std::string &key)
Definition: general.cpp:224
int font_scaling()
Definition: general.cpp:439
bool minimap_draw_terrain()
Definition: general.cpp:943
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...
bool set_music(bool ison)
Definition: general.cpp:686
int joystick_scroll_deadzone()
Definition: general.cpp:756
bool set_turn_bell(bool ison)
Definition: general.cpp:610
bool turbo()
Definition: general.cpp:415
bool scroll_to_action()
Definition: general.cpp:363
point resolution()
Definition: general.cpp:373
int joystick_mouse_deadzone()
Definition: general.cpp:726
bool show_partial_orb
int joystick_cursor_deadzone()
Definition: general.cpp:762
int UI_volume()
Definition: general.cpp:590
void set_damage_prediction_allow_monte_carlo_simulation(bool value)
Definition: general.cpp:1072
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
const config & get_alias()
Definition: general.cpp:1016
int joystick_num_scroll_yaxis()
Definition: general.cpp:798
void set_animate_water(bool value)
Definition: general.cpp:958
void _set_idle_anim_rate(const int rate)
Definition: general.cpp:470
Defines the MAKE_ENUM macro.
bool use_twelve_hour_clock_format()
Definition: general.cpp:1042
void set_show_allied_orb(bool show_orb)
Definition: general.cpp:259
std::string enemy_color()
Definition: general.cpp:323
int music_volume()
Definition: general.cpp:545
void set_gui_theme(const std::string &s)
Definition: general.cpp:490
bool minimap_terrain_coding()
Definition: general.cpp:913
void set_disable_auto_moves(bool value)
Definition: general.cpp:1052