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