1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
18 #endif /* __cplusplus */
21 #include "support.h" /* bool type */
25 #include "fc_types.h" /* enum gui_type */
26 #include "featured_text.h" /* struct ft_color */
29 #define DEFAULT_METASERVER_OPTION "default"
36 #define VIDEO_MODE(ARG_width, ARG_height) \
37 { ARG_width, ARG_height }
39 /****************************************************************************
41 ****************************************************************************/
42 static inline struct video_mode
video_mode_construct(int width
, int height
)
44 struct video_mode mode
= VIDEO_MODE(width
, height
);
50 /* Order must match strings in
51 * options.c:gui_gtk_message_chat_location_name() */
52 GUI_GTK_MSGCHAT_SPLIT
,
53 GUI_GTK_MSGCHAT_SEPARATE
,
54 GUI_GTK_MSGCHAT_MERGED
58 /* Order must match strings in
59 * options.c:gui_popup_tech_help_name() */
60 GUI_POPUP_TECH_HELP_ENABLED
,
61 GUI_POPUP_TECH_HELP_DISABLED
,
62 GUI_POPUP_TECH_HELP_RULESET
65 enum overview_layers
{
69 OLAYER_BORDERS_ON_OCEAN
,
75 /* Holds all information about the overview aka minimap. */
77 /* The following fields are controlled by mapview_common.c. */
78 double map_x0
, map_y0
; /* Origin of the overview, in natural coords. */
79 int width
, height
; /* Size in pixels. */
81 /* Holds the map, unwrapped. */
84 /* A backing store for the window itself, wrapped. */
85 struct canvas
*window
;
88 bool layers
[OLAYER_COUNT
];
93 char default_user_name
[512];
94 char default_server_host
[512];
95 int default_server_port
;
97 bool heartbeat_enabled
;
98 char default_metaserver
[512];
99 char default_tileset_overhead_name
[512];
100 char default_tileset_iso_name
[512];
101 char default_tileset_hex_name
[512];
102 char default_tileset_isohex_name
[512];
103 char default_sound_set_name
[512];
104 char default_music_set_name
[512];
105 char default_sound_plugin_name
[512];
106 char default_chat_logfile
[512];
108 bool save_options_on_exit
;
111 bool first_boot
; /* There was no earlier options saved.
112 * This affects some migrations, but not all. */
113 char default_tileset_name
[512]; /* pre-2.6 had just this one tileset name */
114 bool gui_gtk3_22_migrated_from_gtk3
;
115 bool gui_gtk3_migrated_from_gtk2
;
116 bool gui_sdl2_migrated_from_sdl
;
117 bool gui_gtk2_migrated_from_2_5
;
118 bool gui_gtk3_migrated_from_2_5
;
119 bool gui_qt_migrated_from_2_5
;
121 bool migrate_fullscreen
;
123 /** Local Options: **/
125 bool solid_color_behind_units
;
126 bool sound_bell_at_new_turn
;
127 int smooth_move_unit_msec
;
128 int smooth_center_slide_msec
;
129 int smooth_combat_step_msec
;
130 bool ai_manual_turn_done
;
131 bool auto_center_on_unit
;
132 bool auto_center_on_automated
;
133 bool auto_center_on_combat
;
134 bool auto_center_each_turn
;
136 bool goto_into_unknown
;
137 bool center_when_popup_city
;
138 bool concise_city_production
;
140 bool meta_accelerators
;
142 bool popup_new_cities
;
143 bool popup_actor_arrival
;
144 bool update_city_text_in_refresh_tile
;
145 bool keyboardless_goto
;
146 bool enable_cursor_changes
;
147 bool separate_unit_selection
;
148 bool unit_selection_clears_orders
;
149 struct ft_color highlight_our_names
;
151 bool voteinfo_bar_use
;
152 bool voteinfo_bar_always_show
;
153 bool voteinfo_bar_hide_when_not_player
;
154 bool voteinfo_bar_new_at_front
;
156 bool autoaccept_tileset_suggestion
;
157 bool autoaccept_soundset_suggestion
;
158 bool autoaccept_musicset_suggestion
;
160 bool sound_enable_effects
;
161 bool sound_enable_menu_music
;
162 bool sound_enable_game_music
;
164 bool draw_city_outlines
;
165 bool draw_city_output
;
167 bool draw_city_names
;
168 bool draw_city_growth
;
169 bool draw_city_productions
;
170 bool draw_city_buycost
;
171 bool draw_city_trade_routes
;
174 bool draw_roads_rails
;
175 bool draw_irrigation
;
177 bool draw_fortress_airbase
;
183 bool draw_focus_unit
;
184 bool draw_fog_of_war
;
187 bool draw_full_citybar
;
188 bool draw_unit_shields
;
190 bool player_dlg_show_dead_players
;
191 bool reqtree_show_icons
;
192 bool reqtree_curved_lines
;
194 /* options for map images */
195 char mapimg_format
[64];
197 bool mapimg_layer
[MAPIMG_LAYER_COUNT
];
198 char mapimg_filename
[512];
201 float zoom_default_level
;
203 /* gui-gtk-2.0 client specific options. */
204 #define FC_GTK2_DEFAULT_THEME_NAME "Freeciv"
205 char gui_gtk2_default_theme_name
[512];
206 bool gui_gtk2_fullscreen
;
207 bool gui_gtk2_map_scrollbars
;
208 bool gui_gtk2_dialogs_on_top
;
209 bool gui_gtk2_show_task_icons
;
210 bool gui_gtk2_enable_tabs
;
211 bool gui_gtk2_better_fog
;
212 bool gui_gtk2_show_chat_message_time
;
213 bool gui_gtk2_new_messages_go_to_top
;
214 bool gui_gtk2_show_message_window_buttons
;
215 bool gui_gtk2_metaserver_tab_first
;
216 bool gui_gtk2_allied_chat_only
;
217 int gui_gtk2_message_chat_location
; /* enum GUI_GTK_MSGCHAT_* */
218 bool gui_gtk2_small_display_layout
;
219 bool gui_gtk2_mouse_over_map_focus
;
220 bool gui_gtk2_chatline_autocompletion
;
221 int gui_gtk2_citydlg_xsize
;
222 int gui_gtk2_citydlg_ysize
;
223 int gui_gtk2_popup_tech_help
;
224 char gui_gtk2_font_city_label
[512];
225 char gui_gtk2_font_notify_label
[512];
226 char gui_gtk2_font_spaceship_label
[512];
227 char gui_gtk2_font_help_label
[512];
228 char gui_gtk2_font_help_link
[512];
229 char gui_gtk2_font_help_text
[512];
230 char gui_gtk2_font_chatline
[512];
231 char gui_gtk2_font_beta_label
[512];
232 char gui_gtk2_font_small
[512];
233 char gui_gtk2_font_comment_label
[512];
234 char gui_gtk2_font_city_names
[512];
235 char gui_gtk2_font_city_productions
[512];
236 char gui_gtk2_font_reqtree_text
[512];
238 /* gui-gtk-3.0 client specific options. */
239 #define FC_GTK3_DEFAULT_THEME_NAME "Freeciv"
240 char gui_gtk3_default_theme_name
[512];
241 bool gui_gtk3_fullscreen
;
242 bool gui_gtk3_map_scrollbars
;
243 bool gui_gtk3_dialogs_on_top
;
244 bool gui_gtk3_show_task_icons
;
245 bool gui_gtk3_enable_tabs
;
246 bool gui_gtk3_show_chat_message_time
;
247 bool gui_gtk3_new_messages_go_to_top
;
248 bool gui_gtk3_show_message_window_buttons
;
249 bool gui_gtk3_metaserver_tab_first
;
250 bool gui_gtk3_allied_chat_only
;
251 int gui_gtk3_message_chat_location
; /* enum GUI_GTK_MSGCHAT_* */
252 bool gui_gtk3_small_display_layout
;
253 bool gui_gtk3_mouse_over_map_focus
;
254 bool gui_gtk3_chatline_autocompletion
;
255 int gui_gtk3_citydlg_xsize
;
256 int gui_gtk3_citydlg_ysize
;
257 int gui_gtk3_popup_tech_help
;
258 int gui_gtk3_governor_range_min
;
259 int gui_gtk3_governor_range_max
;
260 char gui_gtk3_font_city_label
[512];
261 char gui_gtk3_font_notify_label
[512];
262 char gui_gtk3_font_spaceship_label
[512];
263 char gui_gtk3_font_help_label
[512];
264 char gui_gtk3_font_help_link
[512];
265 char gui_gtk3_font_help_text
[512];
266 char gui_gtk3_font_chatline
[512];
267 char gui_gtk3_font_beta_label
[512];
268 char gui_gtk3_font_small
[512];
269 char gui_gtk3_font_comment_label
[512];
270 char gui_gtk3_font_city_names
[512];
271 char gui_gtk3_font_city_productions
[512];
272 char gui_gtk3_font_reqtree_text
[512];
274 /* gui-gtk-3.22 client specific options. */
275 #define FC_GTK3_22_DEFAULT_THEME_NAME "Freeciv"
276 char gui_gtk3_22_default_theme_name
[512];
277 bool gui_gtk3_22_fullscreen
;
278 bool gui_gtk3_22_map_scrollbars
;
279 bool gui_gtk3_22_dialogs_on_top
;
280 bool gui_gtk3_22_show_task_icons
;
281 bool gui_gtk3_22_enable_tabs
;
282 bool gui_gtk3_22_show_chat_message_time
;
283 bool gui_gtk3_22_new_messages_go_to_top
;
284 bool gui_gtk3_22_show_message_window_buttons
;
285 bool gui_gtk3_22_metaserver_tab_first
;
286 bool gui_gtk3_22_allied_chat_only
;
287 int gui_gtk3_22_message_chat_location
; /* enum GUI_GTK_MSGCHAT_* */
288 bool gui_gtk3_22_small_display_layout
;
289 bool gui_gtk3_22_mouse_over_map_focus
;
290 bool gui_gtk3_22_chatline_autocompletion
;
291 int gui_gtk3_22_citydlg_xsize
;
292 int gui_gtk3_22_citydlg_ysize
;
293 int gui_gtk3_22_popup_tech_help
;
294 int gui_gtk3_22_governor_range_min
;
295 int gui_gtk3_22_governor_range_max
;
296 char gui_gtk3_22_font_city_label
[512];
297 char gui_gtk3_22_font_notify_label
[512];
298 char gui_gtk3_22_font_spaceship_label
[512];
299 char gui_gtk3_22_font_help_label
[512];
300 char gui_gtk3_22_font_help_link
[512];
301 char gui_gtk3_22_font_help_text
[512];
302 char gui_gtk3_22_font_chatline
[512];
303 char gui_gtk3_22_font_beta_label
[512];
304 char gui_gtk3_22_font_small
[512];
305 char gui_gtk3_22_font_comment_label
[512];
306 char gui_gtk3_22_font_city_names
[512];
307 char gui_gtk3_22_font_city_productions
[512];
308 char gui_gtk3_22_font_reqtree_text
[512];
310 /* gui-sdl client specific options. */
311 #define FC_SDL_DEFAULT_THEME_NAME "human"
312 char gui_sdl_default_theme_name
[512];
313 bool gui_sdl_fullscreen
;
314 struct video_mode gui_sdl_screen
;
315 bool gui_sdl_do_cursor_animation
;
316 bool gui_sdl_use_color_cursors
;
318 /* gui-sdl2 client specific options. */
319 #define FC_SDL2_DEFAULT_THEME_NAME "human"
320 char gui_sdl2_default_theme_name
[512];
321 bool gui_sdl2_fullscreen
;
322 struct video_mode gui_sdl2_screen
;
323 bool gui_sdl2_swrenderer
;
324 bool gui_sdl2_do_cursor_animation
;
325 bool gui_sdl2_use_color_cursors
;
327 /* gui-qt client specific options. */
328 #define FC_QT_DEFAULT_THEME_NAME "NightStalker"
329 bool gui_qt_fullscreen
;
330 bool gui_qt_show_preview
;
331 bool gui_qt_allied_chat_only
;
332 bool gui_qt_sidebar_left
;
333 char gui_qt_default_theme_name
[512];
334 char gui_qt_font_city_label
[512];
335 char gui_qt_font_default
[512];
336 char gui_qt_font_notify_label
[512];
337 char gui_qt_font_spaceship_label
[512];
338 char gui_qt_font_help_label
[512];
339 char gui_qt_font_help_link
[512];
340 char gui_qt_font_help_text
[512];
341 char gui_qt_font_help_title
[512];
342 char gui_qt_font_chatline
[512];
343 char gui_qt_font_beta_label
[512];
344 char gui_qt_font_small
[512];
345 char gui_qt_font_comment_label
[512];
346 char gui_qt_font_city_names
[512];
347 char gui_qt_font_city_productions
[512];
348 char gui_qt_font_reqtree_text
[512];
349 bool gui_qt_show_titlebar
;
350 char gui_qt_wakeup_text
[512];
352 struct overview overview
;
355 extern struct client_options gui_options
;
357 #define SPECENUM_NAME option_type
358 #define SPECENUM_VALUE0 OT_BOOLEAN
359 #define SPECENUM_VALUE1 OT_INTEGER
360 #define SPECENUM_VALUE2 OT_STRING
361 #define SPECENUM_VALUE3 OT_ENUM
362 #define SPECENUM_VALUE4 OT_BITWISE
363 #define SPECENUM_VALUE5 OT_FONT
364 #define SPECENUM_VALUE6 OT_COLOR
365 #define SPECENUM_VALUE7 OT_VIDEO_MODE
366 #include "specenum_gen.h"
369 struct option
; /* Opaque type. */
370 struct option_set
; /* Opaque type. */
372 typedef void (*option_save_log_callback
)(enum log_level lvl
, const char *msg
, ...);
374 /* Main functions. */
375 void options_init(void);
376 void options_free(void);
377 void server_options_init(void);
378 void server_options_free(void);
379 void options_load(void);
380 void options_save(option_save_log_callback log_cb
);
384 extern const struct option_set
*client_optset
;
385 extern const struct option_set
*server_optset
;
387 struct option
*optset_option_by_number(const struct option_set
*poptset
,
389 #define optset_option_by_index optset_option_by_number
390 struct option
*optset_option_by_name(const struct option_set
*poptset
,
392 struct option
*optset_option_first(const struct option_set
*poptset
);
394 int optset_category_number(const struct option_set
*poptset
);
395 const char *optset_category_name(const struct option_set
*poptset
,
399 /* Common option functions. */
400 const struct option_set
*option_optset(const struct option
*poption
);
401 int option_number(const struct option
*poption
);
402 #define option_index option_number
403 const char *option_name(const struct option
*poption
);
404 const char *option_description(const struct option
*poption
);
405 const char *option_help_text(const struct option
*poption
);
406 enum option_type
option_type(const struct option
*poption
);
407 int option_category(const struct option
*poption
);
408 const char *option_category_name(const struct option
*poption
);
409 bool option_is_changeable(const struct option
*poption
);
410 struct option
*option_next(const struct option
*poption
);
412 bool option_reset(struct option
*poption
);
413 void option_set_changed_callback(struct option
*poption
,
414 void (*callback
) (struct option
*));
415 void option_changed(struct option
*poption
);
417 /* Option gui functions. */
418 void option_set_gui_data(struct option
*poption
, void *data
);
419 void *option_get_gui_data(const struct option
*poption
);
421 /* Callback assistance */
422 int option_get_cb_data(const struct option
*poption
);
424 /* Option type OT_BOOLEAN functions. */
425 bool option_bool_get(const struct option
*poption
);
426 bool option_bool_def(const struct option
*poption
);
427 bool option_bool_set(struct option
*poption
, bool val
);
429 /* Option type OT_INTEGER functions. */
430 int option_int_get(const struct option
*poption
);
431 int option_int_def(const struct option
*poption
);
432 int option_int_min(const struct option
*poption
);
433 int option_int_max(const struct option
*poption
);
434 bool option_int_set(struct option
*poption
, int val
);
436 /* Option type OT_STRING functions. */
437 const char *option_str_get(const struct option
*poption
);
438 const char *option_str_def(const struct option
*poption
);
439 const struct strvec
*option_str_values(const struct option
*poption
);
440 bool option_str_set(struct option
*poption
, const char *str
);
442 /* Option type OT_ENUM functions. */
443 int option_enum_str_to_int(const struct option
*poption
, const char *str
);
444 const char *option_enum_int_to_str(const struct option
*poption
, int val
);
445 int option_enum_get_int(const struct option
*poption
);
446 const char *option_enum_get_str(const struct option
*poption
);
447 int option_enum_def_int(const struct option
*poption
);
448 const char *option_enum_def_str(const struct option
*poption
);
449 const struct strvec
*option_enum_values(const struct option
*poption
);
450 bool option_enum_set_int(struct option
*poption
, int val
);
451 bool option_enum_set_str(struct option
*poption
, const char *str
);
453 /* Option type OT_BITWISE functions. */
454 unsigned option_bitwise_get(const struct option
*poption
);
455 unsigned option_bitwise_def(const struct option
*poption
);
456 unsigned option_bitwise_mask(const struct option
*poption
);
457 const struct strvec
*option_bitwise_values(const struct option
*poption
);
458 bool option_bitwise_set(struct option
*poption
, unsigned val
);
460 /* Option type OT_FONT functions. */
461 const char *option_font_get(const struct option
*poption
);
462 const char *option_font_def(const struct option
*poption
);
463 const char *option_font_target(const struct option
*poption
);
464 bool option_font_set(struct option
*poption
, const char *font
);
466 /* Option type OT_COLOR functions. */
467 struct ft_color
option_color_get(const struct option
*poption
);
468 struct ft_color
option_color_def(const struct option
*poption
);
469 bool option_color_set(struct option
*poption
, struct ft_color color
);
471 /* Option type OT_VIDEO_MODE functions. */
472 struct video_mode
option_video_mode_get(const struct option
*poption
);
473 struct video_mode
option_video_mode_def(const struct option
*poption
);
474 bool option_video_mode_set(struct option
*poption
, struct video_mode mode
);
477 #define options_iterate(poptset, poption) \
479 struct option *poption = optset_option_first(poptset); \
480 for (; NULL != poption; poption = option_next(poption)) { \
482 #define options_iterate_end \
487 /** Desired settable options. **/
488 void desired_settable_options_update(void);
489 void desired_settable_option_update(const char *op_name
,
490 const char *op_value
,
494 /** Dialog report options. **/
495 void options_dialogs_update(void);
496 void options_dialogs_set(void);
499 /** Message Options: **/
501 /* for specifying which event messages go where: */
503 #define MW_OUTPUT 1 /* add to the output window */
504 #define MW_MESSAGES 2 /* add to the messages window */
505 #define MW_POPUP 4 /* popup an individual window */
507 extern int messages_where
[]; /* OR-ed MW_ values [E_COUNT] */
510 /** Client options **/
512 #define GUI_DEFAULT_CHAT_LOGFILE "freeciv-chat.log"
514 /* gui-gtk2: [xy]size of the city dialog */
515 #define GUI_GTK2_CITYDLG_DEFAULT_XSIZE 770
516 #define GUI_GTK2_CITYDLG_MIN_XSIZE 256
517 #define GUI_GTK2_CITYDLG_MAX_XSIZE 4096
519 #define GUI_GTK2_CITYDLG_DEFAULT_YSIZE 512
520 #define GUI_GTK2_CITYDLG_MIN_YSIZE 128
521 #define GUI_GTK2_CITYDLG_MAX_YSIZE 4096
523 #define GUI_GTK_OVERVIEW_MIN_XSIZE 160
524 #define GUI_GTK_OVERVIEW_MIN_YSIZE 100
526 /* gui-gtk3: [xy]size of the city dialog */
527 #define GUI_GTK3_CITYDLG_DEFAULT_XSIZE 770
528 #define GUI_GTK3_CITYDLG_MIN_XSIZE 256
529 #define GUI_GTK3_CITYDLG_MAX_XSIZE 4096
531 #define GUI_GTK3_CITYDLG_DEFAULT_YSIZE 512
532 #define GUI_GTK3_CITYDLG_MIN_YSIZE 128
533 #define GUI_GTK3_CITYDLG_MAX_YSIZE 4096
535 #define GUI_GTK3_GOV_RANGE_MIN_DEFAULT -20
536 #define GUI_GTK3_GOV_RANGE_MIN_MIN -100
537 #define GUI_GTK3_GOV_RANGE_MIN_MAX 0
539 #define GUI_GTK3_GOV_RANGE_MAX_DEFAULT 20
540 #define GUI_GTK3_GOV_RANGE_MAX_MIN 0
541 #define GUI_GTK3_GOV_RANGE_MAX_MAX 100
543 /* gui-gtk3.22: [xy]size of the city dialog */
544 #define GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE 770
545 #define GUI_GTK3_22_CITYDLG_MIN_XSIZE 256
546 #define GUI_GTK3_22_CITYDLG_MAX_XSIZE 4096
548 #define GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE 512
549 #define GUI_GTK3_22_CITYDLG_MIN_YSIZE 128
550 #define GUI_GTK3_22_CITYDLG_MAX_YSIZE 4096
552 #define GUI_GTK3_22_GOV_RANGE_MIN_DEFAULT -20
553 #define GUI_GTK3_22_GOV_RANGE_MIN_MIN -100
554 #define GUI_GTK3_22_GOV_RANGE_MIN_MAX 0
556 #define GUI_GTK3_22_GOV_RANGE_MAX_DEFAULT 20
557 #define GUI_GTK3_22_GOV_RANGE_MAX_MIN 0
558 #define GUI_GTK3_22_GOV_RANGE_MAX_MAX 100
560 #define GUI_DEFAULT_MAPIMG_FILENAME "freeciv"
562 bool video_mode_to_string(char *buf
, size_t buf_len
, struct video_mode
*mode
);
563 bool string_to_video_mode(const char *buf
, struct video_mode
*mode
);
567 const char *tileset_name_for_topology(int topology_id
);
568 void option_set_default_ts(struct tileset
*t
);
569 void fill_topo_ts_default(void);
573 #endif /* __cplusplus */
575 #endif /* FC__OPTIONS_H */