The Battle for Wesnoth  1.15.2+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 
48  MAKE_ENUM(SCALING_ALGORITHM,
49  (LINEAR, "linear")
50  (NEAREST_NEIGHBOR, "nn")
51  (XBRZ_LIN, "xbrzlin")
52  (XBRZ_NN, "xbrznn")
53  )
54 
55  extern const SCALING_ALGORITHM default_scaling_algorithm;
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  unsigned int tile_size();
145  void set_tile_size(const unsigned int size);
146 
147  bool turn_bell();
148  bool set_turn_bell(bool ison);
149 
150  bool UI_sound_on();
151  bool set_UI_sound(bool ison);
152 
153  bool message_bell();
154 
155  // Proxies for preferences_dialog
156  void load_hotkeys();
157  void save_hotkeys();
158  void clear_hotkeys();
159 
160  void add_alias(const std::string& alias, const std::string& command);
161  const config &get_alias();
162 
163 
164  std::string allied_color();
165  void set_allied_color(const std::string& color_id);
166 
167  std::string enemy_color();
168  void set_enemy_color(const std::string& color_id);
169 
170  std::string unmoved_color();
171  void set_unmoved_color(const std::string& color_id);
172 
173  std::string partial_color();
174  void set_partial_color(const std::string& color_id);
175 
176  std::string moved_color();
177  void set_moved_color(const std::string& color_id);
178 
179 
180  bool show_allied_orb();
181  void set_show_allied_orb(bool show_orb);
182 
183  bool show_enemy_orb();
184  void set_show_enemy_orb(bool show_orb);
185 
186  bool show_moved_orb();
187  void set_show_moved_orb(bool show_orb);
188 
189  bool show_unmoved_orb();
190  void set_show_unmoved_orb(bool show_orb);
191 
192  bool show_partial_orb();
193  void set_show_partial_orb(bool show_orb);
194 
195 
196  bool use_color_cursors();
197  void _set_color_cursors(bool value);
198 
199  int scroll_speed();
200  void set_scroll_speed(const int scroll);
201 
202  bool middle_click_scrolls();
203  bool mouse_scroll_enabled();
204  void enable_mouse_scroll(bool value);
205 
206  /**
207  * Gets the threshold for when to scroll.
208  *
209  * This scrolling happens when the mouse is in the application and near
210  * the border.
211  */
213 
214  int draw_delay();
215  void set_draw_delay(int value);
216 
217  bool animate_map();
218  void set_animate_map(bool value);
219 
220  bool animate_water();
221  void set_animate_water(bool value);
222 
225 
226  bool minimap_terrain_coding();
228 
229  bool minimap_draw_units();
231 
232  bool minimap_draw_villages();
234 
235  bool minimap_draw_terrain();
237 
238  bool show_fps();
239  void set_show_fps(bool value);
240 
241  bool ellipses();
242  void set_ellipses(bool ison);
243 
244  bool grid();
245  void _set_grid(bool ison);
246 
248 
250  void set_use_twelve_hour_clock_format(bool value);
251 
252  bool disable_auto_moves();
253  void set_disable_auto_moves(bool value);
254 
256  void set_disable_loadingscreen_animation(bool value);
257 
260 
261 } // end namespace preferences
bool disable_auto_moves()
Definition: general.cpp:919
void _set_turbo(bool ison)
Definition: general.cpp:424
bool set_sound(bool ison)
Definition: general.cpp:673
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
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
bool minimap_draw_units()
Definition: general.cpp:795
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:835
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:760
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
Variant for storing WML attributes.
void _set_color_cursors(bool value)
Definition: general.cpp:860
const int min_window_width
Definition: general.cpp:65
void set_disable_loadingscreen_animation(bool value)
Definition: general.cpp:934
int draw_delay()
Definition: general.cpp:845
void set_scroll_speed(const int new_speed)
Definition: general.cpp:739
bool minimap_movement_coding()
Definition: general.cpp:775
int scroll_speed()
Definition: general.cpp:731
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:755
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.
bool idle_anim()
Definition: general.cpp:455
bool message_bell()
Definition: general.cpp:663
std::string gui_theme()
Definition: general.cpp:485
void set_tile_size(const unsigned int size)
Definition: general.cpp:610
unsigned int sample_rate()
Definition: general.cpp:893
double turbo_speed()
Definition: general.cpp:429
bool confirm_load_save_from_different_version()
Definition: general.cpp:909
bool animate_water()
Definition: general.cpp:770
void set_sound_volume(int vol)
Definition: general.cpp:565
bool show_enemy_orb
Definitions for the interface to Wesnoth Markup Language (WML).
bool ellipses()
Definition: general.cpp:495
bool sound_on()
Definition: general.cpp:668
Keyboard shortcuts for game actions.
bool maximized()
Definition: general.cpp:389
void set_use_twelve_hour_clock_format(bool value)
std::string turn_bell
bool minimap_draw_villages()
Definition: general.cpp:805
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:800
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:840
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:820
bool UI_sound_on()
Definition: general.cpp:639
void set_bell_volume(int vol)
Definition: general.cpp:580
void set_stop_music_in_background(bool ison)
Definition: general.cpp:722
bool animate_map()
Definition: general.cpp:765
bool damage_prediction_allow_monte_carlo_simulation()
Definition: general.cpp:939
void set_animate_map(bool value)
Definition: general.cpp:825
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:850
void toggle_minimap_draw_villages()
Definition: general.cpp:810
int idle_anim_rate()
Definition: general.cpp:465
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:898
std::string allied_color()
Definition: general.cpp:303
void add_alias(const std::string &alias, const std::string &command)
Definition: general.cpp:881
std::string moved_color()
Definition: general.cpp:333
void toggle_minimap_terrain_coding()
Definition: general.cpp:790
bool middle_click_scrolls()
Definition: general.cpp:745
bool stop_music_in_background()
Definition: general.cpp:717
static map_location::DIRECTION s
bool music_on()
Definition: general.cpp:691
bool use_color_cursors()
Definition: general.cpp:855
void toggle_minimap_movement_coding()
Definition: general.cpp:780
Holds a 2D point.
Definition: point.hpp:23
bool set_UI_sound(bool ison)
Definition: general.cpp:644
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
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:750
bool disable_loadingscreen_animation()
Definition: general.cpp:929
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:913
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:815
unsigned int tile_size
Definition: game_config.cpp:68
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:696
bool set_turn_bell(bool ison)
Definition: general.cpp:620
bool turbo()
Definition: general.cpp:415
bool scroll_to_action()
Definition: general.cpp:363
point resolution()
Definition: general.cpp:373
bool show_partial_orb
int UI_volume()
Definition: general.cpp:590
void set_damage_prediction_allow_monte_carlo_simulation(bool value)
Definition: general.cpp:944
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
const config & get_alias()
Definition: general.cpp:888
void set_animate_water(bool value)
Definition: general.cpp:830
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:914
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:785
void set_disable_auto_moves(bool value)
Definition: general.cpp:924