Freeciv21
Develop your civilization from humble roots to a global empire
options.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  __ __ part of Freeciv21. Freeciv21 is free software: you can
4 / \\..// \ redistribute it and/or modify it under the terms of the GNU
5  ( oo ) General Public License as published by the Free Software
6  \__/ Foundation, either version 3 of the License, or (at your
7  option) any later version. You should have received
8  a copy of the GNU General Public License along with Freeciv21. If not,
9  see https://www.gnu.org/licenses/.
10 **************************************************************************/
11 #pragma once
12 
13 #include <QFont>
14 
15 // common
16 #include "events.h"
17 #include "featured_text.h" // struct ft_color
18 #include "mapimg.h"
19 
20 #define DEFAULT_METASERVER_OPTION "default"
21 
30 };
31 
32 // Holds all information about the overview aka minimap.
33 struct overview {
34  // The following fields are controlled by mapview_common.c.
35  double map_x0, map_y0; // Origin of the overview, in natural coords.
36  int width, height; // Size in pixels.
37 
38  // Holds the map, unwrapped.
39  QPixmap *map;
40 
41  // A backing store for the window itself, wrapped.
42  QPixmap *window;
43 
44  bool fog;
46 };
47 
49  char default_user_name[512] = "\0";
50  char default_server_host[512] = "localhost";
51  int default_server_port = DEFAULT_SOCK_PORT;
52  bool use_prev_server = false;
53  bool heartbeat_enabled = false;
55  char default_tileset_square_name[512] = "\0";
56  char default_tileset_hex_name[512] = "\0";
57  char default_tileset_isohex_name[512] = "\0";
58  char default_city_bar_style_name[512] = "Simple";
59  char default_sound_set_name[512] = "stdsounds";
60  char default_music_set_name[512] = "stdmusic";
61  char default_sound_plugin_name[512] = "\0";
62  char default_chat_logfile[512] = "freeciv-chat.log";
63 
64  bool save_options_on_exit = true;
65 
67  bool first_boot = true; /* There was no earlier options saved.
68  * This affects some migrations, but not all. */
70  "\0"; /* 2.6 had separate tilesets for
71  ... */
73  "\0"; // ...overhead and iso topologies.
74 
75  bool migrate_fullscreen = false;
76 
80  bool sound_bell_at_new_turn = false;
84  bool ai_manual_turn_done = true;
85  bool auto_center_on_unit = true;
87  bool auto_center_on_combat = false;
88  bool auto_center_each_turn = true;
89  bool wakeup_focus = true;
90  bool goto_into_unknown = true;
94  bool auto_turn_done = false;
95  bool ask_city_name = true;
96  bool popup_new_cities = true;
97  bool popup_actor_arrival = true;
98  bool popup_attack_actions = true;
100  bool keyboardless_goto = false;
104  struct ft_color highlight_our_names = FT_COLOR("#000000", "#FFFF00");
105 
106  bool voteinfo_bar_use = true;
110 
114 
115  bool sound_enable_effects = true;
119 
120  bool draw_city_outlines = true;
121  bool draw_city_output = false;
122  bool draw_map_grid = false;
123  bool draw_city_names = true;
124  bool draw_city_growth = true;
126  bool draw_city_buycost = false;
128  bool draw_coastline = false;
129  bool draw_roads_rails = true;
130  bool draw_irrigation = true;
131  bool draw_mines = true;
133  bool draw_specials = true;
134  bool draw_huts = true;
135  bool draw_pollution = true;
136  bool draw_cities = true;
137  bool draw_units = true;
138  bool draw_focus_unit = false;
139  bool draw_fog_of_war = true;
140  bool draw_borders = true;
141  bool draw_native = false;
142  bool draw_unit_shields = true;
143  bool zoom_scale_fonts = true;
144 
146  bool reqtree_show_icons = true;
147  bool reqtree_curved_lines = false;
148 
149  // options for map images
150  char mapimg_format[64] = "png";
151  int mapimg_zoom = 2;
152  bool mapimg_layer[MAPIMG_LAYER_COUNT] = {
153  false, // a - MAPIMG_LAYER_AREA
154  true, // b - MAPIMG_LAYER_BORDERS
155  true, // c - MAPIMG_LAYER_CITIES
156  true, // f - MAPIMG_LAYER_FOGOFWAR
157  true, // k - MAPIMG_LAYER_KNOWLEDGE
158  true, // t - MAPIMG_LAYER_TERRAIN
159  true // u - MAPIMG_LAYER_UNITS
160  };
161  char mapimg_filename[512] = "mapimage filename";
162 
163 #define FC_QT_DEFAULT_THEME_NAME "NightStalker"
164  bool gui_qt_fullscreen = true;
165  bool gui_qt_show_preview = true;
168  char gui_qt_default_theme_name[512] = "NightStalker";
177  bool gui_qt_show_titlebar = true;
178 
179  struct overview overview = {};
180 
183  std::map<QString, std::map<QString, bool>> tileset_options;
184 };
185 
187 
188 #define SPECENUM_NAME option_type
189 #define SPECENUM_VALUE0 OT_BOOLEAN
190 #define SPECENUM_VALUE1 OT_INTEGER
191 #define SPECENUM_VALUE2 OT_STRING
192 #define SPECENUM_VALUE3 OT_ENUM
193 #define SPECENUM_VALUE4 OT_BITWISE
194 #define SPECENUM_VALUE5 OT_FONT
195 #define SPECENUM_VALUE6 OT_COLOR
196 #include "specenum_gen.h"
197 
198 struct option; // Opaque type.
199 struct option_set; // Opaque type.
200 
201 typedef void (*option_save_log_callback)(QtMsgType lvl, const QString &msg);
202 
203 // Main functions.
204 void options_init();
205 void options_free();
206 void server_options_init();
207 void server_options_free();
208 void options_load();
210 
211 // Option sets.
212 extern const struct option_set *client_optset;
213 extern const struct option_set *server_optset;
214 
215 struct option *optset_option_by_number(const struct option_set *poptset,
216  int id);
217 struct option *optset_option_by_name(const struct option_set *poptset,
218  const char *name);
219 struct option *optset_option_first(const struct option_set *poptset);
220 
221 const char *optset_category_name(const struct option_set *poptset,
222  int category);
223 
224 // Common option functions.
225 const struct option_set *option_optset(const struct option *poption);
226 int option_number(const struct option *poption);
227 const char *option_name(const struct option *poption);
228 const char *option_description(const struct option *poption);
229 QString option_help_text(const struct option *poption);
230 enum option_type option_type(const struct option *poption);
231 QString option_category_name(const struct option *poption);
232 bool option_is_changeable(const struct option *poption);
233 struct option *option_next(const struct option *poption);
234 
235 bool option_reset(struct option *poption);
236 void option_set_changed_callback(struct option *poption,
237  void (*callback)(struct option *));
238 void option_changed(struct option *poption);
239 
240 // Option gui functions.
241 void option_set_gui_data(struct option *poption, void *data);
242 void *option_get_gui_data(const struct option *poption);
243 
244 // Callback assistance
245 int option_get_cb_data(const struct option *poption);
246 
247 // Option type OT_BOOLEAN functions.
248 bool option_bool_get(const struct option *poption);
249 bool option_bool_def(const struct option *poption);
250 bool option_bool_set(struct option *poption, bool val);
251 
252 // Option type OT_INTEGER functions.
253 int option_int_get(const struct option *poption);
254 int option_int_def(const struct option *poption);
255 int option_int_min(const struct option *poption);
256 int option_int_max(const struct option *poption);
257 bool option_int_set(struct option *poption, int val);
258 
259 // Option type OT_STRING functions.
260 const char *option_str_get(const struct option *poption);
261 const char *option_str_def(const struct option *poption);
262 const QVector<QString> *option_str_values(const struct option *poption);
263 bool option_str_set(struct option *poption, const char *str);
264 
265 // Option type OT_ENUM functions.
266 int option_enum_str_to_int(const struct option *poption, const char *str);
267 QString option_enum_int_to_str(const struct option *poption, int val);
268 int option_enum_get_int(const struct option *poption);
269 int option_enum_def_int(const struct option *poption);
270 bool option_enum_set_int(struct option *poption, int val);
271 
272 // Option type OT_BITWISE functions.
273 unsigned option_bitwise_get(const struct option *poption);
274 unsigned option_bitwise_def(const struct option *poption);
275 unsigned option_bitwise_mask(const struct option *poption);
276 const QVector<QString> *option_bitwise_values(const struct option *poption);
277 bool option_bitwise_set(struct option *poption, unsigned val);
278 
279 // Option type OT_FONT functions.
280 QFont option_font_get(const struct option *poption);
281 QFont option_font_def(const struct option *poption);
282 void option_font_set_default(const struct option *poption,
283  const QFont &font);
284 QString option_font_target(const struct option *poption);
285 bool option_font_set(struct option *poption, const QFont &font);
286 
287 // Option type OT_COLOR functions.
288 struct ft_color option_color_get(const struct option *poption);
289 struct ft_color option_color_def(const struct option *poption);
290 bool option_color_set(struct option *poption, struct ft_color color);
291 
292 #define options_iterate(poptset, poption) \
293  { \
294  struct option *poption = optset_option_first(poptset); \
295  for (; nullptr != poption; poption = option_next(poption)) {
296 
297 #define options_iterate_end \
298  } \
299  }
300 
303 void desired_settable_option_update(const char *op_name,
304  const char *op_value,
305  bool allow_replace);
306 
309 void options_dialogs_set();
310 
313 // for specifying which event messages go where:
314 #define NUM_MW 3
315 #define MW_OUTPUT 1 // add to the output window
316 #define MW_MESSAGES 2 // add to the messages window
317 #define MW_POPUP 4 // popup an individual window
318 
319 extern int messages_where[]; // OR-ed MW_ values [E_COUNT]
320 
323 #define GUI_DEFAULT_MAPIMG_FILENAME "freeciv"
324 
325 struct tileset;
326 
327 const char *tileset_name_for_topology(int topology_id);
328 void fill_topo_ts_default();
#define FT_COLOR(fg, bg)
const char * name
Definition: inputfile.cpp:118
unsigned option_bitwise_mask(const struct option *poption)
Returns the mask of this bitwise option.
Definition: options.cpp:704
void desired_settable_options_update()
Desired settable options.
Definition: options.cpp:4064
const char * option_str_def(const struct option *poption)
Returns the default value of this string option.
Definition: options.cpp:564
void option_changed(struct option *poption)
Force to use the option changed callback.
Definition: options.cpp:408
void options_free()
Free the option module.
Definition: options.cpp:4677
unsigned option_bitwise_def(const struct option *poption)
Returns the default value of this bitwise option.
Definition: options.cpp:693
int option_enum_str_to_int(const struct option *poption, const char *str)
Returns the value corresponding to the user-visible (translatable but not translated) string.
Definition: options.cpp:603
int option_int_min(const struct option *poption)
Returns the minimal value of this integer option.
Definition: options.cpp:516
bool option_bool_def(const struct option *poption)
Returns the default value of this boolean option.
Definition: options.cpp:468
void options_init()
Initialize the option module.
Definition: options.cpp:4582
const char * option_name(const struct option *poption)
Returns the name of the option.
Definition: options.cpp:300
const struct option_set * server_optset
Definition: options.cpp:2430
const char * option_str_get(const struct option *poption)
Returns the current value of this string option.
Definition: options.cpp:553
void options_dialogs_set()
This set the city and player report dialog options.
Definition: options.cpp:4332
bool option_reset(struct option *poption)
Set the option to its default value.
Definition: options.cpp:371
const QVector< QString > * option_str_values(const struct option *poption)
Returns the possible string values of this string option.
Definition: options.cpp:575
struct ft_color option_color_get(const struct option *poption)
Returns the current value of this color option.
Definition: options.cpp:808
client_options * gui_options
Definition: options.cpp:74
int option_enum_get_int(const struct option *poption)
Returns the current value of this enum option (as an integer).
Definition: options.cpp:645
void options_dialogs_update()
Dialog report options.
Definition: options.cpp:4306
int option_number(const struct option *poption)
Returns the number of the option.
Definition: options.cpp:290
void server_options_free()
Free the server options, if already received.
Definition: options.cpp:2619
#define DEFAULT_METASERVER_OPTION
Definition: options.h:20
void desired_settable_option_update(const char *op_name, const char *op_value, bool allow_replace)
Update a desired settable option in the hash table from a value which can be different of the current...
Definition: options.cpp:4126
struct option * option_next(const struct option *poption)
Returns the next option or nullptr if this is the last.
Definition: options.cpp:361
QString option_font_target(const struct option *poption)
Returns the target style name of this font option.
Definition: options.cpp:782
bool option_str_set(struct option *poption, const char *str)
Sets the value of this string option.
Definition: options.cpp:586
const struct option_set * client_optset
Definition: options.cpp:860
struct option * optset_option_first(const struct option_set *poptset)
Returns the first option of this option set.
Definition: options.cpp:128
int option_int_get(const struct option *poption)
Returns the current value of this integer option.
Definition: options.cpp:494
int messages_where[]
Message Options:
Definition: options.cpp:3383
bool option_font_set(struct option *poption, const QFont &font)
Sets the value of this font option.
Definition: options.cpp:793
const char * optset_category_name(const struct option_set *poptset, int category)
Returns the name (translated) of the category of this option set.
Definition: options.cpp:138
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Returns the option corresponding of the name in this option set.
Definition: options.cpp:110
bool option_color_set(struct option *poption, struct ft_color color)
Sets the value of this color option.
Definition: options.cpp:835
QString option_enum_int_to_str(const struct option *poption, int val)
Returns the user-visible (translatable but not translated) string corresponding to the value.
Definition: options.cpp:626
void option_set_changed_callback(struct option *poption, void(*callback)(struct option *))
Set the function to call every time this option changes.
Definition: options.cpp:397
void(* option_save_log_callback)(QtMsgType lvl, const QString &msg)
Definition: options.h:201
const QVector< QString > * option_bitwise_values(const struct option *poption)
Returns a vector of strings describing every bit of this option, as user-visible (translatable but no...
Definition: options.cpp:721
bool option_bool_set(struct option *poption, bool val)
Sets the value of this boolean option.
Definition: options.cpp:479
bool option_is_changeable(const struct option *poption)
Returns TRUE if this option can be modified.
Definition: options.cpp:351
void option_set_gui_data(struct option *poption, void *data)
Set the gui data for this option.
Definition: options.cpp:427
const char * option_description(const struct option *poption)
Returns the description (translated) of the option.
Definition: options.cpp:310
bool option_enum_set_int(struct option *poption, int val)
Sets the value of this enum option.
Definition: options.cpp:667
bool option_bool_get(const struct option *poption)
Returns the current value of this boolean option.
Definition: options.cpp:457
enum option_type option_type(const struct option *poption)
Returns the type of the option.
Definition: options.cpp:330
int option_get_cb_data(const struct option *poption)
Returns the callback data of this option.
Definition: options.cpp:447
struct option * optset_option_by_number(const struct option_set *poptset, int id)
Returns the option corresponding of the number in this option set.
Definition: options.cpp:99
void option_font_set_default(const struct option *poption, const QFont &font)
Returns the default value of this font option.
Definition: options.cpp:771
int option_int_max(const struct option *poption)
Returns the maximal value of this integer option.
Definition: options.cpp:527
QString option_category_name(const struct option *poption)
Returns the name (translated) of the category of the option.
Definition: options.cpp:340
void fill_topo_ts_default()
Fill default tilesets for topology-specific settings.
Definition: options.cpp:4906
void * option_get_gui_data(const struct option *poption)
Returns the gui data of this option.
Definition: options.cpp:437
void options_save(option_save_log_callback log_cb)
Save all options.
Definition: options.cpp:4496
QFont option_font_get(const struct option *poption)
Returns the current value of this font option.
Definition: options.cpp:749
void options_load()
Load from the rc file any options that are not ruleset specific.
Definition: options.cpp:4362
bool option_bitwise_set(struct option *poption, unsigned val)
Sets the value of this bitwise option.
Definition: options.cpp:732
QString option_help_text(const struct option *poption)
Returns the help text (translated) of the option.
Definition: options.cpp:320
const char * tileset_name_for_topology(int topology_id)
Option framework wrapper for mapimg_get_format_list()
Definition: options.cpp:4864
struct ft_color option_color_def(const struct option *poption)
Returns the default value of this color option.
Definition: options.cpp:821
overview_layers
Definition: options.h:22
@ OLAYER_COUNT
Definition: options.h:29
@ OLAYER_BORDERS
Definition: options.h:25
@ OLAYER_BACKGROUND
Definition: options.h:23
@ OLAYER_CITIES
Definition: options.h:28
@ OLAYER_BORDERS_ON_OCEAN
Definition: options.h:26
@ OLAYER_UNITS
Definition: options.h:27
@ OLAYER_RELIEF
Definition: options.h:24
unsigned option_bitwise_get(const struct option *poption)
Returns the current value of this bitwise option.
Definition: options.cpp:682
int option_enum_def_int(const struct option *poption)
Returns the default value of this enum option (as an integer).
Definition: options.cpp:656
bool option_int_set(struct option *poption, int val)
Sets the value of this integer option.
Definition: options.cpp:538
QFont option_font_def(const struct option *poption)
Returns the default value of this font option.
Definition: options.cpp:760
void server_options_init()
Initialize the server options (not received yet).
Definition: options.cpp:2566
const struct option_set * option_optset(const struct option *poption)
Returns the option set owner of this option.
Definition: options.cpp:280
int option_int_def(const struct option *poption)
Returns the default value of this integer option.
Definition: options.cpp:505
bool voteinfo_bar_use
Definition: options.h:106
bool gui_qt_fullscreen
Definition: options.h:164
QFont gui_qt_font_city_names
Definition: options.h:174
bool show_previous_turn_messages
Definition: options.h:92
bool draw_native
Definition: options.h:141
char gui_qt_default_theme_name[512]
Definition: options.h:168
bool sound_bell_at_new_turn
Definition: options.h:80
bool autoaccept_tileset_suggestion
Definition: options.h:111
bool autoaccept_musicset_suggestion
Definition: options.h:113
bool reqtree_show_icons
Definition: options.h:146
bool enable_cursor_changes
Definition: options.h:101
bool auto_turn_done
Definition: options.h:94
bool gui_qt_allied_chat_only
Definition: options.h:166
QFont gui_qt_font_city_productions
Definition: options.h:175
int gui_qt_increase_fonts
Definition: options.h:167
bool draw_specials
Definition: options.h:133
int smooth_center_slide_msec
Definition: options.h:82
bool draw_city_output
Definition: options.h:121
bool sound_enable_menu_music
Definition: options.h:116
bool player_dlg_show_dead_players
Definition: options.h:145
char default_tileset_hex_name[512]
Definition: options.h:56
bool draw_city_names
Definition: options.h:123
bool draw_city_productions
Definition: options.h:125
int default_server_port
Definition: options.h:51
char default_sound_set_name[512]
Definition: options.h:59
bool voteinfo_bar_hide_when_not_player
Definition: options.h:108
bool use_prev_server
Definition: options.h:52
QFont gui_qt_font_help_text
Definition: options.h:172
int smooth_move_unit_msec
Definition: options.h:81
QFont gui_qt_font_chatline
Definition: options.h:173
bool goto_into_unknown
Definition: options.h:90
std::map< QString, std::map< QString, bool > > tileset_options
Saved tileset options.
Definition: options.h:183
bool draw_mines
Definition: options.h:131
char default_tileset_iso_name[512]
Definition: options.h:72
char default_metaserver[512]
Definition: options.h:54
bool draw_borders
Definition: options.h:140
bool draw_fortress_airbase
Definition: options.h:132
bool draw_city_buycost
Definition: options.h:126
bool mapimg_layer[MAPIMG_LAYER_COUNT]
Definition: options.h:152
bool popup_new_cities
Definition: options.h:96
bool draw_irrigation
Definition: options.h:130
bool draw_units
Definition: options.h:137
bool auto_center_on_automated
Definition: options.h:86
char default_tileset_overhead_name[512]
Definition: options.h:69
QFont gui_qt_font_help_label
Definition: options.h:171
bool auto_center_each_turn
Definition: options.h:88
bool gui_qt_show_preview
Definition: options.h:165
bool draw_fog_of_war
Definition: options.h:139
char default_server_host[512]
Definition: options.h:50
QFont gui_qt_font_default
Definition: options.h:169
struct ft_color highlight_our_names
Definition: options.h:104
bool draw_city_trade_routes
Definition: options.h:127
char default_chat_logfile[512]
Definition: options.h:62
bool unit_selection_clears_orders
Definition: options.h:103
bool heartbeat_enabled
Definition: options.h:53
bool voteinfo_bar_new_at_front
Definition: options.h:109
bool draw_unit_shields
Definition: options.h:142
bool center_when_popup_city
Definition: options.h:91
char default_tileset_square_name[512]
Definition: options.h:55
bool wakeup_focus
Definition: options.h:89
bool reqtree_curved_lines
Definition: options.h:147
bool draw_cities
Definition: options.h:136
bool save_options_on_exit
Definition: options.h:64
bool gui_qt_show_titlebar
Definition: options.h:177
int sound_effects_volume
Definition: options.h:118
bool sound_enable_effects
Definition: options.h:115
bool draw_map_grid
Definition: options.h:122
bool autoaccept_soundset_suggestion
Definition: options.h:112
bool zoom_scale_fonts
Definition: options.h:143
bool ask_city_name
Definition: options.h:95
bool draw_city_growth
Definition: options.h:124
int mapimg_zoom
Definition: options.h:151
bool ai_manual_turn_done
Definition: options.h:84
int smooth_combat_step_msec
Definition: options.h:83
bool draw_huts
Definition: options.h:134
bool draw_focus_unit
Definition: options.h:138
bool first_boot
Migrations.
Definition: options.h:67
char default_tileset_isohex_name[512]
Definition: options.h:57
bool concise_city_production
Definition: options.h:93
bool voteinfo_bar_always_show
Definition: options.h:107
bool draw_city_outlines
Definition: options.h:120
char mapimg_format[64]
Definition: options.h:150
char mapimg_filename[512]
Definition: options.h:161
char default_music_set_name[512]
Definition: options.h:60
bool draw_coastline
Definition: options.h:128
bool popup_actor_arrival
Definition: options.h:97
char default_city_bar_style_name[512]
Definition: options.h:58
bool draw_roads_rails
Definition: options.h:129
bool sound_enable_game_music
Definition: options.h:117
bool auto_center_on_combat
Definition: options.h:87
bool draw_pollution
Definition: options.h:135
bool separate_unit_selection
Definition: options.h:102
bool migrate_fullscreen
Definition: options.h:75
char default_sound_plugin_name[512]
Definition: options.h:61
bool auto_center_on_unit
Definition: options.h:85
bool popup_attack_actions
Definition: options.h:98
bool solid_color_behind_units
Local Options:
Definition: options.h:79
bool popup_last_move_to_allied
Definition: options.h:99
bool keyboardless_goto
Definition: options.h:100
char default_user_name[512]
Definition: options.h:49
QFont gui_qt_font_notify_label
Definition: options.h:170
QFont gui_qt_font_reqtree_text
Definition: options.h:176
Option set structure.
Definition: options.cpp:88
The base class for options.
Definition: options.cpp:209
const struct option_set * poptset
Definition: options.cpp:211
double map_y0
Definition: options.h:35
QPixmap * window
Definition: options.h:42
double map_x0
Definition: options.h:35
QPixmap * map
Definition: options.h:39
bool fog
Definition: options.h:44
bool layers[OLAYER_COUNT]
Definition: options.h:45
int width
Definition: options.h:36
int height
Definition: options.h:36