Freeciv-3.3
Loading...
Searching...
No Matches
options.c
Go to the documentation of this file.
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)
6 any later version.
7
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***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdarg.h>
19#include <string.h>
20#include <sys/stat.h>
21#include <sys/types.h>
22
23/* utility */
24#include "deprecations.h"
25#include "fcintl.h"
26#include "ioz.h"
27#include "log.h"
28#include "mem.h"
29#include "registry.h"
30#include "shared.h"
31#include "string_vector.h"
32#include "support.h"
33
34/* common */
35#include "events.h"
36#include "version.h"
37
38/* client/agents */
39#include "cma_fec.h"
40
41/* client/include */
42#include "chatline_g.h"
43#include "dialogs_g.h"
44#include "gui_main_g.h"
45#include "menu_g.h"
46#include "optiondlg_g.h"
47#include "repodlgs_g.h"
48#include "voteinfo_bar_g.h"
49
50/* client */
51#include "audio.h"
52#include "cityrepdata.h"
53#include "client_main.h"
54#include "climisc.h"
55#include "connectdlg_common.h"
56#include "global_worklist.h"
57#include "mapctrl_common.h"
58#include "mapview_common.h"
59#include "music.h"
60#include "overview_common.h"
61#include <packhand_gen.h> /* <> so looked from the build directory first. */
62#include "plrdlg_common.h"
63#include "repodlgs_common.h"
64#include "servers.h"
65#include "themes_common.h"
66#include "tilespec.h"
67
68#include "options.h"
69
70
74 .default_user_name = "\0",
75 .default_server_host = "localhost",
76 .default_server_port = DEFAULT_SOCK_PORT,
77 .default_metaserver = DEFAULT_METASERVER_OPTION,
78 .default_tileset_square_name = "\0",
79 .default_tileset_hex_name = "\0",
80 .default_tileset_isohex_name = "\0",
81 .default_sound_set_name = "stdsounds",
82 .default_music_set_name = "stdmusic",
83 .default_sound_plugin_name = "\0",
84 .default_chat_logfile = GUI_DEFAULT_CHAT_LOGFILE,
85 .default_topology = TS_TOPO_ISOHEX,
86
87 .followtag_override = DEFAULT_FOLLOWTAG_OPTION,
88
89 .save_options_on_exit = TRUE,
90
91 .use_prev_server = FALSE,
92 .heartbeat_enabled = FALSE,
93 .send_desired_settings = TRUE,
94
96 .first_boot = FALSE,
97 .default_tileset_name = "\0",
98 .default_tileset_overhead_name = "\0",
99 .default_tileset_iso_name = "\0",
100 .gui_gtk3_migrated_from_gtk2 = FALSE,
101 .gui_gtk3_22_migrated_from_gtk3 = FALSE,
102 .gui_gtk4_migrated_from_gtk3_22 = FALSE,
103 .gui_sdl2_migrated_from_sdl = FALSE,
104 .gui_sdl3_migrated_from_sdl2 = FALSE,
105 .gui_gtk2_migrated_from_2_5 = FALSE,
106 .gui_gtk3_migrated_from_2_5 = FALSE,
107 .gui_qt_migrated_from_2_5 = FALSE,
108
109 .migrate_fullscreen = FALSE,
110
113 .gui_qt_default_fonts_set = FALSE,
114 .gui_sdl2_default_screen_size_set = FALSE,
115 .gui_sdl3_default_screen_size_set = FALSE,
116
119 .solid_color_behind_units = FALSE,
120 .sound_bell_at_new_turn = FALSE,
121 .smooth_move_unit_msec = 30,
122 .smooth_center_slide_msec = 200,
123 .smooth_combat_step_msec = 10,
124 .ai_manual_turn_done = TRUE,
125 .auto_center_on_unit = TRUE,
126 .auto_center_on_automated = TRUE,
127 .auto_center_on_combat = FALSE,
128 .auto_center_each_turn = TRUE,
129 .wakeup_focus = TRUE,
130 .goto_into_unknown = TRUE,
131 .center_when_popup_city = TRUE,
132 .show_previous_turn_messages = TRUE,
133 .concise_city_production = FALSE,
134 .auto_turn_done = FALSE,
135 .meta_accelerators = TRUE,
136 .ask_city_name = TRUE,
137 .popup_new_cities = TRUE,
138 .popup_actor_arrival = TRUE,
139 .popup_attack_actions = TRUE,
140 .popup_last_move_to_allied = TRUE,
141 .keyboardless_goto = TRUE,
142 .enable_cursor_changes = TRUE,
143 .separate_unit_selection = FALSE,
144 .unit_selection_clears_orders = TRUE,
145 .highlight_our_names = FT_COLOR("#000000", "#FFFF00"),
146
147 .voteinfo_bar_use = TRUE,
148 .voteinfo_bar_always_show = FALSE,
149 .voteinfo_bar_hide_when_not_player = FALSE,
150 .voteinfo_bar_new_at_front = FALSE,
151
152 .autoaccept_tileset_suggestion = FALSE,
153 .autoaccept_soundset_suggestion = FALSE,
154 .autoaccept_musicset_suggestion = FALSE,
155
156 .sound_enable_effects = TRUE,
157 .sound_enable_menu_music = TRUE,
158 .sound_enable_game_music = TRUE,
159 .sound_effects_volume = 100,
160 .silent_when_not_in_focus = FALSE,
161
162 /* This option is currently set by the client - not by the user. */
163 .update_city_text_in_refresh_tile = TRUE,
164
165 .draw_city_outlines = TRUE,
166 .draw_city_output = FALSE,
167 .draw_map_grid = FALSE,
168 .draw_city_names = TRUE,
169 .draw_city_growth = TRUE,
170 .draw_city_productions = TRUE,
171 .draw_city_buycost = FALSE,
172 .draw_city_trade_routes = FALSE,
173 .draw_terrain = TRUE,
174 .draw_coastline = FALSE,
175 .draw_paths = TRUE,
176 .draw_irrigation = TRUE,
177 .draw_mines = TRUE,
178 .draw_fortress_airbase = TRUE,
179 .draw_specials = TRUE,
180 .draw_huts = TRUE,
181 .draw_pollution = TRUE,
182 .draw_cities = TRUE,
183 .draw_units = TRUE,
184 .draw_focus_unit = FALSE,
185 .draw_fog_of_war = TRUE,
186 .draw_borders = TRUE,
187 .draw_native = FALSE,
188 .draw_full_citybar = TRUE,
189 .draw_unit_shields = TRUE,
190 .draw_unit_stack_size = TRUE,
191 .player_dlg_show_dead_players = TRUE,
192 .reqtree_show_icons = TRUE,
193 .reqtree_curved_lines = FALSE,
194
195/* Options for map images */
196/* .mapimg_format, */
197 .mapimg_zoom = 2,
198/* See the definition of MAPIMG_LAYER in mapimg.h. */
199 .mapimg_layer = {
200 FALSE, /* a - MAPIMG_LAYER_AREA */
201 TRUE, /* b - MAPIMG_LAYER_BORDERS */
202 TRUE, /* c - MAPIMG_LAYER_CITIES */
203 TRUE, /* f - MAPIMG_LAYER_FOGOFWAR */
204 TRUE, /* k - MAPIMG_LAYER_KNOWLEDGE */
205 TRUE, /* t - MAPIMG_LAYER_TERRAIN */
206 TRUE /* u - MAPIMG_LAYER_UNITS */
207 },
208/* .mapimg_filename, */
209
210 .zoom_set = FALSE,
211 .zoom_default_level = 1.0,
212
213/* gui-gtk-2.0 client specific options.
214 * These are still kept just so users can migrate them to gtk3-client */
215 .gui_gtk2_map_scrollbars = FALSE,
216 .gui_gtk2_dialogs_on_top = TRUE,
217 .gui_gtk2_show_task_icons = TRUE,
218 .gui_gtk2_enable_tabs = TRUE,
219 .gui_gtk2_better_fog = TRUE,
220 .gui_gtk2_show_chat_message_time = FALSE,
221 .gui_gtk2_new_messages_go_to_top = FALSE,
222 .gui_gtk2_show_message_window_buttons = TRUE,
223 .gui_gtk2_metaserver_tab_first = FALSE,
224 .gui_gtk2_allied_chat_only = FALSE,
225 .gui_gtk2_mouse_over_map_focus = FALSE,
226 .gui_gtk2_chatline_autocompletion = TRUE,
227 .gui_gtk2_citydlg_xsize = GUI_GTK2_CITYDLG_DEFAULT_XSIZE,
228 .gui_gtk2_citydlg_ysize = GUI_GTK2_CITYDLG_DEFAULT_YSIZE,
229 .gui_gtk2_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
230 .gui_gtk2_font_city_label = "Monospace 8",
231 .gui_gtk2_font_notify_label = "Monospace Bold 9",
232 .gui_gtk2_font_spaceship_label = "Monospace 8",
233 .gui_gtk2_font_help_label = "Sans Bold 10",
234 .gui_gtk2_font_help_link = "Sans 9",
235 .gui_gtk2_font_help_text = "Monospace 8",
236 .gui_gtk2_font_chatline = "Monospace 8",
237 .gui_gtk2_font_beta_label = "Sans Italic 10",
238 .gui_gtk2_font_small = "Sans 9",
239 .gui_gtk2_font_comment_label = "Sans Italic 9",
240 .gui_gtk2_font_city_names = "Sans Bold 10",
241 .gui_gtk2_font_city_productions = "Serif 10",
242 .gui_gtk2_font_reqtree_text = "Serif 10",
243
244/* gui-gtk-3.0 client specific options. */
245 .gui_gtk3_fullscreen = FALSE,
246 .gui_gtk3_map_scrollbars = FALSE,
247 .gui_gtk3_dialogs_on_top = TRUE,
248 .gui_gtk3_show_task_icons = TRUE,
249 .gui_gtk3_enable_tabs = TRUE,
250 .gui_gtk3_show_chat_message_time = FALSE,
251 .gui_gtk3_new_messages_go_to_top = FALSE,
252 .gui_gtk3_show_message_window_buttons = TRUE,
253 .gui_gtk3_metaserver_tab_first = FALSE,
254 .gui_gtk3_allied_chat_only = FALSE,
255 .gui_gtk3_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
256 .gui_gtk3_small_display_layout = FALSE,
257 .gui_gtk3_mouse_over_map_focus = FALSE,
258 .gui_gtk3_chatline_autocompletion = TRUE,
259 .gui_gtk3_citydlg_xsize = GUI_GTK3_CITYDLG_DEFAULT_XSIZE,
260 .gui_gtk3_citydlg_ysize = GUI_GTK3_CITYDLG_DEFAULT_YSIZE,
261 .gui_gtk3_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
262 .gui_gtk3_governor_range_min = -20,
263 .gui_gtk3_governor_range_max = 20,
264 .gui_gtk3_font_city_label = "Monospace 8",
265 .gui_gtk3_font_notify_label = "Monospace Bold 9",
266 .gui_gtk3_font_spaceship_label = "Monospace 8",
267 .gui_gtk3_font_help_label = "Sans Bold 10",
268 .gui_gtk3_font_help_link = "Sans 9",
269 .gui_gtk3_font_help_text = "Monospace 8",
270 .gui_gtk3_font_chatline = "Monospace 8",
271 .gui_gtk3_font_beta_label = "Sans Italic 10",
272 .gui_gtk3_font_small = "Sans 9",
273 .gui_gtk3_font_comment_label = "Sans Italic 9",
274 .gui_gtk3_font_city_names = "Sans Bold 10",
275 .gui_gtk3_font_city_productions = "Serif 10",
276 .gui_gtk3_font_reqtree_text = "Serif 10",
277
278/* gui-gtk-3.22 client specific options. */
279 .gui_gtk3_22_default_theme_name = FC_GTK3_22_DEFAULT_THEME_NAME,
280 .gui_gtk3_22_fullscreen = FALSE,
281 .gui_gtk3_22_map_scrollbars = FALSE,
282 .gui_gtk3_22_dialogs_on_top = TRUE,
283 .gui_gtk3_22_show_task_icons = TRUE,
284 .gui_gtk3_22_enable_tabs = TRUE,
285 .gui_gtk3_22_show_chat_message_time = FALSE,
286 .gui_gtk3_22_new_messages_go_to_top = FALSE,
287 .gui_gtk3_22_show_message_window_buttons = TRUE,
288 .gui_gtk3_22_metaserver_tab_first = FALSE,
289 .gui_gtk3_22_allied_chat_only = FALSE,
290 .gui_gtk3_22_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
291 .gui_gtk3_22_small_display_layout = FALSE,
292 .gui_gtk3_22_mouse_over_map_focus = FALSE,
293 .gui_gtk3_22_chatline_autocompletion = TRUE,
294 .gui_gtk3_22_citydlg_xsize = GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE,
295 .gui_gtk3_22_citydlg_ysize = GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE,
296 .gui_gtk3_22_helpdlg_xsize = GUI_GTK3_22_HELPDLG_DEFAULT_XSIZE,
297 .gui_gtk3_22_helpdlg_ysize = GUI_GTK3_22_HELPDLG_DEFAULT_YSIZE,
298 .gui_gtk3_22_optionsdlg_xsize = GUI_GTK3_22_OPTIONSDLG_DEFAULT_XSIZE,
299 .gui_gtk3_22_optionsdlg_ysize = GUI_GTK3_22_OPTIONSDLG_DEFAULT_YSIZE,
300 .gui_gtk3_22_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
301 .gui_gtk3_22_governor_range_min = -20,
302 .gui_gtk3_22_governor_range_max = 20,
303 .gui_gtk3_22_font_city_label = "Monospace 8",
304 .gui_gtk3_22_font_notify_label = "Monospace Bold 9",
305 .gui_gtk3_22_font_spaceship_label = "Monospace 8",
306 .gui_gtk3_22_font_help_label = "Sans Bold 10",
307 .gui_gtk3_22_font_help_link = "Sans 9",
308 .gui_gtk3_22_font_help_text = "Monospace 8",
309 .gui_gtk3_22_font_chatline = "Monospace 8",
310 .gui_gtk3_22_font_beta_label = "Sans Italic 10",
311 .gui_gtk3_22_font_small = "Sans 9",
312 .gui_gtk3_22_font_comment_label = "Sans Italic 9",
313 .gui_gtk3_22_font_city_names = "Sans Bold 10",
314 .gui_gtk3_22_font_city_productions = "Serif 10",
315 .gui_gtk3_22_font_reqtree_text = "Serif 10",
316
317/* gui-gtk-4.0 client specific options. */
318 .gui_gtk4_default_theme_name = FC_GTK4_DEFAULT_THEME_NAME,
319 .gui_gtk4_fullscreen = FALSE,
320 .gui_gtk4_map_scrollbars = FALSE,
321 .gui_gtk4_dialogs_on_top = TRUE,
322 .gui_gtk4_show_task_icons = TRUE,
323 .gui_gtk4_enable_tabs = TRUE,
324 .gui_gtk4_show_chat_message_time = FALSE,
325 .gui_gtk4_new_messages_go_to_top = FALSE,
326 .gui_gtk4_show_message_window_buttons = TRUE,
327 .gui_gtk4_metaserver_tab_first = FALSE,
328 .gui_gtk4_allied_chat_only = FALSE,
329 .gui_gtk4_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
330 .gui_gtk4_small_display_layout = FALSE,
331 .gui_gtk4_mouse_over_map_focus = FALSE,
332 .gui_gtk4_chatline_autocompletion = TRUE,
333 .gui_gtk4_citydlg_xsize = GUI_GTK4_CITYDLG_DEFAULT_XSIZE,
334 .gui_gtk4_citydlg_ysize = GUI_GTK4_CITYDLG_DEFAULT_YSIZE,
335 .gui_gtk4_helpdlg_xsize = GUI_GTK4_HELPDLG_DEFAULT_XSIZE,
336 .gui_gtk4_helpdlg_ysize = GUI_GTK4_HELPDLG_DEFAULT_YSIZE,
337 .gui_gtk4_optionsdlg_ysize = GUI_GTK4_OPTIONSDLG_DEFAULT_YSIZE,
338 .gui_gtk4_optionsdlg_xsize = GUI_GTK4_OPTIONSDLG_DEFAULT_XSIZE,
339 .gui_gtk4_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
340 .gui_gtk4_governor_range_min = -20,
341 .gui_gtk4_governor_range_max = 20,
342 .gui_gtk4_font_city_label = "Monospace 8",
343 .gui_gtk4_font_notify_label = "Monospace Bold 9",
344 .gui_gtk4_font_spaceship_label = "Monospace 8",
345 .gui_gtk4_font_help_label = "Sans Bold 10",
346 .gui_gtk4_font_help_link = "Sans 9",
347 .gui_gtk4_font_help_text = "Monospace 8",
348 .gui_gtk4_font_chatline = "Monospace 8",
349 .gui_gtk4_font_beta_label = "Sans Italic 10",
350 .gui_gtk4_font_small = "Sans 9",
351 .gui_gtk4_font_comment_label = "Sans Italic 9",
352 .gui_gtk4_font_city_names = "Sans Bold 10",
353 .gui_gtk4_font_city_productions = "Serif 10",
354 .gui_gtk4_font_reqtree_text = "Serif 10",
355
356/* gui-sdl client specific options. */
357 .gui_sdl_fullscreen = FALSE,
358 .gui_sdl_screen = VIDEO_MODE(640, 480),
359 .gui_sdl_do_cursor_animation = TRUE,
360 .gui_sdl_use_color_cursors = TRUE,
361
362/* gui-sdl2 client specific options. */
363 .gui_sdl2_default_theme_name = FC_SDL2_DEFAULT_THEME_NAME,
364 .gui_sdl2_fullscreen = FALSE,
365 .gui_sdl2_screen = VIDEO_MODE(640, 480),
366 .gui_sdl2_swrenderer = FALSE,
367 .gui_sdl2_do_cursor_animation = TRUE,
368 .gui_sdl2_use_color_cursors = TRUE,
369 .gui_sdl2_font_city_names = "10",
370 .gui_sdl2_font_city_productions = "10",
371 .gui_sdl2_use_theme_font_size = TRUE,
372 .gui_sdl2_font_size = 10,
373
374/* gui-sdl3 client specific options. */
375 .gui_sdl3_default_theme_name = FC_SDL2_DEFAULT_THEME_NAME,
376 .gui_sdl3_fullscreen = FALSE,
377 .gui_sdl3_screen = VIDEO_MODE(640, 480),
378 .gui_sdl3_do_cursor_animation = TRUE,
379 .gui_sdl3_use_color_cursors = TRUE,
380 .gui_sdl3_font_city_names = "10",
381 .gui_sdl3_font_city_productions = "10",
382 .gui_sdl3_use_theme_font_size = TRUE,
383 .gui_sdl3_font_size = 10,
384
385/* gui-qt client specific options. */
386 .gui_qt_fullscreen = FALSE,
387 .gui_qt_show_preview = TRUE,
388 .gui_qt_sidebar_left = TRUE,
389 .gui_qt_default_theme_name = FC_QT_DEFAULT_THEME_NAME,
390 .gui_qt_font_default = "Sans Serif,10,-1,5,75,0,0,0,0,0",
391 .gui_qt_font_notify_label = "Monospace,8,-1,5,75,0,0,0,0,0",
392 .gui_qt_font_help_label = "Sans Serif,9,-1,5,50,0,0,0,0,0",
393 .gui_qt_font_help_text = "Monospace,8,-1,5,50,0,0,0,0,0",
394 .gui_qt_font_chatline = "Monospace,8,-1,5,50,0,0,0,0,0",
395 .gui_qt_font_city_names = "Sans Serif,10,-1,5,75,0,0,0,0,0",
396 .gui_qt_font_city_productions = "Sans Serif,10,-1,5,50,1,0,0,0,0",
397 .gui_qt_font_reqtree_text = "Sans Serif,10,-1,5,50,1,0,0,0,0",
398 .gui_qt_show_titlebar = TRUE,
399 .gui_qt_wakeup_text = "Wake up %1",
400 .gui_qt_show_relations_panel = TRUE,
401 .gui_qt_show_techs_panel = TRUE,
402 .gui_qt_show_wonders_panel = TRUE,
403 .gui_qt_svgflags = TRUE
404};
405
406/* Set to TRUE after the first call to options_init(), to avoid the usage
407 * of non-initialized datas when calling the changed callback. */
409
410static int sync_serial = 0;
411static int reply_serial = 0;
412static bool queue_save = FALSE;
414
415static const struct strvec *get_mapimg_format_list(const struct option *poption);
416
417/****************************************************************************
418 Option set structure.
419****************************************************************************/
421 struct option * (*option_by_number) (int);
422 struct option * (*option_first) (void);
423
425 const char * (*category_name) (int);
426};
427
428/************************************************************************/
432 int id)
433{
435
436 return poptset->option_by_number(id);
437}
438
439/************************************************************************/
443 const char *name)
444{
446
448 if (0 == strcmp(option_name(poption), name)) {
449 return poption;
450 }
452 return NULL;
453}
454
455/************************************************************************/
459{
461
462 return poptset->option_first();
463}
464
465/************************************************************************/
469{
471
472 return poptset->category_number();
473}
474
475/************************************************************************/
478const char *optset_category_name(const struct option_set *poptset,
479 int category)
480{
482
483 return poptset->category_name(category);
484}
485
486
487/****************************************************************************
488 The base class for options.
489****************************************************************************/
490struct option {
491 /* A link to the option set. */
492 const struct option_set *poptset;
493 /* Type of the option. */
495
496 /* Common accessors. */
497 const struct option_common_vtable {
498 int (*number) (const struct option *);
499 const char * (*name) (const struct option *);
500 const char * (*description) (const struct option *);
501 const char * (*help_text) (const struct option *);
502 int (*category) (const struct option *);
503 bool (*is_changeable) (const struct option *);
504 struct option * (*next) (const struct option *);
506 /* Specific typed accessors. */
507 union {
508 /* Specific boolean accessors (OT_BOOLEAN == type). */
509 const struct option_bool_vtable {
510 bool (*get) (const struct option *);
511 bool (*def) (const struct option *);
512 bool (*set) (struct option *, bool);
514 /* Specific integer accessors (OT_INTEGER == type). */
515 const struct option_int_vtable {
516 int (*get) (const struct option *);
517 int (*def) (const struct option *);
518 int (*minimum) (const struct option *);
519 int (*maximum) (const struct option *);
520 bool (*set) (struct option *, int);
522 /* Specific string accessors (OT_STRING == type). */
523 const struct option_str_vtable {
524 const char * (*get) (const struct option *);
525 const char * (*def) (const struct option *);
526 const struct strvec * (*values) (const struct option *);
527 bool (*set) (struct option *, const char *);
529 /* Specific enum accessors (OT_ENUM == type). */
530 const struct option_enum_vtable {
531 int (*get) (const struct option *);
532 int (*def) (const struct option *);
533 const struct strvec * (*values) (const struct option *);
534 bool (*set) (struct option *, int);
535 int (*cmp) (const char *, const char *);
537 /* Specific bitwise accessors (OT_BITWISE == type). */
538 const struct option_bitwise_vtable {
539 unsigned (*get) (const struct option *);
540 unsigned (*def) (const struct option *);
541 const struct strvec * (*values) (const struct option *);
542 bool (*set) (struct option *, unsigned);
544 /* Specific font accessors (OT_FONT == type). */
545 const struct option_font_vtable {
546 const char * (*get) (const struct option *);
547 const char * (*def) (const struct option *);
548 const char * (*target) (const struct option *);
549 bool (*set) (struct option *, const char *);
551 /* Specific color accessors (OT_COLOR == type). */
552 const struct option_color_vtable {
553 struct ft_color (*get) (const struct option *);
554 struct ft_color (*def) (const struct option *);
555 bool (*set) (struct option *, struct ft_color);
557 /* Specific video mode accessors (OT_VIDEO_MODE == type). */
558 const struct option_video_mode_vtable {
559 struct video_mode (*get) (const struct option *);
560 struct video_mode (*def) (const struct option *);
561 bool (*set) (struct option *, struct video_mode);
563 };
564
565 /* Called after the value changed. */
567
569
570 /* Volatile. */
571 void *gui_data;
572};
573
574#define OPTION(poption) ((struct option *) (poption))
575
576#define OPTION_INIT(optset, spec_type, spec_table_var, common_table, \
577 spec_table, changed_cb, cb_data) { \
578 .poptset = optset, \
579 .type = spec_type, \
580 .common_vtable = &common_table, \
581 INIT_BRACE_BEGIN \
582 .spec_table_var = &spec_table \
583 INIT_BRACE_END, \
584 .changed_callback = changed_cb, \
585 .callback_data = cb_data, \
586 .gui_data = NULL \
587}
588#define OPTION_BOOL_INIT(optset, common_table, bool_table, changed_cb) \
589 OPTION_INIT(optset, OT_BOOLEAN, bool_vtable, common_table, bool_table, \
590 changed_cb, 0)
591#define OPTION_INT_INIT(optset, common_table, int_table, changed_cb) \
592 OPTION_INIT(optset, OT_INTEGER, int_vtable, common_table, int_table, \
593 changed_cb, 0)
594#define OPTION_STR_INIT(optset, common_table, str_table, changed_cb, cb_data) \
595 OPTION_INIT(optset, OT_STRING, str_vtable, common_table, str_table, \
596 changed_cb, cb_data)
597#define OPTION_ENUM_INIT(optset, common_table, enum_table, changed_cb) \
598 OPTION_INIT(optset, OT_ENUM, enum_vtable, common_table, enum_table, \
599 changed_cb, 0)
600#define OPTION_BITWISE_INIT(optset, common_table, bitwise_table, \
601 changed_cb) \
602 OPTION_INIT(optset, OT_BITWISE, bitwise_vtable, common_table, \
603 bitwise_table, changed_cb, 0)
604#define OPTION_FONT_INIT(optset, common_table, font_table, changed_cb) \
605 OPTION_INIT(optset, OT_FONT, font_vtable, common_table, font_table, \
606 changed_cb, 0)
607#define OPTION_COLOR_INIT(optset, common_table, color_table, changed_cb) \
608 OPTION_INIT(optset, OT_COLOR, color_vtable, common_table, color_table, \
609 changed_cb, 0)
610#define OPTION_VIDEO_MODE_INIT(optset, common_table, video_mode_table, \
611 changed_cb) \
612 OPTION_INIT(optset, OT_VIDEO_MODE, video_mode_vtable, common_table, \
613 video_mode_table, changed_cb, 0)
614
615
616/************************************************************************/
619const struct option_set *option_optset(const struct option *poption)
620{
622
623 return poption->poptset;
624}
625
626/************************************************************************/
629int option_number(const struct option *poption)
630{
632
633 return poption->common_vtable->number(poption);
634}
635
636/************************************************************************/
639const char *option_name(const struct option *poption)
640{
642
643 return poption->common_vtable->name(poption);
644}
645
646/************************************************************************/
649const char *option_description(const struct option *poption)
650{
652
653 return poption->common_vtable->description(poption);
654}
655
656/************************************************************************/
659const char *option_help_text(const struct option *poption)
660{
662
663 return poption->common_vtable->help_text(poption);
664}
665
666/************************************************************************/
670{
672
673 return poption->type;
674}
675
676/************************************************************************/
680{
682
683 return poption->common_vtable->category(poption);
684}
685
686/************************************************************************/
689const char *option_category_name(const struct option *poption)
690{
692
693 return optset_category_name(poption->poptset,
694 poption->common_vtable->category(poption));
695}
696
697/************************************************************************/
701{
703
704 return poption->common_vtable->is_changeable(poption);
705}
706
707/************************************************************************/
710struct option *option_next(const struct option *poption)
711{
713
714 return poption->common_vtable->next(poption);
715}
716
717/************************************************************************/
744
745/************************************************************************/
749 void (*callback) (struct option *))
750{
752
753 poption->changed_callback = callback;
754}
755
756/************************************************************************/
760{
762
764 /* Prevent to use non-initialized datas. */
765 return;
766 }
767
768 if (poption->changed_callback) {
769 poption->changed_callback(poption);
770 }
771
773}
774
775/************************************************************************/
778void option_set_gui_data(struct option *poption, void *data)
779{
781
782 poption->gui_data = data;
783}
784
785/************************************************************************/
789{
791
792 return poption->gui_data;
793}
794
795/************************************************************************/
799{
801
802 return poption->callback_data;
803}
804
805/************************************************************************/
808bool option_bool_get(const struct option *poption)
809{
812
813 return poption->bool_vtable->get(poption);
814}
815
816/************************************************************************/
819bool option_bool_def(const struct option *poption)
820{
823
824 return poption->bool_vtable->def(poption);
825}
826
827/************************************************************************/
830bool option_bool_set(struct option *poption, bool val)
831{
834
835 if (poption->bool_vtable->set(poption, val)) {
837 return TRUE;
838 }
839 return FALSE;
840}
841
842/************************************************************************/
845int option_int_get(const struct option *poption)
846{
849
850 return poption->int_vtable->get(poption);
851}
852
853/************************************************************************/
856int option_int_def(const struct option *poption)
857{
860
861 return poption->int_vtable->def(poption);
862}
863
864/************************************************************************/
867int option_int_min(const struct option *poption)
868{
871
872 return poption->int_vtable->minimum(poption);
873}
874
875/************************************************************************/
878int option_int_max(const struct option *poption)
879{
882
883 return poption->int_vtable->maximum(poption);
884}
885
886/************************************************************************/
889bool option_int_set(struct option *poption, int val)
890{
893
894 if (poption->int_vtable->set(poption, val)) {
896 return TRUE;
897 }
898 return FALSE;
899}
900
901/************************************************************************/
904const char *option_str_get(const struct option *poption)
905{
908
909 return poption->str_vtable->get(poption);
910}
911
912/************************************************************************/
915const char *option_str_def(const struct option *poption)
916{
919
920 return poption->str_vtable->def(poption);
921}
922
923/************************************************************************/
926const struct strvec *option_str_values(const struct option *poption)
927{
930
931 return poption->str_vtable->values(poption);
932}
933
934/************************************************************************/
937bool option_str_set(struct option *poption, const char *str)
938{
942
943 if (poption->str_vtable->set(poption, str)) {
945 return TRUE;
946 }
947 return FALSE;
948}
949
950/************************************************************************/
954int option_enum_str_to_int(const struct option *poption, const char *str)
955{
956 const struct strvec *values;
957 int val;
958
960 fc_assert_ret_val(OT_ENUM == poption->type, -1);
961 values = poption->enum_vtable->values(poption);
962 fc_assert_ret_val(NULL != values, -1);
963
964 for (val = 0; val < strvec_size(values); val++) {
965 if (0 == poption->enum_vtable->cmp(strvec_get(values, val), str)) {
966 return val;
967 }
968 }
969 return -1;
970}
971
972/************************************************************************/
976const char *option_enum_int_to_str(const struct option *poption, int val)
977{
978 const struct strvec *values;
979
982 values = poption->enum_vtable->values(poption);
983 fc_assert_ret_val(NULL != values, NULL);
984
985 return strvec_get(values, val);
986}
987
988/************************************************************************/
992{
994 fc_assert_ret_val(OT_ENUM == poption->type, -1);
995
996 return poption->enum_vtable->get(poption);
997}
998
999/************************************************************************/
1003const char *option_enum_get_str(const struct option *poption)
1004{
1007
1008 return strvec_get(poption->enum_vtable->values(poption),
1009 poption->enum_vtable->get(poption));
1010}
1011
1012/************************************************************************/
1016{
1018 fc_assert_ret_val(OT_ENUM == poption->type, -1);
1019
1020 return poption->enum_vtable->def(poption);
1021}
1022
1023/************************************************************************/
1027const char *option_enum_def_str(const struct option *poption)
1028{
1031
1032 return strvec_get(poption->enum_vtable->values(poption),
1033 poption->enum_vtable->def(poption));
1034}
1035
1036/************************************************************************/
1040const struct strvec *option_enum_values(const struct option *poption)
1041{
1044
1045 return poption->enum_vtable->values(poption);
1046}
1047
1048/************************************************************************/
1051bool option_enum_set_int(struct option *poption, int val)
1052{
1055
1056 if (poption->enum_vtable->set(poption, val)) {
1058 return TRUE;
1059 }
1060 return FALSE;
1061}
1062
1063/************************************************************************/
1068bool option_enum_set_str(struct option *poption, const char *str)
1069{
1073
1074 if (poption->enum_vtable->set(poption,
1077 return TRUE;
1078 }
1079 return FALSE;
1080}
1081
1082/************************************************************************/
1085unsigned option_bitwise_get(const struct option *poption)
1086{
1089
1090 return poption->bitwise_vtable->get(poption);
1091}
1092
1093/************************************************************************/
1096unsigned option_bitwise_def(const struct option *poption)
1097{
1100
1101 return poption->bitwise_vtable->def(poption);
1102}
1103
1104/************************************************************************/
1107unsigned option_bitwise_mask(const struct option *poption)
1108{
1109 const struct strvec *values;
1110
1113
1114 values = poption->bitwise_vtable->values(poption);
1115 fc_assert_ret_val(NULL != values, 0);
1116
1117 return (1 << strvec_size(values)) - 1;
1118}
1119
1120/************************************************************************/
1124const struct strvec *option_bitwise_values(const struct option *poption)
1125{
1128
1129 return poption->bitwise_vtable->values(poption);
1130}
1131
1132/************************************************************************/
1135bool option_bitwise_set(struct option *poption, unsigned val)
1136{
1139
1140 if (0 != (val & ~option_bitwise_mask(poption))
1141 || !poption->bitwise_vtable->set(poption, val)) {
1142 return FALSE;
1143 }
1144
1146 return TRUE;
1147}
1148
1149/************************************************************************/
1152const char *option_font_get(const struct option *poption)
1153{
1156
1157 return poption->font_vtable->get(poption);
1158}
1159
1160/************************************************************************/
1163const char *option_font_def(const struct option *poption)
1164{
1167
1168 return poption->font_vtable->def(poption);
1169}
1170
1171/************************************************************************/
1174const char *option_font_target(const struct option *poption)
1175{
1178
1179 return poption->font_vtable->target(poption);
1180}
1181
1182/************************************************************************/
1185bool option_font_set(struct option *poption, const char *font)
1186{
1189 fc_assert_ret_val(NULL != font, FALSE);
1190
1191 if (poption->font_vtable->set(poption, font)) {
1193 return TRUE;
1194 }
1195 return FALSE;
1196}
1197
1198/************************************************************************/
1208
1209/************************************************************************/
1219
1220/************************************************************************/
1225{
1228
1229 if (poption->color_vtable->set(poption, color)) {
1231 return TRUE;
1232 }
1233 return FALSE;
1234}
1235
1236/************************************************************************/
1240{
1243 video_mode_construct(-1, -1));
1244
1245 return poption->video_mode_vtable->get(poption);
1246}
1247
1248/************************************************************************/
1252{
1255 video_mode_construct(-1, -1));
1256
1257 return poption->video_mode_vtable->def(poption);
1258}
1259
1260/************************************************************************/
1265{
1268
1269 if (poption->video_mode_vtable->set(poption, mode)) {
1271 return TRUE;
1272 }
1273 return FALSE;
1274}
1275
1276
1277/****************************************************************************
1278 Client option set.
1279****************************************************************************/
1280static struct option *client_optset_option_by_number(int id);
1281static struct option *client_optset_option_first(void);
1282static int client_optset_category_number(void);
1283static const char *client_optset_category_name(int category);
1284
1287 .option_first = client_optset_option_first,
1288 .category_number = client_optset_category_number,
1289 .category_name = client_optset_category_name
1290};
1292
1294 const char *support; /* Untranslated long support name, used
1295 * for saving. */
1296 const char *pretty; /* Translated, used to display to the
1297 * users. */
1298};
1299
1300/****************************************************************************
1301 Virtuals tables for the client options.
1302****************************************************************************/
1303static int client_option_number(const struct option *poption);
1304static const char *client_option_name(const struct option *poption);
1305static const char *client_option_description(const struct option *poption);
1306static const char *client_option_help_text(const struct option *poption);
1307static int client_option_category(const struct option *poption);
1308static bool client_option_is_changeable(const struct option *poption);
1309static struct option *client_option_next(const struct option *poption);
1310
1311static const struct option_common_vtable client_option_common_vtable = {
1312 .number = client_option_number,
1313 .name = client_option_name,
1314 .description = client_option_description,
1315 .help_text = client_option_help_text,
1316 .category = client_option_category,
1317 .is_changeable = client_option_is_changeable,
1318 .next = client_option_next
1319};
1320
1321static bool client_option_bool_get(const struct option *poption);
1322static bool client_option_bool_def(const struct option *poption);
1323static bool client_option_bool_set(struct option *poption, bool val);
1324
1325static const struct option_bool_vtable client_option_bool_vtable = {
1329};
1330
1331static int client_option_int_get(const struct option *poption);
1332static int client_option_int_def(const struct option *poption);
1333static int client_option_int_min(const struct option *poption);
1334static int client_option_int_max(const struct option *poption);
1335static bool client_option_int_set(struct option *poption, int val);
1336
1337static const struct option_int_vtable client_option_int_vtable = {
1338 .get = client_option_int_get,
1339 .def = client_option_int_def,
1340 .minimum = client_option_int_min,
1341 .maximum = client_option_int_max,
1343};
1344
1345static const char *client_option_str_get(const struct option *poption);
1346static const char *client_option_str_def(const struct option *poption);
1347static const struct strvec *
1349static bool client_option_str_set(struct option *poption, const char *str);
1350
1351static const struct option_str_vtable client_option_str_vtable = {
1352 .get = client_option_str_get,
1353 .def = client_option_str_def,
1354 .values = client_option_str_values,
1356};
1357
1358static int client_option_enum_get(const struct option *poption);
1359static int client_option_enum_def(const struct option *poption);
1360static const struct strvec *
1362static bool client_option_enum_set(struct option *poption, int val);
1363
1364static const struct option_enum_vtable client_option_enum_vtable = {
1369 .cmp = fc_strcasecmp
1370};
1371
1372#if 0 /* There's no bitwise options currently */
1373static unsigned client_option_bitwise_get(const struct option *poption);
1374static unsigned client_option_bitwise_def(const struct option *poption);
1375static const struct strvec *
1377static bool client_option_bitwise_set(struct option *poption, unsigned val);
1378
1379static const struct option_bitwise_vtable client_option_bitwise_vtable = {
1384};
1385#endif /* 0 */
1386
1387static const char *client_option_font_get(const struct option *poption);
1388static const char *client_option_font_def(const struct option *poption);
1389static const char *client_option_font_target(const struct option *poption);
1390static bool client_option_font_set(struct option *poption, const char *font);
1391
1392static const struct option_font_vtable client_option_font_vtable = {
1395 .target = client_option_font_target,
1397};
1398
1401static bool client_option_color_set(struct option *poption,
1402 struct ft_color color);
1403
1404static const struct option_color_vtable client_option_color_vtable = {
1408};
1409
1410static struct video_mode
1412static struct video_mode
1414static bool client_option_video_mode_set(struct option *poption,
1415 struct video_mode mode);
1416
1417static const struct option_video_mode_vtable client_option_video_mode_vtable = {
1421};
1422
1433
1434/****************************************************************************
1435 Derived class client option, inherinting of base class option.
1436****************************************************************************/
1438 struct option base_option; /* Base structure, must be the first! */
1439
1440 const char *name; /* Short name - used as an identifier */
1441 const char *description; /* One-line description */
1442 const char *help_text; /* Paragraph-length help text */
1444 enum gui_type specific; /* GUI_STUB for common options. */
1445
1446 union {
1447 /* OT_BOOLEAN type option. */
1448 struct {
1449 bool *const pvalue;
1450 const bool def;
1451 } boolean;
1452 /* OT_INTEGER type option. */
1453 struct {
1454 int *const pvalue;
1455 const int def, min, max;
1456 } integer;
1457 /* OT_STRING type option. */
1458 struct {
1459 char *const pvalue;
1460 const size_t size;
1461 const char *const def;
1462 /*
1463 * A function to return a string vector of possible string values,
1464 * or NULL for none.
1465 */
1466 const struct strvec *(*const val_accessor) (const struct option *);
1467 } string;
1468 /* OT_ENUM type option. */
1469 struct {
1470 int *const pvalue;
1471 const int def;
1472 struct strvec *support_names, *pretty_names; /* untranslated */
1473 const struct copt_val_name * (*const name_accessor) (int value);
1474 } enumerator;
1475 /* OT_BITWISE type option. */
1476 struct {
1477 unsigned *const pvalue;
1478 const unsigned def;
1479 struct strvec *support_names, *pretty_names; /* untranslated */
1480 const struct copt_val_name * (*const name_accessor) (int value);
1481 } bitwise;
1482 /* OT_FONT type option. */
1483 struct {
1484 char *const pvalue;
1485 const size_t size;
1486 const char *const def;
1487 const char *const target;
1488 } font;
1489 /* OT_COLOR type option. */
1490 struct {
1491 struct ft_color *const pvalue;
1492 const struct ft_color def;
1494 /* OT_VIDEO_MODE type option. */
1495 struct {
1496 struct video_mode *const pvalue;
1497 const struct video_mode def;
1499 };
1500};
1501
1502#define CLIENT_OPTION(poption) ((struct client_option *) (poption))
1503
1504/*
1505 * Generate a client option of type OT_BOOLEAN.
1506 *
1507 * oname: The option data. Note it is used as name to be loaded or saved.
1508 * So, you shouldn't change the name of this variable in any case.
1509 * odesc: A short description of the client option. Should be used with the
1510 * N_() macro.
1511 * ohelp: The help text for the client option. Should be used with the N_()
1512 * macro.
1513 * ocat: The client_option_class of this client option.
1514 * ospec: A gui_type enumerator which determine for what particular client
1515 * gui this option is for. Sets to GUI_STUB for common options.
1516 * odef: The default value of this client option (FALSE or TRUE).
1517 * ocb: A callback function of type void (*)(struct option *) called when
1518 * the option changed.
1519 */
1520#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb) \
1521{ \
1522 .base_option = OPTION_BOOL_INIT(&client_optset_static, \
1523 client_option_common_vtable, \
1524 client_option_bool_vtable, ocb), \
1525 .name = #oname, \
1526 .description = odesc, \
1527 .help_text = ohelp, \
1528 .category = ocat, \
1529 .specific = ospec, \
1530 INIT_BRACE_BEGIN \
1531 .boolean = { \
1532 .pvalue = &gui_options.oname, \
1533 .def = odef, \
1534 } \
1535 INIT_BRACE_END \
1536}
1537
1538/*
1539 * Generate a client option of type OT_INTEGER.
1540 *
1541 * oname: The option data. Note it is used as name to be loaded or saved.
1542 * So, you shouldn't change the name of this variable in any case.
1543 * odesc: A short description of the client option. Should be used with the
1544 * N_() macro.
1545 * ohelp: The help text for the client option. Should be used with the N_()
1546 * macro.
1547 * ocat: The client_option_class of this client option.
1548 * ospec: A gui_type enumerator which determine for what particular client
1549 * gui this option is for. Sets to GUI_STUB for common options.
1550 * odef: The default value of this client option.
1551 * omin: The minimal value of this client option.
1552 * omax: The maximal value of this client option.
1553 * ocb: A callback function of type void (*)(struct option *) called when
1554 * the option changed.
1555 */
1556#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb) \
1557{ \
1558 .base_option = OPTION_INT_INIT(&client_optset_static, \
1559 client_option_common_vtable, \
1560 client_option_int_vtable, ocb), \
1561 .name = #oname, \
1562 .description = odesc, \
1563 .help_text = ohelp, \
1564 .category = ocat, \
1565 .specific = ospec, \
1566 INIT_BRACE_BEGIN \
1567 .integer = { \
1568 .pvalue = &gui_options.oname, \
1569 .def = odef, \
1570 .min = omin, \
1571 .max = omax \
1572 } \
1573 INIT_BRACE_END \
1574}
1575
1576/*
1577 * Generate a client option of type OT_STRING.
1578 *
1579 * oname: The option data. Note it is used as name to be loaded or saved.
1580 * So, you shouldn't change the name of this variable in any case.
1581 * Be sure to pass the array variable and not a pointer to it because
1582 * the size is calculated with sizeof().
1583 * odesc: A short description of the client option. Should be used with the
1584 * N_() macro.
1585 * ohelp: The help text for the client option. Should be used with the N_()
1586 * macro.
1587 * ocat: The client_option_class of this client option.
1588 * ospec: A gui_type enumerator which determines for what particular client
1589 * gui this option is for. Set to GUI_STUB for common options.
1590 * odef: The default string for this client option.
1591 * ocb: A callback function of type void (*)(struct option *) called when
1592 * the option changed.
1593 */
1594#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd) \
1595{ \
1596 .base_option = OPTION_STR_INIT(&client_optset_static, \
1597 client_option_common_vtable, \
1598 client_option_str_vtable, ocb, cbd), \
1599 .name = #oname, \
1600 .description = odesc, \
1601 .help_text = ohelp, \
1602 .category = ocat, \
1603 .specific = ospec, \
1604 INIT_BRACE_BEGIN \
1605 .string = { \
1606 .pvalue = gui_options.oname, \
1607 .size = sizeof(gui_options.oname), \
1608 .def = odef, \
1609 .val_accessor = NULL \
1610 } \
1611 INIT_BRACE_END \
1612}
1613
1614/*
1615 * Generate a client option of type OT_STRING with a string accessor
1616 * function.
1617 *
1618 * oname: The option data. Note it is used as name to be loaded or saved.
1619 * So, you shouldn't change the name of this variable in any case.
1620 * Be sure to pass the array variable and not a pointer to it because
1621 * the size is calculated with sizeof().
1622 * odesc: A short description of the client option. Should be used with the
1623 * N_() macro.
1624 * ohelp: The help text for the client option. Should be used with the N_()
1625 * macro.
1626 * ocat: The client_option_class of this client option.
1627 * ospec: A gui_type enumerator which determine for what particular client
1628 * gui this option is for. Sets to GUI_STUB for common options.
1629 * odef: The default string for this client option.
1630 * oacc: The string accessor where to find the allowed values of type
1631 * 'const struct strvec * (*) (void)'.
1632 * ocb: A callback function of type void (*)(struct option *) called when
1633 * the option changed.
1634 */
1635#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd) \
1636{ \
1637 .base_option = OPTION_STR_INIT(&client_optset_static, \
1638 client_option_common_vtable, \
1639 client_option_str_vtable, ocb, cbd), \
1640 .name = #oname, \
1641 .description = odesc, \
1642 .help_text = ohelp, \
1643 .category = ocat, \
1644 .specific = ospec, \
1645 INIT_BRACE_BEGIN \
1646 .string = { \
1647 .pvalue = gui_options.oname, \
1648 .size = sizeof(gui_options.oname), \
1649 .def = odef, \
1650 .val_accessor = oacc \
1651 } \
1652 INIT_BRACE_END \
1653}
1654
1655/*
1656 * Generate a client option of type OT_ENUM.
1657 *
1658 * oname: The option data. Note it is used as name to be loaded or saved.
1659 * So, you shouldn't change the name of this variable in any case.
1660 * odesc: A short description of the client option. Should be used with the
1661 * N_() macro.
1662 * ohelp: The help text for the client option. Should be used with the N_()
1663 * macro.
1664 * ocat: The client_option_class of this client option.
1665 * ospec: A gui_type enumerator which determine for what particular client
1666 * gui this option is for. Sets to GUI_STUB for common options.
1667 * odef: The default value for this client option.
1668 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1669 * ocb: A callback function of type void (*) (struct option *) called when
1670 * the option changed.
1671 */
1672#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb) \
1673{ \
1674 .base_option = OPTION_ENUM_INIT(&client_optset_static, \
1675 client_option_common_vtable, \
1676 client_option_enum_vtable, ocb), \
1677 .name = #oname, \
1678 .description = odesc, \
1679 .help_text = ohelp, \
1680 .category = ocat, \
1681 .specific = ospec, \
1682 INIT_BRACE_BEGIN \
1683 .enumerator = { \
1684 .pvalue = (int *) &gui_options.oname, \
1685 .def = odef, \
1686 .support_names = NULL, /* Set in options_init(). */ \
1687 .pretty_names = NULL, \
1688 .name_accessor = oacc \
1689 } \
1690 INIT_BRACE_END \
1691}
1692
1693/*
1694 * Generate a client option of type OT_BITWISE.
1695 *
1696 * oname: The option data. Note it is used as name to be loaded or saved.
1697 * So, you shouldn't change the name of this variable in any case.
1698 * odesc: A short description of the client option. Should be used with the
1699 * N_() macro.
1700 * ohelp: The help text for the client option. Should be used with the N_()
1701 * macro.
1702 * ocat: The client_option_class of this client option.
1703 * ospec: A gui_type enumerator which determine for what particular client
1704 * gui this option is for. Sets to GUI_STUB for common options.
1705 * odef: The default value for this client option.
1706 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1707 * ocb: A callback function of type void (*) (struct option *) called when
1708 * the option changed.
1709 */
1710#define GEN_BITWISE_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, \
1711 ocb) \
1712{ \
1713 .base_option = OPTION_BITWISE_INIT(&client_optset_static, \
1714 client_option_common_vtable, \
1715 client_option_bitwise_vtable, ocb), \
1716 .name = #oname, \
1717 .description = odesc, \
1718 .help_text = ohelp, \
1719 .category = ocat, \
1720 .specific = ospec, \
1721 INIT_BRACE_BEGIN \
1722 .bitwise = { \
1723 .pvalue = &gui_options.oname, \
1724 .def = odef, \
1725 .support_names = NULL, /* Set in options_init(). */ \
1726 .pretty_names = NULL, \
1727 .name_accessor = oacc \
1728 } \
1729 INIT_BRACE_END \
1730}
1731
1732/*
1733 * Generate a client option of type OT_FONT.
1734 *
1735 * oname: The option data. Note it is used as name to be loaded or saved.
1736 * So, you shouldn't change the name of this variable in any case.
1737 * Be sure to pass the array variable and not a pointer to it because
1738 * the size is calculated with sizeof().
1739 * otgt: The target widget style.
1740 * odesc: A short description of the client option. Should be used with the
1741 * N_() macro.
1742 * ohelp: The help text for the client option. Should be used with the N_()
1743 * macro.
1744 * ocat: The client_option_class of this client option.
1745 * ospec: A gui_type enumerator which determine for what particular client
1746 * gui this option is for. Sets to GUI_STUB for common options.
1747 * odef: The default string for this client option.
1748 * ocb: A callback function of type void (*)(struct option *) called when
1749 * the option changed.
1750 */
1751#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb) \
1752{ \
1753 .base_option = OPTION_FONT_INIT(&client_optset_static, \
1754 client_option_common_vtable, \
1755 client_option_font_vtable, ocb), \
1756 .name = #oname, \
1757 .description = odesc, \
1758 .help_text = ohelp, \
1759 .category = ocat, \
1760 .specific = ospec, \
1761 INIT_BRACE_BEGIN \
1762 .font = { \
1763 .pvalue = gui_options.oname, \
1764 .size = sizeof(gui_options.oname), \
1765 .def = odef, \
1766 .target = otgt, \
1767 } \
1768 INIT_BRACE_END \
1769}
1770
1771/*
1772 * Generate a client option of type OT_COLOR.
1773 *
1774 * oname: The option data. Note it is used as name to be loaded or saved.
1775 * So, you shouldn't change the name of this variable in any case.
1776 * odesc: A short description of the client option. Should be used with the
1777 * N_() macro.
1778 * ohelp: The help text for the client option. Should be used with the N_()
1779 * macro.
1780 * ocat: The client_option_class of this client option.
1781 * ospec: A gui_type enumerator which determine for what particular client
1782 * gui this option is for. Sets to GUI_STUB for common options.
1783 * odef_fg, odef_bg: The default values for this client option.
1784 * ocb: A callback function of type void (*)(struct option *) called when
1785 * the option changed.
1786 */
1787#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, \
1788 odef_bg, ocb) \
1789{ \
1790 .base_option = OPTION_COLOR_INIT(&client_optset_static, \
1791 client_option_common_vtable, \
1792 client_option_color_vtable, ocb), \
1793 .name = #oname, \
1794 .description = odesc, \
1795 .help_text = ohelp, \
1796 .category = ocat, \
1797 .specific = ospec, \
1798 INIT_BRACE_BEGIN \
1799 .color = { \
1800 .pvalue = &gui_options.oname, \
1801 .def = FT_COLOR(odef_fg, odef_bg) \
1802 } \
1803 INIT_BRACE_END \
1804}
1805
1806/*
1807 * Generate a client option of type OT_VIDEO_MODE.
1808 *
1809 * oname: The option data. Note it is used as name to be loaded or saved.
1810 * So, you shouldn't change the name of this variable in any case.
1811 * odesc: A short description of the client option. Should be used with the
1812 * N_() macro.
1813 * ohelp: The help text for the client option. Should be used with the N_()
1814 * macro.
1815 * ocat: The client_option_class of this client option.
1816 * ospec: A gui_type enumerator which determine for what particular client
1817 * gui this option is for. Sets to GUI_STUB for common options.
1818 * odef_width, odef_height: The default values for this client option.
1819 * ocb: A callback function of type void (*)(struct option *) called when
1820 * the option changed.
1821 */
1822#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, \
1823 odef_height, ocb) \
1824{ \
1825 .base_option = OPTION_VIDEO_MODE_INIT(&client_optset_static, \
1826 client_option_common_vtable, \
1827 client_option_video_mode_vtable, \
1828 ocb), \
1829 .name = #oname, \
1830 .description = odesc, \
1831 .help_text = ohelp, \
1832 .category = ocat, \
1833 .specific = ospec, \
1834 INIT_BRACE_BEGIN \
1835 .video_mode = { \
1836 .pvalue = &gui_options.oname, \
1837 .def = VIDEO_MODE(odef_width, odef_height) \
1838 } \
1839 INIT_BRACE_END \
1840}
1841
1842/****************************************************************************
1843 Enumerator name accessors.
1844****************************************************************************/
1845
1846/************************************************************************/
1849static const struct copt_val_name
1851{
1852 /* Order must match enum GUI_GTK_MSGCHAT_* */
1853 static const struct copt_val_name names[] = {
1854 /* TRANS: enum value for 'gtk3_22/gtk4_message_chat_location' */
1855 { "SPLIT", N_("Split") },
1856 /* TRANS: enum value for 'gtk3_22/gtk4_message_chat_location' */
1857 { "SEPARATE", N_("Separate") },
1858 /* TRANS: enum value for 'gtk3_22/gtk4_message_chat_location' */
1859 { "MERGED", N_("Merged") }
1860 };
1861
1862 return (0 <= value && value < ARRAY_SIZE(names)
1863 ? names + value : NULL);
1864}
1865
1866/************************************************************************/
1869static const struct copt_val_name
1871{
1872 /* Order must match enum GUI_POPUP_TECH_HELP_* */
1873 static const struct copt_val_name names[] = {
1874 /* TRANS: enum value for 'gui_popup_tech_help' */
1875 { "ENABLED", N_("Enabled") },
1876 /* TRANS: enum value for 'gui_popup_tech_help' */
1877 { "DISABLED", N_("Disabled") },
1878 /* TRANS: enum value for 'gui_popup_tech_help' */
1879 { "RULESET", N_("Ruleset") }
1880 };
1881
1882 return (0 <= value && value < ARRAY_SIZE(names)
1883 ? names + value : NULL);
1884}
1885
1886/* Some changed callbacks. */
1887static void reqtree_show_icons_callback(struct option *poption);
1888static void view_option_changed_callback(struct option *poption);
1889static void manual_turn_done_callback(struct option *poption);
1890static void voteinfo_bar_callback(struct option *poption);
1891static void font_changed_callback(struct option *poption);
1892static void mapimg_changed_callback(struct option *poption);
1893static void game_music_enable_callback(struct option *poption);
1894static void menu_music_enable_callback(struct option *poption);
1895static void sound_volume_callback(struct option *poption);
1896
1898 GEN_STR_OPTION(default_user_name,
1899 N_("Login name"),
1900 N_("This is the default login username that will be used "
1901 "in the connection dialogs or with the -a command-line "
1902 "parameter."),
1904 GEN_BOOL_OPTION(use_prev_server, N_("Default to previously used server"),
1905 N_("Automatically update \"Server\" and \"Server port\" "
1906 "options to match your latest connection, so by "
1907 "default you connect to the same server you used "
1908 "on the previous run. You should enable "
1909 "saving options on exit too, so that the automatic "
1910 "updates to the options get saved too."),
1912 GEN_STR_OPTION(default_server_host,
1913 N_("Server"),
1914 N_("This is the default server hostname that will be used "
1915 "in the connection dialogs or with the -a command-line "
1916 "parameter."),
1917 COC_NETWORK, GUI_STUB, "localhost", NULL, 0),
1918 GEN_INT_OPTION(default_server_port,
1919 N_("Server port"),
1920 N_("This is the default server port that will be used "
1921 "in the connection dialogs or with the -a command-line "
1922 "parameter."),
1924 GEN_STR_OPTION(default_metaserver,
1925 N_("Metaserver"),
1926 N_("The metaserver is a host that the client contacts to "
1927 "find out about games on the internet. Don't change "
1928 "this from its default value unless you know what "
1929 "you're doing."),
1931 GEN_BOOL_OPTION(heartbeat_enabled,
1932 N_("Send heartbeat messages to the server"),
1933 N_("Periodically send an empty heartbeat message to the "
1934 "server to probe whether the connection is still up. "
1935 "This can help to make it obvious when the server has "
1936 "cut the connection due to a connectivity outage, if "
1937 "the client would otherwise sit idle for a long period."),
1939 GEN_STR_OPTION(followtag_override,
1940 N_("Followtag override"),
1941 /* TRANS: Leave 'builtin' untranslated */
1942 N_("Followtag determines which kind of new freeciv versions' "
1943 "availability gets checked from the metaserver. Special "
1944 "value 'builtin' means that value builtin to the client "
1945 "gets used."),
1947 GEN_BOOL_OPTION(send_desired_settings,
1948 N_("Send desired settings to the server"),
1949 N_("In single-player mode client usually sends user's "
1950 "desired server settings to the server it has "
1951 "launched internally. By disabling this option one "
1952 "can prevent such override of server settings from "
1953 "other sources, such as settings balanced for a "
1954 "custom ruleset."),
1956 GEN_STR_LIST_OPTION(default_sound_set_name,
1957 N_("Soundset"),
1958 N_("This is the soundset that will be used. Changing "
1959 "this is the same as using the -S command-line "
1960 "parameter. Use modpack installer utility to install "
1961 "additional soundsets."),
1962 COC_SOUND, GUI_STUB, "stdsounds", get_soundset_list, NULL, 0),
1963 GEN_STR_LIST_OPTION(default_music_set_name,
1964 N_("Musicset"),
1965 N_("This is the musicset that will be used. Changing "
1966 "this is the same as using the -m command-line "
1967 "parameter. Use modpack installer utility to install "
1968 "additional musicsets."),
1969 COC_SOUND, GUI_STUB, "stdmusic", get_musicset_list,
1971 GEN_STR_LIST_OPTION(default_sound_plugin_name,
1972 N_("Sound plugin"),
1973 N_("If you have a problem with sound, try changing "
1974 "the sound plugin. The new plugin won't take "
1975 "effect until you restart Freeciv. Changing this "
1976 "is the same as using the -P command-line option."),
1978 GEN_STR_OPTION(default_chat_logfile,
1979 N_("The chat log file"),
1980 N_("The name of the chat log file."),
1982 /* gui_gtk3_22/4/5_default_theme_name and gui_sdl2/3_default_theme_name are
1983 * different settings to avoid client crash after loading the
1984 * style for the other gui. Keeps 6 different options! */
1985 GEN_STR_LIST_OPTION(gui_gtk3_22_default_theme_name, N_("Theme"),
1986 N_("By changing this option you change the "
1987 "active theme."),
1990 GEN_STR_LIST_OPTION(gui_gtk4_default_theme_name, N_("Theme"),
1991 N_("By changing this option you change the "
1992 "active theme."),
1995 GEN_STR_LIST_OPTION(gui_sdl2_default_theme_name, N_("Theme"),
1996 N_("By changing this option you change the "
1997 "active theme."),
2000 GEN_STR_LIST_OPTION(gui_sdl3_default_theme_name, N_("Theme"),
2001 N_("By changing this option you change the "
2002 "active theme."),
2005 GEN_STR_LIST_OPTION(gui_qt_default_theme_name, N_("Theme"),
2006 N_("By changing this option you change the "
2007 "active theme."),
2010
2011 /* It's important to give empty string instead of NULL as as default
2012 * value. For NULL value it would default to assigning first value
2013 * from the tileset list returned by get_tileset_list() as default
2014 * tileset. We don't want default tileset assigned at all here, but
2015 * leave it to tilespec code that can handle tileset priority. */
2016 GEN_STR_LIST_OPTION(default_tileset_square_name, N_("Tileset (Square)"),
2017 N_("Select the tileset used with Square based maps. "
2018 "This may change the currently active tileset, if "
2019 "you are playing on such a map, in which "
2020 "case this is the same as using the -t "
2021 "command-line parameter. "
2022 "Use modpack installer utility to install "
2023 "additional tilesets."),
2026 GEN_STR_LIST_OPTION(default_tileset_hex_name, N_("Tileset (Hex)"),
2027 N_("Select the tileset used with Hex maps. "
2028 "This may change the currently active tileset, if "
2029 "you are playing on such a map, in which "
2030 "case this is the same as using the -t "
2031 "command-line parameter. "
2032 "Use modpack installer utility to install "
2033 "additional tilesets."),
2036 GEN_STR_LIST_OPTION(default_tileset_isohex_name, N_("Tileset (Iso-Hex)"),
2037 N_("Select the tileset used with Iso-Hex maps. "
2038 "This may change the currently active tileset, if "
2039 "you are playing on such a map, in which "
2040 "case this is the same as using the -t "
2041 "command-line parameter."
2042 "Use modpack installer utility to install "
2043 "additional tilesets."),
2046
2047 GEN_BOOL_OPTION(draw_city_outlines, N_("Draw city outlines"),
2048 N_("Setting this option will draw a line at the city "
2049 "workable limit."),
2052 GEN_BOOL_OPTION(draw_city_output, N_("Draw city output"),
2053 N_("Setting this option will draw city output for every "
2054 "citizen."),
2057 GEN_BOOL_OPTION(draw_map_grid, N_("Draw the map grid"),
2058 N_("Setting this option will draw a grid over the map."),
2061 GEN_BOOL_OPTION(draw_full_citybar, N_("Draw the city bar"),
2062 N_("Setting this option will display a 'city bar' "
2063 "containing useful information beneath each city. "
2064 "Disabling this option will display only the city's "
2065 "name and, optionally, production."),
2068 GEN_BOOL_OPTION(draw_city_names, N_("Draw the city names"),
2069 N_("Setting this option will draw the names of the cities "
2070 "on the map."),
2073 GEN_BOOL_OPTION(draw_city_growth, N_("Draw the city growth"),
2074 N_("Setting this option will draw in how many turns the "
2075 "cities will grow or shrink."),
2078 GEN_BOOL_OPTION(draw_city_productions, N_("Draw the city productions"),
2079 N_("Setting this option will draw what the cities are "
2080 "currently building on the map."),
2083 GEN_BOOL_OPTION(draw_city_buycost, N_("Draw the city buy costs"),
2084 N_("Setting this option will draw how much gold is "
2085 "needed to buy the production of the cities."),
2088 GEN_BOOL_OPTION(draw_city_trade_routes, N_("Draw the city trade routes"),
2089 N_("Setting this option will draw trade route lines "
2090 "between cities which have trade routes."),
2093 GEN_BOOL_OPTION(draw_terrain, N_("Draw the terrain"),
2094 N_("Setting this option will draw the terrain."),
2097 GEN_BOOL_OPTION(draw_coastline, N_("Draw the coast line"),
2098 N_("Setting this option will draw a line to separate the "
2099 "land from the ocean."),
2102 GEN_BOOL_OPTION(draw_paths, N_("Draw the paths"),
2103 N_("Setting this option will draw all kind of paths "
2104 "on the map."),
2107 GEN_BOOL_OPTION(draw_irrigation, N_("Draw the irrigation"),
2108 N_("Setting this option will draw the irrigation systems "
2109 "on the map."),
2112 GEN_BOOL_OPTION(draw_mines, N_("Draw the mines"),
2113 N_("Setting this option will draw the mines on the map."),
2116 GEN_BOOL_OPTION(draw_fortress_airbase, N_("Draw the bases"),
2117 N_("Setting this option will draw the bases on the map."),
2120 GEN_BOOL_OPTION(draw_specials, N_("Draw the resources"),
2121 N_("Setting this option will draw the resources on the "
2122 "map."),
2125 GEN_BOOL_OPTION(draw_huts, N_("Draw the huts"),
2126 N_("Setting this option will draw the huts on the "
2127 "map."),
2130 GEN_BOOL_OPTION(draw_pollution, N_("Draw the pollution/nuclear fallout"),
2131 N_("Setting this option will draw pollution and "
2132 "nuclear fallout on the map."),
2135 GEN_BOOL_OPTION(draw_cities, N_("Draw the cities"),
2136 N_("Setting this option will draw the cities on the map."),
2139 GEN_BOOL_OPTION(draw_units, N_("Draw the units"),
2140 N_("Setting this option will draw the units on the map."),
2143 GEN_BOOL_OPTION(solid_color_behind_units,
2144 N_("Solid unit background color"),
2145 N_("Setting this option will cause units on the map "
2146 "view to be drawn with a solid background color "
2147 "instead of the flag backdrop."),
2150 GEN_BOOL_OPTION(draw_unit_shields, N_("Draw shield graphics for units"),
2151 N_("Setting this option will draw a shield icon "
2152 "as the flags on units. If unset, the full flag will "
2153 "be drawn."),
2155 GEN_BOOL_OPTION(draw_unit_stack_size, N_("Draw size of the unit stacks"),
2156 N_("Setting this option will draw a numbers indicating "
2157 "size of the unit stacks. Not all clients support "
2158 "this."),
2160 GEN_BOOL_OPTION(draw_focus_unit, N_("Draw the units in focus"),
2161 N_("Setting this option will cause the currently focused "
2162 "unit(s) to always be drawn, even if units are not "
2163 "otherwise being drawn (for instance if 'Draw the units' "
2164 "is unset)."),
2167 GEN_BOOL_OPTION(draw_fog_of_war, N_("Draw the fog of war"),
2168 N_("Setting this option will draw the fog of war."),
2171 GEN_BOOL_OPTION(draw_borders, N_("Draw the borders"),
2172 N_("Setting this option will draw the national borders."),
2175 GEN_BOOL_OPTION(draw_native, N_("Draw whether tiles are native to "
2176 "selected unit"),
2177 N_("Setting this option will highlight tiles that the "
2178 "currently selected unit cannot enter unaided due to "
2179 "non-native terrain. (If multiple units are selected, "
2180 "only tiles that all of them can enter are indicated.)"),
2183 GEN_BOOL_OPTION(player_dlg_show_dead_players,
2184 N_("Show dead players in Nations report"),
2185 N_("This option controls whether defeated nations are "
2186 "shown on the Nations report page."),
2189 GEN_BOOL_OPTION(sound_bell_at_new_turn, N_("Sound bell at new turn"),
2190 N_("Set this option to have a \"bell\" event be generated "
2191 "at the start of a new turn. You can control the "
2192 "behavior of the \"bell\" event by editing the message "
2193 "options."),
2195 GEN_INT_OPTION(smooth_move_unit_msec,
2196 N_("Unit movement animation time (milliseconds)"),
2197 N_("This option controls how long unit \"animation\" takes "
2198 "when a unit moves on the map view. Set it to 0 to "
2199 "disable animation entirely."),
2200 COC_GRAPHICS, GUI_STUB, 30, 0, 2000, NULL),
2201 GEN_INT_OPTION(smooth_center_slide_msec,
2202 N_("Mapview recentering time (milliseconds)"),
2203 N_("When the map view is recentered, it will slide "
2204 "smoothly over the map to its new position. This "
2205 "option controls how long this slide lasts. Set it to "
2206 "0 to disable mapview sliding entirely."),
2207 COC_GRAPHICS, GUI_STUB, 200, 0, 5000, NULL),
2208 GEN_INT_OPTION(smooth_combat_step_msec,
2209 N_("Combat animation step time (milliseconds)"),
2210 N_("This option controls the speed of combat animation "
2211 "between units on the mapview. Set it to 0 to disable "
2212 "animation entirely."),
2213 COC_GRAPHICS, GUI_STUB, 10, 0, 100, NULL),
2214 GEN_BOOL_OPTION(reqtree_show_icons,
2215 N_("Show icons in the technology tree"),
2216 N_("Setting this option will display icons "
2217 "on the technology tree diagram. Turning "
2218 "this option off makes the technology tree "
2219 "more compact."),
2221 GEN_BOOL_OPTION(reqtree_curved_lines,
2222 N_("Use curved lines in the technology tree"),
2223 N_("Setting this option make the technology tree "
2224 "diagram use curved lines to show technology "
2225 "relations. Turning this option off causes "
2226 "the lines to be drawn straight."),
2229 GEN_COLOR_OPTION(highlight_our_names,
2230 N_("Color to highlight your player/user name"),
2231 N_("If set, your player and user name in the new chat "
2232 "messages will be highlighted using this color as "
2233 "background. If not set, it will just not highlight "
2234 "anything."),
2235 COC_GRAPHICS, GUI_STUB, "#000000", "#FFFF00", NULL),
2236 GEN_BOOL_OPTION(ai_manual_turn_done, N_("Manual Turn Done in AI mode"),
2237 N_("Disable this option if you do not want to "
2238 "press the Turn Done button manually when watching "
2239 "an AI player."),
2241 GEN_BOOL_OPTION(auto_center_on_unit, N_("Auto center on units"),
2242 N_("Set this option to have the active unit centered "
2243 "automatically when the unit focus changes."),
2245 GEN_BOOL_OPTION(auto_center_on_automated, N_("Show automated units"),
2246 N_("Disable this option if you do not want to see "
2247 "automated units autocentered and animated."),
2249 GEN_BOOL_OPTION(auto_center_on_combat, N_("Auto center on combat"),
2250 N_("Set this option to have any combat be centered "
2251 "automatically. Disabling this will speed up the time "
2252 "between turns but may cause you to miss combat "
2253 "entirely."),
2255 GEN_BOOL_OPTION(auto_center_each_turn, N_("Auto center on new turn"),
2256 N_("Set this option to have the client automatically "
2257 "recenter the map on a suitable location at the "
2258 "start of each turn."),
2260 GEN_BOOL_OPTION(wakeup_focus, N_("Focus on awakened units"),
2261 N_("Set this option to have newly awoken units be "
2262 "focused automatically."),
2264 GEN_BOOL_OPTION(keyboardless_goto, N_("Keyboardless goto"),
2265 N_("If this option is set then a goto may be initiated "
2266 "by left-clicking and then holding down the mouse "
2267 "button while dragging the mouse onto a different "
2268 "tile."),
2270 GEN_BOOL_OPTION(goto_into_unknown, N_("Allow goto into the unknown"),
2271 N_("Setting this option will make the game consider "
2272 "moving into unknown tiles. If not, then goto routes "
2273 "will detour around or be blocked by unknown tiles."),
2275 GEN_BOOL_OPTION(center_when_popup_city, N_("Center map when popup city"),
2276 N_("Setting this option makes the mapview center on a "
2277 "city when its city dialog is popped up."),
2279 GEN_BOOL_OPTION(show_previous_turn_messages, N_("Show messages from previous turn"),
2280 N_("Message Window shows messages also from previous turn. "
2281 "This makes sure you don't miss messages received in the end of "
2282 "the turn, just before the window gets cleared."),
2284 GEN_BOOL_OPTION(concise_city_production, N_("Concise city production"),
2285 N_("Set this option to make the city production (as shown "
2286 "in the city dialog) to be more compact."),
2288 GEN_BOOL_OPTION(auto_turn_done, N_("End turn when done moving"),
2289 N_("Setting this option makes your turn end automatically "
2290 "when all your units are done moving."),
2292 GEN_BOOL_OPTION(ask_city_name, N_("Prompt for city names"),
2293 N_("Disabling this option will make the names of newly "
2294 "founded cities be chosen automatically by the server."),
2296 GEN_BOOL_OPTION(popup_new_cities, N_("Pop up city dialog for new cities"),
2297 N_("Setting this option will pop up a newly-founded "
2298 "city's city dialog automatically."),
2300 GEN_BOOL_OPTION(popup_actor_arrival, N_("Pop up caravan and spy actions"),
2301 N_("If this option is enabled, when a unit arrives at "
2302 "a city where it can perform an action like "
2303 "establishing a trade route, helping build a wonder, or "
2304 "establishing an embassy, a window will pop up asking "
2305 "which action should be performed. "
2306 "Disabling this option means you will have to do the "
2307 "action manually by pressing either 'r' (for a trade "
2308 "route), 'b' (for building a wonder) or 'd' (for a "
2309 "spy action) when the unit is in the city."),
2311 GEN_BOOL_OPTION(popup_attack_actions, N_("Pop up attack questions"),
2312 N_("If this option is enabled, when a unit arrives at a "
2313 "target it can attack, a window will pop up asking "
2314 "which action should be performed even if an attack "
2315 "action is legal and no other interesting action are. "
2316 "This allows you to change your mind or to select an "
2317 "uninteresting action."),
2319 GEN_BOOL_OPTION(popup_last_move_to_allied,
2320 /* TODO: Rename option ..._last_... to match _final_ in
2321 * the descriptions.
2322 * Changes options file format, needs migration
2323 * when loading old version. */
2324 N_("Pop up actions when final move to allied tile"),
2325 N_("If this option is enabled the final move in a unit's"
2326 " orders to a tile with allied units or cities it can"
2327 " perform an action to is interpreted as an attempted"
2328 " action. This makes the action selection dialog pop up"
2329 " while the unit is at the adjacent tile."
2330 " This can, in cases where the action requires that"
2331 " the actor unit has moves left, save a turn."
2332 " The down side is that the unit remains adjacent to"
2333 " rather than inside the protection of an allied city"
2334 " or unit stack."),
2336 GEN_BOOL_OPTION(enable_cursor_changes, N_("Enable cursor changing"),
2337 N_("This option controls whether the client should "
2338 "try to change the mouse cursor depending on what "
2339 "is being pointed at, as well as to indicate "
2340 "changes in the client or server state."),
2342 GEN_BOOL_OPTION(separate_unit_selection, N_("Select cities before units"),
2343 N_("If this option is enabled, when both cities and "
2344 "units are present in the selection rectangle, only "
2345 "cities will be selected. See the help on Controls."),
2347 GEN_BOOL_OPTION(unit_selection_clears_orders,
2348 N_("Clear unit orders on selection"),
2349 N_("Enabling this option will cause unit orders to be "
2350 "cleared as soon as one or more units are selected. If "
2351 "this option is disabled, busy units will not stop "
2352 "their current activity when selected. Giving them "
2353 "new orders will clear their current ones; pressing "
2354 "<space> once will clear their orders and leave them "
2355 "selected, and pressing <space> a second time will "
2356 "dismiss them."),
2358 GEN_BOOL_OPTION(voteinfo_bar_use, N_("Enable vote bar"),
2359 N_("If this option is turned on, the vote bar will be "
2360 "displayed to show vote information."),
2362 GEN_BOOL_OPTION(voteinfo_bar_always_show,
2363 N_("Always display the vote bar"),
2364 N_("If this option is turned on, the vote bar will never "
2365 "be hidden, even if there is no running vote."),
2367 GEN_BOOL_OPTION(voteinfo_bar_hide_when_not_player,
2368 N_("Do not show vote bar if not a player"),
2369 N_("If this option is enabled, the client won't show the "
2370 "vote bar if you are not a player."),
2372 GEN_BOOL_OPTION(voteinfo_bar_new_at_front, N_("Set new votes at front"),
2373 N_("If this option is enabled, then new votes will go "
2374 "to the front of the vote list."),
2376 GEN_BOOL_OPTION(autoaccept_tileset_suggestion,
2377 N_("Autoaccept tileset suggestions"),
2378 N_("If this option is enabled, any tileset suggested by "
2379 "the ruleset is automatically used; otherwise you "
2380 "are prompted to change tileset."),
2382
2383 GEN_BOOL_OPTION(sound_enable_effects,
2384 N_("Enable sound effects"),
2385 N_("Play sound effects, assuming there's suitable "
2386 "sound plugin and soundset with the sounds."),
2388 GEN_BOOL_OPTION(sound_enable_game_music,
2389 N_("Enable in-game music"),
2390 N_("Play music during the game, assuming there's suitable "
2391 "sound plugin and musicset with in-game tracks."),
2393 GEN_BOOL_OPTION(sound_enable_menu_music,
2394 N_("Enable menu music"),
2395 N_("Play music while not in actual game, "
2396 "assuming there's suitable "
2397 "sound plugin and musicset with menu music tracks."),
2399 GEN_BOOL_OPTION(silent_when_not_in_focus,
2400 N_("Silent when not in focus"),
2401 N_("Fade all sound out when the client is not in focus. "
2402 "Not all clients support this."),
2404 GEN_INT_OPTION(sound_effects_volume,
2405 N_("Sound volume"),
2406 N_("Volume scale from 0-100"),
2407 COC_SOUND, GUI_STUB, 100,
2408 0, 100,
2410
2411 GEN_BOOL_OPTION(autoaccept_soundset_suggestion,
2412 N_("Autoaccept soundset suggestions"),
2413 N_("If this option is enabled, any soundset suggested by "
2414 "the ruleset is automatically used."),
2416 GEN_BOOL_OPTION(autoaccept_musicset_suggestion,
2417 N_("Autoaccept musicset suggestions"),
2418 N_("If this option is enabled, any musicset suggested by "
2419 "the ruleset is automatically used."),
2421
2423 N_("Background layer"),
2424 N_("The background layer of the overview shows just "
2425 "ocean and land."),
2428 N_("Terrain relief map layer"),
2429 N_("The relief layer shows all terrains on the map."),
2432 N_("Borders layer"),
2433 N_("The borders layer of the overview shows which tiles "
2434 "are owned by each player."),
2437 N_("Borders layer on ocean tiles"),
2438 N_("The borders layer of the overview are drawn on "
2439 "ocean tiles as well (this may look ugly with many "
2440 "islands). This option is only of interest if you "
2441 "have set the option \"Borders layer\" already."),
2444 N_("Units layer"),
2445 N_("Enabling this will draw units on the overview."),
2448 N_("Cities layer"),
2449 N_("Enabling this will draw cities on the overview."),
2452 N_("Overview fog of war"),
2453 N_("Enabling this will show fog of war on the "
2454 "overview."),
2456
2457 /* options for map images */
2458 GEN_STR_LIST_OPTION(mapimg_format,
2459 N_("Image format"),
2460 N_("The image toolkit and file format used for "
2461 "map images."),
2463 NULL, 0),
2464 GEN_INT_OPTION(mapimg_zoom,
2465 N_("Zoom factor for map images"),
2466 N_("The magnification used for map images."),
2468 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_AREA],
2469 N_("Show area within borders"),
2470 N_("If set, the territory of each nation is shown "
2471 "on the saved image."),
2474 N_("Show borders"),
2475 N_("If set, the border of each nation is shown on the "
2476 "saved image."),
2479 N_("Show cities"),
2480 N_("If set, cities are shown on the saved image."),
2483 N_("Show fog of war"),
2484 N_("If set, the extent of fog of war is shown on the "
2485 "saved image."),
2488 N_("Show full terrain"),
2489 N_("If set, terrain relief is shown with different colors "
2490 "in the saved image; otherwise, only land and water are "
2491 "distinguished."),
2493 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_UNITS],
2494 N_("Show units"),
2495 N_("If set, units are shown in the saved image."),
2497 GEN_STR_OPTION(mapimg_filename,
2498 N_("Map image file name"),
2499 N_("The base part of the filename for saved map images. "
2500 "A string identifying the game turn and map options will "
2501 "be appended."),
2503
2504 /* gui-gtk-2.0 client specific options.
2505 * These are still kept just so users can migrate them to later gtk-clients */
2506 GEN_BOOL_OPTION(gui_gtk2_map_scrollbars, NULL, NULL,
2508 GEN_BOOL_OPTION(gui_gtk2_dialogs_on_top, NULL, NULL,
2510 GEN_BOOL_OPTION(gui_gtk2_show_task_icons, NULL, NULL,
2512 GEN_BOOL_OPTION(gui_gtk2_enable_tabs, NULL, NULL,
2514 GEN_BOOL_OPTION(gui_gtk2_better_fog, NULL, NULL,
2517 GEN_BOOL_OPTION(gui_gtk2_show_chat_message_time, NULL, NULL,
2519 GEN_BOOL_OPTION(gui_gtk2_new_messages_go_to_top, NULL, NULL,
2521 GEN_BOOL_OPTION(gui_gtk2_show_message_window_buttons, NULL, NULL,
2523 GEN_BOOL_OPTION(gui_gtk2_metaserver_tab_first, NULL, NULL,
2525 GEN_BOOL_OPTION(gui_gtk2_allied_chat_only, NULL, NULL,
2527 GEN_BOOL_OPTION(gui_gtk2_mouse_over_map_focus, NULL, NULL,
2529 GEN_BOOL_OPTION(gui_gtk2_chatline_autocompletion, NULL, NULL,
2531 GEN_INT_OPTION(gui_gtk2_citydlg_xsize, NULL, NULL,
2534 NULL),
2535 GEN_INT_OPTION(gui_gtk2_citydlg_ysize, NULL, NULL,
2538 NULL),
2539 GEN_ENUM_OPTION(gui_gtk2_popup_tech_help, NULL, NULL,
2543 GEN_FONT_OPTION(gui_gtk2_font_city_label, "city_label",
2544 NULL, NULL,
2546 "Monospace 8", font_changed_callback),
2547 GEN_FONT_OPTION(gui_gtk2_font_notify_label, "notify_label",
2548 NULL, NULL,
2550 "Monospace Bold 9", font_changed_callback),
2551 GEN_FONT_OPTION(gui_gtk2_font_spaceship_label, "spaceship_label",
2552 NULL, NULL,
2554 "Monospace 8", font_changed_callback),
2555 GEN_FONT_OPTION(gui_gtk2_font_help_label, "help_label",
2556 NULL, NULL,
2558 "Sans Bold 10", font_changed_callback),
2559 GEN_FONT_OPTION(gui_gtk2_font_help_link, "help_link",
2560 NULL, NULL,
2562 "Sans 9", font_changed_callback),
2563 GEN_FONT_OPTION(gui_gtk2_font_help_text, "help_text",
2564 NULL, NULL,
2566 "Monospace 8", font_changed_callback),
2567 GEN_FONT_OPTION(gui_gtk2_font_chatline, "chatline",
2568 NULL, NULL,
2570 "Monospace 8", font_changed_callback),
2571 GEN_FONT_OPTION(gui_gtk2_font_beta_label, "beta_label",
2572 NULL, NULL,
2574 "Sans Italic 10", font_changed_callback),
2575 GEN_FONT_OPTION(gui_gtk2_font_small, "small_font",
2576 NULL, NULL,
2578 "Sans 9", NULL),
2579 GEN_FONT_OPTION(gui_gtk2_font_comment_label, "comment_label",
2580 NULL, NULL,
2582 "Sans Italic 9", font_changed_callback),
2583 GEN_FONT_OPTION(gui_gtk2_font_city_names, "city_names",
2584 NULL, NULL,
2586 "Sans Bold 10", NULL),
2587 GEN_FONT_OPTION(gui_gtk2_font_city_productions, "city_productions",
2588 NULL, NULL,
2590 "Serif 10", NULL),
2591 GEN_FONT_OPTION(gui_gtk2_font_reqtree_text, "reqtree_text",
2592 NULL, NULL,
2594 "Serif 10", NULL),
2595
2596 /* gui-gtk-3.0 client specific options.
2597 * These are still kept just so users can migrate them to later gtk-clients */
2598 GEN_BOOL_OPTION(gui_gtk3_fullscreen, NULL, NULL,
2600 GEN_BOOL_OPTION(gui_gtk3_map_scrollbars, N_("Show map scrollbars"),
2601 N_("Disable this option to hide the scrollbars on the "
2602 "map view."),
2604 GEN_BOOL_OPTION(gui_gtk3_dialogs_on_top, NULL, NULL,
2606 GEN_BOOL_OPTION(gui_gtk3_show_task_icons, NULL, NULL,
2608 GEN_BOOL_OPTION(gui_gtk3_enable_tabs, NULL, NULL,
2610 GEN_BOOL_OPTION(gui_gtk3_show_chat_message_time, NULL, NULL,
2612 GEN_BOOL_OPTION(gui_gtk3_new_messages_go_to_top, NULL, NULL,
2614 GEN_BOOL_OPTION(gui_gtk3_show_message_window_buttons, NULL, NULL,
2616 GEN_BOOL_OPTION(gui_gtk3_metaserver_tab_first, NULL, NULL,
2618 GEN_BOOL_OPTION(gui_gtk3_allied_chat_only, NULL, NULL,
2620 GEN_ENUM_OPTION(gui_gtk3_message_chat_location, NULL, NULL,
2624 GEN_BOOL_OPTION(gui_gtk3_small_display_layout, NULL, NULL,
2626 GEN_BOOL_OPTION(gui_gtk3_mouse_over_map_focus, NULL, NULL,
2628 GEN_BOOL_OPTION(gui_gtk3_chatline_autocompletion, NULL, NULL,
2630 GEN_INT_OPTION(gui_gtk3_citydlg_xsize, NULL, NULL,
2633 NULL),
2634 GEN_INT_OPTION(gui_gtk3_citydlg_ysize, NULL, NULL,
2637 NULL),
2638 GEN_ENUM_OPTION(gui_gtk3_popup_tech_help, NULL, NULL,
2642 GEN_INT_OPTION(gui_gtk3_governor_range_min, NULL, NULL,
2645 NULL),
2646 GEN_INT_OPTION(gui_gtk3_governor_range_max, NULL, NULL,
2649 NULL),
2650 GEN_FONT_OPTION(gui_gtk3_font_city_label, "city_label",
2651 NULL, NULL,
2653 "Monospace 8", font_changed_callback),
2654 GEN_FONT_OPTION(gui_gtk3_font_notify_label, "notify_label",
2655 NULL, NULL,
2657 "Monospace Bold 9", font_changed_callback),
2658 GEN_FONT_OPTION(gui_gtk3_font_spaceship_label, "spaceship_label",
2659 NULL, NULL,
2661 "Monospace 8", font_changed_callback),
2662 GEN_FONT_OPTION(gui_gtk3_font_help_label, "help_label",
2663 NULL, NULL,
2665 "Sans Bold 10", font_changed_callback),
2666 GEN_FONT_OPTION(gui_gtk3_font_help_link, "help_link",
2667 NULL, NULL,
2669 "Sans 9", font_changed_callback),
2670 GEN_FONT_OPTION(gui_gtk3_font_help_text, "help_text",
2671 NULL, NULL,
2673 "Monospace 8", font_changed_callback),
2674 GEN_FONT_OPTION(gui_gtk3_font_chatline, "chatline",
2675 NULL, NULL,
2677 "Monospace 8", font_changed_callback),
2678 GEN_FONT_OPTION(gui_gtk3_font_beta_label, "beta_label",
2679 NULL, NULL,
2681 "Sans Italic 10", font_changed_callback),
2682 GEN_FONT_OPTION(gui_gtk3_font_small, "small_font",
2683 NULL, NULL,
2685 "Sans 9", NULL),
2686 GEN_FONT_OPTION(gui_gtk3_font_comment_label, "comment_label",
2687 NULL, NULL,
2689 "Sans Italic 9", font_changed_callback),
2690 GEN_FONT_OPTION(gui_gtk3_font_city_names, "city_names",
2691 NULL, NULL,
2693 "Sans Bold 10", NULL),
2694 GEN_FONT_OPTION(gui_gtk3_font_city_productions, "city_productions",
2695 NULL, NULL,
2697 "Serif 10", NULL),
2698 GEN_FONT_OPTION(gui_gtk3_font_reqtree_text, "reqtree_text",
2699 NULL, NULL,
2701 "Serif 10", NULL),
2702
2703 /* gui-gtk-3.22 client specific options. */
2704 GEN_BOOL_OPTION(gui_gtk3_22_fullscreen, N_("Fullscreen"),
2705 N_("If this option is set the client will use the "
2706 "whole screen area for drawing."),
2708 GEN_BOOL_OPTION(gui_gtk3_22_map_scrollbars, N_("Show map scrollbars"),
2709 N_("Disable this option to hide the scrollbars on the "
2710 "map view."),
2712 GEN_BOOL_OPTION(gui_gtk3_22_dialogs_on_top, N_("Keep dialogs on top"),
2713 N_("If this option is set then dialog windows will always "
2714 "remain in front of the main Freeciv window. "
2715 "Disabling this has no effect in fullscreen mode."),
2717 GEN_BOOL_OPTION(gui_gtk3_22_show_task_icons, N_("Show worklist task icons"),
2718 N_("Disabling this will turn off the unit and building "
2719 "icons in the worklist dialog and the production "
2720 "tab of the city dialog."),
2722 GEN_BOOL_OPTION(gui_gtk3_22_enable_tabs, N_("Enable status report tabs"),
2723 N_("If this option is enabled then report dialogs will "
2724 "be shown as separate tabs rather than in popup "
2725 "dialogs."),
2727 GEN_BOOL_OPTION(gui_gtk3_22_show_chat_message_time,
2728 N_("Show time for each chat message"),
2729 N_("If this option is enabled then all chat messages "
2730 "will be prefixed by a time string of the form "
2731 "[hour:minute:second]."),
2733 GEN_BOOL_OPTION(gui_gtk3_22_new_messages_go_to_top,
2734 N_("New message events go to top of list"),
2735 N_("If this option is enabled, new events in the "
2736 "message window will appear at the top of the list, "
2737 "rather than being appended at the bottom."),
2739 GEN_BOOL_OPTION(gui_gtk3_22_show_message_window_buttons,
2740 N_("Show extra message window buttons"),
2741 N_("If this option is enabled, there will be two "
2742 "buttons displayed in the message window for "
2743 "inspecting a city and going to a location. If this "
2744 "option is disabled, these buttons will not appear "
2745 "(you can still double-click with the left mouse "
2746 "button or right-click on a row to inspect or goto "
2747 "respectively). This option will only take effect "
2748 "once the message window is closed and reopened."),
2750 GEN_BOOL_OPTION(gui_gtk3_22_metaserver_tab_first,
2751 N_("Metaserver tab first in network page"),
2752 N_("If this option is enabled, the metaserver tab will "
2753 "be the first notebook tab in the network page. This "
2754 "option requires a restart in order to take effect."),
2756 GEN_BOOL_OPTION(gui_gtk3_22_allied_chat_only,
2757 N_("Plain chat messages are sent to allies only"),
2758 N_("If this option is enabled, then plain messages "
2759 "typed into the chat entry while the game is "
2760 "running will only be sent to your allies. "
2761 "Otherwise plain messages will be sent as "
2762 "public chat messages. To send a public chat "
2763 "message with this option enabled, prefix the "
2764 "message with a single colon ':'. This option "
2765 "can also be set using a toggle button beside "
2766 "the chat entry (only visible in multiplayer "
2767 "games)."),
2769 GEN_ENUM_OPTION(gui_gtk3_22_message_chat_location,
2770 N_("Messages and Chat reports location"),
2771 /* TRANS: The strings used in the UI for 'Split' etc are
2772 * tagged 'gui_gtk3_22/gtk4/gtk4_message_chat_location' */
2773 N_("Controls where the Messages and Chat reports "
2774 "appear relative to the main view containing the map.\n"
2775 "'Split' allows all three to be seen simultaneously, "
2776 "which is best for multiplayer, but requires a large "
2777 "window to be usable.\n"
2778 "'Separate' puts Messages and Chat in a notebook "
2779 "separate from the main view, so that one of them "
2780 "can always be seen alongside the main view.\n"
2781 "'Merged' makes the Messages and Chat reports into "
2782 "tabs alongside the map and other reports; this "
2783 "allows a larger map view on small screens.\n"
2784 "This option requires a restart in order to take "
2785 "effect."), COC_INTERFACE, GUI_GTK3_22,
2788 GEN_BOOL_OPTION(gui_gtk3_22_small_display_layout,
2789 N_("Arrange widgets for small displays"),
2790 N_("If this option is enabled, widgets in the main "
2791 "window will be arranged so that they take up the "
2792 "least amount of total screen space. Specifically, "
2793 "the left panel containing the overview, player "
2794 "status, and the unit information box will be "
2795 "extended over the entire left side of the window. "
2796 "This option requires a restart in order to take "
2797 "effect."), COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2798 GEN_BOOL_OPTION(gui_gtk3_22_mouse_over_map_focus,
2799 N_("Mouse over the map widget selects it automatically"),
2800 N_("If this option is enabled, then the map will be "
2801 "focused when the mouse hovers over it."),
2803 GEN_BOOL_OPTION(gui_gtk3_22_chatline_autocompletion,
2804 N_("Player or user name autocompletion"),
2805 N_("If this option is turned on, the tabulation key "
2806 "will be used in the chatline to complete the word you "
2807 "are typing with the name of a player or a user."),
2809 GEN_INT_OPTION(gui_gtk3_22_citydlg_xsize,
2810 N_("Width of the city dialog"),
2811 N_("This value is only used if the width of the city "
2812 "dialog is saved."),
2815 NULL),
2816 GEN_INT_OPTION(gui_gtk3_22_citydlg_ysize,
2817 N_("Height of the city dialog"),
2818 N_("This value is only used if the height of the city "
2819 "dialog is saved."),
2822 NULL),
2823 GEN_INT_OPTION(gui_gtk3_22_helpdlg_xsize,
2824 N_("Width of the help dialog"),
2825 NULL,
2828 NULL),
2829 GEN_INT_OPTION(gui_gtk3_22_helpdlg_ysize,
2830 N_("Height of the help dialog"),
2831 NULL,
2834 NULL),
2835 GEN_INT_OPTION(gui_gtk3_22_optionsdlg_xsize,
2836 N_("Width of the options dialog"),
2837 NULL,
2840 NULL),
2841 GEN_INT_OPTION(gui_gtk3_22_optionsdlg_ysize,
2842 N_("Height of the options dialog"),
2843 NULL,
2846 NULL),
2847 GEN_ENUM_OPTION(gui_gtk3_22_popup_tech_help,
2848 N_("Popup tech help when gained"),
2849 N_("Controls if tech help should be opened when "
2850 "new tech has been gained.\n"
2851 "'Ruleset' means that behavior suggested by "
2852 "current ruleset is used."), COC_INTERFACE, GUI_GTK3_22,
2855 GEN_INT_OPTION(gui_gtk3_22_governor_range_min,
2856 N_("Minimum surplus for a governor"),
2857 N_("The lower limit of the range for requesting surpluses "
2858 "from the governor."),
2861 NULL),
2862 GEN_INT_OPTION(gui_gtk3_22_governor_range_max,
2863 N_("Maximum surplus for a governor"),
2864 N_("The higher limit of the range for requesting surpluses "
2865 "from the governor."),
2868 NULL),
2869 GEN_FONT_OPTION(gui_gtk3_22_font_city_label, "city_label",
2870 N_("City Label"),
2871 N_("This font is used to display the city labels on city "
2872 "dialogs."),
2874 "Monospace 8", font_changed_callback),
2875 GEN_FONT_OPTION(gui_gtk3_22_font_notify_label, "notify_label",
2876 N_("Notify Label"),
2877 N_("This font is used to display server reports such "
2878 "as the demographic report or historian publications."),
2880 "Monospace Bold 9", font_changed_callback),
2881 GEN_FONT_OPTION(gui_gtk3_22_font_spaceship_label, "spaceship_label",
2882 N_("Spaceship Label"),
2883 N_("This font is used to display the spaceship widgets."),
2885 "Monospace 8", font_changed_callback),
2886 GEN_FONT_OPTION(gui_gtk3_22_font_help_label, "help_label",
2887 N_("Help Label"),
2888 N_("This font is used to display the help headers in the "
2889 "help window."),
2891 "Sans Bold 10", font_changed_callback),
2892 GEN_FONT_OPTION(gui_gtk3_22_font_help_link, "help_link",
2893 N_("Help Link"),
2894 N_("This font is used to display the help links in the "
2895 "help window."),
2897 "Sans 9", font_changed_callback),
2898 GEN_FONT_OPTION(gui_gtk3_22_font_help_text, "help_text",
2899 N_("Help Text"),
2900 N_("This font is used to display the help body text in "
2901 "the help window."),
2903 "Monospace 8", font_changed_callback),
2904 GEN_FONT_OPTION(gui_gtk3_22_font_chatline, "chatline",
2905 N_("Chatline Area"),
2906 N_("This font is used to display the text in the "
2907 "chatline area."),
2909 "Monospace 8", font_changed_callback),
2910 GEN_FONT_OPTION(gui_gtk3_22_font_beta_label, "beta_label",
2911 N_("Beta Label"),
2912 N_("This font is used to display the beta label."),
2914 "Sans Italic 10", font_changed_callback),
2915 GEN_FONT_OPTION(gui_gtk3_22_font_small, "small_font",
2916 N_("Small Font"),
2917 N_("This font is used for any small font request. For "
2918 "example, it is used for display the building lists "
2919 "in the city dialog, the Economy report or the Units "
2920 "report."),
2922 "Sans 9", font_changed_callback),
2923 GEN_FONT_OPTION(gui_gtk3_22_font_comment_label, "comment_label",
2924 N_("Comment Label"),
2925 N_("This font is used to display comment labels, such as "
2926 "in the governor page of the city dialogs."),
2928 "Sans Italic 9", font_changed_callback),
2929 GEN_FONT_OPTION(gui_gtk3_22_font_city_names, "city_names",
2930 N_("City Names"),
2931 N_("This font is used to the display the city names "
2932 "on the map."),
2934 "Sans Bold 10", NULL),
2935 GEN_FONT_OPTION(gui_gtk3_22_font_city_productions, "city_productions",
2936 N_("City Productions"),
2937 N_("This font is used to display the city production "
2938 "on the map."),
2940 "Serif 10", NULL),
2941 GEN_FONT_OPTION(gui_gtk3_22_font_reqtree_text, "reqtree_text",
2942 N_("Requirement Tree"),
2943 N_("This font is used to the display the requirement tree "
2944 "in the Research report."),
2946 "Serif 10", NULL),
2947
2948 /* gui-gtk-4.0 client specific options. */
2949 GEN_BOOL_OPTION(gui_gtk4_fullscreen, N_("Fullscreen"),
2950 N_("If this option is set the client will use the "
2951 "whole screen area for drawing."),
2953 GEN_BOOL_OPTION(gui_gtk4_map_scrollbars, N_("Show map scrollbars"),
2954 N_("Disable this option to hide the scrollbars on the "
2955 "map view."),
2957 GEN_BOOL_OPTION(gui_gtk4_dialogs_on_top, N_("Keep dialogs on top"),
2958 N_("If this option is set then dialog windows will always "
2959 "remain in front of the main Freeciv window. "
2960 "Disabling this has no effect in fullscreen mode."),
2962 GEN_BOOL_OPTION(gui_gtk4_show_task_icons, N_("Show worklist task icons"),
2963 N_("Disabling this will turn off the unit and building "
2964 "icons in the worklist dialog and the production "
2965 "tab of the city dialog."),
2967 GEN_BOOL_OPTION(gui_gtk4_enable_tabs, N_("Enable status report tabs"),
2968 N_("If this option is enabled then report dialogs will "
2969 "be shown as separate tabs rather than in popup "
2970 "dialogs."),
2972 GEN_BOOL_OPTION(gui_gtk4_show_chat_message_time,
2973 N_("Show time for each chat message"),
2974 N_("If this option is enabled then all chat messages "
2975 "will be prefixed by a time string of the form "
2976 "[hour:minute:second]."),
2978 GEN_BOOL_OPTION(gui_gtk4_new_messages_go_to_top,
2979 N_("New message events go to top of list"),
2980 N_("If this option is enabled, new events in the "
2981 "message window will appear at the top of the list, "
2982 "rather than being appended at the bottom."),
2984 GEN_BOOL_OPTION(gui_gtk4_show_message_window_buttons,
2985 N_("Show extra message window buttons"),
2986 N_("If this option is enabled, there will be two "
2987 "buttons displayed in the message window for "
2988 "inspecting a city and going to a location. If this "
2989 "option is disabled, these buttons will not appear "
2990 "(you can still double-click with the left mouse "
2991 "button or right-click on a row to inspect or goto "
2992 "respectively). This option will only take effect "
2993 "once the message window is closed and reopened."),
2995 GEN_BOOL_OPTION(gui_gtk4_metaserver_tab_first,
2996 N_("Metaserver tab first in network page"),
2997 N_("If this option is enabled, the metaserver tab will "
2998 "be the first notebook tab in the network page. This "
2999 "option requires a restart in order to take effect."),
3001 GEN_BOOL_OPTION(gui_gtk4_allied_chat_only,
3002 N_("Plain chat messages are sent to allies only"),
3003 N_("If this option is enabled, then plain messages "
3004 "typed into the chat entry while the game is "
3005 "running will only be sent to your allies. "
3006 "Otherwise plain messages will be sent as "
3007 "public chat messages. To send a public chat "
3008 "message with this option enabled, prefix the "
3009 "message with a single colon ':'. This option "
3010 "can also be set using a toggle button beside "
3011 "the chat entry (only visible in multiplayer "
3012 "games)."),
3014 GEN_ENUM_OPTION(gui_gtk4_message_chat_location,
3015 N_("Messages and Chat reports location"),
3016 /* TRANS: The strings used in the UI for 'Split' etc are
3017 * tagged 'gui_gtk3_22/gtk4_message_chat_location' */
3018 N_("Controls where the Messages and Chat reports "
3019 "appear relative to the main view containing the map.\n"
3020 "'Split' allows all three to be seen simultaneously, "
3021 "which is best for multiplayer, but requires a large "
3022 "window to be usable.\n"
3023 "'Separate' puts Messages and Chat in a notebook "
3024 "separate from the main view, so that one of them "
3025 "can always be seen alongside the main view.\n"
3026 "'Merged' makes the Messages and Chat reports into "
3027 "tabs alongside the map and other reports; this "
3028 "allows a larger map view on small screens.\n"
3029 "This option requires a restart in order to take "
3030 "effect."), COC_INTERFACE, GUI_GTK4,
3033 GEN_BOOL_OPTION(gui_gtk4_small_display_layout,
3034 N_("Arrange widgets for small displays"),
3035 N_("If this option is enabled, widgets in the main "
3036 "window will be arranged so that they take up the "
3037 "least amount of total screen space. Specifically, "
3038 "the left panel containing the overview, player "
3039 "status, and the unit information box will be "
3040 "extended over the entire left side of the window. "
3041 "This option requires a restart in order to take "
3042 "effect."), COC_INTERFACE, GUI_GTK4, FALSE, NULL),
3043 GEN_BOOL_OPTION(gui_gtk4_mouse_over_map_focus,
3044 N_("Mouse over the map widget selects it automatically"),
3045 N_("If this option is enabled, then the map will be "
3046 "focused when the mouse hovers over it."),
3048 GEN_BOOL_OPTION(gui_gtk4_chatline_autocompletion,
3049 N_("Player or user name autocompletion"),
3050 N_("If this option is turned on, the tabulation key "
3051 "will be used in the chatline to complete the word you "
3052 "are typing with the name of a player or a user."),
3054 GEN_INT_OPTION(gui_gtk4_citydlg_xsize,
3055 N_("Width of the city dialog"),
3056 N_("This value is only used if the width of the city "
3057 "dialog is saved."),
3060 NULL),
3061 GEN_INT_OPTION(gui_gtk4_citydlg_ysize,
3062 N_("Height of the city dialog"),
3063 N_("This value is only used if the height of the city "
3064 "dialog is saved."),
3067 NULL),
3068 GEN_INT_OPTION(gui_gtk4_helpdlg_xsize,
3069 N_("Width of the help dialog"),
3070 N_("This value is only used if the width of the help "
3071 "dialog is saved."),
3074 NULL),
3075 GEN_INT_OPTION(gui_gtk4_helpdlg_ysize,
3076 N_("Height of the help dialog"),
3077 N_("This value is only used if the height of the help "
3078 "dialog is saved."),
3081 NULL),
3082 GEN_INT_OPTION(gui_gtk4_optionsdlg_xsize,
3083 N_("Width of the options dialog"),
3084 NULL,
3087 NULL),
3088 GEN_INT_OPTION(gui_gtk4_optionsdlg_ysize,
3089 N_("Height of the options dialog"),
3090 NULL,
3093 NULL),
3094 GEN_ENUM_OPTION(gui_gtk4_popup_tech_help,
3095 N_("Popup tech help when gained"),
3096 N_("Controls if tech help should be opened when "
3097 "new tech has been gained.\n"
3098 "'Ruleset' means that behavior suggested by "
3099 "current ruleset is used."), COC_INTERFACE, GUI_GTK4,
3102 GEN_INT_OPTION(gui_gtk4_governor_range_min,
3103 N_("Minimum surplus for a governor"),
3104 N_("The lower limit of the range for requesting surpluses "
3105 "from the governor."),
3108 NULL),
3109 GEN_INT_OPTION(gui_gtk4_governor_range_max,
3110 N_("Maximum surplus for a governor"),
3111 N_("The higher limit of the range for requesting surpluses "
3112 "from the governor."),
3115 NULL),
3116 GEN_FONT_OPTION(gui_gtk4_font_city_label, "city_label",
3117 N_("City Label"),
3118 N_("This font is used to display the city labels on city "
3119 "dialogs."),
3121 "Monospace 8", font_changed_callback),
3122 GEN_FONT_OPTION(gui_gtk4_font_notify_label, "notify_label",
3123 N_("Notify Label"),
3124 N_("This font is used to display server reports such "
3125 "as the demographic report or historian publications."),
3127 "Monospace Bold 9", font_changed_callback),
3128 GEN_FONT_OPTION(gui_gtk4_font_spaceship_label, "spaceship_label",
3129 N_("Spaceship Label"),
3130 N_("This font is used to display the spaceship widgets."),
3132 "Monospace 8", font_changed_callback),
3133 GEN_FONT_OPTION(gui_gtk4_font_help_label, "help_label",
3134 N_("Help Label"),
3135 N_("This font is used to display the help headers in the "
3136 "help window."),
3138 "Sans Bold 10", font_changed_callback),
3139 GEN_FONT_OPTION(gui_gtk4_font_help_link, "help_link",
3140 N_("Help Link"),
3141 N_("This font is used to display the help links in the "
3142 "help window."),
3144 "Sans 9", font_changed_callback),
3145 GEN_FONT_OPTION(gui_gtk4_font_help_text, "help_text",
3146 N_("Help Text"),
3147 N_("This font is used to display the help body text in "
3148 "the help window."),
3150 "Monospace 8", font_changed_callback),
3151 GEN_FONT_OPTION(gui_gtk4_font_chatline, "chatline",
3152 N_("Chatline Area"),
3153 N_("This font is used to display the text in the "
3154 "chatline area."),
3156 "Monospace 8", font_changed_callback),
3157 GEN_FONT_OPTION(gui_gtk4_font_beta_label, "beta_label",
3158 N_("Beta Label"),
3159 N_("This font is used to display the beta label."),
3161 "Sans Italic 10", font_changed_callback),
3162 GEN_FONT_OPTION(gui_gtk4_font_small, "small_font",
3163 N_("Small Font"),
3164 N_("This font is used for any small font request. For "
3165 "example, it is used for display the building lists "
3166 "in the city dialog, the Economy report or the Units "
3167 "report."),
3169 "Sans 9", font_changed_callback),
3170 GEN_FONT_OPTION(gui_gtk4_font_comment_label, "comment_label",
3171 N_("Comment Label"),
3172 N_("This font is used to display comment labels, such as "
3173 "in the governor page of the city dialogs."),
3175 "Sans Italic 9", font_changed_callback),
3176 GEN_FONT_OPTION(gui_gtk4_font_city_names, "city_names",
3177 N_("City Names"),
3178 N_("This font is used to the display the city names "
3179 "on the map."),
3181 "Sans Bold 10", NULL),
3182 GEN_FONT_OPTION(gui_gtk4_font_city_productions, "city_productions",
3183 N_("City Productions"),
3184 N_("This font is used to display the city production "
3185 "on the map."),
3187 "Serif 10", NULL),
3188 GEN_FONT_OPTION(gui_gtk4_font_reqtree_text, "reqtree_text",
3189 N_("Requirement Tree"),
3190 N_("This font is used to the display the requirement tree "
3191 "in the Research report."),
3193 "Serif 10", NULL),
3194
3195 /* gui-sdl client specific options.
3196 * These are still kept just so users can migrate them to sdl2-client */
3197 GEN_BOOL_OPTION(gui_sdl_fullscreen, NULL, NULL,
3199 GEN_VIDEO_OPTION(gui_sdl_screen, NULL, NULL,
3200 COC_INTERFACE, GUI_SDL, 640, 480, NULL),
3201 GEN_BOOL_OPTION(gui_sdl_do_cursor_animation, NULL, NULL,
3203 GEN_BOOL_OPTION(gui_sdl_use_color_cursors, NULL, NULL,
3205
3206 /* gui-sdl2 client specific options. */
3207 GEN_BOOL_OPTION(gui_sdl2_fullscreen, N_("Fullscreen"),
3208 N_("If this option is set the client will use the "
3209 "whole screen area for drawing."),
3211 GEN_VIDEO_OPTION(gui_sdl2_screen, N_("Screen resolution"),
3212 N_("This option controls the resolution of the "
3213 "selected screen."),
3214 COC_INTERFACE, GUI_SDL2, 640, 480, NULL),
3215 GEN_BOOL_OPTION(gui_sdl2_swrenderer, N_("Use software rendering"),
3216 N_("Usually hardware rendering is used when possible. "
3217 "With this option set, software rendering is always used."),
3219 GEN_BOOL_OPTION(gui_sdl2_do_cursor_animation, N_("Do cursor animation"),
3220 N_("If this option is disabled, the cursor will "
3221 "always be displayed as static."),
3223 GEN_BOOL_OPTION(gui_sdl2_use_color_cursors, N_("Use color cursors"),
3224 N_("If this option is disabled, the cursor will "
3225 "always be displayed in black and white."),
3227 GEN_FONT_OPTION(gui_sdl2_font_city_names, "FONT_CITY_NAME",
3228 N_("City Names"),
3229 N_("The size of font used to the display the city names "
3230 "on the map."),
3232 "10", font_changed_callback),
3233 GEN_FONT_OPTION(gui_sdl2_font_city_productions, "FONT_CITY_PROD",
3234 N_("City Productions"),
3235 N_("The size of font used to the display the city "
3236 "production names on the map."),
3238 "10", font_changed_callback),
3239 GEN_BOOL_OPTION(gui_sdl2_use_theme_font_size, N_("Use theme defined font size"),
3240 N_("Disable this to override base font size set by theme "
3241 "by the setting below."),
3243 GEN_INT_OPTION(gui_sdl2_font_size, N_("Base Font Size"),
3244 N_("Base Font Size. All the fonts' sizes are defined relative "
3245 "to this. This option has effect only if theme font sizes "
3246 "option is disabled."),
3247 COC_FONT, GUI_SDL2, 10, 6, 50, NULL),
3248
3249 /* gui-sdl3 client specific options. */
3250 GEN_BOOL_OPTION(gui_sdl3_fullscreen, N_("Fullscreen"),
3251 N_("If this option is set the client will use the "
3252 "whole screen area for drawing."),
3254 GEN_VIDEO_OPTION(gui_sdl3_screen, N_("Screen resolution"),
3255 N_("This option controls the resolution of the "
3256 "selected screen."),
3257 COC_INTERFACE, GUI_SDL3, 640, 480, NULL),
3258 GEN_BOOL_OPTION(gui_sdl3_do_cursor_animation, N_("Do cursor animation"),
3259 N_("If this option is disabled, the cursor will "
3260 "always be displayed as static."),
3262 GEN_BOOL_OPTION(gui_sdl3_use_color_cursors, N_("Use color cursors"),
3263 N_("If this option is disabled, the cursor will "
3264 "always be displayed in black and white."),
3266 GEN_FONT_OPTION(gui_sdl3_font_city_names, "FONT_CITY_NAME",
3267 N_("City Names"),
3268 N_("The size of font used to the display the city names "
3269 "on the map."),
3271 "10", font_changed_callback),
3272 GEN_FONT_OPTION(gui_sdl3_font_city_productions, "FONT_CITY_PROD",
3273 N_("City Productions"),
3274 N_("The size of font used to the display the city "
3275 "production names on the map."),
3277 "10", font_changed_callback),
3278 GEN_BOOL_OPTION(gui_sdl3_use_theme_font_size, N_("Use theme defined font size"),
3279 N_("Disable this to override base font size set by theme "
3280 "by the setting below."),
3282 GEN_INT_OPTION(gui_sdl3_font_size, N_("Base Font Size"),
3283 N_("Base Font Size. All the fonts' sizes are defined relative "
3284 "to this. This option has effect only if theme font sizes "
3285 "option is disabled."),
3286 COC_FONT, GUI_SDL3, 10, 6, 50, NULL),
3287
3288 /* gui-qt client specific options. */
3289 GEN_BOOL_OPTION(gui_qt_fullscreen, N_("Fullscreen"),
3290 N_("If this option is set the client will use the "
3291 "whole screen area for drawing."),
3293 GEN_BOOL_OPTION(gui_qt_show_titlebar, N_("Show titlebar"),
3294 N_("If this option is set the client will show a titlebar. "
3295 "If disabled, then no titlebar will be shown, and "
3296 "minimize/maximize/etc buttons will be placed on the "
3297 "menu bar."),
3299 GEN_FONT_OPTION(gui_qt_font_default, "default_font",
3300 N_("Default font"),
3301 N_("This is default font"),
3303 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3304 GEN_FONT_OPTION(gui_qt_font_notify_label, "notify_label",
3305 N_("Notify Label"),
3306 N_("This font is used to display server reports such "
3307 "as the demographic report or historian publications."),
3309 "Monospace,9,-1,5,75,0,0,0,0,0", font_changed_callback),
3310 GEN_FONT_OPTION(gui_qt_font_help_label, "help_label",
3311 N_("Help Label"),
3312 N_("This font is used to display the help labels in the "
3313 "help window."),
3315 "Sans Serif,9,-1,5,50,0,0,0,0,0", font_changed_callback),
3316 GEN_FONT_OPTION(gui_qt_font_help_text, "help_text",
3317 N_("Help Text"),
3318 N_("This font is used to display the help body text in "
3319 "the help window."),
3321 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3322 GEN_FONT_OPTION(gui_qt_font_chatline, "chatline",
3323 N_("Chatline Area"),
3324 N_("This font is used to display the text in the "
3325 "chatline area."),
3327 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3328 GEN_FONT_OPTION(gui_qt_font_city_names, "city_names",
3329 N_("City Names"),
3330 N_("This font is used to the display the city names "
3331 "on the map."),
3333 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3334 GEN_FONT_OPTION(gui_qt_font_city_productions, "city_productions",
3335 N_("City Productions"),
3336 N_("This font is used to display the city production "
3337 "on the map."),
3339 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3340 GEN_FONT_OPTION(gui_qt_font_reqtree_text, "reqtree_text",
3341 N_("Requirement Tree"),
3342 N_("This font is used to the display the requirement tree "
3343 "in the Research report."),
3345 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3346 GEN_BOOL_OPTION(gui_qt_show_preview, N_("Show savegame information"),
3347 N_("If this option is set the client will show "
3348 "information and map preview of current savegame."),
3350 GEN_BOOL_OPTION(gui_qt_sidebar_left, N_("Sidebar position"),
3351 N_("If this option is set, the sidebar will be to the left "
3352 "of the map, otherwise to the right."),
3354 GEN_STR_OPTION(gui_qt_wakeup_text,
3355 N_("Wake up sequence"),
3356 N_("String which will trigger sound in pregame page; "
3357 "%1 stands for username."),
3358 COC_INTERFACE, GUI_QT, "Wake up %1", NULL, 0),
3359 GEN_BOOL_OPTION(gui_qt_svgflags, N_("SVG flags features"),
3361 N_("Enable svgflags features, such as bigger flags "
3362 "on the diplomacy dialog. Change to this comes "
3363 "to an effect on next client start."),
3364#else /* FREECIV_SVG_FLAGS */
3365 N_("Enable svgflags features, such as bigger flags "
3366 "on the diplomacy dialog. This has no effect on "
3367 "this freeciv build, as the svg support has not "
3368 "been built in."),
3369#endif /* FREECIV_SVG_FLAGS */
3371};
3373
3374/* Iteration loop, including invalid options for the current gui type. */
3375#define client_options_iterate_all(poption) \
3376{ \
3377 const struct client_option *const poption##_max = \
3378 client_options + client_options_num; \
3379 struct client_option *client_##poption = client_options; \
3380 struct option *poption; \
3381 for (; client_##poption < poption##_max; client_##poption++) { \
3382 poption = OPTION(client_##poption);
3383
3384#define client_options_iterate_all_end \
3385 } \
3386}
3387
3388
3389/************************************************************************/
3392static struct client_option *
3394{
3395 const struct client_option *const max =
3397 const enum gui_type our_type = get_gui_type();
3398
3399 while (poption < max
3400 && poption->specific != GUI_STUB
3401 && poption->specific != our_type) {
3402 poption++;
3403 }
3404
3405 return (poption < max ? poption : NULL);
3406}
3407
3408/************************************************************************/
3412{
3413 if (0 > id || id > client_options_num) {
3414 return NULL;
3415 }
3416 return OPTION(client_options + id);
3417}
3418
3419/************************************************************************/
3426
3427/************************************************************************/
3431{
3432 return COC_MAX;
3433}
3434
3435/************************************************************************/
3438static const char *client_optset_category_name(int category)
3439{
3440 switch (category) {
3441 case COC_GRAPHICS:
3442 return _("Graphics");
3443 case COC_OVERVIEW:
3444 /* TRANS: Options section for overview map (mini-map) */
3445 return Q_("?map:Overview");
3446 case COC_SOUND:
3447 return _("Sound");
3448 case COC_INTERFACE:
3449 return _("Interface");
3450 case COC_MAPIMG:
3451 return _("Map Image");
3452 case COC_NETWORK:
3453 return _("Network");
3454 case COC_FONT:
3455 return _("Font");
3456 case COC_MAX:
3457 break;
3458 }
3459
3460 log_error("%s: invalid option category number %d.",
3461 __FUNCTION__, category);
3462 return NULL;
3463}
3464
3465/************************************************************************/
3468static int client_option_number(const struct option *poption)
3469{
3471}
3472
3473/************************************************************************/
3476static const char *client_option_name(const struct option *poption)
3477{
3478 return CLIENT_OPTION(poption)->name;
3479}
3480
3481/************************************************************************/
3484static const char *client_option_description(const struct option *poption)
3485{
3486 return _(CLIENT_OPTION(poption)->description);
3487}
3488
3489/************************************************************************/
3492static const char *client_option_help_text(const struct option *poption)
3493{
3494 return _(CLIENT_OPTION(poption)->help_text);
3495}
3496
3497/************************************************************************/
3500static int client_option_category(const struct option *poption)
3501{
3502 return CLIENT_OPTION(poption)->category;
3503}
3504
3505/************************************************************************/
3509{
3510 return TRUE;
3511}
3512
3513/************************************************************************/
3516static struct option *client_option_next(const struct option *poption)
3517{
3519}
3520
3521/************************************************************************/
3524static bool client_option_bool_get(const struct option *poption)
3525{
3526 return *(CLIENT_OPTION(poption)->boolean.pvalue);
3527}
3528
3529/************************************************************************/
3532static bool client_option_bool_def(const struct option *poption)
3533{
3534 return CLIENT_OPTION(poption)->boolean.def;
3535}
3536
3537/************************************************************************/
3541static bool client_option_bool_set(struct option *poption, bool val)
3542{
3544
3545 if (*pcoption->boolean.pvalue == val) {
3546 return FALSE;
3547 }
3548
3549 *pcoption->boolean.pvalue = val;
3550 return TRUE;
3551}
3552
3553/************************************************************************/
3556static int client_option_int_get(const struct option *poption)
3557{
3558 return *(CLIENT_OPTION(poption)->integer.pvalue);
3559}
3560
3561/************************************************************************/
3564static int client_option_int_def(const struct option *poption)
3565{
3566 return CLIENT_OPTION(poption)->integer.def;
3567}
3568
3569/************************************************************************/
3572static int client_option_int_min(const struct option *poption)
3573{
3574 return CLIENT_OPTION(poption)->integer.min;
3575}
3576
3577/************************************************************************/
3580static int client_option_int_max(const struct option *poption)
3581{
3582 return CLIENT_OPTION(poption)->integer.max;
3583}
3584
3585/************************************************************************/
3589static bool client_option_int_set(struct option *poption, int val)
3590{
3592
3594 || val > pcoption->integer.max
3595 || *pcoption->integer.pvalue == val) {
3596 return FALSE;
3597 }
3598
3599 *pcoption->integer.pvalue = val;
3600 return TRUE;
3601}
3602
3603/************************************************************************/
3606static const char *client_option_str_get(const struct option *poption)
3607{
3608 return CLIENT_OPTION(poption)->string.pvalue;
3609}
3610
3611/************************************************************************/
3614static const char *client_option_str_def(const struct option *poption)
3615{
3616 return CLIENT_OPTION(poption)->string.def;
3617}
3618
3619/************************************************************************/
3623static const struct strvec *
3625{
3626 return (CLIENT_OPTION(poption)->string.val_accessor
3627 ? CLIENT_OPTION(poption)->string.val_accessor(poption) : NULL);
3628}
3629
3630/************************************************************************/
3634static bool client_option_str_set(struct option *poption, const char *str)
3635{
3637
3638 if (strlen(str) >= pcoption->string.size
3639 || 0 == strcmp(pcoption->string.pvalue, str)) {
3640 return FALSE;
3641 }
3642
3643 fc_strlcpy(pcoption->string.pvalue, str, pcoption->string.size);
3644 return TRUE;
3645}
3646
3647/************************************************************************/
3650static int client_option_enum_get(const struct option *poption)
3651{
3652 return *(CLIENT_OPTION(poption)->enumerator.pvalue);
3653}
3654
3655/************************************************************************/
3658static int client_option_enum_def(const struct option *poption)
3659{
3660 return CLIENT_OPTION(poption)->enumerator.def;
3661}
3662
3663/************************************************************************/
3667static const struct strvec *
3669{
3670 return CLIENT_OPTION(poption)->enumerator.pretty_names;
3671}
3672
3673/************************************************************************/
3677static bool client_option_enum_set(struct option *poption, int val)
3678{
3680
3681 if (*pcoption->enumerator.pvalue == val
3682 || 0 > val
3683 || val >= strvec_size(pcoption->enumerator.support_names)) {
3684 return FALSE;
3685 }
3686
3687 *pcoption->enumerator.pvalue = val;
3688 return TRUE;
3689}
3690
3691/************************************************************************/
3697 int val)
3698{
3699 const struct strvec *names = CLIENT_OPTION(data)->enumerator.support_names;
3700
3701 return (0 <= val && val < strvec_size(names)
3702 ? strvec_get(names, val) : NULL);
3703}
3704
3705#if 0 /* There's no bitwise options currently */
3706/************************************************************************/
3709static unsigned client_option_bitwise_get(const struct option *poption)
3710{
3711 return *(CLIENT_OPTION(poption)->bitwise.pvalue);
3712}
3713
3714/************************************************************************/
3717static unsigned client_option_bitwise_def(const struct option *poption)
3718{
3719 return CLIENT_OPTION(poption)->bitwise.def;
3720}
3721
3722/************************************************************************/
3726static const struct strvec *
3728{
3729 return CLIENT_OPTION(poption)->bitwise.pretty_names;
3730}
3731
3732/************************************************************************/
3736static bool client_option_bitwise_set(struct option *poption, unsigned val)
3737{
3739
3740 if (*pcoption->bitwise.pvalue == val) {
3741 return FALSE;
3742 }
3743
3744 *pcoption->bitwise.pvalue = val;
3745 return TRUE;
3746}
3747#endif /* 0 */
3748
3749/************************************************************************/
3755 int val)
3756{
3757 const struct strvec *names = CLIENT_OPTION(data)->bitwise.support_names;
3758
3759 return (0 <= val && val < strvec_size(names)
3760 ? strvec_get(names, val) : NULL);
3761}
3762
3763/************************************************************************/
3766static const char *client_option_font_get(const struct option *poption)
3767{
3768 return CLIENT_OPTION(poption)->font.pvalue;
3769}
3770
3771/************************************************************************/
3774static const char *client_option_font_def(const struct option *poption)
3775{
3776 return CLIENT_OPTION(poption)->font.def;
3777}
3778
3779/************************************************************************/
3782static const char *client_option_font_target(const struct option *poption)
3783{
3784 return CLIENT_OPTION(poption)->font.target;
3785}
3786
3787/************************************************************************/
3791static bool client_option_font_set(struct option *poption, const char *font)
3792{
3794
3795 if (strlen(font) >= pcoption->font.size
3796 || 0 == strcmp(pcoption->font.pvalue, font)) {
3797 return FALSE;
3798 }
3799
3800 fc_strlcpy(pcoption->font.pvalue, font, pcoption->font.size);
3801 return TRUE;
3802}
3803
3804/************************************************************************/
3808{
3809 return *CLIENT_OPTION(poption)->color.pvalue;
3810}
3811
3812/************************************************************************/
3816{
3817 return CLIENT_OPTION(poption)->color.def;
3818}
3819
3820/************************************************************************/
3825 struct ft_color color)
3826{
3827 struct ft_color *pcolor = CLIENT_OPTION(poption)->color.pvalue;
3828 bool changed = FALSE;
3829
3830#define color_set(color_tgt, color) \
3831 if (NULL == color_tgt) { \
3832 if (NULL != color) { \
3833 color_tgt = fc_strdup(color); \
3834 changed = TRUE; \
3835 } \
3836 } else { \
3837 if (NULL == color) { \
3838 free((void *) color_tgt); \
3839 color_tgt = NULL; \
3840 changed = TRUE; \
3841 } else if (0 != strcmp(color_tgt, color)) { \
3842 free((void *) color_tgt); \
3843 color_tgt = fc_strdup(color); \
3844 changed = TRUE; \
3845 } \
3846 }
3847
3848 color_set(pcolor->foreground, color.foreground);
3849 color_set(pcolor->background, color.background);
3850
3851#undef color_set
3852
3853 return changed;
3854}
3855
3856/************************************************************************/
3859static struct video_mode
3861{
3862 return *CLIENT_OPTION(poption)->video_mode.pvalue;
3863}
3864
3865/************************************************************************/
3868static struct video_mode
3873
3874/************************************************************************/
3879 struct video_mode mode)
3880{
3882
3883 if (0 == memcmp(&mode, pcoption->video_mode.pvalue,
3884 sizeof(struct video_mode))) {
3885 return FALSE;
3886 }
3887
3888 *pcoption->video_mode.pvalue = mode;
3889 return TRUE;
3890}
3891
3892/************************************************************************/
3896 struct section_file *sf)
3897{
3900
3901 switch (option_type(poption)) {
3902 case OT_BOOLEAN:
3903 {
3904 bool value;
3905 const char *pname = option_name(poption);
3906 const char *old_paths = "draw_roads_rails";
3907
3908 if (!strcmp("draw_paths", pname)) {
3909 /* Renamed in freeciv-3.2 */
3910 if (secfile_lookup_bool(sf, &value, "client.draw_paths")
3911 && option_bool_set(poption, value)) {
3912 return TRUE;
3913 }
3914
3915 /* Try by old name. */
3916 pname = old_paths;
3917 }
3918
3919 return (secfile_lookup_bool(sf, &value, "client.%s",
3920 pname)
3921 && option_bool_set(poption, value));
3922 }
3923 case OT_INTEGER:
3924 {
3925 int value;
3926
3927 return (secfile_lookup_int(sf, &value, "client.%s",
3929 && option_int_set(poption, value));
3930 }
3931 case OT_STRING:
3932 {
3933 const char *string;
3934
3935 return ((string = secfile_lookup_str(sf, "client.%s",
3937 && option_str_set(poption, string));
3938 }
3939 case OT_ENUM:
3940 {
3941 int value;
3942
3943 return (secfile_lookup_enum_data(sf, &value, FALSE,
3945 poption, "client.%s",
3947 && option_enum_set_int(poption, value));
3948 }
3949 case OT_BITWISE:
3950 {
3951 int value;
3952
3953 return (secfile_lookup_enum_data(sf, &value, TRUE,
3955 poption, "client.%s",
3957 && option_bitwise_set(poption, value));
3958 }
3959 case OT_FONT:
3960 {
3961 const char *string;
3962
3963 return ((string = secfile_lookup_str(sf, "client.%s",
3965 && option_font_set(poption, string));
3966 }
3967 case OT_COLOR:
3968 {
3969 struct ft_color color;
3970
3971 return ((color.foreground =
3972 secfile_lookup_str(sf, "client.%s.foreground",
3974 && (color.background =
3975 secfile_lookup_str(sf, "client.%s.background",
3978 }
3979 case OT_VIDEO_MODE:
3980 {
3981 struct video_mode mode;
3982
3983 return (secfile_lookup_int(sf, &mode.width, "client.%s.width",
3985 && secfile_lookup_int(sf, &mode.height, "client.%s.height",
3987 && option_video_mode_set(poption, mode));
3988 }
3989 }
3990 return FALSE;
3991}
3992
3993/************************************************************************/
3997 struct section_file *sf)
3998{
4000 fc_assert_ret(NULL != sf);
4001
4002 switch (option_type(poption)) {
4003 case OT_BOOLEAN:
4005 "client.%s", option_name(poption));
4006 break;
4007 case OT_INTEGER:
4009 "client.%s", option_name(poption));
4010 break;
4011 case OT_STRING:
4013 "client.%s", option_name(poption));
4014 break;
4015 case OT_ENUM:
4018 "client.%s", option_name(poption));
4019 break;
4020 case OT_BITWISE:
4023 "client.%s", option_name(poption));
4024 break;
4025 case OT_FONT:
4027 "client.%s", option_name(poption));
4028 break;
4029 case OT_COLOR:
4030 {
4032
4033 secfile_insert_str(sf, color.foreground, "client.%s.foreground",
4035 secfile_insert_str(sf, color.background, "client.%s.background",
4037 }
4038 break;
4039 case OT_VIDEO_MODE:
4040 {
4042
4043 secfile_insert_int(sf, mode.width, "client.%s.width",
4045 secfile_insert_int(sf, mode.height, "client.%s.height",
4047 }
4048 break;
4049 }
4050}
4051
4052
4053/****************************************************************************
4054 Server options variables.
4055****************************************************************************/
4058
4060static int server_options_num = 0;
4061
4062
4063/****************************************************************************
4064 Server option set.
4065****************************************************************************/
4066static struct option *server_optset_option_by_number(int id);
4067static struct option *server_optset_option_first(void);
4068static int server_optset_category_number(void);
4069static const char *server_optset_category_name(int category);
4070
4073 .option_first = server_optset_option_first,
4074 .category_number = server_optset_category_number,
4075 .category_name = server_optset_category_name
4076};
4078
4079
4080/****************************************************************************
4081 Virtuals tables for the client options.
4082****************************************************************************/
4083static int server_option_number(const struct option *poption);
4084static const char *server_option_name(const struct option *poption);
4085static const char *server_option_description(const struct option *poption);
4086static const char *server_option_help_text(const struct option *poption);
4087static int server_option_category(const struct option *poption);
4088static bool server_option_is_changeable(const struct option *poption);
4089static struct option *server_option_next(const struct option *poption);
4090
4091static const struct option_common_vtable server_option_common_vtable = {
4092 .number = server_option_number,
4093 .name = server_option_name,
4094 .description = server_option_description,
4095 .help_text = server_option_help_text,
4096 .category = server_option_category,
4097 .is_changeable = server_option_is_changeable,
4098 .next = server_option_next
4099};
4100
4101static bool server_option_bool_get(const struct option *poption);
4102static bool server_option_bool_def(const struct option *poption);
4103static bool server_option_bool_set(struct option *poption, bool val);
4104
4105static const struct option_bool_vtable server_option_bool_vtable = {
4109};
4110
4111static int server_option_int_get(const struct option *poption);
4112static int server_option_int_def(const struct option *poption);
4113static int server_option_int_min(const struct option *poption);
4114static int server_option_int_max(const struct option *poption);
4115static bool server_option_int_set(struct option *poption, int val);
4116
4117static const struct option_int_vtable server_option_int_vtable = {
4118 .get = server_option_int_get,
4119 .def = server_option_int_def,
4120 .minimum = server_option_int_min,
4121 .maximum = server_option_int_max,
4123};
4124
4125static const char *server_option_str_get(const struct option *poption);
4126static const char *server_option_str_def(const struct option *poption);
4127static const struct strvec *
4129static bool server_option_str_set(struct option *poption, const char *str);
4130
4131static const struct option_str_vtable server_option_str_vtable = {
4132 .get = server_option_str_get,
4133 .def = server_option_str_def,
4134 .values = server_option_str_values,
4136};
4137
4138static int server_option_enum_get(const struct option *poption);
4139static int server_option_enum_def(const struct option *poption);
4140static const struct strvec *
4142static bool server_option_enum_set(struct option *poption, int val);
4143
4144static const struct option_enum_vtable server_option_enum_vtable = {
4147 .values = server_option_enum_pretty,
4149 .cmp = strcmp
4150};
4151
4152static unsigned server_option_bitwise_get(const struct option *poption);
4153static unsigned server_option_bitwise_def(const struct option *poption);
4154static const struct strvec *
4156static bool server_option_bitwise_set(struct option *poption, unsigned val);
4157
4158static const struct option_bitwise_vtable server_option_bitwise_vtable = {
4163};
4164
4165/****************************************************************************
4166 Derived class server option, inheriting from base class option.
4167****************************************************************************/
4169 struct option base_option; /* Base structure, must be the first! */
4170
4171 char *name; /* Short name - used as an identifier */
4172 char *description; /* One-line description */
4173 char *help_text; /* Paragraph-length help text */
4174 unsigned char category;
4179
4180 union {
4181 /* OT_BOOLEAN type option. */
4182 struct {
4183 bool value;
4184 bool def;
4185 } boolean;
4186 /* OT_INTEGER type option. */
4187 struct {
4189 int def, min, max;
4190 } integer;
4191 /* OT_STRING type option. */
4192 struct {
4193 char *value;
4194 char *def;
4195 } string;
4196 /* OT_ENUM type option. */
4197 struct {
4198 int value;
4199 int def;
4201 struct strvec *pretty_names; /* untranslated */
4202 } enumerator;
4203 /* OT_BITWISE type option. */
4204 struct {
4205 unsigned value;
4206 unsigned def;
4207 struct strvec *support_names;
4208 struct strvec *pretty_names; /* untranslated */
4209 } bitwise;
4210 };
4211};
4212
4213#define SERVER_OPTION(poption) ((struct server_option *) (poption))
4214
4215static void desired_settable_option_send(struct option *poption);
4216
4217
4218/************************************************************************/
4228
4229/************************************************************************/
4233{
4234 option_gui_remove(&(poption->base_option));
4235
4236 switch (poption->base_option.type) {
4237 case OT_STRING:
4238 if (NULL != poption->string.value) {
4239 FC_FREE(poption->string.value);
4240 }
4241 if (NULL != poption->string.def) {
4242 FC_FREE(poption->string.def);
4243 }
4244 break;
4245
4246 case OT_ENUM:
4247 if (NULL != poption->enumerator.support_names) {
4248 strvec_destroy(poption->enumerator.support_names);
4249 poption->enumerator.support_names = NULL;
4250 }
4251 if (NULL != poption->enumerator.pretty_names) {
4252 strvec_destroy(poption->enumerator.pretty_names);
4253 poption->enumerator.pretty_names = NULL;
4254 }
4255 break;
4256
4257 case OT_BITWISE:
4258 if (NULL != poption->bitwise.support_names) {
4259 strvec_destroy(poption->bitwise.support_names);
4260 poption->bitwise.support_names = NULL;
4261 }
4262 if (NULL != poption->bitwise.pretty_names) {
4263 strvec_destroy(poption->bitwise.pretty_names);
4264 poption->bitwise.pretty_names = NULL;
4265 }
4266 break;
4267
4268 case OT_BOOLEAN:
4269 case OT_INTEGER:
4270 case OT_FONT:
4271 case OT_COLOR:
4272 case OT_VIDEO_MODE:
4273 break;
4274 }
4275
4276 if (NULL != poption->name) {
4277 FC_FREE(poption->name);
4278 }
4279 if (NULL != poption->description) {
4280 FC_FREE(poption->description);
4281 }
4282 if (NULL != poption->help_text) {
4283 FC_FREE(poption->help_text);
4284 }
4285}
4286
4287/************************************************************************/
4291{
4292 int i;
4293
4294 /* Don't keep this dialog open. */
4296
4297 /* Free the options themselves. */
4298 if (NULL != server_options) {
4299 for (i = 0; i < server_options_num; i++) {
4301 }
4304 }
4305
4306 /* Free the categories. */
4308 for (i = 0; i < server_options_categories_num; i++) {
4311 }
4312 }
4315 }
4316}
4317
4318/************************************************************************/
4322 (const struct packet_server_setting_control *packet)
4323{
4324 int i;
4325
4326 /* This packet should be received only once. */
4331
4332 /* Allocate server option categories. */
4333 if (0 < packet->categories_num) {
4337 sizeof(*server_options_categories));
4338
4339 for (i = 0; i < server_options_categories_num; i++) {
4340 /* NB: Translate now. */
4342 }
4343 }
4344
4345 /* Allocate server options. */
4346 if (0 < packet->settings_num) {
4349 }
4350}
4351
4352/************************************************************************/
4356 (const struct packet_server_setting_const *packet)
4357{
4360
4362
4363 fc_assert(NULL == psoption->name);
4364 psoption->name = fc_strdup(packet->name);
4365 fc_assert(NULL == psoption->description);
4366 /* NB: Translate now. */
4367 psoption->description = fc_strdup(_(packet->short_help));
4368 fc_assert(NULL == psoption->help_text);
4369 /* NB: Translate now. */
4370 psoption->help_text = fc_strdup(_(packet->extra_help));
4371 psoption->category = packet->category;
4372}
4373
4374/****************************************************************************
4375 Common part of handle_server_setting_*() functions. See below.
4376****************************************************************************/
4377#define handle_server_setting_common(psoption, packet) \
4378 psoption->is_changeable = packet->is_changeable; \
4379 psoption->setdef = packet->setdef; \
4380 if (psoption->is_visible != packet->is_visible) { \
4381 if (psoption->is_visible) { \
4382 need_gui_remove = TRUE; \
4383 } else if (packet->is_visible) { \
4384 need_gui_add = TRUE; \
4385 } \
4386 psoption->is_visible = packet->is_visible; \
4387 } \
4388 \
4389 /* Keep this list of conditions in sync with one in \
4390 resend_desired_settable_options() */ \
4391 if (!psoption->desired_sent \
4392 && psoption->is_visible \
4393 && psoption->is_changeable \
4394 && gui_options.send_desired_settings \
4395 && is_server_running() \
4396 && packet->initial_setting) { \
4397 /* Only send our private settings if we are running \
4398 * on a forked local server, i.e. started by the \
4399 * client with the "Start New Game" button. \
4400 * Do now override settings that are already saved to savegame \
4401 * and now loaded. */ \
4402 desired_settable_option_send(OPTION(poption)); \
4403 dsend_packet_sync_serial(&client.conn, ++sync_serial); \
4404 psoption->desired_sent = TRUE; \
4405 } \
4406 \
4407 /* Update the GUI. */ \
4408 if (need_gui_remove) { \
4409 option_gui_remove(poption); \
4410 } else if (need_gui_add) { \
4411 option_gui_add(poption); \
4412 } else { \
4413 option_gui_update(poption); \
4415
4416/************************************************************************/
4420 (const struct packet_server_setting_bool *packet)
4421{
4424 bool need_gui_remove = FALSE;
4425 bool need_gui_add = FALSE;
4426
4428
4429 if (NULL == poption->common_vtable) {
4430 /* Not initialized yet. */
4431 poption->poptset = server_optset;
4432 poption->common_vtable = &server_option_common_vtable;
4433 poption->type = OT_BOOLEAN;
4434 poption->bool_vtable = &server_option_bool_vtable;
4435 }
4437 "Server setting \"%s\" (nb %d) has type %s (%d), "
4438 "expected %s (%d)",
4440 option_type_name(poption->type), poption->type,
4442
4443 if (packet->is_visible) {
4444 psoption->boolean.value = packet->val;
4445 psoption->boolean.def = packet->default_val;
4446 }
4447
4450
4451/************************************************************************/
4455 (const struct packet_server_setting_int *packet)
4456{
4459 bool need_gui_remove = FALSE;
4460 bool need_gui_add = FALSE;
4461
4463
4464 if (NULL == poption->common_vtable) {
4465 /* Not initialized yet. */
4466 poption->poptset = server_optset;
4467 poption->common_vtable = &server_option_common_vtable;
4468 poption->type = OT_INTEGER;
4469 poption->int_vtable = &server_option_int_vtable;
4470 }
4472 "Server setting \"%s\" (nb %d) has type %s (%d), "
4473 "expected %s (%d)",
4475 option_type_name(poption->type), poption->type,
4477
4478 if (packet->is_visible) {
4479 psoption->integer.value = packet->val;
4480 psoption->integer.def = packet->default_val;
4481 psoption->integer.min = packet->min_val;
4482 psoption->integer.max = packet->max_val;
4483 }
4484
4487
4488/************************************************************************/
4492 (const struct packet_server_setting_str *packet)
4493{
4496 bool need_gui_remove = FALSE;
4497 bool need_gui_add = FALSE;
4498
4500
4501 if (NULL == poption->common_vtable) {
4502 /* Not initialized yet. */
4503 poption->poptset = server_optset;
4504 poption->common_vtable = &server_option_common_vtable;
4505 poption->type = OT_STRING;
4506 poption->str_vtable = &server_option_str_vtable;
4507 }
4509 "Server setting \"%s\" (nb %d) has type %s (%d), "
4510 "expected %s (%d)",
4512 option_type_name(poption->type), poption->type,
4514
4515 if (packet->is_visible) {
4516 if (NULL == psoption->string.value) {
4517 psoption->string.value = fc_strdup(packet->val);
4518 } else if (0 != strcmp(packet->val, psoption->string.value)) {
4519 free(psoption->string.value);
4520 psoption->string.value = fc_strdup(packet->val);
4521 }
4522 if (NULL == psoption->string.def) {
4523 psoption->string.def = fc_strdup(packet->default_val);
4524 } else if (0 != strcmp(packet->default_val, psoption->string.def)) {
4525 free(psoption->string.def);
4526 psoption->string.def = fc_strdup(packet->default_val);
4527 }
4528 }
4529
4532
4533/************************************************************************/
4537 (const struct packet_server_setting_enum *packet)
4538{
4541 bool need_gui_remove = FALSE;
4542 bool need_gui_add = FALSE;
4543
4545
4546 if (NULL == poption->common_vtable) {
4547 /* Not initialized yet. */
4548 poption->poptset = server_optset;
4549 poption->common_vtable = &server_option_common_vtable;
4550 poption->type = OT_ENUM;
4551 poption->enum_vtable = &server_option_enum_vtable;
4552 }
4554 "Server setting \"%s\" (nb %d) has type %s (%d), "
4555 "expected %s (%d)",
4557 option_type_name(poption->type), poption->type,
4559
4560 if (packet->is_visible) {
4561 int i;
4562
4563 psoption->enumerator.value = packet->val;
4564 psoption->enumerator.def = packet->default_val;
4565
4566 if (NULL == psoption->enumerator.support_names) {
4567 /* First time we get this packet. */
4568 fc_assert(NULL == psoption->enumerator.pretty_names);
4569 psoption->enumerator.support_names = strvec_new();
4570 strvec_reserve(psoption->enumerator.support_names, packet->values_num);
4571 psoption->enumerator.pretty_names = strvec_new();
4572 strvec_reserve(psoption->enumerator.pretty_names, packet->values_num);
4573 for (i = 0; i < packet->values_num; i++) {
4574 strvec_set(psoption->enumerator.support_names, i,
4575 packet->support_names[i]);
4576 /* Store untranslated string from server. */
4577 strvec_set(psoption->enumerator.pretty_names, i,
4578 packet->pretty_names[i]);
4579 }
4580 } else if (strvec_size(psoption->enumerator.support_names)
4581 != packet->values_num) {
4582 fc_assert(strvec_size(psoption->enumerator.support_names)
4583 == strvec_size(psoption->enumerator.pretty_names));
4584 /* The number of values have changed, we need to reset the list
4585 * of possible values. */
4586 strvec_reserve(psoption->enumerator.support_names, packet->values_num);
4587 strvec_reserve(psoption->enumerator.pretty_names, packet->values_num);
4588 for (i = 0; i < packet->values_num; i++) {
4589 strvec_set(psoption->enumerator.support_names, i,
4590 packet->support_names[i]);
4591 /* Store untranslated string from server. */
4592 strvec_set(psoption->enumerator.pretty_names, i,
4593 packet->pretty_names[i]);
4594 }
4597 } else {
4598 /* Check if a value changed, then we need to reset the list
4599 * of possible values. */
4600 const char *str;
4601
4602 for (i = 0; i < packet->values_num; i++) {
4603 str = strvec_get(psoption->enumerator.pretty_names, i);
4604 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4605 /* Store untranslated string from server. */
4606 strvec_set(psoption->enumerator.pretty_names, i,
4607 packet->pretty_names[i]);
4610 }
4611 /* Support names are not visible, we don't need to check if it
4612 * has changed. */
4613 strvec_set(psoption->enumerator.support_names, i,
4614 packet->support_names[i]);
4615 }
4616 }
4617 }
4618
4621
4622/************************************************************************/
4626 (const struct packet_server_setting_bitwise *packet)
4627{
4630 bool need_gui_remove = FALSE;
4631 bool need_gui_add = FALSE;
4632
4634
4635 if (NULL == poption->common_vtable) {
4636 /* Not initialized yet. */
4637 poption->poptset = server_optset;
4638 poption->common_vtable = &server_option_common_vtable;
4639 poption->type = OT_BITWISE;
4640 poption->bitwise_vtable = &server_option_bitwise_vtable;
4641 }
4643 "Server setting \"%s\" (nb %d) has type %s (%d), "
4644 "expected %s (%d)",
4646 option_type_name(poption->type), poption->type,
4648
4649 if (packet->is_visible) {
4650 int i;
4651
4652 psoption->bitwise.value = packet->val;
4653 psoption->bitwise.def = packet->default_val;
4654
4655 if (NULL == psoption->bitwise.support_names) {
4656 /* First time we get this packet. */
4657 fc_assert(NULL == psoption->bitwise.pretty_names);
4658 psoption->bitwise.support_names = strvec_new();
4659 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4660 psoption->bitwise.pretty_names = strvec_new();
4661 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4662 for (i = 0; i < packet->bits_num; i++) {
4663 strvec_set(psoption->bitwise.support_names, i,
4664 packet->support_names[i]);
4665 /* Store untranslated string from server. */
4666 strvec_set(psoption->bitwise.pretty_names, i,
4667 packet->pretty_names[i]);
4668 }
4669 } else if (strvec_size(psoption->bitwise.support_names)
4670 != packet->bits_num) {
4671 fc_assert(strvec_size(psoption->bitwise.support_names)
4672 == strvec_size(psoption->bitwise.pretty_names));
4673 /* The number of values have changed, we need to reset the list
4674 * of possible values. */
4675 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4676 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4677 for (i = 0; i < packet->bits_num; i++) {
4678 strvec_set(psoption->bitwise.support_names, i,
4679 packet->support_names[i]);
4680 /* Store untranslated string from server. */
4681 strvec_set(psoption->bitwise.pretty_names, i,
4682 packet->pretty_names[i]);
4683 }
4686 } else {
4687 /* Check if a value changed, then we need to reset the list
4688 * of possible values. */
4689 const char *str;
4690
4691 for (i = 0; i < packet->bits_num; i++) {
4692 str = strvec_get(psoption->bitwise.pretty_names, i);
4693 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4694 /* Store untranslated string from server. */
4695 strvec_set(psoption->bitwise.pretty_names, i,
4696 packet->pretty_names[i]);
4699 }
4700 /* Support names are not visible, we don't need to check if it
4701 * has changed. */
4702 strvec_set(psoption->bitwise.support_names, i,
4703 packet->support_names[i]);
4704 }
4705 }
4706 }
4707
4709}
4711/************************************************************************/
4714static struct server_option *
4716{
4717 if (server_options != NULL) {
4718 const struct server_option *const max =
4720
4722 poption++;
4723 }
4724
4725 return (poption < max ? poption : NULL);
4726 }
4727
4728 return NULL;
4730
4731/************************************************************************/
4735{
4736 if (0 > id || id > server_options_num) {
4737 return NULL;
4738 }
4739 return OPTION(server_options + id);
4741
4742/************************************************************************/
4746{
4749
4750/************************************************************************/
4754{
4757
4758/************************************************************************/
4761const char *server_optset_category_name(int category)
4762{
4763 if (0 > category || category >= server_options_categories_num) {
4764 return NULL;
4765 }
4766
4767 return server_options_categories[category];
4769
4770/************************************************************************/
4773static int server_option_number(const struct option *poption)
4774{
4777
4778/************************************************************************/
4781static const char *server_option_name(const struct option *poption)
4782{
4783 return SERVER_OPTION(poption)->name;
4785
4786/************************************************************************/
4789static const char *server_option_description(const struct option *poption)
4790{
4791 return SERVER_OPTION(poption)->description;
4793
4794/************************************************************************/
4797static const char *server_option_help_text(const struct option *poption)
4798{
4799 return SERVER_OPTION(poption)->help_text;
4801
4802/************************************************************************/
4805static int server_option_category(const struct option *poption)
4806{
4807 return SERVER_OPTION(poption)->category;
4809
4810/************************************************************************/
4813static bool server_option_is_changeable(const struct option *poption)
4814{
4815 return SERVER_OPTION(poption)->is_changeable;
4817
4818/************************************************************************/
4821static struct option *server_option_next(const struct option *poption)
4822{
4825
4826/************************************************************************/
4829static bool server_option_bool_get(const struct option *poption)
4830{
4831 return SERVER_OPTION(poption)->boolean.value;
4833
4834/************************************************************************/
4837static bool server_option_bool_def(const struct option *poption)
4838{
4839 return SERVER_OPTION(poption)->boolean.def;
4840}
4842/************************************************************************/
4846static bool server_option_bool_set(struct option *poption, bool val)
4847{
4849
4850 if (psoption->boolean.value == val) {
4851 return FALSE;
4852 }
4853
4854 send_chat_printf("/set %s %s", psoption->name,
4855 val ? "enabled" : "disabled");
4857
4858 return TRUE;
4860
4861/************************************************************************/
4864static int server_option_int_get(const struct option *poption)
4865{
4866 return SERVER_OPTION(poption)->integer.value;
4868
4869/************************************************************************/
4872static int server_option_int_def(const struct option *poption)
4873{
4874 return SERVER_OPTION(poption)->integer.def;
4876
4877/************************************************************************/
4880static int server_option_int_min(const struct option *poption)
4881{
4882 return SERVER_OPTION(poption)->integer.min;
4884
4885/************************************************************************/
4888static int server_option_int_max(const struct option *poption)
4889{
4890 return SERVER_OPTION(poption)->integer.max;
4891}
4893/************************************************************************/
4897static bool server_option_int_set(struct option *poption, int val)
4898{
4900
4902 || val > psoption->integer.max
4903 || psoption->integer.value == val) {
4904 return FALSE;
4905 }
4906
4907 send_chat_printf("/set %s %d", psoption->name, val);
4909
4910 return TRUE;
4912
4913/************************************************************************/
4916static const char *server_option_str_get(const struct option *poption)
4917{
4918 return SERVER_OPTION(poption)->string.value;
4920
4921/************************************************************************/
4924static const char *server_option_str_def(const struct option *poption)
4925{
4926 return SERVER_OPTION(poption)->string.def;
4927}
4928
4929/************************************************************************/
4933static const struct strvec *
4935{
4936 return NULL;
4937}
4939/************************************************************************/
4943static bool server_option_str_set(struct option *poption, const char *str)
4944{
4946
4947 if (0 == strcmp(psoption->string.value, str)) {
4948 return FALSE;
4949 }
4950
4951 send_chat_printf("/set %s \"%s\"", psoption->name, str);
4953
4954 return TRUE;
4956
4957/************************************************************************/
4960static int server_option_enum_get(const struct option *poption)
4961{
4962 return SERVER_OPTION(poption)->enumerator.value;
4964
4965/************************************************************************/
4968static int server_option_enum_def(const struct option *poption)
4969{
4970 return SERVER_OPTION(poption)->enumerator.def;
4971}
4972
4973/************************************************************************/
4977static const struct strvec *
4979{
4980 return SERVER_OPTION(poption)->enumerator.pretty_names;
4981}
4983/************************************************************************/
4987static bool server_option_enum_set(struct option *poption, int val)
4988{
4990 const char *name;
4991
4992 if (val == psoption->enumerator.value
4993 || !(name = strvec_get(psoption->enumerator.support_names, val))) {
4994 return FALSE;
4995 }
4996
4997 send_chat_printf("/set %s \"%s\"", psoption->name, name);
4999
5000 return TRUE;
5001}
5003/************************************************************************/
5007static void server_option_enum_support_name(const struct option *poption,
5008 const char **pvalue,
5009 const char **pdefault)
5010{
5012 const struct strvec *values = psoption->enumerator.support_names;
5013
5014 if (NULL != pvalue) {
5015 *pvalue = strvec_get(values, psoption->enumerator.value);
5016 }
5017 if (NULL != pdefault) {
5018 *pdefault = strvec_get(values, psoption->enumerator.def);
5019 }
5021
5022/************************************************************************/
5025static unsigned server_option_bitwise_get(const struct option *poption)
5026{
5027 return SERVER_OPTION(poption)->bitwise.value;
5029
5030/************************************************************************/
5033static unsigned server_option_bitwise_def(const struct option *poption)
5034{
5035 return SERVER_OPTION(poption)->bitwise.def;
5036}
5037
5038/************************************************************************/
5042static const struct strvec *
5044{
5045 return SERVER_OPTION(poption)->bitwise.pretty_names;
5047
5048/************************************************************************/
5051static void server_option_bitwise_support_base(const struct strvec *values,
5052 unsigned val,
5053 char *buf, size_t buf_len)
5054{
5055 int bit;
5056
5057 buf[0] = '\0';
5058 for (bit = 0; bit < strvec_size(values); bit++) {
5059 if ((1 << bit) & val) {
5060 if ('\0' != buf[0]) {
5061 fc_strlcat(buf, "|", buf_len);
5062 }
5063 fc_strlcat(buf, strvec_get(values, bit), buf_len);
5064 }
5065 }
5066}
5068/************************************************************************/
5072static bool server_option_bitwise_set(struct option *poption, unsigned val)
5073{
5075 char name[MAX_LEN_MSG];
5076
5077 if (val == psoption->bitwise.value) {
5078 return FALSE;
5079 }
5080
5081 server_option_bitwise_support_base(psoption->bitwise.support_names, val,
5082 name, sizeof(name));
5083 send_chat_printf("/set %s \"%s\"", psoption->name, name);
5085
5086 return TRUE;
5087}
5089/************************************************************************/
5093static void server_option_bitwise_support_name(const struct option *poption,
5094 char *val_buf, size_t val_len,
5095 char *def_buf, size_t def_len)
5096{
5098 const struct strvec *values = psoption->bitwise.support_names;
5099
5100 if (NULL != val_buf && 0 < val_len) {
5101 server_option_bitwise_support_base(values, psoption->bitwise.value,
5102 val_buf, val_len);
5103 }
5104 if (NULL != def_buf && 0 < def_len) {
5105 server_option_bitwise_support_base(values, psoption->bitwise.def,
5106 def_buf, def_len);
5107 }
5109
5110
5114
5116/************************************************************************/
5120static void message_options_init(void)
5121{
5122 int none[] = {
5128 };
5129 int out_only[] = {
5132 };
5133 int all[] = {
5135 };
5136 int i;
5137
5138 for (i = 0; i <= event_type_max(); i++) {
5139 /* Include possible undefined values. */
5141 }
5142 for (i = 0; i < ARRAY_SIZE(none); i++) {
5143 messages_where[none[i]] = 0;
5144 }
5145 for (i = 0; i < ARRAY_SIZE(out_only); i++) {
5147 }
5148 for (i = 0; i < ARRAY_SIZE(all); i++) {
5150 }
5151
5152 events_init();
5154
5155/************************************************************************/
5158static void message_options_free(void)
5159{
5160 events_free();
5161}
5163/************************************************************************/
5167static void message_options_load(struct section_file *file,
5168 const char *prefix)
5169{
5170 enum event_type event;
5171 int i, num_events;
5172 const char *p;
5173
5174 if (!secfile_lookup_int(file, &num_events, "messages.count")) {
5175 /* version < 2.2 */
5176 /* Order of the events in 2.1. */
5177 const enum event_type old_events[] = {
5206 };
5207 const size_t old_events_num = ARRAY_SIZE(old_events);
5208
5209 for (i = 0; i < old_events_num; i++) {
5212 "%s.message_where_%02d", prefix, i);
5213 }
5214 return;
5215 }
5216
5217 for (i = 0; i < num_events; i++) {
5218 p = secfile_lookup_str(file, "messages.event%d.name", i);
5219 if (NULL == p) {
5220 log_error("Corruption in file %s: %s",
5221 secfile_name(file), secfile_error());
5222 continue;
5223 }
5224 /* Compatibility: Before 3.0 E_UNIT_WIN_DEF was called E_UNIT_WIN. */
5225 if (!fc_strcasecmp("E_UNIT_WIN", p)) {
5226 log_deprecation(_("Deprecated event type E_UNIT_WIN in client options."));
5227 p = "E_UNIT_WIN_DEF";
5228 }
5229 event = event_type_by_name(p, strcmp);
5230 if (!event_type_is_valid(event)) {
5231 log_error("Event not supported: %s", p);
5232 continue;
5233 }
5234
5236 "messages.event%d.where", i)) {
5237 log_error("Corruption in file %s: %s",
5238 secfile_name(file), secfile_error());
5239 }
5240 }
5241}
5243/************************************************************************/
5247static void message_options_save(struct section_file *file,
5248 const char *prefix)
5249{
5250 enum event_type event;
5251 int i = 0;
5252
5253 for (event = event_type_begin(); event != event_type_end();
5254 event = event_type_next(event)) {
5256 "messages.event%d.name", i);
5258 "messages.event%d.where", i);
5259 i++;
5260 }
5261
5262 secfile_insert_int(file, i, "messages.count");
5264
5265/************************************************************************/
5268static void load_cma_preset(struct section_file *file, int i)
5269{
5270 struct cm_parameter parameter;
5271 const char *name =
5272 secfile_lookup_str_default(file, "preset",
5273 "cma.preset%d.name", i);
5274
5275 /* Init correct default values even for the fields that are not
5276 * loaded below. */
5277 cm_init_parameter(&parameter);
5278
5280 parameter.minimal_surplus[o] =
5281 secfile_lookup_int_default(file, 0, "cma.preset%d.minsurp%d", i, o);
5282 parameter.factor[o] =
5283 secfile_lookup_int_default(file, 0, "cma.preset%d.factor%d", i, o);
5285 parameter.require_happy =
5286 secfile_lookup_bool_default(file, FALSE, "cma.preset%d.reqhappy", i);
5287 parameter.happy_factor =
5288 secfile_lookup_int_default(file, 0, "cma.preset%d.happyfactor", i);
5289 parameter.allow_disorder = FALSE;
5290 parameter.allow_specialists = TRUE;
5291
5292 cmafec_preset_add(name, &parameter);
5294
5295/************************************************************************/
5298static void save_cma_preset(struct section_file *file, int i)
5299{
5300 const struct cm_parameter *const pparam = cmafec_preset_get_parameter(i);
5302
5303 secfile_insert_str(file, name, "cma.preset%d.name", i);
5304
5306 secfile_insert_int(file, pparam->minimal_surplus[o],
5307 "cma.preset%d.minsurp%d", i, o);
5308 secfile_insert_int(file, pparam->factor[o],
5309 "cma.preset%d.factor%d", i, o);
5311 secfile_insert_bool(file, pparam->require_happy,
5312 "cma.preset%d.reqhappy", i);
5313 secfile_insert_int(file, pparam->happy_factor,
5314 "cma.preset%d.happyfactor", i);
5316
5317/************************************************************************/
5320static void save_cma_presets(struct section_file *file)
5321{
5322 int i;
5323
5325 _("If you add a preset by hand,"
5326 " also update \"number_of_presets\""),
5327 "cma.number_of_presets");
5328 for (i = 0; i < cmafec_preset_num(); i++) {
5331}
5332
5333/* RC file name. */
5334#define MID_OPTION_FILE_NAME ".freeciv-client-rc-%d.%d"
5335#define NEW_OPTION_FILE_NAME "freeciv-client-rc-%d.%d"
5337/* The first version the new option name appeared (2.6). */
5338#define FIRST_MAJOR_NEW_OPTION_FILE_NAME 2
5339#define FIRST_MINOR_NEW_OPTION_FILE_NAME 6
5340/* The first version the mid option name appeared (2.2). */
5341#define FIRST_MAJOR_MID_OPTION_FILE_NAME 2
5342#define FIRST_MINOR_MID_OPTION_FILE_NAME 2
5343/* The first version the new boolean values appeared (2.3). */
5344#define FIRST_MAJOR_NEW_BOOLEAN 2
5345#define FIRST_MINOR_NEW_BOOLEAN 3
5346
5347/************************************************************************/
5354static const char *get_current_option_file_name(void)
5355{
5356 static char name_buffer[256];
5357 const char *name;
5358
5359 name = getenv("FREECIV_OPT");
5360
5361 if (name) {
5363 } else {
5364#ifdef OPTION_FILE_NAME
5366#else
5368 if (!name) {
5369 log_error(_("Cannot find freeciv storage directory"));
5370 return NULL;
5371 }
5375#endif /* OPTION_FILE_NAME */
5376 }
5377 log_verbose("settings file is %s", name_buffer);
5378 return name_buffer;
5379}
5380
5381/************************************************************************/
5389static const char *get_last_option_file_name(bool *allow_digital_boolean)
5390{
5391 static char name_buffer[256];
5392 const char *name;
5393 static int last_minors[] = {
5394 0, /* There was no 0.x releases */
5395 14, /* 1.14 */
5396 6 /* 2.6 */
5397 };
5398
5399#if MINOR_VERSION >= 90
5401#else
5403#endif
5404
5405 *allow_digital_boolean = FALSE;
5406 name = getenv("FREECIV_OPT");
5407 if (name) {
5409 } else {
5410#ifdef OPTION_FILE_NAME
5412#else
5413 int major, minor;
5414 struct stat buf;
5415
5417 if (name == NULL) {
5418 log_error(_("Cannot find freeciv storage directory"));
5419
5420 return NULL;
5421 }
5422
5428 : minor >= 0); minor--) {
5431 if (0 == fc_stat(name_buffer, &buf)) {
5434 log_normal(_("Didn't find '%s' option file, "
5435 "loading from '%s' instead."),
5437 name_buffer + strlen(name) + 1);
5438 }
5439
5440 return name_buffer;
5441 }
5442 }
5443 minor = last_minors[major - 1];
5444 }
5445
5446 /* Older versions had options file in user home directory */
5447 name = user_home_dir();
5448 if (name == NULL) {
5449 log_error(_("Cannot find your home directory"));
5450
5451 return NULL;
5452 }
5453
5454 /* Minor having max value of FIRST_MINOR_NEW_OPTION_FILE_NAME
5455 * works since MID versioning scheme was used within major version 2
5456 * only (2.2 - 2.6) so the last minor is bigger than any earlier minor. */
5460 minor--) {
5463 if (0 == fc_stat(name_buffer, &buf)) {
5464 log_normal(_("Didn't find '%s' option file, "
5465 "loading from '%s' instead."),
5467 name_buffer + strlen(name) + 1);
5468
5470 *allow_digital_boolean = TRUE;
5471 }
5472 return name_buffer;
5473 }
5474 }
5475
5476 return NULL;
5477#endif /* OPTION_FILE_NAME */
5478 }
5479 log_verbose("settings file is %s", name_buffer);
5480
5481 return name_buffer;
5482}
5483#undef MID_OPTION_FILE_NAME
5484#undef NEW_OPTION_FILE_NAME
5485#undef FIRST_MAJOR_NEW_OPTION_FILE_NAME
5486#undef FIRST_MINOR_NEW_OPTION_FILE_NAME
5487#undef FIRST_MAJOR_MID_OPTION_FILE_NAME
5488#undef FIRST_MINOR_MID_OPTION_FILE_NAME
5489#undef FIRST_MINOR_NEW_BOOLEAN
5492/****************************************************************************
5493 Desired settable options.
5494****************************************************************************/
5495#define SPECHASH_TAG settable_options
5496#define SPECHASH_ASTR_KEY_TYPE
5497#define SPECHASH_ASTR_DATA_TYPE
5498#include "spechash.h"
5499#define settable_options_hash_iterate(hash, name, value) \
5500 TYPED_HASH_ITERATE(const char *, const char *, hash, name, value)
5501#define settable_options_hash_iterate_end HASH_ITERATE_END
5502
5504
5505/************************************************************************/
5508static void settable_options_load(struct section_file *sf)
5509{
5510 char buf[64];
5511 const struct section *psection;
5512 const struct entry_list *entries;
5513 const char *string;
5514 bool bval;
5515 int ival;
5516
5518
5520
5521 psection = secfile_section_by_name(sf, "server");
5522 if (NULL == psection) {
5523 /* Does not exist! */
5524 return;
5525 }
5526
5527 entries = section_entries(psection);
5529 string = NULL;
5530 switch (entry_type_get(pentry)) {
5531 case ENTRY_BOOL:
5532 if (entry_bool_get(pentry, &bval)) {
5533 fc_strlcpy(buf, bval ? "enabled" : "disabled", sizeof(buf));
5534 string = buf;
5535 }
5536 break;
5537
5538 case ENTRY_INT:
5539 if (entry_int_get(pentry, &ival)) {
5540 fc_snprintf(buf, sizeof(buf), "%d", ival);
5541 string = buf;
5542 }
5543 break;
5544
5545 case ENTRY_STR:
5546 (void) entry_str_get(pentry, &string);
5547 break;
5548
5549 case ENTRY_FLOAT:
5551 /* Not supported yet */
5552 break;
5553 case ENTRY_LONG_COMMENT:
5555 break;
5556 case ENTRY_ILLEGAL:
5558 break;
5559 }
5560
5561 if (NULL == string) {
5562 log_error("Entry type variant of \"%s.%s\" is not supported.",
5563 section_name(psection), entry_name(pentry));
5564 continue;
5565 }
5566
5568 string);
5571
5572/************************************************************************/
5575static void settable_options_save(struct section_file *sf)
5576{
5578
5580 if (!fc_strcasecmp(name, "gameseed") || !fc_strcasecmp(name, "mapseed")) {
5581 /* Do not save mapseed or gameseed. */
5582 continue;
5583 }
5584 if (!fc_strcasecmp(name, "topology")) {
5585 /* client_start_server() sets topology based on tileset. Don't store
5586 * its choice. The tileset is already stored. Storing topology leads
5587 * to all sort of breakage:
5588 * - it breaks ruleset default topology.
5589 * - it interacts badly with tileset ruleset change, ruleset tileset
5590 * change and topology tileset change.
5591 * - its value is probably based on what tileset was loaded when
5592 * client_start_server() decided to set topology, not on player
5593 * choice.
5594 */
5595 continue;
5596 }
5597 secfile_insert_str(sf, value, "server.%s", name);
5599}
5601/************************************************************************/
5606{
5607 char val_buf[1024], def_buf[1024];
5608 const char *value, *def_val;
5609
5611
5614
5615 if (srv->setdef != SETDEF_CHANGED) {
5616 /* Some level default - do not store */
5619 } else {
5620 value = NULL;
5621 def_val = NULL;
5622 switch (option_type(poption)) {
5623 case OT_BOOLEAN:
5624 fc_strlcpy(val_buf, option_bool_get(poption) ? "enabled" : "disabled",
5625 sizeof(val_buf));
5626 value = val_buf;
5627 fc_strlcpy(def_buf, option_bool_def(poption) ? "enabled" : "disabled",
5628 sizeof(def_buf));
5629 def_val = def_buf;
5630 break;
5631 case OT_INTEGER:
5633 value = val_buf;
5635 def_val = def_buf;
5636 break;
5637 case OT_STRING:
5640 break;
5641 case OT_ENUM:
5643 break;
5644 case OT_BITWISE:
5646 def_buf, sizeof(def_buf));
5647 value = val_buf;
5648 def_val = def_buf;
5649 break;
5650 case OT_FONT:
5651 case OT_COLOR:
5652 case OT_VIDEO_MODE:
5653 break;
5654 }
5655
5656 if (NULL == value || NULL == def_val) {
5657 log_error("Option type %s (%d) not supported for '%s'.",
5660 continue;
5661 }
5662
5665 }
5667}
5669/************************************************************************/
5674 const char *op_value,
5675 bool allow_replace)
5676{
5678
5679 if (allow_replace) {
5681 } else {
5683 }
5684}
5686/************************************************************************/
5690static bool settable_option_upgrade_value(const struct option *poption,
5691 int old_value,
5692 char *buf, size_t buf_len)
5693{
5694 const char *name = option_name(poption);
5695
5696#define SETTING_CASE(ARG_name, ...) \
5697 if (0 == strcmp(ARG_name, name)) { \
5698 static const char *values[] = { __VA_ARGS__ }; \
5699 if (0 <= old_value && old_value < ARRAY_SIZE(values) \
5700 && NULL != values[old_value]) { \
5701 fc_strlcpy(buf, values[old_value], buf_len); \
5702 return TRUE; \
5703 } else { \
5704 return FALSE; \
5705 } \
5706 }
5707
5708 SETTING_CASE("topology", "", "WRAPX", "WRAPY", "WRAPX|WRAPY", "ISO",
5709 "WRAPX|ISO", "WRAPY|ISO", "WRAPX|WRAPY|ISO", "HEX",
5710 "WRAPX|HEX", "WRAPY|HEX", "WRAPX|WRAPY|HEX", "ISO|HEX",
5711 "WRAPX|ISO|HEX", "WRAPY|ISO|HEX", "WRAPX|WRAPY|ISO|HEX");
5712 SETTING_CASE("generator", NULL, "RANDOM", "FRACTAL", "ISLAND");
5713 SETTING_CASE("startpos", "DEFAULT", "SINGLE", "2or3", "ALL", "VARIABLE");
5714 SETTING_CASE("borders", "DISABLED", "ENABLED", "SEE_INSIDE", "EXPAND");
5715 SETTING_CASE("diplomacy", "ALL", "HUMAN", "AI", "TEAM", "DISABLED");
5716 SETTING_CASE("citynames", "NO_RESTRICTIONS", "PLAYER_UNIQUE",
5717 "GLOBAL_UNIQUE", "NO_STEALING");
5718 SETTING_CASE("barbarians", "DISABLED", "HUTS_ONLY", "NORMAL", "FREQUENT",
5719 "HORDES");
5720 SETTING_CASE("phasemode", "ALL", "PLAYER", "TEAM");
5721 SETTING_CASE("compresstype", "PLAIN", "LIBZ", "BZIP2");
5722
5723#undef SETTING_CASE
5724 return FALSE;
5726
5727/************************************************************************/
5730static void desired_settable_option_send(struct option *poption)
5731{
5732 char *desired;
5733 int value;
5734
5736
5739 /* No change explicitly desired. */
5740 return;
5741 }
5742
5743 switch (option_type(poption)) {
5744 case OT_BOOLEAN:
5745 if ((0 == fc_strcasecmp("enabled", desired)
5746 || (str_to_int(desired, &value) && 1 == value))
5747 && !option_bool_get(poption)) {
5748 send_chat_printf("/set %s enabled", option_name(poption));
5749 } else if ((0 == fc_strcasecmp("disabled", desired)
5750 || (str_to_int(desired, &value) && 0 == value))
5752 send_chat_printf("/set %s disabled", option_name(poption));
5753 }
5754 return;
5755 case OT_INTEGER:
5757 send_chat_printf("/set %s %d", option_name(poption), value);
5758 }
5759 return;
5760 case OT_STRING:
5761 if (0 != strcmp(desired, option_str_get(poption))) {
5762 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5763 }
5764 return;
5765 case OT_ENUM:
5766 {
5767 char desired_buf[256];
5768 const char *value_str;
5769
5770 /* Handle old values. */
5771 if (str_to_int(desired, &value)
5773 sizeof(desired_buf))) {
5775 }
5776
5778 if (0 != strcmp(desired, value_str)) {
5779 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5780 }
5781 }
5782 return;
5783 case OT_BITWISE:
5784 {
5785 char desired_buf[256], value_buf[256];
5786
5787 /* Handle old values. */
5788 if (str_to_int(desired, &value)
5790 sizeof(desired_buf))) {
5792 }
5793
5795 sizeof(value_buf), NULL, 0);
5796 if (0 != strcmp(desired, value_buf)) {
5797 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5798 }
5799 }
5800 return;
5801 case OT_FONT:
5802 case OT_COLOR:
5803 case OT_VIDEO_MODE:
5804 break;
5805 }
5806
5807 log_error("Option type %s (%d) not supported for '%s'.",
5810}
5812/************************************************************************/
5817{
5820 (void) value; /* Silence compiler warning about unused variable */
5822
5823 if (poption != NULL) {
5825
5826 /* We only sent the option if it has been sent already in the past.
5827 * Otherwise we leave it for that "initial" sending functionality
5828 * to send it. That has the benefit that the initial send (can) check
5829 * that server is not currently using value from the savegame that
5830 * we should not override */
5831 if (psoption->desired_sent) {
5832 /* Keep this list of conditions in sync with one in
5833 * handle_server_setting_common()
5834 * For lacking initial_setting check here, see comment above about
5835 * checking psoption->desired_sent. */
5836 if (psoption->is_visible
5837 && psoption->is_changeable) {
5840 }
5841 }
5842 }
5844 }
5845}
5846
5847
5848/****************************************************************************
5849 City and player report dialog options.
5850****************************************************************************/
5851#define SPECHASH_TAG dialog_options
5852#define SPECHASH_ASTR_KEY_TYPE
5853#define SPECHASH_IDATA_TYPE bool
5854#define SPECHASH_UDATA_TO_IDATA FC_INT_TO_PTR
5855#define SPECHASH_IDATA_TO_UDATA FC_PTR_TO_INT
5856#define SPECHASH_VPTR_TO_IDATA FC_PTR_TO_INT
5857#include "spechash.h"
5858#define dialog_options_hash_iterate(hash, column, visible) \
5859 TYPED_HASH_ITERATE(const char *, intptr_t, hash, column, visible)
5860#define dialog_options_hash_iterate_end HASH_ITERATE_END
5861
5863
5864/************************************************************************/
5867static void options_dialogs_load(struct section_file *sf)
5868{
5869 const struct entry_list *entries;
5870 const char *prefixes[] = { "player_dlg_", "city_report_", NULL };
5871 const char **prefix;
5872 bool visible;
5873
5875
5877
5878 if (NULL != entries) {
5880 for (prefix = prefixes; NULL != *prefix; prefix++) {
5881 if (!fc_strncmp(*prefix, entry_name(pentry), strlen(*prefix))
5882 && secfile_lookup_bool(sf, &visible, "client.%s",
5883 entry_name(pentry))) {
5886 break;
5887 }
5888 }
5890 }
5892
5893/************************************************************************/
5896static void options_dialogs_save(struct section_file *sf)
5897{
5899
5902 secfile_insert_bool(sf, visible, "client.%s", column);
5904}
5905
5906/************************************************************************/
5911void options_dialogs_update(void)
5912{
5913 char buf[64];
5914 int i;
5915
5917
5918 /* Player report dialog options. */
5919 for (i = 1; i < num_player_dlg_columns; i++) {
5920 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5921 player_dlg_columns[i].tagname);
5924 }
5925
5926 /* City report dialog options. */
5927 for (i = 0; i < num_city_report_spec(); i++) {
5928 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5932 }
5933}
5935/************************************************************************/
5939void options_dialogs_set(void)
5940{
5941 char buf[64];
5942 bool visible;
5943 int i;
5944
5946
5947 /* Player report dialog options. */
5948 for (i = 1; i < num_player_dlg_columns; i++) {
5949 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5950 player_dlg_columns[i].tagname);
5953 }
5954 }
5955
5956 /* City report dialog options. */
5957 for (i = 0; i < num_city_report_spec(); i++) {
5958 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5962 }
5963 }
5964}
5965
5966/************************************************************************/
5972void options_load(void)
5973{
5974 struct section_file *sf;
5976 int i, num;
5977 const char *name;
5978 const char *const prefix = "client";
5979 const char *str;
5980
5982 if (!name) {
5983 log_normal(_("Didn't find the option file. Creating a new one."));
5987 return;
5988 }
5989 if (!(sf = secfile_load(name, TRUE))) {
5990 log_debug("Error loading option file '%s':\n%s", name, secfile_error());
5991 /* Try to create the rc file */
5992 sf = secfile_new(TRUE);
5993 secfile_insert_str(sf, VERSION_STRING, "client.version");
5994
5997 save_cma_presets(sf);
5998
5999 /* FIXME: need better messages */
6000 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
6001 log_error(_("Save failed, cannot write to file %s"), name);
6002 } else {
6003 log_normal(_("Saved settings to file %s"), name);
6004 }
6005 secfile_destroy(sf);
6007 return;
6008 }
6010
6011 /* A "secret" option for the lazy. TODO: make this saveable */
6013 secfile_lookup_str_default(sf, "", "%s.password", prefix));
6014
6017 "%s.save_options_on_exit", prefix);
6020 "%s.fullscreen_mode", prefix);
6021
6022 /* Settings migrations */
6025 "%s.migration_gtk3_from_gtk2", prefix);
6028 "%s.migration_gtk3_22_from_gtk3", prefix);
6031 "%s.migration_gtk4_from_gtk3_22", prefix);
6034 "%s.migration_sdl2_from_sdl", prefix);
6037 "%s.migration_sdl3_from_sdl2", prefix);
6040 "%s.migration_gtk2_from_2_5", prefix);
6043 "%s.migration_gtk3_from_2_5", prefix);
6046 "%s.migration_qt_from_2_5", prefix);
6047
6048 /* Flag values */
6051 "%s.flag_qt_default_fonts_set", prefix);
6054 "%s.flag_sdl2_default_screen_size_set", prefix);
6057 "%s.flag_sdl3_default_screen_size_set", prefix);
6058
6059 /* These are not gui-enabled yet */
6061 = secfile_lookup_bool_default(sf, FALSE, "%s.zoom_set", prefix);
6064 "%s.zoom_default_level", prefix);
6065
6068 "%s.gui_qt_show_relations_panel", prefix);
6071 "%s.gui_qt_show_techs_panel", prefix);
6074 "%s.gui_qt_show_wonders_panel", prefix);
6075
6076 /* default_tileset_name present until freeciv-3.2 */
6077 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_name");
6078 if (str == NULL) {
6080 "client.default_topology");
6081 } else {
6083 }
6084 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_overhead_name");
6085 if (str != NULL) {
6087 }
6088 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_iso_name");
6089 if (str != NULL) {
6091 }
6092
6093 /* Backwards compatibility for removed options replaced by entirely "new"
6094 * options. The equivalent "new" option will override these, if set. */
6095
6096 /* Renamed in 2.6 */
6098 "%s.popup_caravan_arrival", prefix);
6099
6100 /* Load all the regular options */
6104
6105 /* More backwards compatibility, for removed options that had been
6106 * folded into then-existing options. Here, the backwards-compatibility
6107 * behavior overrides the "destination" option. */
6108
6109 /* Removed in 2.4 */
6111 "%s.do_combat_animation", prefix)) {
6113 }
6114
6115 message_options_load(sf, prefix);
6117
6118 /* Load cma presets. If cma.number_of_presets doesn't exist, don't load
6119 * any, the order here should be reversed to keep the order the same */
6120 if (secfile_lookup_int(sf, &num, "cma.number_of_presets")) {
6121 for (i = num - 1; i >= 0; i--) {
6122 load_cma_preset(sf, i);
6123 }
6124 } else {
6126 }
6127
6130
6131 secfile_destroy(sf);
6134
6135/************************************************************************/
6139 const char *msg, ...)
6140{
6141 va_list args;
6142
6143 va_start(args, msg);
6145 va_end(args);
6147
6148/************************************************************************/
6152{
6153 if (reply_serial >= sync_serial) {
6154 /* We've already got reply to the latest options sync request */
6155 log_debug("Options save immediate (%d vs %d)", sync_serial, reply_serial);
6157 options_save(log_cb);
6158 } else {
6159 log_debug("Options save queued (%d vs %d)", sync_serial, reply_serial);
6160 queue_save = TRUE;
6161 queued_cb = log_cb;
6162 }
6164
6165/************************************************************************/
6168void options_sync_reply(int serial)
6169{
6170 reply_serial = serial;
6171
6173 log_debug("Pop queued options saving.");
6176 }
6178
6179/************************************************************************/
6183{
6184 struct section_file *sf;
6185 const char *name = get_current_option_file_name();
6186 char dir_name[2048];
6187 int i;
6188
6189 queue_save = FALSE;
6190
6191 if (log_cb == NULL) {
6192 /* Default callback */
6194 }
6195
6196 if (!name) {
6197 log_cb(LOG_ERROR, _("Save failed, cannot find a filename."));
6198 return;
6199 }
6200
6201 sf = secfile_new(TRUE);
6202 secfile_insert_str(sf, VERSION_STRING, "client.version");
6203
6205 "client.save_options_on_exit");
6207 "deprecated", "client.fullscreen_mode");
6208
6209 /* Migrations */
6211 "client.migration_gtk3_from_gtk2");
6213 "client.migration_gtk3_22_from_gtk3");
6215 "client.migration_gtk4_from_gtk3_22");
6217 "client.migration_sdl2_from_sdl");
6219 "client.migration_sdl3_from_sdl2");
6221 "client.migration_gtk2_from_2_5");
6223 "client.migration_gtk3_from_2_5");
6225 "client.migration_qt_from_2_5");
6226
6227 /* Flag */
6229 "client.flag_qt_default_fonts_set");
6231 "client.flag_sdl2_default_screen_size_set");
6233 "client.flag_sdl3_default_screen_size_set");
6234
6235 /* gui-enabled options */
6240 /* Once options have been migrated from a client that no longer exist to a newer client,
6241 * there's no use for those settings of dropped client any more, so no point in saving them. */
6243 }
6245
6246 /* These are not gui-enabled yet. */
6247 secfile_insert_bool(sf, gui_options.zoom_set, "client.zoom_set");
6249 "client.zoom_default_level");
6250
6252 "client.gui_qt_show_relations_panel");
6254 "client.gui_qt_show_techs_panel");
6256 "client.gui_qt_show_wonders_panel");
6257
6258 if (tileset != NULL) {
6260 "client.default_topology");
6261 } else {
6263 "client.default_topology");
6264 }
6265
6266 message_options_save(sf, "client");
6268
6269 /* Server settings */
6270 save_cma_presets(sf);
6272
6273 /* Insert global worklists */
6275
6276 /* Directory name */
6278 for (i = strlen(dir_name) - 1 ; dir_name[i] != DIR_SEPARATOR_CHAR && i >= 0; i--) {
6279 /* Nothing */
6280 }
6281
6282 if (i > 0) {
6283 dir_name[i] = '\0';
6285 log_cb(LOG_ERROR, _("Saving options failed, cannot create directory %s"),
6286 dir_name);
6287 secfile_destroy(sf);
6288 return;
6289 }
6290 }
6291
6292 /* Save to disk */
6293 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
6294 log_cb(LOG_ERROR, _("Saving options failed, cannot write to file %s"), name);
6295 } else {
6296 log_cb(LOG_VERBOSE, _("Saved options to file %s"), name);
6297 }
6298 secfile_destroy(sf);
6300
6301/************************************************************************/
6304static void options_init_names(const struct copt_val_name *(*acc)(int),
6305 struct strvec **support, struct strvec **pretty)
6306{
6307 int val;
6308 const struct copt_val_name *name;
6309
6311 *support = strvec_new();
6312 *pretty = strvec_new();
6313 for (val = 0; (name = acc(val)); val++) {
6314 strvec_append(*support, name->support);
6315 strvec_append(*pretty, name->pretty);
6316 }
6318
6319/************************************************************************/
6322void options_init(void)
6323{
6327
6330
6333
6334 switch (option_type(poption)) {
6335 case OT_INTEGER:
6342
6343 log_error("option %s has default value of %d, which is "
6344 "out of its range [%d; %d], changing to %d.",
6347 new_default);
6348 *((int *) &(pcoption->integer.def)) = new_default;
6349 }
6350 break;
6351
6352 case OT_STRING:
6354 /* Hack to get a default value. */
6355 *((const char **) &(pcoption->string.def)) =
6357 }
6358
6359 if (NULL == option_str_def(poption)) {
6360 const struct strvec *values = option_str_values(poption);
6361
6362 if (NULL == values || strvec_size(values) == 0) {
6363 log_error("Invalid NULL default string for option %s.",
6365 } else {
6366 *((const char **) &(pcoption->string.def)) =
6367 strvec_get(values, 0);
6368 }
6369 }
6370 break;
6371
6372 case OT_ENUM:
6373 fc_assert(NULL == pcoption->enumerator.support_names);
6374 fc_assert(NULL == pcoption->enumerator.pretty_names);
6375 options_init_names(pcoption->enumerator.name_accessor,
6376 &pcoption->enumerator.support_names,
6377 &pcoption->enumerator.pretty_names);
6378 fc_assert(NULL != pcoption->enumerator.support_names);
6379 fc_assert(NULL != pcoption->enumerator.pretty_names);
6380 break;
6381
6382 case OT_BITWISE:
6383 fc_assert(NULL == pcoption->bitwise.support_names);
6384 fc_assert(NULL == pcoption->bitwise.pretty_names);
6385 options_init_names(pcoption->bitwise.name_accessor,
6386 &pcoption->bitwise.support_names,
6387 &pcoption->bitwise.pretty_names);
6388 fc_assert(NULL != pcoption->bitwise.support_names);
6389 fc_assert(NULL != pcoption->bitwise.pretty_names);
6390 break;
6391
6392 case OT_COLOR:
6393 {
6394 /* Duplicate the string pointers. */
6395 struct ft_color *pcolor = pcoption->color.pvalue;
6396
6397 if (NULL != pcolor->foreground) {
6398 pcolor->foreground = fc_strdup(pcolor->foreground);
6399 }
6400 if (NULL != pcolor->background) {
6401 pcolor->background = fc_strdup(pcolor->background);
6402 }
6403 }
6404 break;
6405
6406 case OT_BOOLEAN:
6407 case OT_FONT:
6408 case OT_VIDEO_MODE:
6409 break;
6410 }
6411
6412 /* Set to default. */
6416
6417/************************************************************************/
6420void options_free(void)
6421{
6424
6426
6427 switch (option_type(poption)) {
6428 case OT_ENUM:
6429 fc_assert_action(NULL != pcoption->enumerator.support_names, break);
6430 strvec_destroy(pcoption->enumerator.support_names);
6431 pcoption->enumerator.support_names = NULL;
6432 fc_assert_action(NULL != pcoption->enumerator.pretty_names, break);
6433 strvec_destroy(pcoption->enumerator.pretty_names);
6434 pcoption->enumerator.pretty_names = NULL;
6435 break;
6436
6437 case OT_BITWISE:
6438 fc_assert_action(NULL != pcoption->bitwise.support_names, break);
6439 strvec_destroy(pcoption->bitwise.support_names);
6440 pcoption->bitwise.support_names = NULL;
6441 fc_assert_action(NULL != pcoption->bitwise.pretty_names, break);
6442 strvec_destroy(pcoption->bitwise.pretty_names);
6443 pcoption->bitwise.pretty_names = NULL;
6444 break;
6445
6446 case OT_BOOLEAN:
6447 case OT_INTEGER:
6448 case OT_STRING:
6449 case OT_FONT:
6450 case OT_COLOR:
6451 case OT_VIDEO_MODE:
6452 break;
6453 }
6455
6456 if (NULL != settable_options_hash) {
6459 }
6460
6461 if (NULL != dialog_options_hash) {
6464 }
6465
6468}
6470/************************************************************************/
6474static void reqtree_show_icons_callback(struct option *poption)
6475{
6478
6479/************************************************************************/
6482static void view_option_changed_callback(struct option *poption)
6483{
6484 menus_init();
6487
6488/************************************************************************/
6491static void manual_turn_done_callback(struct option *poption)
6492{
6494
6496 struct player *pplayer = client_player();
6497
6498 if (pplayer != NULL && is_ai(pplayer)
6499 && can_end_turn()) {
6501 }
6502 }
6504
6505/****************************************************************************
6506 Callback for changing music volume
6507****************************************************************************/
6508static void sound_volume_callback(struct option *poption)
6509{
6512
6513/************************************************************************/
6516static void voteinfo_bar_callback(struct option *poption)
6517{
6520
6521/************************************************************************/
6524static void font_changed_callback(struct option *poption)
6525{
6529
6530/************************************************************************/
6533static void mapimg_changed_callback(struct option *poption)
6534{
6536#ifndef FREECIV_NDEBUG
6537 bool success;
6538#endif
6539
6540 log_normal("Error setting the value for %s (%s). Restoring the default "
6541 "value.", option_name(poption), mapimg_error());
6542
6543 /* Reset the value to the default value. */
6544#ifndef FREECIV_NDEBUG
6545 success =
6546#endif
6548
6550 "Failed to reset the option \"%s\".",
6552#ifndef FREECIV_NDEBUG
6553 success =
6554#endif
6556
6558 "Failed to restore mapimg definition for option \"%s\".",
6560 }
6562
6563/************************************************************************/
6566static void game_music_enable_callback(struct option *poption)
6567{
6568 if (client_state() == C_S_RUNNING) {
6571 } else {
6573 }
6574 }
6576
6577/************************************************************************/
6580static void menu_music_enable_callback(struct option *poption)
6581{
6582 if (client_state() != C_S_RUNNING) {
6584 start_menu_music("music_menu", NULL);
6585 } else {
6587 }
6588 }
6590
6591/************************************************************************/
6594bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
6595{
6596 return (2 < fc_snprintf(buf, buf_len, "%dx%d", mode->width, mode->height));
6598
6599/************************************************************************/
6602bool string_to_video_mode(const char *buf, struct video_mode *mode)
6603{
6604 return (2 == sscanf(buf, "%dx%d", &mode->width, &mode->height));
6606
6607/************************************************************************/
6610static const struct strvec *get_mapimg_format_list(const struct option *poption)
6611{
6612 return mapimg_get_format_list();
6614
6615/************************************************************************/
6618const char *tileset_name_for_topology(int topology_id)
6619{
6620 const char *tsn = NULL;
6621
6622 switch (topology_id & (TF_ISO | TF_HEX)) {
6623 case 0:
6624 case TF_ISO:
6626 break;
6627 case TF_HEX:
6629 break;
6630 case TF_ISO | TF_HEX:
6632 break;
6633 }
6634
6635 if (tsn == NULL) {
6637 }
6638
6639 return tsn;
6641
6642/************************************************************************/
6645void option_set_default_ts(struct tileset *t)
6646{
6647 const char *optname = "<not set>";
6648 struct option *opt;
6649
6650 switch (tileset_topo_index(t)) {
6651 case TS_TOPO_SQUARE:
6652 /* Overhead */
6653 optname = "default_tileset_square_name";
6654 break;
6655 case TS_TOPO_HEX:
6656 /* Hex */
6657 optname = "default_tileset_hex_name";
6658 break;
6659 case TS_TOPO_ISOHEX:
6660 /* Isohex */
6661 optname = "default_tileset_isohex_name";
6662 break;
6663 }
6664
6666
6667 if (opt == NULL) {
6668 log_error("Unknown option name \"%s\" in option_set_default_ts()", optname);
6669 return;
6670 }
6671
6672 /* Do not call option_str_set() since we don't want option changed callback
6673 * to reload this tileset. */
6674 opt->str_vtable->set(opt, tileset_basename(t));
6677
6678/************************************************************************/
6681static bool is_ts_option_unset(const char *optname)
6682{
6683 struct option *opt;
6684 const char *val;
6685
6687
6688 if (opt == NULL) {
6689 return TRUE;
6690 }
6691
6692 val = opt->str_vtable->get(opt);
6693
6694 if (val == NULL || val[0] == '\0') {
6695 return TRUE;
6696 }
6697
6698 return FALSE;
6700
6701/************************************************************************/
6704void fill_topo_ts_default(void)
6705{
6706 if (is_ts_option_unset("default_tileset_square_name")) {
6707 if (gui_options.default_tileset_iso_name[0] != '\0') {
6711 } else if (gui_options.default_tileset_overhead_name[0] != '\0') {
6715 } else {
6716 log_debug("Setting tileset for square topologies.");
6718 }
6719 }
6720 if (is_ts_option_unset("default_tileset_hex_name")) {
6721 log_debug("Setting tileset for hex topology.");
6723 }
6724 if (is_ts_option_unset("default_tileset_isohex_name")) {
6725 log_debug("Setting tileset for isohex topology.");
6727 }
6728}
struct @130::my_agent entries[MAX_AGENTS]
#define str
Definition astring.c:76
void audio_set_volume(double volume)
Definition audio.c:647
const struct strvec * get_musicset_list(const struct option *poption)
Definition audio.c:126
const struct strvec * get_soundset_list(const struct option *poption)
Definition audio.c:116
const struct strvec * get_soundplugin_list(const struct option *poption)
Definition audio.c:80
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
Definition canvas_g.h:56
int send_chat_printf(const char *format,...)
void output_window_vprintf(const struct ft_color color, const char *format, va_list args)
static int cmp(int v1, int v2)
Definition city.c:325
#define output_type_iterate(output)
Definition city.h:842
#define output_type_iterate_end
Definition city.h:848
int num_city_report_spec(void)
const char * city_report_spec_tagname(int i)
bool * city_report_spec_show_ptr(int i)
void user_ended_turn(void)
struct civclient client
enum client_states client_state(void)
char fc_password[MAX_LEN_PASSWORD]
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
bool mapimg_client_define(void)
Definition climisc.c:1409
void cm_init_parameter(struct cm_parameter *dest)
Definition cm.c:2183
char * cmafec_preset_get_descr(int idx)
Definition cma_fec.c:169
const struct cm_parameter * cmafec_preset_get_parameter(int idx)
Definition cma_fec.c:182
void cmafec_preset_add(const char *descr_name, struct cm_parameter *pparam)
Definition cma_fec.c:136
int cmafec_preset_num(void)
Definition cma_fec.c:213
void create_default_cma_presets(void)
Definition cma_fec.c:384
char * incite_cost
Definition comments.c:76
#define MAX_LEN_MSG
Definition conn_types.h:37
bool is_server_running(void)
#define log_deprecation(message,...)
enum event_type event
Definition events.c:81
void events_init(void)
Definition events.c:331
void events_free(void)
Definition events.c:377
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
const struct ft_color ftc_client
#define FT_COLOR(fg, bg)
static struct ft_color ft_color_construct(const char *foreground, const char *background)
static bool static void void global_worklists_init(void)
void global_worklists_load(struct section_file *file)
void global_worklists_free(void)
void global_worklists_save(struct section_file *file)
enum gui_type get_gui_type(void)
Definition gui_main.c:2078
void options_extra_init(void)
Definition gui_main.c:2480
static GtkTextBuffer * help_text
Definition helpdlg.c:70
void option_gui_remove(struct option *poption)
Definition optiondlg.c:1053
void option_dialog_popdown(const struct option_set *poptset)
Definition optiondlg.c:998
void option_gui_update(struct option *poption)
Definition optiondlg.c:1025
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
void voteinfo_gui_update(void)
#define show(id)
Definition widget.h:235
gui_update_font
Definition gui_main_g.h:43
const char * name
Definition inputfile.c:127
@ FZ_PLAIN
Definition ioz.h:38
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert_ret(condition)
Definition log.h:192
#define log_verbose(message,...)
Definition log.h:110
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_msg(condition, message,...)
Definition log.h:206
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define fc_assert_action(condition, action)
Definition log.h:188
#define log_debug(message,...)
Definition log.h:116
#define log_normal(message,...)
Definition log.h:108
log_level
Definition log.h:29
@ LOG_ERROR
Definition log.h:31
@ LOG_VERBOSE
Definition log.h:34
#define log_error(message,...)
Definition log.h:104
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:238
void update_turn_done_button_state(void)
bool can_end_turn(void)
bool mapimg_initialised(void)
Definition mapimg.c:1558
const struct strvec * mapimg_get_format_list(void)
Definition mapimg.c:1156
const char * mapimg_error(void)
Definition mapimg.c:759
void update_map_canvas_visible(void)
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
void menus_init(void)
void musicspec_reread_callback(struct option *poption)
Definition music.c:129
void start_menu_music(const char *const tag, char *const alt_tag)
Definition music.c:98
void stop_menu_music(void)
Definition music.c:108
void start_style_music(void)
Definition music.c:44
void stop_style_music(void)
Definition music.c:90
str prefix(str prefix, str text)
static struct option * client_optset_option_first(void)
Definition options.c:3422
void handle_server_setting_const(const struct packet_server_setting_const *packet)
Definition options.c:4356
void handle_server_setting_int(const struct packet_server_setting_int *packet)
Definition options.c:4450
static int server_option_int_max(const struct option *poption)
Definition options.c:4883
static bool client_option_font_set(struct option *poption, const char *font)
Definition options.c:3791
unsigned option_bitwise_mask(const struct option *poption)
Definition options.c:1107
void fill_topo_ts_default(void)
Definition options.c:6699
#define FIRST_MAJOR_MID_OPTION_FILE_NAME
Definition options.c:5336
#define client_options_iterate_all_end
Definition options.c:3384
static const struct strvec * server_option_str_values(const struct option *poption)
Definition options.c:4929
static int client_option_enum_get(const struct option *poption)
Definition options.c:3650
void resend_desired_settable_options(void)
Definition options.c:5811
const struct strvec * option_str_values(const struct option *poption)
Definition options.c:926
static void desired_settable_option_send(struct option *poption)
Definition options.c:5725
static const char * client_option_name(const struct option *poption)
Definition options.c:3476
static int sync_serial
Definition options.c:410
static unsigned server_option_bitwise_def(const struct option *poption)
Definition options.c:5028
#define FIRST_MAJOR_NEW_OPTION_FILE_NAME
Definition options.c:5333
static const struct option_video_mode_vtable client_option_video_mode_vtable
Definition options.c:1417
#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd)
Definition options.c:1594
static struct dialog_options_hash * dialog_options_hash
Definition options.c:5857
static bool queue_save
Definition options.c:412
void option_changed(struct option *poption)
Definition options.c:759
static void menu_music_enable_callback(struct option *poption)
Definition options.c:6575
static bool options_fully_initialized
Definition options.c:408
static const struct option_str_vtable client_option_str_vtable
Definition options.c:1351
static int reply_serial
Definition options.c:411
unsigned option_bitwise_def(const struct option *poption)
Definition options.c:1096
int option_enum_str_to_int(const struct option *poption, const char *str)
Definition options.c:954
static const char * client_option_description(const struct option *poption)
Definition options.c:3484
int option_int_min(const struct option *poption)
Definition options.c:867
static void option_save_output_window_callback(enum log_level lvl, const char *msg,...)
Definition options.c:6133
static void message_options_save(struct section_file *file, const char *prefix)
Definition options.c:5242
bool option_bool_def(const struct option *poption)
Definition options.c:819
static struct option * client_option_next(const struct option *poption)
Definition options.c:3516
static const char * server_option_name(const struct option *poption)
Definition options.c:4776
const char * option_font_def(const struct option *poption)
Definition options.c:1163
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6613
static const struct copt_val_name * gui_gtk_message_chat_location_name(int value)
Definition options.c:1850
static bool server_option_str_set(struct option *poption, const char *str)
Definition options.c:4938
static const struct copt_val_name * gui_popup_tech_help_name(int value)
Definition options.c:1870
struct option * optset_option_first(const struct option_set *poptset)
Definition options.c:458
static const char * server_optset_category_name(int category)
Definition options.c:4756
const struct option_set * server_optset
Definition options.c:4077
static void view_option_changed_callback(struct option *poption)
Definition options.c:6477
static const char * client_option_font_target(const struct option *poption)
Definition options.c:3782
static void server_option_enum_support_name(const struct option *poption, const char **pvalue, const char **pdefault)
Definition options.c:5002
#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb)
Definition options.c:1556
static const char * server_option_description(const struct option *poption)
Definition options.c:4784
static unsigned server_option_bitwise_get(const struct option *poption)
Definition options.c:5020
static bool client_option_is_changeable(const struct option *poption)
Definition options.c:3508
static int server_option_int_min(const struct option *poption)
Definition options.c:4875
static const char * client_optset_category_name(int category)
Definition options.c:3438
static struct option * server_option_next(const struct option *poption)
Definition options.c:4816
static struct client_option client_options[]
Definition options.c:1897
#define SERVER_OPTION(poption)
Definition options.c:4213
static void settable_options_save(struct section_file *sf)
Definition options.c:5570
static bool server_option_bool_get(const struct option *poption)
Definition options.c:4824
bool option_reset(struct option *poption)
Definition options.c:720
void options_free(void)
Definition options.c:6415
const char * option_description(const struct option *poption)
Definition options.c:649
const char * option_help_text(const struct option *poption)
Definition options.c:659
#define settable_options_hash_iterate_end
Definition options.c:5496
static const char * client_option_font_get(const struct option *poption)
Definition options.c:3766
static int server_option_enum_def(const struct option *poption)
Definition options.c:4963
static int server_option_int_def(const struct option *poption)
Definition options.c:4867
#define client_options_iterate_all(poption)
Definition options.c:3375
static int client_option_int_min(const struct option *poption)
Definition options.c:3572
static int server_options_categories_num
Definition options.c:4059
const char * option_enum_get_str(const struct option *poption)
Definition options.c:1003
static struct ft_color client_option_color_def(const struct option *poption)
Definition options.c:3815
static const struct strvec * client_option_enum_pretty_names(const struct option *poption)
Definition options.c:3668
static bool server_option_enum_set(struct option *poption, int val)
Definition options.c:4982
static void save_cma_presets(struct section_file *file)
Definition options.c:5315
struct ft_color option_color_get(const struct option *poption)
Definition options.c:1201
static struct video_mode client_option_video_mode_def(const struct option *poption)
Definition options.c:3869
static int client_option_int_get(const struct option *poption)
Definition options.c:3556
static char ** server_options_categories
Definition options.c:4056
int option_enum_get_int(const struct option *poption)
Definition options.c:991
static void settable_options_load(struct section_file *sf)
Definition options.c:5503
int option_number(const struct option *poption)
Definition options.c:629
static struct option * server_optset_option_first(void)
Definition options.c:4740
static struct settable_options_hash * settable_options_hash
Definition options.c:5498
int option_category(const struct option *poption)
Definition options.c:679
static struct server_option * server_options
Definition options.c:4057
static const struct option_int_vtable server_option_int_vtable
Definition options.c:4117
static void options_dialogs_save(struct section_file *sf)
Definition options.c:5891
static struct option_set client_optset_static
Definition options.c:1285
void options_sync_reply(int serial)
Definition options.c:6163
static bool client_option_color_set(struct option *poption, struct ft_color color)
Definition options.c:3824
#define dialog_options_hash_iterate_end
Definition options.c:5855
static void save_cma_preset(struct section_file *file, int i)
Definition options.c:5293
static int client_optset_category_number(void)
Definition options.c:3430
static const char * client_option_str_def(const struct option *poption)
Definition options.c:3614
static bool client_option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:3878
void handle_server_setting_bitwise(const struct packet_server_setting_bitwise *packet)
Definition options.c:4621
static const struct option_font_vtable client_option_font_vtable
Definition options.c:1392
static bool client_option_enum_set(struct option *poption, int val)
Definition options.c:3677
void desired_settable_option_update(const char *op_name, const char *op_value, bool allow_replace)
Definition options.c:5668
void option_set_default_ts(struct tileset *t)
Definition options.c:6640
bool option_str_set(struct option *poption, const char *str)
Definition options.c:937
void handle_server_setting_bool(const struct packet_server_setting_bool *packet)
Definition options.c:4415
static const struct strvec * client_option_str_values(const struct option *poption)
Definition options.c:3624
const struct option_set * client_optset
Definition options.c:1291
static const struct option_bool_vtable server_option_bool_vtable
Definition options.c:4105
static const struct option_bitwise_vtable server_option_bitwise_vtable
Definition options.c:4158
const char * option_name(const struct option *poption)
Definition options.c:639
static const char * client_option_help_text(const struct option *poption)
Definition options.c:3492
static void message_options_init(void)
Definition options.c:5115
static int client_option_number(const struct option *poption)
Definition options.c:3468
void handle_server_setting_str(const struct packet_server_setting_str *packet)
Definition options.c:4487
int option_int_get(const struct option *poption)
Definition options.c:845
static void client_option_save(struct option *poption, struct section_file *sf)
Definition options.c:3996
void options_init(void)
Definition options.c:6317
static int client_option_int_def(const struct option *poption)
Definition options.c:3564
static int server_option_category(const struct option *poption)
Definition options.c:4800
#define FIRST_MINOR_MID_OPTION_FILE_NAME
Definition options.c:5337
static const struct option_enum_vtable client_option_enum_vtable
Definition options.c:1364
static const struct option_str_vtable server_option_str_vtable
Definition options.c:4131
static int server_options_num
Definition options.c:4060
#define handle_server_setting_common(psoption, packet)
Definition options.c:4377
static const struct option_color_vtable client_option_color_vtable
Definition options.c:1404
bool option_enum_set_str(struct option *poption, const char *str)
Definition options.c:1068
static const struct strvec * server_option_enum_pretty(const struct option *poption)
Definition options.c:4973
static void server_option_bitwise_support_name(const struct option *poption, char *val_buf, size_t val_len, char *def_buf, size_t def_len)
Definition options.c:5088
bool option_color_set(struct option *poption, struct ft_color color)
Definition options.c:1224
#define SETTING_CASE(ARG_name,...)
static struct video_mode client_option_video_mode_get(const struct option *poption)
Definition options.c:3860
static bool is_ts_option_unset(const char *optname)
Definition options.c:6676
void option_set_changed_callback(struct option *poption, void(*callback)(struct option *))
Definition options.c:748
#define OPTION(poption)
Definition options.c:574
#define NEW_OPTION_FILE_NAME
Definition options.c:5330
static bool server_option_bool_set(struct option *poption, bool val)
Definition options.c:4841
bool option_bool_set(struct option *poption, bool val)
Definition options.c:830
bool option_is_changeable(const struct option *poption)
Definition options.c:700
#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb)
Definition options.c:1672
bool option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:1264
#define MID_OPTION_FILE_NAME
Definition options.c:5329
static int server_option_number(const struct option *poption)
Definition options.c:4768
#define dialog_options_hash_iterate(hash, column, visible)
Definition options.c:5853
#define FIRST_MINOR_NEW_BOOLEAN
Definition options.c:5340
static const char * server_option_str_get(const struct option *poption)
Definition options.c:4911
#define settable_options_hash_iterate(hash, name, value)
Definition options.c:5494
void option_set_gui_data(struct option *poption, void *data)
Definition options.c:778
#define FIRST_MINOR_NEW_OPTION_FILE_NAME
Definition options.c:5334
#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1520
const char * option_str_get(const struct option *poption)
Definition options.c:904
struct option * optset_option_by_number(const struct option_set *poptset, int id)
Definition options.c:431
static bool client_option_bool_get(const struct option *poption)
Definition options.c:3524
void * option_get_gui_data(const struct option *poption)
Definition options.c:788
static const char * server_option_str_def(const struct option *poption)
Definition options.c:4919
static const struct option_common_vtable client_option_common_vtable
Definition options.c:1311
static bool settable_option_upgrade_value(const struct option *poption, int old_value, char *buf, size_t buf_len)
Definition options.c:5685
const struct strvec * option_enum_values(const struct option *poption)
Definition options.c:1040
static const struct strvec * get_mapimg_format_list(const struct option *poption)
Definition options.c:6605
static void sound_volume_callback(struct option *poption)
Definition options.c:6503
bool option_enum_set_int(struct option *poption, int val)
Definition options.c:1051
bool option_bool_get(const struct option *poption)
Definition options.c:808
int optset_category_number(const struct option_set *poptset)
Definition options.c:468
#define color_set(color_tgt, color)
static bool client_option_bool_def(const struct option *poption)
Definition options.c:3532
static const struct strvec * server_option_bitwise_pretty(const struct option *poption)
Definition options.c:5038
void server_options_init(void)
Definition options.c:4221
enum option_type option_type(const struct option *poption)
Definition options.c:669
static int client_option_enum_def(const struct option *poption)
Definition options.c:3658
const char * option_enum_int_to_str(const struct option *poption, int val)
Definition options.c:976
void options_dialogs_update(void)
Definition options.c:5906
int option_get_cb_data(const struct option *poption)
Definition options.c:798
bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
Definition options.c:6589
static void options_dialogs_load(struct section_file *sf)
Definition options.c:5862
const struct option_set * option_optset(const struct option *poption)
Definition options.c:619
void server_options_free(void)
Definition options.c:4290
struct video_mode option_video_mode_get(const struct option *poption)
Definition options.c:1239
static int server_option_enum_get(const struct option *poption)
Definition options.c:4955
struct option * option_next(const struct option *poption)
Definition options.c:710
static struct option * client_optset_option_by_number(int id)
Definition options.c:3411
static void font_changed_callback(struct option *poption)
Definition options.c:6519
const char * option_str_def(const struct option *poption)
Definition options.c:915
const char * optset_category_name(const struct option_set *poptset, int category)
Definition options.c:478
int option_int_max(const struct option *poption)
Definition options.c:878
#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, odef_bg, ocb)
Definition options.c:1787
const char * option_enum_def_str(const struct option *poption)
Definition options.c:1027
void options_load(void)
Definition options.c:5967
static const char * client_option_str_get(const struct option *poption)
Definition options.c:3606
static option_save_log_callback queued_cb
Definition options.c:413
static const struct option_common_vtable server_option_common_vtable
Definition options.c:4091
static int server_optset_category_number(void)
Definition options.c:4748
static bool client_option_bool_set(struct option *poption, bool val)
Definition options.c:3541
static const char * server_option_help_text(const struct option *poption)
Definition options.c:4792
static const struct option_bool_vtable client_option_bool_vtable
Definition options.c:1325
static bool client_option_load(struct option *poption, struct section_file *sf)
Definition options.c:3895
bool option_font_set(struct option *poption, const char *font)
Definition options.c:1185
static bool server_option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:5067
const char * option_font_target(const struct option *poption)
Definition options.c:1174
static const char * client_option_enum_secfile_str(secfile_data_t data, int val)
Definition options.c:3696
static struct server_option * server_option_next_valid(struct server_option *poption)
Definition options.c:4710
static void server_option_bitwise_support_base(const struct strvec *values, unsigned val, char *buf, size_t buf_len)
Definition options.c:5046
void queue_options_save(option_save_log_callback log_cb)
Definition options.c:6146
static void voteinfo_bar_callback(struct option *poption)
Definition options.c:6511
static struct option * server_optset_option_by_number(int id)
Definition options.c:4729
void options_save(option_save_log_callback log_cb)
Definition options.c:6177
static void message_options_free(void)
Definition options.c:5153
static const struct option_enum_vtable server_option_enum_vtable
Definition options.c:4144
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6597
const struct strvec * option_bitwise_values(const struct option *poption)
Definition options.c:1124
static bool server_option_int_set(struct option *poption, int val)
Definition options.c:4892
int messages_where[E_COUNT]
Definition options.c:5108
static void message_options_load(struct section_file *file, const char *prefix)
Definition options.c:5162
struct client_options gui_options
Definition options.c:71
static void server_option_free(struct server_option *poption)
Definition options.c:4232
#define CLIENT_OPTION(poption)
Definition options.c:1502
#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1751
static struct option_set server_optset_static
Definition options.c:4071
void handle_server_setting_control(const struct packet_server_setting_control *packet)
Definition options.c:4322
static void mapimg_changed_callback(struct option *poption)
Definition options.c:6528
bool option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:1135
static int server_option_int_get(const struct option *poption)
Definition options.c:4859
static void manual_turn_done_callback(struct option *poption)
Definition options.c:6486
static void reqtree_show_icons_callback(struct option *poption)
Definition options.c:6469
const char * option_font_get(const struct option *poption)
Definition options.c:1152
void desired_settable_options_update(void)
Definition options.c:5600
static void load_cma_preset(struct section_file *file, int i)
Definition options.c:5263
static bool client_option_str_set(struct option *poption, const char *str)
Definition options.c:3634
void handle_server_setting_enum(const struct packet_server_setting_enum *packet)
Definition options.c:4532
struct ft_color option_color_def(const struct option *poption)
Definition options.c:1212
static int client_option_int_max(const struct option *poption)
Definition options.c:3580
#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd)
Definition options.c:1635
client_option_category
Definition options.c:1423
@ COC_MAX
Definition options.c:1431
@ COC_SOUND
Definition options.c:1426
@ COC_NETWORK
Definition options.c:1429
@ COC_INTERFACE
Definition options.c:1427
@ COC_GRAPHICS
Definition options.c:1424
@ COC_OVERVIEW
Definition options.c:1425
@ COC_FONT
Definition options.c:1430
@ COC_MAPIMG
Definition options.c:1428
unsigned option_bitwise_get(const struct option *poption)
Definition options.c:1085
static bool server_option_is_changeable(const struct option *poption)
Definition options.c:4808
static struct ft_color client_option_color_get(const struct option *poption)
Definition options.c:3807
int option_enum_def_int(const struct option *poption)
Definition options.c:1015
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:442
static const int client_options_num
Definition options.c:3372
static bool client_option_int_set(struct option *poption, int val)
Definition options.c:3589
void options_dialogs_set(void)
Definition options.c:5934
bool option_int_set(struct option *poption, int val)
Definition options.c:889
static struct client_option * client_option_next_valid(struct client_option *poption)
Definition options.c:3393
static const char * client_option_bitwise_secfile_str(secfile_data_t data, int val)
Definition options.c:3754
#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, odef_height, ocb)
Definition options.c:1822
static const struct option_int_vtable client_option_int_vtable
Definition options.c:1337
static const char * client_option_font_def(const struct option *poption)
Definition options.c:3774
static const char * get_last_option_file_name(bool *allow_digital_boolean)
Definition options.c:5384
const char * option_category_name(const struct option *poption)
Definition options.c:689
static void game_music_enable_callback(struct option *poption)
Definition options.c:6561
static const char * get_current_option_file_name(void)
Definition options.c:5349
int option_int_def(const struct option *poption)
Definition options.c:856
static void options_init_names(const struct copt_val_name *(*acc)(int), struct strvec **support, struct strvec **pretty)
Definition options.c:6299
struct video_mode option_video_mode_def(const struct option *poption)
Definition options.c:1251
static bool server_option_bool_def(const struct option *poption)
Definition options.c:4832
#define GUI_GTK3_CITYDLG_DEFAULT_XSIZE
Definition options.h:612
#define GUI_GTK3_22_GOV_RANGE_MIN_DEFAULT
Definition options.h:655
#define MW_POPUP
Definition options.h:590
#define GUI_GTK3_CITYDLG_MAX_YSIZE
Definition options.h:618
#define GUI_GTK3_22_OPTIONSDLG_MAX_XSIZE
Definition options.h:649
#define GUI_GTK3_22_OPTIONSDLG_DEFAULT_YSIZE
Definition options.h:651
#define GUI_GTK3_22_GOV_RANGE_MIN_MIN
Definition options.h:656
#define GUI_GTK3_GOV_RANGE_MIN_DEFAULT
Definition options.h:620
#define GUI_GTK3_22_HELPDLG_MIN_YSIZE
Definition options.h:643
#define GUI_GTK4_GOV_RANGE_MIN_MAX
Definition options.h:692
#define GUI_GTK3_22_CITYDLG_MIN_YSIZE
Definition options.h:634
#define GUI_GTK4_CITYDLG_MAX_XSIZE
Definition options.h:666
#define GUI_GTK4_GOV_RANGE_MIN_DEFAULT
Definition options.h:690
#define GUI_GTK3_GOV_RANGE_MAX_DEFAULT
Definition options.h:624
void(* option_save_log_callback)(enum log_level lvl, const char *msg,...)
Definition options.h:453
#define GUI_GTK4_OPTIONSDLG_MIN_XSIZE
Definition options.h:683
#define GUI_GTK4_CITYDLG_DEFAULT_XSIZE
Definition options.h:664
#define FC_SDL3_DEFAULT_THEME_NAME
Definition options.h:400
#define GUI_GTK2_CITYDLG_DEFAULT_YSIZE
Definition options.h:604
#define GUI_GTK4_HELPDLG_MAX_YSIZE
Definition options.h:679
#define FC_GTK3_22_DEFAULT_THEME_NAME
Definition options.h:300
#define GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE
Definition options.h:629
#define FC_QT_DEFAULT_THEME_NAME
Definition options.h:412
#define GUI_GTK3_22_HELPDLG_MIN_XSIZE
Definition options.h:639
#define GUI_GTK4_OPTIONSDLG_DEFAULT_YSIZE
Definition options.h:686
#define GUI_GTK3_CITYDLG_MIN_YSIZE
Definition options.h:617
@ GUI_GTK_MSGCHAT_SEPARATE
Definition options.h:68
#define GUI_GTK3_CITYDLG_MIN_XSIZE
Definition options.h:613
#define GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE
Definition options.h:633
#define GUI_GTK4_OPTIONSDLG_MIN_YSIZE
Definition options.h:687
#define GUI_GTK4_CITYDLG_MIN_YSIZE
Definition options.h:669
#define DEFAULT_FOLLOWTAG_OPTION
Definition options.h:30
#define GUI_GTK2_CITYDLG_MIN_YSIZE
Definition options.h:605
#define options_iterate(poptset, poption)
Definition options.h:561
#define GUI_GTK3_22_OPTIONSDLG_MAX_YSIZE
Definition options.h:653
#define GUI_GTK2_CITYDLG_MAX_XSIZE
Definition options.h:602
#define GUI_DEFAULT_CHAT_LOGFILE
Definition options.h:597
#define GUI_GTK3_22_HELPDLG_DEFAULT_YSIZE
Definition options.h:642
#define GUI_GTK4_HELPDLG_MIN_XSIZE
Definition options.h:674
#define GUI_GTK3_GOV_RANGE_MAX_MAX
Definition options.h:626
#define GUI_GTK4_CITYDLG_MIN_XSIZE
Definition options.h:665
#define GUI_GTK4_HELPDLG_MIN_YSIZE
Definition options.h:678
#define GUI_GTK3_22_GOV_RANGE_MAX_DEFAULT
Definition options.h:659
#define DEFAULT_METASERVER_OPTION
Definition options.h:29
#define GUI_GTK3_CITYDLG_DEFAULT_YSIZE
Definition options.h:616
static struct video_mode video_mode_construct(int width, int height)
Definition options.h:57
#define GUI_GTK3_22_CITYDLG_MAX_XSIZE
Definition options.h:631
#define GUI_GTK4_OPTIONSDLG_MAX_XSIZE
Definition options.h:684
#define GUI_GTK3_22_GOV_RANGE_MAX_MIN
Definition options.h:660
#define GUI_GTK3_GOV_RANGE_MIN_MIN
Definition options.h:621
#define GUI_GTK3_GOV_RANGE_MIN_MAX
Definition options.h:622
#define GUI_GTK3_22_CITYDLG_MIN_XSIZE
Definition options.h:630
#define GUI_GTK4_GOV_RANGE_MAX_DEFAULT
Definition options.h:694
#define MAJOR_NEW_OPTION_FILE_NAME
Definition options.h:38
#define GUI_GTK4_HELPDLG_DEFAULT_YSIZE
Definition options.h:677
#define GUI_GTK3_22_HELPDLG_DEFAULT_XSIZE
Definition options.h:638
#define GUI_GTK3_22_OPTIONSDLG_MIN_YSIZE
Definition options.h:652
#define GUI_GTK3_GOV_RANGE_MAX_MIN
Definition options.h:625
#define GUI_GTK2_CITYDLG_MAX_YSIZE
Definition options.h:606
#define GUI_DEFAULT_MAPIMG_FILENAME
Definition options.h:698
#define GUI_GTK3_22_HELPDLG_MAX_YSIZE
Definition options.h:644
#define GUI_GTK3_22_CITYDLG_MAX_YSIZE
Definition options.h:635
@ GUI_POPUP_TECH_HELP_RULESET
Definition options.h:77
#define GUI_GTK4_HELPDLG_MAX_XSIZE
Definition options.h:675
#define GUI_GTK4_GOV_RANGE_MIN_MIN
Definition options.h:691
#define GUI_GTK4_CITYDLG_MAX_YSIZE
Definition options.h:670
#define MW_OUTPUT
Definition options.h:588
#define GUI_GTK4_CITYDLG_DEFAULT_YSIZE
Definition options.h:668
#define options_iterate_end
Definition options.h:566
#define GUI_GTK3_22_OPTIONSDLG_MIN_XSIZE
Definition options.h:648
#define GUI_GTK4_GOV_RANGE_MAX_MAX
Definition options.h:696
#define MW_MESSAGES
Definition options.h:589
#define FC_GTK4_DEFAULT_THEME_NAME
Definition options.h:340
#define GUI_GTK3_22_GOV_RANGE_MIN_MAX
Definition options.h:657
#define GUI_GTK4_HELPDLG_DEFAULT_XSIZE
Definition options.h:673
#define MINOR_NEW_OPTION_FILE_NAME
Definition options.h:42
#define GUI_GTK2_CITYDLG_DEFAULT_XSIZE
Definition options.h:600
#define FC_SDL2_DEFAULT_THEME_NAME
Definition options.h:387
#define GUI_GTK3_22_GOV_RANGE_MAX_MAX
Definition options.h:661
#define GUI_GTK3_22_OPTIONSDLG_DEFAULT_XSIZE
Definition options.h:647
#define VIDEO_MODE(ARG_width, ARG_height)
Definition options.h:51
@ OLAYER_BORDERS
Definition options.h:83
@ OLAYER_BACKGROUND
Definition options.h:81
@ OLAYER_CITIES
Definition options.h:86
@ OLAYER_BORDERS_ON_OCEAN
Definition options.h:84
@ OLAYER_UNITS
Definition options.h:85
@ OLAYER_RELIEF
Definition options.h:82
#define GUI_GTK4_OPTIONSDLG_MAX_YSIZE
Definition options.h:688
#define GUI_GTK3_CITYDLG_MAX_XSIZE
Definition options.h:614
#define GUI_GTK3_22_HELPDLG_MAX_XSIZE
Definition options.h:640
#define GUI_GTK4_GOV_RANGE_MAX_MIN
Definition options.h:695
#define GUI_GTK4_OPTIONSDLG_DEFAULT_XSIZE
Definition options.h:682
#define GUI_GTK2_CITYDLG_MIN_XSIZE
Definition options.h:601
void overview_redraw_callback(struct option *option)
int dsend_packet_sync_serial(struct connection *pc, int serial)
#define is_ai(plr)
Definition player.h:232
struct player_dlg_column player_dlg_columns[]
const int num_player_dlg_columns
struct section_file * secfile_load(const char *filename, bool allow_duplicates)
Definition registry.c:51
void secfile_allow_digital_boolean(struct section_file *secfile, bool allow_digital_boolean) fc__attribute((nonnull(1)))
struct section_file * secfile_new(bool allow_duplicates)
const char * secfile_error(void)
const char * section_name(const struct section *psection)
void secfile_destroy(struct section_file *secfile)
bool entry_bool_get(const struct entry *pentry, bool *value)
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
bool secfile_lookup_enum_data(const struct section_file *secfile, int *pvalue, bool bitwise, secfile_enum_name_data_fn_t name_fn, secfile_data_t data, const char *path,...)
const struct entry_list * section_entries(const struct section *psection)
const char * entry_name(const struct entry *pentry)
bool entry_str_get(const struct entry *pentry, const char **value)
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
float secfile_lookup_float_default(const struct section_file *secfile, float def, const char *path,...)
bool secfile_save(const struct section_file *secfile, const char *filename, int compression_level, enum fz_method compression_method)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
bool entry_int_get(const struct entry *pentry, int *value)
const char * secfile_name(const struct section_file *secfile)
struct section * secfile_section_by_name(const struct section_file *secfile, const char *name)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
bool secfile_lookup_bool(const struct section_file *secfile, bool *bval, const char *path,...)
enum entry_type entry_type_get(const struct entry *pentry)
#define secfile_insert_int(secfile, value, path,...)
#define secfile_insert_bool_comment(secfile, value, comment, path,...)
@ ENTRY_FILEREFERENCE
@ ENTRY_LONG_COMMENT
@ ENTRY_INT
@ ENTRY_FLOAT
@ ENTRY_STR
@ ENTRY_ILLEGAL
@ ENTRY_BOOL
#define entry_list_iterate_end
#define secfile_insert_str(secfile, string, path,...)
#define secfile_insert_bool(secfile, value, path,...)
#define entry_list_iterate(entlist, pentry)
#define secfile_insert_enum_data(secfile, value, bitwise, name_fn, data, path,...)
#define secfile_insert_int_comment(secfile, value, comment, path,...)
#define secfile_insert_float(secfile, value, path,...)
const void * secfile_data_t
char * user_home_dir(void)
Definition shared.c:627
bool str_to_int(const char *str, int *pint)
Definition shared.c:515
bool make_dir(const char *pathname, int mode)
Definition shared.c:1779
char * freeciv_storage_dir(void)
Definition shared.c:671
#define DIR_SEPARATOR
Definition shared.h:127
#define DIR_SEPARATOR_CHAR
Definition shared.h:128
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define DIRMODE_DEFAULT
Definition shared.h:258
#define MAX(x, y)
Definition shared.h:54
size_t size
Definition specvec.h:72
void strvec_destroy(struct strvec *psv)
bool strvec_set(struct strvec *psv, size_t svindex, const char *string)
void strvec_append(struct strvec *psv, const char *string)
void strvec_reserve(struct strvec *psv, size_t reserve)
const char * strvec_get(const struct strvec *psv, size_t svindex)
struct strvec * strvec_new(void)
size_t strvec_size(const struct strvec *psv)
struct connection conn
Definition client_main.h:96
const int def
Definition options.c:1455
struct client_option::@214::@221 font
const unsigned def
Definition options.c:1478
struct client_option::@214::@217 integer
enum gui_type specific
Definition options.c:1444
const char * description
Definition options.c:1441
const char *const def
Definition options.c:1461
struct ft_color *const pvalue
Definition options.c:1491
struct video_mode *const pvalue
Definition options.c:1496
const size_t size
Definition options.c:1460
char *const pvalue
Definition options.c:1459
struct client_option::@214::@218 string
const int max
Definition options.c:1455
const bool def
Definition options.c:1450
const char *const target
Definition options.c:1487
bool *const pvalue
Definition options.c:1449
struct option base_option
Definition options.c:1438
const char * help_text
Definition options.c:1442
unsigned *const pvalue
Definition options.c:1477
enum client_option_category category
Definition options.c:1443
int *const pvalue
Definition options.c:1454
const char * name
Definition options.c:1440
bool gui_gtk3_22_migrated_from_gtk3
Definition options.h:134
bool gui_gtk2_migrated_from_2_5
Definition options.h:138
bool gui_sdl2_migrated_from_sdl
Definition options.h:136
bool sound_enable_menu_music
Definition options.h:188
char default_tileset_hex_name[512]
Definition options.h:117
bool gui_qt_show_relations_panel
Definition options.h:428
char default_tileset_iso_name[512]
Definition options.h:132
bool gui_qt_show_techs_panel
Definition options.h:429
char default_tileset_name[512]
Definition options.h:130
bool send_desired_settings
Definition options.h:113
char default_tileset_overhead_name[512]
Definition options.h:131
bool gui_gtk3_migrated_from_2_5
Definition options.h:139
int default_topology
Definition options.h:123
char default_tileset_square_name[512]
Definition options.h:116
bool save_options_on_exit
Definition options.h:125
int sound_effects_volume
Definition options.h:190
bool ai_manual_turn_done
Definition options.h:154
bool gui_sdl2_default_screen_size_set
Definition options.h:142
bool gui_sdl3_default_screen_size_set
Definition options.h:143
int smooth_combat_step_msec
Definition options.h:153
bool first_boot
Definition options.h:128
float zoom_default_level
Definition options.h:231
char default_tileset_isohex_name[512]
Definition options.h:118
bool gui_qt_migrated_from_2_5
Definition options.h:140
bool popup_actor_arrival
Definition options.h:168
bool gui_sdl3_migrated_from_sdl2
Definition options.h:137
bool gui_qt_show_wonders_panel
Definition options.h:430
bool sound_enable_game_music
Definition options.h:189
bool migrate_fullscreen
Definition options.h:145
bool gui_qt_default_fonts_set
Definition options.h:141
bool gui_gtk3_migrated_from_gtk2
Definition options.h:133
char default_user_name[512]
Definition options.h:108
bool gui_gtk4_migrated_from_gtk3_22
Definition options.h:135
bool allow_disorder
Definition cm.h:44
int factor[O_LAST]
Definition cm.h:47
bool allow_specialists
Definition cm.h:45
bool require_happy
Definition cm.h:43
int minimal_surplus[O_LAST]
Definition cm.h:41
int happy_factor
Definition cm.h:48
Definition colors.h:21
const char * support
Definition options.c:1294
const char * pretty
Definition options.c:1296
int(* number)(const struct option *)
Definition options.c:498
int(* category)(const struct option *)
Definition options.c:502
bool(* is_changeable)(const struct option *)
Definition options.c:503
struct option *(* option_by_number)(int)
Definition options.c:421
struct option *(* option_first)(void)
Definition options.c:422
const char *(* category_name)(int)
Definition options.c:425
int(* category_number)(void)
Definition options.c:424
const struct option::option_common_vtable * common_vtable
const struct option::@212::option_font_vtable * font_vtable
const struct option::@212::option_str_vtable * str_vtable
const struct option::@212::option_enum_vtable * enum_vtable
const struct option::@212::option_video_mode_vtable * video_mode_vtable
const struct option::@212::option_bitwise_vtable * bitwise_vtable
enum option_type type
Definition options.c:494
const struct option_set * poptset
Definition options.c:492
const struct option::@212::option_bool_vtable * bool_vtable
int callback_data
Definition options.c:568
const struct option::@212::option_int_vtable * int_vtable
void(* changed_callback)(struct option *option)
Definition options.c:566
void * gui_data
Definition options.c:571
const struct option::@212::option_color_vtable * color_vtable
bool fog
Definition options.h:102
bool layers[OLAYER_COUNT]
Definition options.h:103
char support_names[64][MAX_LEN_NAME]
char pretty_names[64][MAX_LEN_ENUM]
char name[MAX_LEN_NAME]
char short_help[MAX_LEN_PACKET]
char extra_help[MAX_LEN_PACKET]
char category_names[256][MAX_LEN_NAME]
char pretty_names[64][MAX_LEN_ENUM]
char support_names[64][MAX_LEN_NAME]
char default_val[MAX_LEN_PACKET]
char val[MAX_LEN_PACKET]
bool allow_digital_boolean
struct strvec * support_names
Definition options.c:4200
unsigned value
Definition options.c:4205
char * help_text
Definition options.c:4173
char * name
Definition options.c:4171
bool is_visible
Definition options.c:4177
char * description
Definition options.c:4172
unsigned char category
Definition options.c:4174
struct strvec * pretty_names
Definition options.c:4201
enum setting_default_level setdef
Definition options.c:4178
unsigned def
Definition options.c:4206
bool is_changeable
Definition options.c:4176
struct server_option::@224::@227 integer
char * value
Definition options.c:4193
struct option base_option
Definition options.c:4169
bool desired_sent
Definition options.c:4175
int height
Definition options.h:48
int width
Definition options.h:47
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:777
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
size_t fc_strlcat(char *dest, const char *src, size_t n)
Definition support.c:822
int fc_stat(const char *filename, struct stat *buf)
Definition support.c:574
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define bool
Definition support.h:71
#define fc_strncmp(_s1_, _s2_, _len_)
Definition support.h:160
void theme_reread_callback(struct option *poption)
const struct strvec * get_themes_list(const struct option *poption)
bool tilespec_try_read(const char *tileset_name, bool verbose, int topo_id, bool global_default)
Definition tilespec.c:1360
const struct strvec * get_tileset_list(const struct option *poption)
Definition tilespec.c:1150
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:730
void tilespec_reread_callback(struct option *poption)
Definition tilespec.c:1555
int tileset_topo_index(struct tileset *t)
Definition tilespec.c:7808
#define TS_TOPO_ISOHEX
Definition tilespec.h:455
#define TS_TOPO_HEX
Definition tilespec.h:454
#define TS_TOPO_SQUARE
Definition tilespec.h:453