Freeciv-3.2
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 "capability.h"
25#include "deprecations.h"
26#include "fcintl.h"
27#include "ioz.h"
28#include "log.h"
29#include "mem.h"
30#include "registry.h"
31#include "shared.h"
32#include "string_vector.h"
33#include "support.h"
34
35/* common */
36#include "events.h"
37#include "version.h"
38
39/* client/agents */
40#include "cma_fec.h"
41
42/* client/include */
43#include "chatline_g.h"
44#include "dialogs_g.h"
45#include "gui_main_g.h"
46#include "menu_g.h"
47#include "optiondlg_g.h"
48#include "repodlgs_g.h"
49#include "voteinfo_bar_g.h"
50
51/* client */
52#include "audio.h"
53#include "cityrepdata.h"
54#include "client_main.h"
55#include "climisc.h"
56#include "connectdlg_common.h"
57#include "global_worklist.h"
58#include "mapctrl_common.h"
59#include "mapview_common.h"
60#include "music.h"
61#include "overview_common.h"
62#include <packhand_gen.h> /* <> so looked from the build directory first. */
63#include "plrdlg_common.h"
64#include "repodlgs_common.h"
65#include "servers.h"
66#include "themes_common.h"
67#include "tilespec.h"
68
69#include "options.h"
70
71
75 .default_user_name = "\0",
76 .default_server_host = "localhost",
77 .default_server_port = DEFAULT_SOCK_PORT,
78 .default_metaserver = DEFAULT_METASERVER_OPTION,
79 .default_tileset_square_name = "\0",
80 .default_tileset_hex_name = "\0",
81 .default_tileset_isohex_name = "\0",
82 .default_sound_set_name = "stdsounds",
83 .default_music_set_name = "stdmusic",
84 .default_sound_plugin_name = "\0",
85 .default_chat_logfile = GUI_DEFAULT_CHAT_LOGFILE,
86 .default_topology = TS_TOPO_ISOHEX,
87
88 .followtag_override = DEFAULT_FOLLOWTAG_OPTION,
89
90 .save_options_on_exit = TRUE,
91
92 .use_prev_server = FALSE,
93 .heartbeat_enabled = FALSE,
94 .send_desired_settings = TRUE,
95
97 .first_boot = FALSE,
98 .default_tileset_name = "\0",
99 .default_tileset_overhead_name = "\0",
100 .default_tileset_iso_name = "\0",
101 .gui_gtk3_migrated_from_gtk2 = FALSE,
102 .gui_gtk3_22_migrated_from_gtk3 = FALSE,
103 .gui_gtk4_migrated_from_gtk3_22 = FALSE,
104 .gui_sdl2_migrated_from_sdl = FALSE,
105 .gui_sdl3_migrated_from_sdl2 = FALSE,
106 .gui_gtk2_migrated_from_2_5 = FALSE,
107 .gui_gtk3_migrated_from_2_5 = FALSE,
108 .gui_qt_migrated_from_2_5 = FALSE,
109
110 .migrate_fullscreen = FALSE,
111
114 .gui_qt_default_fonts_set = FALSE,
115 .gui_sdl2_default_screen_size_set = FALSE,
116 .gui_sdl3_default_screen_size_set = FALSE,
117
120 .solid_color_behind_units = FALSE,
121 .sound_bell_at_new_turn = FALSE,
122 .smooth_move_unit_msec = 30,
123 .smooth_center_slide_msec = 200,
124 .smooth_combat_step_msec = 10,
125 .ai_manual_turn_done = TRUE,
126 .auto_center_on_unit = TRUE,
127 .auto_center_on_automated = TRUE,
128 .auto_center_on_combat = FALSE,
129 .auto_center_each_turn = TRUE,
130 .wakeup_focus = TRUE,
131 .goto_into_unknown = TRUE,
132 .center_when_popup_city = TRUE,
133 .show_previous_turn_messages = TRUE,
134 .concise_city_production = FALSE,
135 .auto_turn_done = FALSE,
136 .meta_accelerators = TRUE,
137 .ask_city_name = TRUE,
138 .popup_new_cities = TRUE,
139 .popup_actor_arrival = TRUE,
140 .popup_attack_actions = TRUE,
141 .popup_last_move_to_allied = TRUE,
142 .keyboardless_goto = TRUE,
143 .enable_cursor_changes = TRUE,
144 .separate_unit_selection = FALSE,
145 .unit_selection_clears_orders = TRUE,
146 .highlight_our_names = FT_COLOR("#000000", "#FFFF00"),
147
148 .voteinfo_bar_use = TRUE,
149 .voteinfo_bar_always_show = FALSE,
150 .voteinfo_bar_hide_when_not_player = FALSE,
151 .voteinfo_bar_new_at_front = FALSE,
152
153 .autoaccept_tileset_suggestion = FALSE,
154 .autoaccept_soundset_suggestion = FALSE,
155 .autoaccept_musicset_suggestion = FALSE,
156
157 .sound_enable_effects = TRUE,
158 .sound_enable_menu_music = TRUE,
159 .sound_enable_game_music = TRUE,
160 .sound_effects_volume = 100,
161 .silent_when_not_in_focus = FALSE,
162
163 /* This option is currently set by the client - not by the user. */
164 .update_city_text_in_refresh_tile = TRUE,
165
166 .draw_city_outlines = TRUE,
167 .draw_city_output = FALSE,
168 .draw_map_grid = FALSE,
169 .draw_city_names = TRUE,
170 .draw_city_growth = TRUE,
171 .draw_city_productions = TRUE,
172 .draw_city_buycost = FALSE,
173 .draw_city_trade_routes = FALSE,
174 .draw_terrain = TRUE,
175 .draw_coastline = FALSE,
176 .draw_paths = TRUE,
177 .draw_irrigation = TRUE,
178 .draw_mines = TRUE,
179 .draw_fortress_airbase = TRUE,
180 .draw_specials = TRUE,
181 .draw_huts = TRUE,
182 .draw_pollution = TRUE,
183 .draw_cities = TRUE,
184 .draw_units = TRUE,
185 .draw_focus_unit = FALSE,
186 .draw_fog_of_war = TRUE,
187 .draw_borders = TRUE,
188 .draw_native = FALSE,
189 .draw_full_citybar = TRUE,
190 .draw_unit_shields = TRUE,
191 .draw_unit_stack_size = TRUE,
192 .player_dlg_show_dead_players = TRUE,
193 .reqtree_show_icons = TRUE,
194 .reqtree_curved_lines = FALSE,
195
196/* Options for map images */
197/* .mapimg_format, */
198 .mapimg_zoom = 2,
199/* See the definition of MAPIMG_LAYER in mapimg.h. */
200 .mapimg_layer = {
201 FALSE, /* a - MAPIMG_LAYER_AREA */
202 TRUE, /* b - MAPIMG_LAYER_BORDERS */
203 TRUE, /* c - MAPIMG_LAYER_CITIES */
204 TRUE, /* f - MAPIMG_LAYER_FOGOFWAR */
205 TRUE, /* k - MAPIMG_LAYER_KNOWLEDGE */
206 TRUE, /* t - MAPIMG_LAYER_TERRAIN */
207 TRUE /* u - MAPIMG_LAYER_UNITS */
208 },
209/* .mapimg_filename, */
210
211 .zoom_set = FALSE,
212 .zoom_default_level = 1.0,
213
214/* gui-gtk-2.0 client specific options.
215 * These are still kept just so users can migrate them to gtk3-client */
216 .gui_gtk2_map_scrollbars = FALSE,
217 .gui_gtk2_dialogs_on_top = TRUE,
218 .gui_gtk2_show_task_icons = TRUE,
219 .gui_gtk2_enable_tabs = TRUE,
220 .gui_gtk2_better_fog = TRUE,
221 .gui_gtk2_show_chat_message_time = FALSE,
222 .gui_gtk2_new_messages_go_to_top = FALSE,
223 .gui_gtk2_show_message_window_buttons = TRUE,
224 .gui_gtk2_metaserver_tab_first = FALSE,
225 .gui_gtk2_allied_chat_only = FALSE,
226 .gui_gtk2_mouse_over_map_focus = FALSE,
227 .gui_gtk2_chatline_autocompletion = TRUE,
228 .gui_gtk2_citydlg_xsize = GUI_GTK2_CITYDLG_DEFAULT_XSIZE,
229 .gui_gtk2_citydlg_ysize = GUI_GTK2_CITYDLG_DEFAULT_YSIZE,
230 .gui_gtk2_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
231 .gui_gtk2_font_city_label = "Monospace 8",
232 .gui_gtk2_font_notify_label = "Monospace Bold 9",
233 .gui_gtk2_font_spaceship_label = "Monospace 8",
234 .gui_gtk2_font_help_label = "Sans Bold 10",
235 .gui_gtk2_font_help_link = "Sans 9",
236 .gui_gtk2_font_help_text = "Monospace 8",
237 .gui_gtk2_font_chatline = "Monospace 8",
238 .gui_gtk2_font_beta_label = "Sans Italic 10",
239 .gui_gtk2_font_small = "Sans 9",
240 .gui_gtk2_font_comment_label = "Sans Italic 9",
241 .gui_gtk2_font_city_names = "Sans Bold 10",
242 .gui_gtk2_font_city_productions = "Serif 10",
243 .gui_gtk2_font_reqtree_text = "Serif 10",
244
245/* gui-gtk-3.0 client specific options. */
246 .gui_gtk3_fullscreen = FALSE,
247 .gui_gtk3_map_scrollbars = FALSE,
248 .gui_gtk3_dialogs_on_top = TRUE,
249 .gui_gtk3_show_task_icons = TRUE,
250 .gui_gtk3_enable_tabs = TRUE,
251 .gui_gtk3_show_chat_message_time = FALSE,
252 .gui_gtk3_new_messages_go_to_top = FALSE,
253 .gui_gtk3_show_message_window_buttons = TRUE,
254 .gui_gtk3_metaserver_tab_first = FALSE,
255 .gui_gtk3_allied_chat_only = FALSE,
256 .gui_gtk3_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
257 .gui_gtk3_small_display_layout = FALSE,
258 .gui_gtk3_mouse_over_map_focus = FALSE,
259 .gui_gtk3_chatline_autocompletion = TRUE,
260 .gui_gtk3_citydlg_xsize = GUI_GTK3_CITYDLG_DEFAULT_XSIZE,
261 .gui_gtk3_citydlg_ysize = GUI_GTK3_CITYDLG_DEFAULT_YSIZE,
262 .gui_gtk3_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
263 .gui_gtk3_governor_range_min = -20,
264 .gui_gtk3_governor_range_max = 20,
265 .gui_gtk3_font_city_label = "Monospace 8",
266 .gui_gtk3_font_notify_label = "Monospace Bold 9",
267 .gui_gtk3_font_spaceship_label = "Monospace 8",
268 .gui_gtk3_font_help_label = "Sans Bold 10",
269 .gui_gtk3_font_help_link = "Sans 9",
270 .gui_gtk3_font_help_text = "Monospace 8",
271 .gui_gtk3_font_chatline = "Monospace 8",
272 .gui_gtk3_font_beta_label = "Sans Italic 10",
273 .gui_gtk3_font_small = "Sans 9",
274 .gui_gtk3_font_comment_label = "Sans Italic 9",
275 .gui_gtk3_font_city_names = "Sans Bold 10",
276 .gui_gtk3_font_city_productions = "Serif 10",
277 .gui_gtk3_font_reqtree_text = "Serif 10",
278
279/* gui-gtk-3.22 client specific options. */
280 .gui_gtk3_22_default_theme_name = FC_GTK3_22_DEFAULT_THEME_NAME,
281 .gui_gtk3_22_fullscreen = FALSE,
282 .gui_gtk3_22_map_scrollbars = FALSE,
283 .gui_gtk3_22_dialogs_on_top = TRUE,
284 .gui_gtk3_22_show_task_icons = TRUE,
285 .gui_gtk3_22_enable_tabs = TRUE,
286 .gui_gtk3_22_show_chat_message_time = FALSE,
287 .gui_gtk3_22_new_messages_go_to_top = FALSE,
288 .gui_gtk3_22_show_message_window_buttons = TRUE,
289 .gui_gtk3_22_metaserver_tab_first = FALSE,
290 .gui_gtk3_22_allied_chat_only = FALSE,
291 .gui_gtk3_22_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
292 .gui_gtk3_22_small_display_layout = FALSE,
293 .gui_gtk3_22_mouse_over_map_focus = FALSE,
294 .gui_gtk3_22_chatline_autocompletion = TRUE,
295 .gui_gtk3_22_citydlg_xsize = GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE,
296 .gui_gtk3_22_citydlg_ysize = GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE,
297 .gui_gtk3_22_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
298 .gui_gtk3_22_governor_range_min = -20,
299 .gui_gtk3_22_governor_range_max = 20,
300 .gui_gtk3_22_font_city_label = "Monospace 8",
301 .gui_gtk3_22_font_notify_label = "Monospace Bold 9",
302 .gui_gtk3_22_font_spaceship_label = "Monospace 8",
303 .gui_gtk3_22_font_help_label = "Sans Bold 10",
304 .gui_gtk3_22_font_help_link = "Sans 9",
305 .gui_gtk3_22_font_help_text = "Monospace 8",
306 .gui_gtk3_22_font_chatline = "Monospace 8",
307 .gui_gtk3_22_font_beta_label = "Sans Italic 10",
308 .gui_gtk3_22_font_small = "Sans 9",
309 .gui_gtk3_22_font_comment_label = "Sans Italic 9",
310 .gui_gtk3_22_font_city_names = "Sans Bold 10",
311 .gui_gtk3_22_font_city_productions = "Serif 10",
312 .gui_gtk3_22_font_reqtree_text = "Serif 10",
313
314/* gui-gtk-4.0 client specific options. */
315 .gui_gtk4_default_theme_name = FC_GTK4_DEFAULT_THEME_NAME,
316 .gui_gtk4_fullscreen = FALSE,
317 .gui_gtk4_map_scrollbars = FALSE,
318 .gui_gtk4_dialogs_on_top = TRUE,
319 .gui_gtk4_show_task_icons = TRUE,
320 .gui_gtk4_enable_tabs = TRUE,
321 .gui_gtk4_show_chat_message_time = FALSE,
322 .gui_gtk4_new_messages_go_to_top = FALSE,
323 .gui_gtk4_show_message_window_buttons = TRUE,
324 .gui_gtk4_metaserver_tab_first = FALSE,
325 .gui_gtk4_allied_chat_only = FALSE,
326 .gui_gtk4_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
327 .gui_gtk4_small_display_layout = FALSE,
328 .gui_gtk4_mouse_over_map_focus = FALSE,
329 .gui_gtk4_chatline_autocompletion = TRUE,
330 .gui_gtk4_citydlg_xsize = GUI_GTK4_CITYDLG_DEFAULT_XSIZE,
331 .gui_gtk4_citydlg_ysize = GUI_GTK4_CITYDLG_DEFAULT_YSIZE,
332 .gui_gtk4_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
333 .gui_gtk4_governor_range_min = -20,
334 .gui_gtk4_governor_range_max = 20,
335 .gui_gtk4_font_city_label = "Monospace 8",
336 .gui_gtk4_font_notify_label = "Monospace Bold 9",
337 .gui_gtk4_font_spaceship_label = "Monospace 8",
338 .gui_gtk4_font_help_label = "Sans Bold 10",
339 .gui_gtk4_font_help_link = "Sans 9",
340 .gui_gtk4_font_help_text = "Monospace 8",
341 .gui_gtk4_font_chatline = "Monospace 8",
342 .gui_gtk4_font_beta_label = "Sans Italic 10",
343 .gui_gtk4_font_small = "Sans 9",
344 .gui_gtk4_font_comment_label = "Sans Italic 9",
345 .gui_gtk4_font_city_names = "Sans Bold 10",
346 .gui_gtk4_font_city_productions = "Serif 10",
347 .gui_gtk4_font_reqtree_text = "Serif 10",
348
349/* gui-sdl client specific options. */
350 .gui_sdl_fullscreen = FALSE,
351 .gui_sdl_screen = VIDEO_MODE(640, 480),
352 .gui_sdl_do_cursor_animation = TRUE,
353 .gui_sdl_use_color_cursors = TRUE,
354
355/* gui-sdl2 client specific options. */
356 .gui_sdl2_default_theme_name = FC_SDL2_DEFAULT_THEME_NAME,
357 .gui_sdl2_fullscreen = FALSE,
358 .gui_sdl2_screen = VIDEO_MODE(640, 480),
359 .gui_sdl2_swrenderer = FALSE,
360 .gui_sdl2_do_cursor_animation = TRUE,
361 .gui_sdl2_use_color_cursors = TRUE,
362 .gui_sdl2_font_city_names = "10",
363 .gui_sdl2_font_city_productions = "10",
364 .gui_sdl2_use_theme_font_size = TRUE,
365 .gui_sdl2_font_size = 10,
366
367/* gui-sdl3 client specific options. */
368 .gui_sdl3_default_theme_name = FC_SDL2_DEFAULT_THEME_NAME,
369 .gui_sdl3_fullscreen = FALSE,
370 .gui_sdl3_screen = VIDEO_MODE(640, 480),
371 .gui_sdl3_do_cursor_animation = TRUE,
372 .gui_sdl3_use_color_cursors = TRUE,
373 .gui_sdl3_font_city_names = "10",
374 .gui_sdl3_font_city_productions = "10",
375 .gui_sdl3_use_theme_font_size = TRUE,
376 .gui_sdl3_font_size = 10,
377
378/* gui-qt client specific options. */
379 .gui_qt_fullscreen = FALSE,
380 .gui_qt_show_preview = TRUE,
381 .gui_qt_sidebar_left = TRUE,
382 .gui_qt_default_theme_name = FC_QT_DEFAULT_THEME_NAME,
383 .gui_qt_font_default = "Sans Serif,10,-1,5,75,0,0,0,0,0",
384 .gui_qt_font_notify_label = "Monospace,8,-1,5,75,0,0,0,0,0",
385 .gui_qt_font_help_label = "Sans Serif,9,-1,5,50,0,0,0,0,0",
386 .gui_qt_font_help_text = "Monospace,8,-1,5,50,0,0,0,0,0",
387 .gui_qt_font_chatline = "Monospace,8,-1,5,50,0,0,0,0,0",
388 .gui_qt_font_city_names = "Sans Serif,10,-1,5,75,0,0,0,0,0",
389 .gui_qt_font_city_productions = "Sans Serif,10,-1,5,50,1,0,0,0,0",
390 .gui_qt_font_reqtree_text = "Sans Serif,10,-1,5,50,1,0,0,0,0",
391 .gui_qt_show_titlebar = TRUE,
392 .gui_qt_wakeup_text = "Wake up %1",
393 .gui_qt_show_relations_panel = TRUE,
394 .gui_qt_show_techs_panel = TRUE,
395 .gui_qt_show_wonders_panel = TRUE,
396 .gui_qt_svgflags = TRUE
397};
398
399/* Set to TRUE after the first call to options_init(), to avoid the usage
400 * of non-initialized datas when calling the changed callback. */
402
403static int sync_serial = 0;
404static int reply_serial = 0;
405static bool queue_save = FALSE;
407
408static const struct strvec *get_mapimg_format_list(const struct option *poption);
409
410/****************************************************************************
411 Option set structure.
412****************************************************************************/
414 struct option * (*option_by_number) (int);
415 struct option * (*option_first) (void);
416
418 const char * (*category_name) (int);
419};
420
421/************************************************************************/
425 int id)
426{
428
429 return poptset->option_by_number(id);
430}
431
432/************************************************************************/
436 const char *name)
437{
439
441 if (0 == strcmp(option_name(poption), name)) {
442 return poption;
443 }
445 return NULL;
446}
447
448/************************************************************************/
452{
454
455 return poptset->option_first();
456}
457
458/************************************************************************/
462{
464
465 return poptset->category_number();
466}
467
468/************************************************************************/
471const char *optset_category_name(const struct option_set *poptset,
472 int category)
473{
475
476 return poptset->category_name(category);
477}
478
479
480/****************************************************************************
481 The base class for options.
482****************************************************************************/
483struct option {
484 /* A link to the option set. */
485 const struct option_set *poptset;
486 /* Type of the option. */
488
489 /* Common accessors. */
490 const struct option_common_vtable {
491 int (*number) (const struct option *);
492 const char * (*name) (const struct option *);
493 const char * (*description) (const struct option *);
494 const char * (*help_text) (const struct option *);
495 int (*category) (const struct option *);
496 bool (*is_changeable) (const struct option *);
497 struct option * (*next) (const struct option *);
499 /* Specific typed accessors. */
500 union {
501 /* Specific boolean accessors (OT_BOOLEAN == type). */
502 const struct option_bool_vtable {
503 bool (*get) (const struct option *);
504 bool (*def) (const struct option *);
505 bool (*set) (struct option *, bool);
507 /* Specific integer accessors (OT_INTEGER == type). */
508 const struct option_int_vtable {
509 int (*get) (const struct option *);
510 int (*def) (const struct option *);
511 int (*minimum) (const struct option *);
512 int (*maximum) (const struct option *);
513 bool (*set) (struct option *, int);
515 /* Specific string accessors (OT_STRING == type). */
516 const struct option_str_vtable {
517 const char * (*get) (const struct option *);
518 const char * (*def) (const struct option *);
519 const struct strvec * (*values) (const struct option *);
520 bool (*set) (struct option *, const char *);
522 /* Specific enum accessors (OT_ENUM == type). */
523 const struct option_enum_vtable {
524 int (*get) (const struct option *);
525 int (*def) (const struct option *);
526 const struct strvec * (*values) (const struct option *);
527 bool (*set) (struct option *, int);
528 int (*cmp) (const char *, const char *);
530 /* Specific bitwise accessors (OT_BITWISE == type). */
531 const struct option_bitwise_vtable {
532 unsigned (*get) (const struct option *);
533 unsigned (*def) (const struct option *);
534 const struct strvec * (*values) (const struct option *);
535 bool (*set) (struct option *, unsigned);
537 /* Specific font accessors (OT_FONT == type). */
538 const struct option_font_vtable {
539 const char * (*get) (const struct option *);
540 const char * (*def) (const struct option *);
541 const char * (*target) (const struct option *);
542 bool (*set) (struct option *, const char *);
544 /* Specific color accessors (OT_COLOR == type). */
545 const struct option_color_vtable {
546 struct ft_color (*get) (const struct option *);
547 struct ft_color (*def) (const struct option *);
548 bool (*set) (struct option *, struct ft_color);
550 /* Specific video mode accessors (OT_VIDEO_MODE == type). */
551 const struct option_video_mode_vtable {
552 struct video_mode (*get) (const struct option *);
553 struct video_mode (*def) (const struct option *);
554 bool (*set) (struct option *, struct video_mode);
556 };
557
558 /* Called after the value changed. */
560
562
563 /* Volatile. */
564 void *gui_data;
565};
566
567#define OPTION(poption) ((struct option *) (poption))
568
569#define OPTION_INIT(optset, spec_type, spec_table_var, common_table, \
570 spec_table, changed_cb, cb_data) { \
571 .poptset = optset, \
572 .type = spec_type, \
573 .common_vtable = &common_table, \
574 INIT_BRACE_BEGIN \
575 .spec_table_var = &spec_table \
576 INIT_BRACE_END, \
577 .changed_callback = changed_cb, \
578 .callback_data = cb_data, \
579 .gui_data = NULL \
580}
581#define OPTION_BOOL_INIT(optset, common_table, bool_table, changed_cb) \
582 OPTION_INIT(optset, OT_BOOLEAN, bool_vtable, common_table, bool_table, \
583 changed_cb, 0)
584#define OPTION_INT_INIT(optset, common_table, int_table, changed_cb) \
585 OPTION_INIT(optset, OT_INTEGER, int_vtable, common_table, int_table, \
586 changed_cb, 0)
587#define OPTION_STR_INIT(optset, common_table, str_table, changed_cb, cb_data) \
588 OPTION_INIT(optset, OT_STRING, str_vtable, common_table, str_table, \
589 changed_cb, cb_data)
590#define OPTION_ENUM_INIT(optset, common_table, enum_table, changed_cb) \
591 OPTION_INIT(optset, OT_ENUM, enum_vtable, common_table, enum_table, \
592 changed_cb, 0)
593#define OPTION_BITWISE_INIT(optset, common_table, bitwise_table, \
594 changed_cb) \
595 OPTION_INIT(optset, OT_BITWISE, bitwise_vtable, common_table, \
596 bitwise_table, changed_cb, 0)
597#define OPTION_FONT_INIT(optset, common_table, font_table, changed_cb) \
598 OPTION_INIT(optset, OT_FONT, font_vtable, common_table, font_table, \
599 changed_cb, 0)
600#define OPTION_COLOR_INIT(optset, common_table, color_table, changed_cb) \
601 OPTION_INIT(optset, OT_COLOR, color_vtable, common_table, color_table, \
602 changed_cb, 0)
603#define OPTION_VIDEO_MODE_INIT(optset, common_table, video_mode_table, \
604 changed_cb) \
605 OPTION_INIT(optset, OT_VIDEO_MODE, video_mode_vtable, common_table, \
606 video_mode_table, changed_cb, 0)
607
608
609/************************************************************************/
612const struct option_set *option_optset(const struct option *poption)
613{
615
616 return poption->poptset;
617}
618
619/************************************************************************/
622int option_number(const struct option *poption)
623{
625
626 return poption->common_vtable->number(poption);
627}
628
629/************************************************************************/
632const char *option_name(const struct option *poption)
633{
635
636 return poption->common_vtable->name(poption);
637}
638
639/************************************************************************/
642const char *option_description(const struct option *poption)
643{
645
646 return poption->common_vtable->description(poption);
647}
648
649/************************************************************************/
652const char *option_help_text(const struct option *poption)
653{
655
656 return poption->common_vtable->help_text(poption);
657}
658
659/************************************************************************/
663{
665
666 return poption->type;
667}
668
669/************************************************************************/
673{
675
676 return poption->common_vtable->category(poption);
677}
678
679/************************************************************************/
682const char *option_category_name(const struct option *poption)
683{
685
686 return optset_category_name(poption->poptset,
687 poption->common_vtable->category(poption));
688}
689
690/************************************************************************/
694{
696
697 return poption->common_vtable->is_changeable(poption);
698}
699
700/************************************************************************/
703struct option *option_next(const struct option *poption)
704{
706
707 return poption->common_vtable->next(poption);
708}
709
710/************************************************************************/
737
738/************************************************************************/
742 void (*callback) (struct option *))
743{
745
746 poption->changed_callback = callback;
747}
748
749/************************************************************************/
753{
755
757 /* Prevent to use non-initialized datas. */
758 return;
759 }
760
761 if (poption->changed_callback) {
762 poption->changed_callback(poption);
763 }
764
766}
767
768/************************************************************************/
771void option_set_gui_data(struct option *poption, void *data)
772{
774
775 poption->gui_data = data;
776}
777
778/************************************************************************/
782{
784
785 return poption->gui_data;
786}
787
788/************************************************************************/
792{
794
795 return poption->callback_data;
796}
797
798/************************************************************************/
801bool option_bool_get(const struct option *poption)
802{
805
806 return poption->bool_vtable->get(poption);
807}
808
809/************************************************************************/
812bool option_bool_def(const struct option *poption)
813{
816
817 return poption->bool_vtable->def(poption);
818}
819
820/************************************************************************/
823bool option_bool_set(struct option *poption, bool val)
824{
827
828 if (poption->bool_vtable->set(poption, val)) {
830 return TRUE;
831 }
832 return FALSE;
833}
834
835/************************************************************************/
838int option_int_get(const struct option *poption)
839{
842
843 return poption->int_vtable->get(poption);
844}
845
846/************************************************************************/
849int option_int_def(const struct option *poption)
850{
853
854 return poption->int_vtable->def(poption);
855}
856
857/************************************************************************/
860int option_int_min(const struct option *poption)
861{
864
865 return poption->int_vtable->minimum(poption);
866}
867
868/************************************************************************/
871int option_int_max(const struct option *poption)
872{
875
876 return poption->int_vtable->maximum(poption);
877}
878
879/************************************************************************/
882bool option_int_set(struct option *poption, int val)
883{
886
887 if (poption->int_vtable->set(poption, val)) {
889 return TRUE;
890 }
891 return FALSE;
892}
893
894/************************************************************************/
897const char *option_str_get(const struct option *poption)
898{
901
902 return poption->str_vtable->get(poption);
903}
904
905/************************************************************************/
908const char *option_str_def(const struct option *poption)
909{
912
913 return poption->str_vtable->def(poption);
914}
915
916/************************************************************************/
919const struct strvec *option_str_values(const struct option *poption)
920{
923
924 return poption->str_vtable->values(poption);
925}
926
927/************************************************************************/
930bool option_str_set(struct option *poption, const char *str)
931{
935
936 if (poption->str_vtable->set(poption, str)) {
938 return TRUE;
939 }
940 return FALSE;
941}
942
943/************************************************************************/
947int option_enum_str_to_int(const struct option *poption, const char *str)
948{
949 const struct strvec *values;
950 int val;
951
953 fc_assert_ret_val(OT_ENUM == poption->type, -1);
954 values = poption->enum_vtable->values(poption);
955 fc_assert_ret_val(NULL != values, -1);
956
957 for (val = 0; val < strvec_size(values); val++) {
958 if (0 == poption->enum_vtable->cmp(strvec_get(values, val), str)) {
959 return val;
960 }
961 }
962 return -1;
963}
964
965/************************************************************************/
969const char *option_enum_int_to_str(const struct option *poption, int val)
970{
971 const struct strvec *values;
972
975 values = poption->enum_vtable->values(poption);
976 fc_assert_ret_val(NULL != values, NULL);
977
978 return strvec_get(values, val);
979}
980
981/************************************************************************/
985{
987 fc_assert_ret_val(OT_ENUM == poption->type, -1);
988
989 return poption->enum_vtable->get(poption);
990}
991
992/************************************************************************/
996const char *option_enum_get_str(const struct option *poption)
997{
1000
1001 return strvec_get(poption->enum_vtable->values(poption),
1002 poption->enum_vtable->get(poption));
1003}
1004
1005/************************************************************************/
1009{
1011 fc_assert_ret_val(OT_ENUM == poption->type, -1);
1012
1013 return poption->enum_vtable->def(poption);
1014}
1015
1016/************************************************************************/
1020const char *option_enum_def_str(const struct option *poption)
1021{
1024
1025 return strvec_get(poption->enum_vtable->values(poption),
1026 poption->enum_vtable->def(poption));
1027}
1028
1029/************************************************************************/
1033const struct strvec *option_enum_values(const struct option *poption)
1034{
1037
1038 return poption->enum_vtable->values(poption);
1039}
1040
1041/************************************************************************/
1044bool option_enum_set_int(struct option *poption, int val)
1045{
1048
1049 if (poption->enum_vtable->set(poption, val)) {
1051 return TRUE;
1052 }
1053 return FALSE;
1054}
1055
1056/************************************************************************/
1061bool option_enum_set_str(struct option *poption, const char *str)
1062{
1066
1067 if (poption->enum_vtable->set(poption,
1070 return TRUE;
1071 }
1072 return FALSE;
1073}
1074
1075/************************************************************************/
1078unsigned option_bitwise_get(const struct option *poption)
1079{
1082
1083 return poption->bitwise_vtable->get(poption);
1084}
1085
1086/************************************************************************/
1089unsigned option_bitwise_def(const struct option *poption)
1090{
1093
1094 return poption->bitwise_vtable->def(poption);
1095}
1096
1097/************************************************************************/
1100unsigned option_bitwise_mask(const struct option *poption)
1101{
1102 const struct strvec *values;
1103
1106
1107 values = poption->bitwise_vtable->values(poption);
1108 fc_assert_ret_val(NULL != values, 0);
1109
1110 return (1 << strvec_size(values)) - 1;
1111}
1112
1113/************************************************************************/
1117const struct strvec *option_bitwise_values(const struct option *poption)
1118{
1121
1122 return poption->bitwise_vtable->values(poption);
1123}
1124
1125/************************************************************************/
1128bool option_bitwise_set(struct option *poption, unsigned val)
1129{
1132
1133 if (0 != (val & ~option_bitwise_mask(poption))
1134 || !poption->bitwise_vtable->set(poption, val)) {
1135 return FALSE;
1136 }
1137
1139 return TRUE;
1140}
1141
1142/************************************************************************/
1145const char *option_font_get(const struct option *poption)
1146{
1149
1150 return poption->font_vtable->get(poption);
1151}
1152
1153/************************************************************************/
1156const char *option_font_def(const struct option *poption)
1157{
1160
1161 return poption->font_vtable->def(poption);
1162}
1163
1164/************************************************************************/
1167const char *option_font_target(const struct option *poption)
1168{
1171
1172 return poption->font_vtable->target(poption);
1173}
1174
1175/************************************************************************/
1178bool option_font_set(struct option *poption, const char *font)
1179{
1182 fc_assert_ret_val(NULL != font, FALSE);
1183
1184 if (poption->font_vtable->set(poption, font)) {
1186 return TRUE;
1187 }
1188 return FALSE;
1189}
1190
1191/************************************************************************/
1201
1202/************************************************************************/
1212
1213/************************************************************************/
1218{
1221
1222 if (poption->color_vtable->set(poption, color)) {
1224 return TRUE;
1225 }
1226 return FALSE;
1227}
1228
1229/************************************************************************/
1233{
1236 video_mode_construct(-1, -1));
1237
1238 return poption->video_mode_vtable->get(poption);
1239}
1240
1241/************************************************************************/
1245{
1248 video_mode_construct(-1, -1));
1249
1250 return poption->video_mode_vtable->def(poption);
1251}
1252
1253/************************************************************************/
1258{
1261
1262 if (poption->video_mode_vtable->set(poption, mode)) {
1264 return TRUE;
1265 }
1266 return FALSE;
1267}
1268
1269
1270/****************************************************************************
1271 Client option set.
1272****************************************************************************/
1273static struct option *client_optset_option_by_number(int id);
1274static struct option *client_optset_option_first(void);
1275static int client_optset_category_number(void);
1276static const char *client_optset_category_name(int category);
1277
1280 .option_first = client_optset_option_first,
1281 .category_number = client_optset_category_number,
1282 .category_name = client_optset_category_name
1283};
1285
1287 const char *support; /* Untranslated long support name, used
1288 * for saving. */
1289 const char *pretty; /* Translated, used to display to the
1290 * users. */
1291};
1292
1293/****************************************************************************
1294 Virtuals tables for the client options.
1295****************************************************************************/
1296static int client_option_number(const struct option *poption);
1297static const char *client_option_name(const struct option *poption);
1298static const char *client_option_description(const struct option *poption);
1299static const char *client_option_help_text(const struct option *poption);
1300static int client_option_category(const struct option *poption);
1301static bool client_option_is_changeable(const struct option *poption);
1302static struct option *client_option_next(const struct option *poption);
1303
1304static const struct option_common_vtable client_option_common_vtable = {
1305 .number = client_option_number,
1306 .name = client_option_name,
1307 .description = client_option_description,
1308 .help_text = client_option_help_text,
1309 .category = client_option_category,
1310 .is_changeable = client_option_is_changeable,
1311 .next = client_option_next
1312};
1313
1314static bool client_option_bool_get(const struct option *poption);
1315static bool client_option_bool_def(const struct option *poption);
1316static bool client_option_bool_set(struct option *poption, bool val);
1317
1318static const struct option_bool_vtable client_option_bool_vtable = {
1322};
1323
1324static int client_option_int_get(const struct option *poption);
1325static int client_option_int_def(const struct option *poption);
1326static int client_option_int_min(const struct option *poption);
1327static int client_option_int_max(const struct option *poption);
1328static bool client_option_int_set(struct option *poption, int val);
1329
1330static const struct option_int_vtable client_option_int_vtable = {
1331 .get = client_option_int_get,
1332 .def = client_option_int_def,
1333 .minimum = client_option_int_min,
1334 .maximum = client_option_int_max,
1336};
1337
1338static const char *client_option_str_get(const struct option *poption);
1339static const char *client_option_str_def(const struct option *poption);
1340static const struct strvec *
1342static bool client_option_str_set(struct option *poption, const char *str);
1343
1344static const struct option_str_vtable client_option_str_vtable = {
1345 .get = client_option_str_get,
1346 .def = client_option_str_def,
1347 .values = client_option_str_values,
1349};
1350
1351static int client_option_enum_get(const struct option *poption);
1352static int client_option_enum_def(const struct option *poption);
1353static const struct strvec *
1355static bool client_option_enum_set(struct option *poption, int val);
1356
1357static const struct option_enum_vtable client_option_enum_vtable = {
1362 .cmp = fc_strcasecmp
1363};
1364
1365#if 0 /* There's no bitwise options currently */
1366static unsigned client_option_bitwise_get(const struct option *poption);
1367static unsigned client_option_bitwise_def(const struct option *poption);
1368static const struct strvec *
1370static bool client_option_bitwise_set(struct option *poption, unsigned val);
1371
1372static const struct option_bitwise_vtable client_option_bitwise_vtable = {
1377};
1378#endif /* 0 */
1379
1380static const char *client_option_font_get(const struct option *poption);
1381static const char *client_option_font_def(const struct option *poption);
1382static const char *client_option_font_target(const struct option *poption);
1383static bool client_option_font_set(struct option *poption, const char *font);
1384
1385static const struct option_font_vtable client_option_font_vtable = {
1388 .target = client_option_font_target,
1390};
1391
1394static bool client_option_color_set(struct option *poption,
1395 struct ft_color color);
1396
1397static const struct option_color_vtable client_option_color_vtable = {
1401};
1402
1403static struct video_mode
1405static struct video_mode
1407static bool client_option_video_mode_set(struct option *poption,
1408 struct video_mode mode);
1409
1410static const struct option_video_mode_vtable client_option_video_mode_vtable = {
1414};
1415
1426
1427/****************************************************************************
1428 Derived class client option, inherinting of base class option.
1429****************************************************************************/
1431 struct option base_option; /* Base structure, must be the first! */
1432
1433 const char *name; /* Short name - used as an identifier */
1434 const char *description; /* One-line description */
1435 const char *help_text; /* Paragraph-length help text */
1437 enum gui_type specific; /* GUI_STUB for common options. */
1438
1439 union {
1440 /* OT_BOOLEAN type option. */
1441 struct {
1442 bool *const pvalue;
1443 const bool def;
1444 } boolean;
1445 /* OT_INTEGER type option. */
1446 struct {
1447 int *const pvalue;
1448 const int def, min, max;
1449 } integer;
1450 /* OT_STRING type option. */
1451 struct {
1452 char *const pvalue;
1453 const size_t size;
1454 const char *const def;
1455 /*
1456 * A function to return a string vector of possible string values,
1457 * or NULL for none.
1458 */
1459 const struct strvec *(*const val_accessor) (const struct option *);
1460 } string;
1461 /* OT_ENUM type option. */
1462 struct {
1463 int *const pvalue;
1464 const int def;
1465 struct strvec *support_names, *pretty_names; /* untranslated */
1466 const struct copt_val_name * (*const name_accessor) (int value);
1467 } enumerator;
1468 /* OT_BITWISE type option. */
1469 struct {
1470 unsigned *const pvalue;
1471 const unsigned def;
1472 struct strvec *support_names, *pretty_names; /* untranslated */
1473 const struct copt_val_name * (*const name_accessor) (int value);
1474 } bitwise;
1475 /* OT_FONT type option. */
1476 struct {
1477 char *const pvalue;
1478 const size_t size;
1479 const char *const def;
1480 const char *const target;
1481 } font;
1482 /* OT_COLOR type option. */
1483 struct {
1484 struct ft_color *const pvalue;
1485 const struct ft_color def;
1487 /* OT_VIDEO_MODE type option. */
1488 struct {
1489 struct video_mode *const pvalue;
1490 const struct video_mode def;
1492 };
1493};
1494
1495#define CLIENT_OPTION(poption) ((struct client_option *) (poption))
1496
1497/*
1498 * Generate a client option of type OT_BOOLEAN.
1499 *
1500 * oname: The option data. Note it is used as name to be loaded or saved.
1501 * So, you shouldn't change the name of this variable in any case.
1502 * odesc: A short description of the client option. Should be used with the
1503 * N_() macro.
1504 * ohelp: The help text for the client option. Should be used with the N_()
1505 * macro.
1506 * ocat: The client_option_class of this client option.
1507 * ospec: A gui_type enumerator which determine for what particular client
1508 * gui this option is for. Sets to GUI_STUB for common options.
1509 * odef: The default value of this client option (FALSE or TRUE).
1510 * ocb: A callback function of type void (*)(struct option *) called when
1511 * the option changed.
1512 */
1513#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb) \
1514{ \
1515 .base_option = OPTION_BOOL_INIT(&client_optset_static, \
1516 client_option_common_vtable, \
1517 client_option_bool_vtable, ocb), \
1518 .name = #oname, \
1519 .description = odesc, \
1520 .help_text = ohelp, \
1521 .category = ocat, \
1522 .specific = ospec, \
1523 INIT_BRACE_BEGIN \
1524 .boolean = { \
1525 .pvalue = &gui_options.oname, \
1526 .def = odef, \
1527 } \
1528 INIT_BRACE_END \
1529}
1530
1531/*
1532 * Generate a client option of type OT_INTEGER.
1533 *
1534 * oname: The option data. Note it is used as name to be loaded or saved.
1535 * So, you shouldn't change the name of this variable in any case.
1536 * odesc: A short description of the client option. Should be used with the
1537 * N_() macro.
1538 * ohelp: The help text for the client option. Should be used with the N_()
1539 * macro.
1540 * ocat: The client_option_class of this client option.
1541 * ospec: A gui_type enumerator which determine for what particular client
1542 * gui this option is for. Sets to GUI_STUB for common options.
1543 * odef: The default value of this client option.
1544 * omin: The minimal value of this client option.
1545 * omax: The maximal value of this client option.
1546 * ocb: A callback function of type void (*)(struct option *) called when
1547 * the option changed.
1548 */
1549#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb) \
1550{ \
1551 .base_option = OPTION_INT_INIT(&client_optset_static, \
1552 client_option_common_vtable, \
1553 client_option_int_vtable, ocb), \
1554 .name = #oname, \
1555 .description = odesc, \
1556 .help_text = ohelp, \
1557 .category = ocat, \
1558 .specific = ospec, \
1559 INIT_BRACE_BEGIN \
1560 .integer = { \
1561 .pvalue = &gui_options.oname, \
1562 .def = odef, \
1563 .min = omin, \
1564 .max = omax \
1565 } \
1566 INIT_BRACE_END \
1567}
1568
1569/*
1570 * Generate a client option of type OT_STRING.
1571 *
1572 * oname: The option data. Note it is used as name to be loaded or saved.
1573 * So, you shouldn't change the name of this variable in any case.
1574 * Be sure to pass the array variable and not a pointer to it because
1575 * the size is calculated with sizeof().
1576 * odesc: A short description of the client option. Should be used with the
1577 * N_() macro.
1578 * ohelp: The help text for the client option. Should be used with the N_()
1579 * macro.
1580 * ocat: The client_option_class of this client option.
1581 * ospec: A gui_type enumerator which determines for what particular client
1582 * gui this option is for. Set to GUI_STUB for common options.
1583 * odef: The default string for this client option.
1584 * ocb: A callback function of type void (*)(struct option *) called when
1585 * the option changed.
1586 */
1587#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd) \
1588{ \
1589 .base_option = OPTION_STR_INIT(&client_optset_static, \
1590 client_option_common_vtable, \
1591 client_option_str_vtable, ocb, cbd), \
1592 .name = #oname, \
1593 .description = odesc, \
1594 .help_text = ohelp, \
1595 .category = ocat, \
1596 .specific = ospec, \
1597 INIT_BRACE_BEGIN \
1598 .string = { \
1599 .pvalue = gui_options.oname, \
1600 .size = sizeof(gui_options.oname), \
1601 .def = odef, \
1602 .val_accessor = NULL \
1603 } \
1604 INIT_BRACE_END \
1605}
1606
1607/*
1608 * Generate a client option of type OT_STRING with a string accessor
1609 * function.
1610 *
1611 * oname: The option data. Note it is used as name to be loaded or saved.
1612 * So, you shouldn't change the name of this variable in any case.
1613 * Be sure to pass the array variable and not a pointer to it because
1614 * the size is calculated with sizeof().
1615 * odesc: A short description of the client option. Should be used with the
1616 * N_() macro.
1617 * ohelp: The help text for the client option. Should be used with the N_()
1618 * macro.
1619 * ocat: The client_option_class of this client option.
1620 * ospec: A gui_type enumerator which determine for what particular client
1621 * gui this option is for. Sets to GUI_STUB for common options.
1622 * odef: The default string for this client option.
1623 * oacc: The string accessor where to find the allowed values of type
1624 * 'const struct strvec * (*) (void)'.
1625 * ocb: A callback function of type void (*)(struct option *) called when
1626 * the option changed.
1627 */
1628#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd) \
1629{ \
1630 .base_option = OPTION_STR_INIT(&client_optset_static, \
1631 client_option_common_vtable, \
1632 client_option_str_vtable, ocb, cbd), \
1633 .name = #oname, \
1634 .description = odesc, \
1635 .help_text = ohelp, \
1636 .category = ocat, \
1637 .specific = ospec, \
1638 INIT_BRACE_BEGIN \
1639 .string = { \
1640 .pvalue = gui_options.oname, \
1641 .size = sizeof(gui_options.oname), \
1642 .def = odef, \
1643 .val_accessor = oacc \
1644 } \
1645 INIT_BRACE_END \
1646}
1647
1648/*
1649 * Generate a client option of type OT_ENUM.
1650 *
1651 * oname: The option data. Note it is used as name to be loaded or saved.
1652 * So, you shouldn't change the name of this variable in any case.
1653 * odesc: A short description of the client option. Should be used with the
1654 * N_() macro.
1655 * ohelp: The help text for the client option. Should be used with the N_()
1656 * macro.
1657 * ocat: The client_option_class of this client option.
1658 * ospec: A gui_type enumerator which determine for what particular client
1659 * gui this option is for. Sets to GUI_STUB for common options.
1660 * odef: The default value for this client option.
1661 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1662 * ocb: A callback function of type void (*) (struct option *) called when
1663 * the option changed.
1664 */
1665#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb) \
1666{ \
1667 .base_option = OPTION_ENUM_INIT(&client_optset_static, \
1668 client_option_common_vtable, \
1669 client_option_enum_vtable, ocb), \
1670 .name = #oname, \
1671 .description = odesc, \
1672 .help_text = ohelp, \
1673 .category = ocat, \
1674 .specific = ospec, \
1675 INIT_BRACE_BEGIN \
1676 .enumerator = { \
1677 .pvalue = (int *) &gui_options.oname, \
1678 .def = odef, \
1679 .support_names = NULL, /* Set in options_init(). */ \
1680 .pretty_names = NULL, \
1681 .name_accessor = oacc \
1682 } \
1683 INIT_BRACE_END \
1684}
1685
1686/*
1687 * Generate a client option of type OT_BITWISE.
1688 *
1689 * oname: The option data. Note it is used as name to be loaded or saved.
1690 * So, you shouldn't change the name of this variable in any case.
1691 * odesc: A short description of the client option. Should be used with the
1692 * N_() macro.
1693 * ohelp: The help text for the client option. Should be used with the N_()
1694 * macro.
1695 * ocat: The client_option_class of this client option.
1696 * ospec: A gui_type enumerator which determine for what particular client
1697 * gui this option is for. Sets to GUI_STUB for common options.
1698 * odef: The default value for this client option.
1699 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1700 * ocb: A callback function of type void (*) (struct option *) called when
1701 * the option changed.
1702 */
1703#define GEN_BITWISE_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, \
1704 ocb) \
1705{ \
1706 .base_option = OPTION_BITWISE_INIT(&client_optset_static, \
1707 client_option_common_vtable, \
1708 client_option_bitwise_vtable, ocb), \
1709 .name = #oname, \
1710 .description = odesc, \
1711 .help_text = ohelp, \
1712 .category = ocat, \
1713 .specific = ospec, \
1714 INIT_BRACE_BEGIN \
1715 .bitwise = { \
1716 .pvalue = &gui_options.oname, \
1717 .def = odef, \
1718 .support_names = NULL, /* Set in options_init(). */ \
1719 .pretty_names = NULL, \
1720 .name_accessor = oacc \
1721 } \
1722 INIT_BRACE_END \
1723}
1724
1725/*
1726 * Generate a client option of type OT_FONT.
1727 *
1728 * oname: The option data. Note it is used as name to be loaded or saved.
1729 * So, you shouldn't change the name of this variable in any case.
1730 * Be sure to pass the array variable and not a pointer to it because
1731 * the size is calculated with sizeof().
1732 * otgt: The target widget style.
1733 * odesc: A short description of the client option. Should be used with the
1734 * N_() macro.
1735 * ohelp: The help text for the client option. Should be used with the N_()
1736 * macro.
1737 * ocat: The client_option_class of this client option.
1738 * ospec: A gui_type enumerator which determine for what particular client
1739 * gui this option is for. Sets to GUI_STUB for common options.
1740 * odef: The default string for this client option.
1741 * ocb: A callback function of type void (*)(struct option *) called when
1742 * the option changed.
1743 */
1744#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb) \
1745{ \
1746 .base_option = OPTION_FONT_INIT(&client_optset_static, \
1747 client_option_common_vtable, \
1748 client_option_font_vtable, ocb), \
1749 .name = #oname, \
1750 .description = odesc, \
1751 .help_text = ohelp, \
1752 .category = ocat, \
1753 .specific = ospec, \
1754 INIT_BRACE_BEGIN \
1755 .font = { \
1756 .pvalue = gui_options.oname, \
1757 .size = sizeof(gui_options.oname), \
1758 .def = odef, \
1759 .target = otgt, \
1760 } \
1761 INIT_BRACE_END \
1762}
1763
1764/*
1765 * Generate a client option of type OT_COLOR.
1766 *
1767 * oname: The option data. Note it is used as name to be loaded or saved.
1768 * So, you shouldn't change the name of this variable in any case.
1769 * odesc: A short description of the client option. Should be used with the
1770 * N_() macro.
1771 * ohelp: The help text for the client option. Should be used with the N_()
1772 * macro.
1773 * ocat: The client_option_class of this client option.
1774 * ospec: A gui_type enumerator which determine for what particular client
1775 * gui this option is for. Sets to GUI_STUB for common options.
1776 * odef_fg, odef_bg: The default values for this client option.
1777 * ocb: A callback function of type void (*)(struct option *) called when
1778 * the option changed.
1779 */
1780#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, \
1781 odef_bg, ocb) \
1782{ \
1783 .base_option = OPTION_COLOR_INIT(&client_optset_static, \
1784 client_option_common_vtable, \
1785 client_option_color_vtable, ocb), \
1786 .name = #oname, \
1787 .description = odesc, \
1788 .help_text = ohelp, \
1789 .category = ocat, \
1790 .specific = ospec, \
1791 INIT_BRACE_BEGIN \
1792 .color = { \
1793 .pvalue = &gui_options.oname, \
1794 .def = FT_COLOR(odef_fg, odef_bg) \
1795 } \
1796 INIT_BRACE_END \
1797}
1798
1799/*
1800 * Generate a client option of type OT_VIDEO_MODE.
1801 *
1802 * oname: The option data. Note it is used as name to be loaded or saved.
1803 * So, you shouldn't change the name of this variable in any case.
1804 * odesc: A short description of the client option. Should be used with the
1805 * N_() macro.
1806 * ohelp: The help text for the client option. Should be used with the N_()
1807 * macro.
1808 * ocat: The client_option_class of this client option.
1809 * ospec: A gui_type enumerator which determine for what particular client
1810 * gui this option is for. Sets to GUI_STUB for common options.
1811 * odef_width, odef_height: The default values for this client option.
1812 * ocb: A callback function of type void (*)(struct option *) called when
1813 * the option changed.
1814 */
1815#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, \
1816 odef_height, ocb) \
1817{ \
1818 .base_option = OPTION_VIDEO_MODE_INIT(&client_optset_static, \
1819 client_option_common_vtable, \
1820 client_option_video_mode_vtable, \
1821 ocb), \
1822 .name = #oname, \
1823 .description = odesc, \
1824 .help_text = ohelp, \
1825 .category = ocat, \
1826 .specific = ospec, \
1827 INIT_BRACE_BEGIN \
1828 .video_mode = { \
1829 .pvalue = &gui_options.oname, \
1830 .def = VIDEO_MODE(odef_width, odef_height) \
1831 } \
1832 INIT_BRACE_END \
1833}
1834
1835/****************************************************************************
1836 Enumerator name accessors.
1837****************************************************************************/
1838
1839/************************************************************************/
1842static const struct copt_val_name
1844{
1845 /* Order must match enum GUI_GTK_MSGCHAT_* */
1846 static const struct copt_val_name names[] = {
1847 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1848 { "SPLIT", N_("Split") },
1849 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1850 { "SEPARATE", N_("Separate") },
1851 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1852 { "MERGED", N_("Merged") }
1853 };
1854
1855 return (0 <= value && value < ARRAY_SIZE(names)
1856 ? names + value : NULL);
1857}
1858
1859/************************************************************************/
1862static const struct copt_val_name
1864{
1865 /* Order must match enum GUI_POPUP_TECH_HELP_* */
1866 static const struct copt_val_name names[] = {
1867 /* TRANS: enum value for 'gui_popup_tech_help' */
1868 { "ENABLED", N_("Enabled") },
1869 /* TRANS: enum value for 'gui_popup_tech_help' */
1870 { "DISABLED", N_("Disabled") },
1871 /* TRANS: enum value for 'gui_popup_tech_help' */
1872 { "RULESET", N_("Ruleset") }
1873 };
1874
1875 return (0 <= value && value < ARRAY_SIZE(names)
1876 ? names + value : NULL);
1877}
1878
1879/* Some changed callbacks. */
1880static void reqtree_show_icons_callback(struct option *poption);
1881static void view_option_changed_callback(struct option *poption);
1882static void manual_turn_done_callback(struct option *poption);
1883static void voteinfo_bar_callback(struct option *poption);
1884static void font_changed_callback(struct option *poption);
1885static void mapimg_changed_callback(struct option *poption);
1886static void game_music_enable_callback(struct option *poption);
1887static void menu_music_enable_callback(struct option *poption);
1888static void sound_volume_callback(struct option *poption);
1889
1891 GEN_STR_OPTION(default_user_name,
1892 N_("Login name"),
1893 N_("This is the default login username that will be used "
1894 "in the connection dialogs or with the -a command-line "
1895 "parameter."),
1897 GEN_BOOL_OPTION(use_prev_server, N_("Default to previously used server"),
1898 N_("Automatically update \"Server\" and \"Server port\" "
1899 "options to match your latest connection, so by "
1900 "default you connect to the same server you used "
1901 "on the previous run. You should enable "
1902 "saving options on exit too, so that the automatic "
1903 "updates to the options get saved too."),
1905 GEN_STR_OPTION(default_server_host,
1906 N_("Server"),
1907 N_("This is the default server hostname that will be used "
1908 "in the connection dialogs or with the -a command-line "
1909 "parameter."),
1910 COC_NETWORK, GUI_STUB, "localhost", NULL, 0),
1911 GEN_INT_OPTION(default_server_port,
1912 N_("Server port"),
1913 N_("This is the default server port that will be used "
1914 "in the connection dialogs or with the -a command-line "
1915 "parameter."),
1917 GEN_STR_OPTION(default_metaserver,
1918 N_("Metaserver"),
1919 N_("The metaserver is a host that the client contacts to "
1920 "find out about games on the internet. Don't change "
1921 "this from its default value unless you know what "
1922 "you're doing."),
1924 GEN_BOOL_OPTION(heartbeat_enabled,
1925 N_("Send heartbeat messages to the server"),
1926 N_("Periodically send an empty heartbeat message to the "
1927 "server to probe whether the connection is still up. "
1928 "This can help to make it obvious when the server has "
1929 "cut the connection due to a connectivity outage, if "
1930 "the client would otherwise sit idle for a long period."),
1932 GEN_STR_OPTION(followtag_override,
1933 N_("Followtag override"),
1934 /* TRANS: Leave 'builtin' untranslated */
1935 N_("Followtag determines which kind of new freeciv versions' "
1936 "availability gets checked from the metaserver. Special "
1937 "value 'builtin' means that value builtin to the client "
1938 "gets used."),
1940 GEN_BOOL_OPTION(send_desired_settings,
1941 N_("Send desired settings to the server"),
1942 N_("In single-player mode client usually sends user's "
1943 "desired server settings to the server it has "
1944 "launched internally. By disabling this option one "
1945 "can prevent such override of server settings from "
1946 "other sources, such as settings balanced for a "
1947 "custom ruleset."),
1949 GEN_STR_LIST_OPTION(default_sound_set_name,
1950 N_("Soundset"),
1951 N_("This is the soundset that will be used. Changing "
1952 "this is the same as using the -S command-line "
1953 "parameter. Use modpack installer utility to install "
1954 "additional soundsets."),
1955 COC_SOUND, GUI_STUB, "stdsounds", get_soundset_list, NULL, 0),
1956 GEN_STR_LIST_OPTION(default_music_set_name,
1957 N_("Musicset"),
1958 N_("This is the musicset that will be used. Changing "
1959 "this is the same as using the -m command-line "
1960 "parameter. Use modpack installer utility to install "
1961 "additional musicsets."),
1962 COC_SOUND, GUI_STUB, "stdmusic", get_musicset_list,
1964 GEN_STR_LIST_OPTION(default_sound_plugin_name,
1965 N_("Sound plugin"),
1966 N_("If you have a problem with sound, try changing "
1967 "the sound plugin. The new plugin won't take "
1968 "effect until you restart Freeciv. Changing this "
1969 "is the same as using the -P command-line option."),
1971 GEN_STR_OPTION(default_chat_logfile,
1972 N_("The chat log file"),
1973 N_("The name of the chat log file."),
1975 /* gui_gtk3_22/4_default_theme_name and gui_sdl2/3_default_theme_name are
1976 * different settings to avoid client crash after loading the
1977 * style for the other gui. Keeps 5 different options! */
1978 GEN_STR_LIST_OPTION(gui_gtk3_22_default_theme_name, N_("Theme"),
1979 N_("By changing this option you change the "
1980 "active theme."),
1983 GEN_STR_LIST_OPTION(gui_gtk4_default_theme_name, N_("Theme"),
1984 N_("By changing this option you change the "
1985 "active theme."),
1988 GEN_STR_LIST_OPTION(gui_sdl2_default_theme_name, N_("Theme"),
1989 N_("By changing this option you change the "
1990 "active theme."),
1993 GEN_STR_LIST_OPTION(gui_sdl3_default_theme_name, N_("Theme"),
1994 N_("By changing this option you change the "
1995 "active theme."),
1998 GEN_STR_LIST_OPTION(gui_qt_default_theme_name, N_("Theme"),
1999 N_("By changing this option you change the "
2000 "active theme."),
2003
2004 /* It's important to give empty string instead of NULL as as default
2005 * value. For NULL value it would default to assigning first value
2006 * from the tileset list returned by get_tileset_list() as default
2007 * tileset. We don't want default tileset assigned at all here, but
2008 * leave it to tilespec code that can handle tileset priority. */
2009 GEN_STR_LIST_OPTION(default_tileset_square_name, N_("Tileset (Square)"),
2010 N_("Select the tileset used with Square based maps. "
2011 "This may change the currently active tileset, if "
2012 "you are playing on such a map, in which "
2013 "case this is the same as using the -t "
2014 "command-line parameter. "
2015 "Use modpack installer utility to install "
2016 "additional tilesets."),
2019 GEN_STR_LIST_OPTION(default_tileset_hex_name, N_("Tileset (Hex)"),
2020 N_("Select the tileset used with Hex maps. "
2021 "This may change the currently active tileset, if "
2022 "you are playing on such a map, in which "
2023 "case this is the same as using the -t "
2024 "command-line parameter. "
2025 "Use modpack installer utility to install "
2026 "additional tilesets."),
2029 GEN_STR_LIST_OPTION(default_tileset_isohex_name, N_("Tileset (Iso-Hex)"),
2030 N_("Select the tileset used with Iso-Hex maps. "
2031 "This may change the currently active tileset, if "
2032 "you are playing on such a map, in which "
2033 "case this is the same as using the -t "
2034 "command-line parameter."
2035 "Use modpack installer utility to install "
2036 "additional tilesets."),
2039
2040 GEN_BOOL_OPTION(draw_city_outlines, N_("Draw city outlines"),
2041 N_("Setting this option will draw a line at the city "
2042 "workable limit."),
2045 GEN_BOOL_OPTION(draw_city_output, N_("Draw city output"),
2046 N_("Setting this option will draw city output for every "
2047 "citizen."),
2050 GEN_BOOL_OPTION(draw_map_grid, N_("Draw the map grid"),
2051 N_("Setting this option will draw a grid over the map."),
2054 GEN_BOOL_OPTION(draw_full_citybar, N_("Draw the city bar"),
2055 N_("Setting this option will display a 'city bar' "
2056 "containing useful information beneath each city. "
2057 "Disabling this option will display only the city's "
2058 "name and, optionally, production."),
2061 GEN_BOOL_OPTION(draw_city_names, N_("Draw the city names"),
2062 N_("Setting this option will draw the names of the cities "
2063 "on the map."),
2066 GEN_BOOL_OPTION(draw_city_growth, N_("Draw the city growth"),
2067 N_("Setting this option will draw in how many turns the "
2068 "cities will grow or shrink."),
2071 GEN_BOOL_OPTION(draw_city_productions, N_("Draw the city productions"),
2072 N_("Setting this option will draw what the cities are "
2073 "currently building on the map."),
2076 GEN_BOOL_OPTION(draw_city_buycost, N_("Draw the city buy costs"),
2077 N_("Setting this option will draw how much gold is "
2078 "needed to buy the production of the cities."),
2081 GEN_BOOL_OPTION(draw_city_trade_routes, N_("Draw the city trade routes"),
2082 N_("Setting this option will draw trade route lines "
2083 "between cities which have trade routes."),
2086 GEN_BOOL_OPTION(draw_terrain, N_("Draw the terrain"),
2087 N_("Setting this option will draw the terrain."),
2090 GEN_BOOL_OPTION(draw_coastline, N_("Draw the coast line"),
2091 N_("Setting this option will draw a line to separate the "
2092 "land from the ocean."),
2095 GEN_BOOL_OPTION(draw_paths, N_("Draw the paths"),
2096 N_("Setting this option will draw all kind of paths "
2097 "on the map."),
2100 GEN_BOOL_OPTION(draw_irrigation, N_("Draw the irrigation"),
2101 N_("Setting this option will draw the irrigation systems "
2102 "on the map."),
2105 GEN_BOOL_OPTION(draw_mines, N_("Draw the mines"),
2106 N_("Setting this option will draw the mines on the map."),
2109 GEN_BOOL_OPTION(draw_fortress_airbase, N_("Draw the bases"),
2110 N_("Setting this option will draw the bases on the map."),
2113 GEN_BOOL_OPTION(draw_specials, N_("Draw the resources"),
2114 N_("Setting this option will draw the resources on the "
2115 "map."),
2118 GEN_BOOL_OPTION(draw_huts, N_("Draw the huts"),
2119 N_("Setting this option will draw the huts on the "
2120 "map."),
2123 GEN_BOOL_OPTION(draw_pollution, N_("Draw the pollution/nuclear fallout"),
2124 N_("Setting this option will draw pollution and "
2125 "nuclear fallout on the map."),
2128 GEN_BOOL_OPTION(draw_cities, N_("Draw the cities"),
2129 N_("Setting this option will draw the cities on the map."),
2132 GEN_BOOL_OPTION(draw_units, N_("Draw the units"),
2133 N_("Setting this option will draw the units on the map."),
2136 GEN_BOOL_OPTION(solid_color_behind_units,
2137 N_("Solid unit background color"),
2138 N_("Setting this option will cause units on the map "
2139 "view to be drawn with a solid background color "
2140 "instead of the flag backdrop."),
2143 GEN_BOOL_OPTION(draw_unit_shields, N_("Draw shield graphics for units"),
2144 N_("Setting this option will draw a shield icon "
2145 "as the flags on units. If unset, the full flag will "
2146 "be drawn."),
2148 GEN_BOOL_OPTION(draw_unit_stack_size, N_("Draw size of the unit stacks"),
2149 N_("Setting this option will draw a numbers indicating "
2150 "size of the unit stacks. Not all clients support "
2151 "this."),
2153 GEN_BOOL_OPTION(draw_focus_unit, N_("Draw the units in focus"),
2154 N_("Setting this option will cause the currently focused "
2155 "unit(s) to always be drawn, even if units are not "
2156 "otherwise being drawn (for instance if 'Draw the units' "
2157 "is unset)."),
2160 GEN_BOOL_OPTION(draw_fog_of_war, N_("Draw the fog of war"),
2161 N_("Setting this option will draw the fog of war."),
2164 GEN_BOOL_OPTION(draw_borders, N_("Draw the borders"),
2165 N_("Setting this option will draw the national borders."),
2168 GEN_BOOL_OPTION(draw_native, N_("Draw whether tiles are native to "
2169 "selected unit"),
2170 N_("Setting this option will highlight tiles that the "
2171 "currently selected unit cannot enter unaided due to "
2172 "non-native terrain. (If multiple units are selected, "
2173 "only tiles that all of them can enter are indicated.)"),
2176 GEN_BOOL_OPTION(player_dlg_show_dead_players,
2177 N_("Show dead players in Nations report"),
2178 N_("This option controls whether defeated nations are "
2179 "shown on the Nations report page."),
2182 GEN_BOOL_OPTION(sound_bell_at_new_turn, N_("Sound bell at new turn"),
2183 N_("Set this option to have a \"bell\" event be generated "
2184 "at the start of a new turn. You can control the "
2185 "behavior of the \"bell\" event by editing the message "
2186 "options."),
2188 GEN_INT_OPTION(smooth_move_unit_msec,
2189 N_("Unit movement animation time (milliseconds)"),
2190 N_("This option controls how long unit \"animation\" takes "
2191 "when a unit moves on the map view. Set it to 0 to "
2192 "disable animation entirely."),
2193 COC_GRAPHICS, GUI_STUB, 30, 0, 2000, NULL),
2194 GEN_INT_OPTION(smooth_center_slide_msec,
2195 N_("Mapview recentering time (milliseconds)"),
2196 N_("When the map view is recentered, it will slide "
2197 "smoothly over the map to its new position. This "
2198 "option controls how long this slide lasts. Set it to "
2199 "0 to disable mapview sliding entirely."),
2200 COC_GRAPHICS, GUI_STUB, 200, 0, 5000, NULL),
2201 GEN_INT_OPTION(smooth_combat_step_msec,
2202 N_("Combat animation step time (milliseconds)"),
2203 N_("This option controls the speed of combat animation "
2204 "between units on the mapview. Set it to 0 to disable "
2205 "animation entirely."),
2206 COC_GRAPHICS, GUI_STUB, 10, 0, 100, NULL),
2207 GEN_BOOL_OPTION(reqtree_show_icons,
2208 N_("Show icons in the technology tree"),
2209 N_("Setting this option will display icons "
2210 "on the technology tree diagram. Turning "
2211 "this option off makes the technology tree "
2212 "more compact."),
2214 GEN_BOOL_OPTION(reqtree_curved_lines,
2215 N_("Use curved lines in the technology tree"),
2216 N_("Setting this option make the technology tree "
2217 "diagram use curved lines to show technology "
2218 "relations. Turning this option off causes "
2219 "the lines to be drawn straight."),
2222 GEN_COLOR_OPTION(highlight_our_names,
2223 N_("Color to highlight your player/user name"),
2224 N_("If set, your player and user name in the new chat "
2225 "messages will be highlighted using this color as "
2226 "background. If not set, it will just not highlight "
2227 "anything."),
2228 COC_GRAPHICS, GUI_STUB, "#000000", "#FFFF00", NULL),
2229 GEN_BOOL_OPTION(ai_manual_turn_done, N_("Manual Turn Done in AI mode"),
2230 N_("Disable this option if you do not want to "
2231 "press the Turn Done button manually when watching "
2232 "an AI player."),
2234 GEN_BOOL_OPTION(auto_center_on_unit, N_("Auto center on units"),
2235 N_("Set this option to have the active unit centered "
2236 "automatically when the unit focus changes."),
2238 GEN_BOOL_OPTION(auto_center_on_automated, N_("Show automated units"),
2239 N_("Disable this option if you do not want to see "
2240 "automated units autocentered and animated."),
2242 GEN_BOOL_OPTION(auto_center_on_combat, N_("Auto center on combat"),
2243 N_("Set this option to have any combat be centered "
2244 "automatically. Disabling this will speed up the time "
2245 "between turns but may cause you to miss combat "
2246 "entirely."),
2248 GEN_BOOL_OPTION(auto_center_each_turn, N_("Auto center on new turn"),
2249 N_("Set this option to have the client automatically "
2250 "recenter the map on a suitable location at the "
2251 "start of each turn."),
2253 GEN_BOOL_OPTION(wakeup_focus, N_("Focus on awakened units"),
2254 N_("Set this option to have newly awoken units be "
2255 "focused automatically."),
2257 GEN_BOOL_OPTION(keyboardless_goto, N_("Keyboardless goto"),
2258 N_("If this option is set then a goto may be initiated "
2259 "by left-clicking and then holding down the mouse "
2260 "button while dragging the mouse onto a different "
2261 "tile."),
2263 GEN_BOOL_OPTION(goto_into_unknown, N_("Allow goto into the unknown"),
2264 N_("Setting this option will make the game consider "
2265 "moving into unknown tiles. If not, then goto routes "
2266 "will detour around or be blocked by unknown tiles."),
2268 GEN_BOOL_OPTION(center_when_popup_city, N_("Center map when popup city"),
2269 N_("Setting this option makes the mapview center on a "
2270 "city when its city dialog is popped up."),
2272 GEN_BOOL_OPTION(show_previous_turn_messages, N_("Show messages from previous turn"),
2273 N_("Message Window shows messages also from previous turn. "
2274 "This makes sure you don't miss messages received in the end of "
2275 "the turn, just before the window gets cleared."),
2277 GEN_BOOL_OPTION(concise_city_production, N_("Concise city production"),
2278 N_("Set this option to make the city production (as shown "
2279 "in the city dialog) to be more compact."),
2281 GEN_BOOL_OPTION(auto_turn_done, N_("End turn when done moving"),
2282 N_("Setting this option makes your turn end automatically "
2283 "when all your units are done moving."),
2285 GEN_BOOL_OPTION(ask_city_name, N_("Prompt for city names"),
2286 N_("Disabling this option will make the names of newly "
2287 "founded cities be chosen automatically by the server."),
2289 GEN_BOOL_OPTION(popup_new_cities, N_("Pop up city dialog for new cities"),
2290 N_("Setting this option will pop up a newly-founded "
2291 "city's city dialog automatically."),
2293 GEN_BOOL_OPTION(popup_actor_arrival, N_("Pop up caravan and spy actions"),
2294 N_("If this option is enabled, when a unit arrives at "
2295 "a city where it can perform an action like "
2296 "establishing a trade route, helping build a wonder, or "
2297 "establishing an embassy, a window will pop up asking "
2298 "which action should be performed. "
2299 "Disabling this option means you will have to do the "
2300 "action manually by pressing either 'r' (for a trade "
2301 "route), 'b' (for building a wonder) or 'd' (for a "
2302 "spy action) when the unit is in the city."),
2304 GEN_BOOL_OPTION(popup_attack_actions, N_("Pop up attack questions"),
2305 N_("If this option is enabled, when a unit arrives at a "
2306 "target it can attack, a window will pop up asking "
2307 "which action should be performed even if an attack "
2308 "action is legal and no other interesting action are. "
2309 "This allows you to change your mind or to select an "
2310 "uninteresting action."),
2312 GEN_BOOL_OPTION(popup_last_move_to_allied,
2313 /* TODO: Rename option ..._last_... to match _final_ in
2314 * the descriptions.
2315 * Changes options file format, needs migration
2316 * when loading old version. */
2317 N_("Pop up actions when final move to allied tile"),
2318 N_("If this option is enabled the final move in a unit's"
2319 " orders to a tile with allied units or cities it can"
2320 " perform an action to is interpreted as an attempted"
2321 " action. This makes the action selection dialog pop up"
2322 " while the unit is at the adjacent tile."
2323 " This can, in cases where the action requires that"
2324 " the actor unit has moves left, save a turn."
2325 " The down side is that the unit remains adjacent to"
2326 " rather than inside the protection of an allied city"
2327 " or unit stack."),
2329 GEN_BOOL_OPTION(enable_cursor_changes, N_("Enable cursor changing"),
2330 N_("This option controls whether the client should "
2331 "try to change the mouse cursor depending on what "
2332 "is being pointed at, as well as to indicate "
2333 "changes in the client or server state."),
2335 GEN_BOOL_OPTION(separate_unit_selection, N_("Select cities before units"),
2336 N_("If this option is enabled, when both cities and "
2337 "units are present in the selection rectangle, only "
2338 "cities will be selected. See the help on Controls."),
2340 GEN_BOOL_OPTION(unit_selection_clears_orders,
2341 N_("Clear unit orders on selection"),
2342 N_("Enabling this option will cause unit orders to be "
2343 "cleared as soon as one or more units are selected. If "
2344 "this option is disabled, busy units will not stop "
2345 "their current activity when selected. Giving them "
2346 "new orders will clear their current ones; pressing "
2347 "<space> once will clear their orders and leave them "
2348 "selected, and pressing <space> a second time will "
2349 "dismiss them."),
2351 GEN_BOOL_OPTION(voteinfo_bar_use, N_("Enable vote bar"),
2352 N_("If this option is turned on, the vote bar will be "
2353 "displayed to show vote information."),
2355 GEN_BOOL_OPTION(voteinfo_bar_always_show,
2356 N_("Always display the vote bar"),
2357 N_("If this option is turned on, the vote bar will never "
2358 "be hidden, even if there is no running vote."),
2360 GEN_BOOL_OPTION(voteinfo_bar_hide_when_not_player,
2361 N_("Do not show vote bar if not a player"),
2362 N_("If this option is enabled, the client won't show the "
2363 "vote bar if you are not a player."),
2365 GEN_BOOL_OPTION(voteinfo_bar_new_at_front, N_("Set new votes at front"),
2366 N_("If this option is enabled, then new votes will go "
2367 "to the front of the vote list."),
2369 GEN_BOOL_OPTION(autoaccept_tileset_suggestion,
2370 N_("Autoaccept tileset suggestions"),
2371 N_("If this option is enabled, any tileset suggested by "
2372 "the ruleset is automatically used; otherwise you "
2373 "are prompted to change tileset."),
2375
2376 GEN_BOOL_OPTION(sound_enable_effects,
2377 N_("Enable sound effects"),
2378 N_("Play sound effects, assuming there's suitable "
2379 "sound plugin and soundset with the sounds."),
2381 GEN_BOOL_OPTION(sound_enable_game_music,
2382 N_("Enable in-game music"),
2383 N_("Play music during the game, assuming there's suitable "
2384 "sound plugin and musicset with in-game tracks."),
2386 GEN_BOOL_OPTION(sound_enable_menu_music,
2387 N_("Enable menu music"),
2388 N_("Play music while not in actual game, "
2389 "assuming there's suitable "
2390 "sound plugin and musicset with menu music tracks."),
2392 GEN_BOOL_OPTION(silent_when_not_in_focus,
2393 N_("Silent when not in focus"),
2394 N_("Fade all sound out when the client is not in focus. "
2395 "Not all clients support this."),
2397 GEN_INT_OPTION(sound_effects_volume,
2398 N_("Sound volume"),
2399 N_("Volume scale from 0-100"),
2400 COC_SOUND, GUI_STUB, 100,
2401 0, 100,
2403
2404 GEN_BOOL_OPTION(autoaccept_soundset_suggestion,
2405 N_("Autoaccept soundset suggestions"),
2406 N_("If this option is enabled, any soundset suggested by "
2407 "the ruleset is automatically used."),
2409 GEN_BOOL_OPTION(autoaccept_musicset_suggestion,
2410 N_("Autoaccept musicset suggestions"),
2411 N_("If this option is enabled, any musicset suggested by "
2412 "the ruleset is automatically used."),
2414
2416 N_("Background layer"),
2417 N_("The background layer of the overview shows just "
2418 "ocean and land."),
2421 N_("Terrain relief map layer"),
2422 N_("The relief layer shows all terrains on the map."),
2425 N_("Borders layer"),
2426 N_("The borders layer of the overview shows which tiles "
2427 "are owned by each player."),
2430 N_("Borders layer on ocean tiles"),
2431 N_("The borders layer of the overview are drawn on "
2432 "ocean tiles as well (this may look ugly with many "
2433 "islands). This option is only of interest if you "
2434 "have set the option \"Borders layer\" already."),
2437 N_("Units layer"),
2438 N_("Enabling this will draw units on the overview."),
2441 N_("Cities layer"),
2442 N_("Enabling this will draw cities on the overview."),
2445 N_("Overview fog of war"),
2446 N_("Enabling this will show fog of war on the "
2447 "overview."),
2449
2450 /* options for map images */
2451 GEN_STR_LIST_OPTION(mapimg_format,
2452 N_("Image format"),
2453 N_("The image toolkit and file format used for "
2454 "map images."),
2456 NULL, 0),
2457 GEN_INT_OPTION(mapimg_zoom,
2458 N_("Zoom factor for map images"),
2459 N_("The magnification used for map images."),
2461 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_AREA],
2462 N_("Show area within borders"),
2463 N_("If set, the territory of each nation is shown "
2464 "on the saved image."),
2467 N_("Show borders"),
2468 N_("If set, the border of each nation is shown on the "
2469 "saved image."),
2472 N_("Show cities"),
2473 N_("If set, cities are shown on the saved image."),
2476 N_("Show fog of war"),
2477 N_("If set, the extent of fog of war is shown on the "
2478 "saved image."),
2481 N_("Show full terrain"),
2482 N_("If set, terrain relief is shown with different colors "
2483 "in the saved image; otherwise, only land and water are "
2484 "distinguished."),
2486 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_UNITS],
2487 N_("Show units"),
2488 N_("If set, units are shown in the saved image."),
2490 GEN_STR_OPTION(mapimg_filename,
2491 N_("Map image file name"),
2492 N_("The base part of the filename for saved map images. "
2493 "A string identifying the game turn and map options will "
2494 "be appended."),
2496
2497 /* gui-gtk-2.0 client specific options.
2498 * These are still kept just so users can migrate them to later gtk-clients */
2499 GEN_BOOL_OPTION(gui_gtk2_map_scrollbars, NULL, NULL,
2501 GEN_BOOL_OPTION(gui_gtk2_dialogs_on_top, NULL, NULL,
2503 GEN_BOOL_OPTION(gui_gtk2_show_task_icons, NULL, NULL,
2505 GEN_BOOL_OPTION(gui_gtk2_enable_tabs, NULL, NULL,
2507 GEN_BOOL_OPTION(gui_gtk2_better_fog, NULL, NULL,
2510 GEN_BOOL_OPTION(gui_gtk2_show_chat_message_time, NULL, NULL,
2512 GEN_BOOL_OPTION(gui_gtk2_new_messages_go_to_top, NULL, NULL,
2514 GEN_BOOL_OPTION(gui_gtk2_show_message_window_buttons, NULL, NULL,
2516 GEN_BOOL_OPTION(gui_gtk2_metaserver_tab_first, NULL, NULL,
2518 GEN_BOOL_OPTION(gui_gtk2_allied_chat_only, NULL, NULL,
2520 GEN_BOOL_OPTION(gui_gtk2_mouse_over_map_focus, NULL, NULL,
2522 GEN_BOOL_OPTION(gui_gtk2_chatline_autocompletion, NULL, NULL,
2524 GEN_INT_OPTION(gui_gtk2_citydlg_xsize, NULL, NULL,
2527 NULL),
2528 GEN_INT_OPTION(gui_gtk2_citydlg_ysize, NULL, NULL,
2531 NULL),
2532 GEN_ENUM_OPTION(gui_gtk2_popup_tech_help, NULL, NULL,
2536 GEN_FONT_OPTION(gui_gtk2_font_city_label, "city_label",
2537 NULL, NULL,
2539 "Monospace 8", font_changed_callback),
2540 GEN_FONT_OPTION(gui_gtk2_font_notify_label, "notify_label",
2541 NULL, NULL,
2543 "Monospace Bold 9", font_changed_callback),
2544 GEN_FONT_OPTION(gui_gtk2_font_spaceship_label, "spaceship_label",
2545 NULL, NULL,
2547 "Monospace 8", font_changed_callback),
2548 GEN_FONT_OPTION(gui_gtk2_font_help_label, "help_label",
2549 NULL, NULL,
2551 "Sans Bold 10", font_changed_callback),
2552 GEN_FONT_OPTION(gui_gtk2_font_help_link, "help_link",
2553 NULL, NULL,
2555 "Sans 9", font_changed_callback),
2556 GEN_FONT_OPTION(gui_gtk2_font_help_text, "help_text",
2557 NULL, NULL,
2559 "Monospace 8", font_changed_callback),
2560 GEN_FONT_OPTION(gui_gtk2_font_chatline, "chatline",
2561 NULL, NULL,
2563 "Monospace 8", font_changed_callback),
2564 GEN_FONT_OPTION(gui_gtk2_font_beta_label, "beta_label",
2565 NULL, NULL,
2567 "Sans Italic 10", font_changed_callback),
2568 GEN_FONT_OPTION(gui_gtk2_font_small, "small_font",
2569 NULL, NULL,
2571 "Sans 9", NULL),
2572 GEN_FONT_OPTION(gui_gtk2_font_comment_label, "comment_label",
2573 NULL, NULL,
2575 "Sans Italic 9", font_changed_callback),
2576 GEN_FONT_OPTION(gui_gtk2_font_city_names, "city_names",
2577 NULL, NULL,
2579 "Sans Bold 10", NULL),
2580 GEN_FONT_OPTION(gui_gtk2_font_city_productions, "city_productions",
2581 NULL, NULL,
2583 "Serif 10", NULL),
2584 GEN_FONT_OPTION(gui_gtk2_font_reqtree_text, "reqtree_text",
2585 NULL, NULL,
2587 "Serif 10", NULL),
2588
2589 /* gui-gtk-3.0 client specific options.
2590 * These are still kept just so users can migrate them to later gtk-clients */
2591 GEN_BOOL_OPTION(gui_gtk3_fullscreen, NULL, NULL,
2593 GEN_BOOL_OPTION(gui_gtk3_map_scrollbars, N_("Show map scrollbars"),
2594 N_("Disable this option to hide the scrollbars on the "
2595 "map view."),
2597 GEN_BOOL_OPTION(gui_gtk3_dialogs_on_top, NULL, NULL,
2599 GEN_BOOL_OPTION(gui_gtk3_show_task_icons, NULL, NULL,
2601 GEN_BOOL_OPTION(gui_gtk3_enable_tabs, NULL, NULL,
2603 GEN_BOOL_OPTION(gui_gtk3_show_chat_message_time, NULL, NULL,
2605 GEN_BOOL_OPTION(gui_gtk3_new_messages_go_to_top, NULL, NULL,
2607 GEN_BOOL_OPTION(gui_gtk3_show_message_window_buttons, NULL, NULL,
2609 GEN_BOOL_OPTION(gui_gtk3_metaserver_tab_first, NULL, NULL,
2611 GEN_BOOL_OPTION(gui_gtk3_allied_chat_only, NULL, NULL,
2613 GEN_ENUM_OPTION(gui_gtk3_message_chat_location, NULL, NULL,
2617 GEN_BOOL_OPTION(gui_gtk3_small_display_layout, NULL, NULL,
2619 GEN_BOOL_OPTION(gui_gtk3_mouse_over_map_focus, NULL, NULL,
2621 GEN_BOOL_OPTION(gui_gtk3_chatline_autocompletion, NULL, NULL,
2623 GEN_INT_OPTION(gui_gtk3_citydlg_xsize, NULL, NULL,
2626 NULL),
2627 GEN_INT_OPTION(gui_gtk3_citydlg_ysize, NULL, NULL,
2630 NULL),
2631 GEN_ENUM_OPTION(gui_gtk3_popup_tech_help, NULL, NULL,
2635 GEN_INT_OPTION(gui_gtk3_governor_range_min, NULL, NULL,
2638 NULL),
2639 GEN_INT_OPTION(gui_gtk3_governor_range_max, NULL, NULL,
2642 NULL),
2643 GEN_FONT_OPTION(gui_gtk3_font_city_label, "city_label",
2644 NULL, NULL,
2646 "Monospace 8", font_changed_callback),
2647 GEN_FONT_OPTION(gui_gtk3_font_notify_label, "notify_label",
2648 NULL, NULL,
2650 "Monospace Bold 9", font_changed_callback),
2651 GEN_FONT_OPTION(gui_gtk3_font_spaceship_label, "spaceship_label",
2652 NULL, NULL,
2654 "Monospace 8", font_changed_callback),
2655 GEN_FONT_OPTION(gui_gtk3_font_help_label, "help_label",
2656 NULL, NULL,
2658 "Sans Bold 10", font_changed_callback),
2659 GEN_FONT_OPTION(gui_gtk3_font_help_link, "help_link",
2660 NULL, NULL,
2662 "Sans 9", font_changed_callback),
2663 GEN_FONT_OPTION(gui_gtk3_font_help_text, "help_text",
2664 NULL, NULL,
2666 "Monospace 8", font_changed_callback),
2667 GEN_FONT_OPTION(gui_gtk3_font_chatline, "chatline",
2668 NULL, NULL,
2670 "Monospace 8", font_changed_callback),
2671 GEN_FONT_OPTION(gui_gtk3_font_beta_label, "beta_label",
2672 NULL, NULL,
2674 "Sans Italic 10", font_changed_callback),
2675 GEN_FONT_OPTION(gui_gtk3_font_small, "small_font",
2676 NULL, NULL,
2678 "Sans 9", NULL),
2679 GEN_FONT_OPTION(gui_gtk3_font_comment_label, "comment_label",
2680 NULL, NULL,
2682 "Sans Italic 9", font_changed_callback),
2683 GEN_FONT_OPTION(gui_gtk3_font_city_names, "city_names",
2684 NULL, NULL,
2686 "Sans Bold 10", NULL),
2687 GEN_FONT_OPTION(gui_gtk3_font_city_productions, "city_productions",
2688 NULL, NULL,
2690 "Serif 10", NULL),
2691 GEN_FONT_OPTION(gui_gtk3_font_reqtree_text, "reqtree_text",
2692 NULL, NULL,
2694 "Serif 10", NULL),
2695
2696 /* gui-gtk-3.22 client specific options. */
2697 GEN_BOOL_OPTION(gui_gtk3_22_fullscreen, N_("Fullscreen"),
2698 N_("If this option is set the client will use the "
2699 "whole screen area for drawing."),
2701 GEN_BOOL_OPTION(gui_gtk3_22_map_scrollbars, N_("Show map scrollbars"),
2702 N_("Disable this option to hide the scrollbars on the "
2703 "map view."),
2705 GEN_BOOL_OPTION(gui_gtk3_22_dialogs_on_top, N_("Keep dialogs on top"),
2706 N_("If this option is set then dialog windows will always "
2707 "remain in front of the main Freeciv window. "
2708 "Disabling this has no effect in fullscreen mode."),
2710 GEN_BOOL_OPTION(gui_gtk3_22_show_task_icons, N_("Show worklist task icons"),
2711 N_("Disabling this will turn off the unit and building "
2712 "icons in the worklist dialog and the production "
2713 "tab of the city dialog."),
2715 GEN_BOOL_OPTION(gui_gtk3_22_enable_tabs, N_("Enable status report tabs"),
2716 N_("If this option is enabled then report dialogs will "
2717 "be shown as separate tabs rather than in popup "
2718 "dialogs."),
2720 GEN_BOOL_OPTION(gui_gtk3_22_show_chat_message_time,
2721 N_("Show time for each chat message"),
2722 N_("If this option is enabled then all chat messages "
2723 "will be prefixed by a time string of the form "
2724 "[hour:minute:second]."),
2726 GEN_BOOL_OPTION(gui_gtk3_22_new_messages_go_to_top,
2727 N_("New message events go to top of list"),
2728 N_("If this option is enabled, new events in the "
2729 "message window will appear at the top of the list, "
2730 "rather than being appended at the bottom."),
2732 GEN_BOOL_OPTION(gui_gtk3_22_show_message_window_buttons,
2733 N_("Show extra message window buttons"),
2734 N_("If this option is enabled, there will be two "
2735 "buttons displayed in the message window for "
2736 "inspecting a city and going to a location. If this "
2737 "option is disabled, these buttons will not appear "
2738 "(you can still double-click with the left mouse "
2739 "button or right-click on a row to inspect or goto "
2740 "respectively). This option will only take effect "
2741 "once the message window is closed and reopened."),
2743 GEN_BOOL_OPTION(gui_gtk3_22_metaserver_tab_first,
2744 N_("Metaserver tab first in network page"),
2745 N_("If this option is enabled, the metaserver tab will "
2746 "be the first notebook tab in the network page. This "
2747 "option requires a restart in order to take effect."),
2749 GEN_BOOL_OPTION(gui_gtk3_22_allied_chat_only,
2750 N_("Plain chat messages are sent to allies only"),
2751 N_("If this option is enabled, then plain messages "
2752 "typed into the chat entry while the game is "
2753 "running will only be sent to your allies. "
2754 "Otherwise plain messages will be sent as "
2755 "public chat messages. To send a public chat "
2756 "message with this option enabled, prefix the "
2757 "message with a single colon ':'. This option "
2758 "can also be set using a toggle button beside "
2759 "the chat entry (only visible in multiplayer "
2760 "games)."),
2762 GEN_ENUM_OPTION(gui_gtk3_22_message_chat_location,
2763 N_("Messages and Chat reports location"),
2764 /* TRANS: The strings used in the UI for 'Split' etc are
2765 * tagged 'gui_gtk2/gtk3/gtk4_message_chat_location' */
2766 N_("Controls where the Messages and Chat reports "
2767 "appear relative to the main view containing the map.\n"
2768 "'Split' allows all three to be seen simultaneously, "
2769 "which is best for multiplayer, but requires a large "
2770 "window to be usable.\n"
2771 "'Separate' puts Messages and Chat in a notebook "
2772 "separate from the main view, so that one of them "
2773 "can always be seen alongside the main view.\n"
2774 "'Merged' makes the Messages and Chat reports into "
2775 "tabs alongside the map and other reports; this "
2776 "allows a larger map view on small screens.\n"
2777 "This option requires a restart in order to take "
2778 "effect."), COC_INTERFACE, GUI_GTK3_22,
2781 GEN_BOOL_OPTION(gui_gtk3_22_small_display_layout,
2782 N_("Arrange widgets for small displays"),
2783 N_("If this option is enabled, widgets in the main "
2784 "window will be arranged so that they take up the "
2785 "least amount of total screen space. Specifically, "
2786 "the left panel containing the overview, player "
2787 "status, and the unit information box will be "
2788 "extended over the entire left side of the window. "
2789 "This option requires a restart in order to take "
2790 "effect."), COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2791 GEN_BOOL_OPTION(gui_gtk3_22_mouse_over_map_focus,
2792 N_("Mouse over the map widget selects it automatically"),
2793 N_("If this option is enabled, then the map will be "
2794 "focused when the mouse hovers over it."),
2796 GEN_BOOL_OPTION(gui_gtk3_22_chatline_autocompletion,
2797 N_("Player or user name autocompletion"),
2798 N_("If this option is turned on, the tabulation key "
2799 "will be used in the chatline to complete the word you "
2800 "are typing with the name of a player or a user."),
2802 GEN_INT_OPTION(gui_gtk3_22_citydlg_xsize,
2803 N_("Width of the city dialog"),
2804 N_("This value is only used if the width of the city "
2805 "dialog is saved."),
2808 NULL),
2809 GEN_INT_OPTION(gui_gtk3_22_citydlg_ysize,
2810 N_("Height of the city dialog"),
2811 N_("This value is only used if the height of the city "
2812 "dialog is saved."),
2815 NULL),
2816 GEN_ENUM_OPTION(gui_gtk3_22_popup_tech_help,
2817 N_("Popup tech help when gained"),
2818 N_("Controls if tech help should be opened when "
2819 "new tech has been gained.\n"
2820 "'Ruleset' means that behavior suggested by "
2821 "current ruleset is used."), COC_INTERFACE, GUI_GTK3_22,
2824 GEN_INT_OPTION(gui_gtk3_22_governor_range_min,
2825 N_("Minimum surplus for a governor"),
2826 N_("The lower limit of the range for requesting surpluses "
2827 "from the governor."),
2830 NULL),
2831 GEN_INT_OPTION(gui_gtk3_22_governor_range_max,
2832 N_("Maximum surplus for a governor"),
2833 N_("The higher limit of the range for requesting surpluses "
2834 "from the governor."),
2837 NULL),
2838 GEN_FONT_OPTION(gui_gtk3_22_font_city_label, "city_label",
2839 N_("City Label"),
2840 N_("This font is used to display the city labels on city "
2841 "dialogs."),
2843 "Monospace 8", font_changed_callback),
2844 GEN_FONT_OPTION(gui_gtk3_22_font_notify_label, "notify_label",
2845 N_("Notify Label"),
2846 N_("This font is used to display server reports such "
2847 "as the demographic report or historian publications."),
2849 "Monospace Bold 9", font_changed_callback),
2850 GEN_FONT_OPTION(gui_gtk3_22_font_spaceship_label, "spaceship_label",
2851 N_("Spaceship Label"),
2852 N_("This font is used to display the spaceship widgets."),
2854 "Monospace 8", font_changed_callback),
2855 GEN_FONT_OPTION(gui_gtk3_22_font_help_label, "help_label",
2856 N_("Help Label"),
2857 N_("This font is used to display the help headers in the "
2858 "help window."),
2860 "Sans Bold 10", font_changed_callback),
2861 GEN_FONT_OPTION(gui_gtk3_22_font_help_link, "help_link",
2862 N_("Help Link"),
2863 N_("This font is used to display the help links in the "
2864 "help window."),
2866 "Sans 9", font_changed_callback),
2867 GEN_FONT_OPTION(gui_gtk3_22_font_help_text, "help_text",
2868 N_("Help Text"),
2869 N_("This font is used to display the help body text in "
2870 "the help window."),
2872 "Monospace 8", font_changed_callback),
2873 GEN_FONT_OPTION(gui_gtk3_22_font_chatline, "chatline",
2874 N_("Chatline Area"),
2875 N_("This font is used to display the text in the "
2876 "chatline area."),
2878 "Monospace 8", font_changed_callback),
2879 GEN_FONT_OPTION(gui_gtk3_22_font_beta_label, "beta_label",
2880 N_("Beta Label"),
2881 N_("This font is used to display the beta label."),
2883 "Sans Italic 10", font_changed_callback),
2884 GEN_FONT_OPTION(gui_gtk3_22_font_small, "small_font",
2885 N_("Small Font"),
2886 N_("This font is used for any small font request. For "
2887 "example, it is used for display the building lists "
2888 "in the city dialog, the Economy report or the Units "
2889 "report."),
2891 "Sans 9", font_changed_callback),
2892 GEN_FONT_OPTION(gui_gtk3_22_font_comment_label, "comment_label",
2893 N_("Comment Label"),
2894 N_("This font is used to display comment labels, such as "
2895 "in the governor page of the city dialogs."),
2897 "Sans Italic 9", font_changed_callback),
2898 GEN_FONT_OPTION(gui_gtk3_22_font_city_names, "city_names",
2899 N_("City Names"),
2900 N_("This font is used to the display the city names "
2901 "on the map."),
2903 "Sans Bold 10", NULL),
2904 GEN_FONT_OPTION(gui_gtk3_22_font_city_productions, "city_productions",
2905 N_("City Productions"),
2906 N_("This font is used to display the city production "
2907 "on the map."),
2909 "Serif 10", NULL),
2910 GEN_FONT_OPTION(gui_gtk3_22_font_reqtree_text, "reqtree_text",
2911 N_("Requirement Tree"),
2912 N_("This font is used to the display the requirement tree "
2913 "in the Research report."),
2915 "Serif 10", NULL),
2916
2917 /* gui-gtk-4.0 client specific options. */
2918 GEN_BOOL_OPTION(gui_gtk4_fullscreen, N_("Fullscreen"),
2919 N_("If this option is set the client will use the "
2920 "whole screen area for drawing."),
2922 GEN_BOOL_OPTION(gui_gtk4_map_scrollbars, N_("Show map scrollbars"),
2923 N_("Disable this option to hide the scrollbars on the "
2924 "map view."),
2926 GEN_BOOL_OPTION(gui_gtk4_dialogs_on_top, N_("Keep dialogs on top"),
2927 N_("If this option is set then dialog windows will always "
2928 "remain in front of the main Freeciv window. "
2929 "Disabling this has no effect in fullscreen mode."),
2931 GEN_BOOL_OPTION(gui_gtk4_show_task_icons, N_("Show worklist task icons"),
2932 N_("Disabling this will turn off the unit and building "
2933 "icons in the worklist dialog and the production "
2934 "tab of the city dialog."),
2936 GEN_BOOL_OPTION(gui_gtk4_enable_tabs, N_("Enable status report tabs"),
2937 N_("If this option is enabled then report dialogs will "
2938 "be shown as separate tabs rather than in popup "
2939 "dialogs."),
2941 GEN_BOOL_OPTION(gui_gtk4_show_chat_message_time,
2942 N_("Show time for each chat message"),
2943 N_("If this option is enabled then all chat messages "
2944 "will be prefixed by a time string of the form "
2945 "[hour:minute:second]."),
2947 GEN_BOOL_OPTION(gui_gtk4_new_messages_go_to_top,
2948 N_("New message events go to top of list"),
2949 N_("If this option is enabled, new events in the "
2950 "message window will appear at the top of the list, "
2951 "rather than being appended at the bottom."),
2953 GEN_BOOL_OPTION(gui_gtk4_show_message_window_buttons,
2954 N_("Show extra message window buttons"),
2955 N_("If this option is enabled, there will be two "
2956 "buttons displayed in the message window for "
2957 "inspecting a city and going to a location. If this "
2958 "option is disabled, these buttons will not appear "
2959 "(you can still double-click with the left mouse "
2960 "button or right-click on a row to inspect or goto "
2961 "respectively). This option will only take effect "
2962 "once the message window is closed and reopened."),
2964 GEN_BOOL_OPTION(gui_gtk4_metaserver_tab_first,
2965 N_("Metaserver tab first in network page"),
2966 N_("If this option is enabled, the metaserver tab will "
2967 "be the first notebook tab in the network page. This "
2968 "option requires a restart in order to take effect."),
2970 GEN_BOOL_OPTION(gui_gtk4_allied_chat_only,
2971 N_("Plain chat messages are sent to allies only"),
2972 N_("If this option is enabled, then plain messages "
2973 "typed into the chat entry while the game is "
2974 "running will only be sent to your allies. "
2975 "Otherwise plain messages will be sent as "
2976 "public chat messages. To send a public chat "
2977 "message with this option enabled, prefix the "
2978 "message with a single colon ':'. This option "
2979 "can also be set using a toggle button beside "
2980 "the chat entry (only visible in multiplayer "
2981 "games)."),
2983 GEN_ENUM_OPTION(gui_gtk4_message_chat_location,
2984 N_("Messages and Chat reports location"),
2985 /* TRANS: The strings used in the UI for 'Split' etc are
2986 * tagged 'gui_gtk2/gtk3/gtk4_message_chat_location' */
2987 N_("Controls where the Messages and Chat reports "
2988 "appear relative to the main view containing the map.\n"
2989 "'Split' allows all three to be seen simultaneously, "
2990 "which is best for multiplayer, but requires a large "
2991 "window to be usable.\n"
2992 "'Separate' puts Messages and Chat in a notebook "
2993 "separate from the main view, so that one of them "
2994 "can always be seen alongside the main view.\n"
2995 "'Merged' makes the Messages and Chat reports into "
2996 "tabs alongside the map and other reports; this "
2997 "allows a larger map view on small screens.\n"
2998 "This option requires a restart in order to take "
2999 "effect."), COC_INTERFACE, GUI_GTK4,
3002 GEN_BOOL_OPTION(gui_gtk4_small_display_layout,
3003 N_("Arrange widgets for small displays"),
3004 N_("If this option is enabled, widgets in the main "
3005 "window will be arranged so that they take up the "
3006 "least amount of total screen space. Specifically, "
3007 "the left panel containing the overview, player "
3008 "status, and the unit information box will be "
3009 "extended over the entire left side of the window. "
3010 "This option requires a restart in order to take "
3011 "effect."), COC_INTERFACE, GUI_GTK4, FALSE, NULL),
3012 GEN_BOOL_OPTION(gui_gtk4_mouse_over_map_focus,
3013 N_("Mouse over the map widget selects it automatically"),
3014 N_("If this option is enabled, then the map will be "
3015 "focused when the mouse hovers over it."),
3017 GEN_BOOL_OPTION(gui_gtk4_chatline_autocompletion,
3018 N_("Player or user name autocompletion"),
3019 N_("If this option is turned on, the tabulation key "
3020 "will be used in the chatline to complete the word you "
3021 "are typing with the name of a player or a user."),
3023 GEN_INT_OPTION(gui_gtk4_citydlg_xsize,
3024 N_("Width of the city dialog"),
3025 N_("This value is only used if the width of the city "
3026 "dialog is saved."),
3029 NULL),
3030 GEN_INT_OPTION(gui_gtk4_citydlg_ysize,
3031 N_("Height of the city dialog"),
3032 N_("This value is only used if the height of the city "
3033 "dialog is saved."),
3036 NULL),
3037 GEN_ENUM_OPTION(gui_gtk4_popup_tech_help,
3038 N_("Popup tech help when gained"),
3039 N_("Controls if tech help should be opened when "
3040 "new tech has been gained.\n"
3041 "'Ruleset' means that behavior suggested by "
3042 "current ruleset is used."), COC_INTERFACE, GUI_GTK4,
3045 GEN_INT_OPTION(gui_gtk4_governor_range_min,
3046 N_("Minimum surplus for a governor"),
3047 N_("The lower limit of the range for requesting surpluses "
3048 "from the governor."),
3051 NULL),
3052 GEN_INT_OPTION(gui_gtk4_governor_range_max,
3053 N_("Maximum surplus for a governor"),
3054 N_("The higher limit of the range for requesting surpluses "
3055 "from the governor."),
3058 NULL),
3059 GEN_FONT_OPTION(gui_gtk4_font_city_label, "city_label",
3060 N_("City Label"),
3061 N_("This font is used to display the city labels on city "
3062 "dialogs."),
3064 "Monospace 8", font_changed_callback),
3065 GEN_FONT_OPTION(gui_gtk4_font_notify_label, "notify_label",
3066 N_("Notify Label"),
3067 N_("This font is used to display server reports such "
3068 "as the demographic report or historian publications."),
3070 "Monospace Bold 9", font_changed_callback),
3071 GEN_FONT_OPTION(gui_gtk4_font_spaceship_label, "spaceship_label",
3072 N_("Spaceship Label"),
3073 N_("This font is used to display the spaceship widgets."),
3075 "Monospace 8", font_changed_callback),
3076 GEN_FONT_OPTION(gui_gtk4_font_help_label, "help_label",
3077 N_("Help Label"),
3078 N_("This font is used to display the help headers in the "
3079 "help window."),
3081 "Sans Bold 10", font_changed_callback),
3082 GEN_FONT_OPTION(gui_gtk4_font_help_link, "help_link",
3083 N_("Help Link"),
3084 N_("This font is used to display the help links in the "
3085 "help window."),
3087 "Sans 9", font_changed_callback),
3088 GEN_FONT_OPTION(gui_gtk4_font_help_text, "help_text",
3089 N_("Help Text"),
3090 N_("This font is used to display the help body text in "
3091 "the help window."),
3093 "Monospace 8", font_changed_callback),
3094 GEN_FONT_OPTION(gui_gtk4_font_chatline, "chatline",
3095 N_("Chatline Area"),
3096 N_("This font is used to display the text in the "
3097 "chatline area."),
3099 "Monospace 8", font_changed_callback),
3100 GEN_FONT_OPTION(gui_gtk4_font_beta_label, "beta_label",
3101 N_("Beta Label"),
3102 N_("This font is used to display the beta label."),
3104 "Sans Italic 10", font_changed_callback),
3105 GEN_FONT_OPTION(gui_gtk4_font_small, "small_font",
3106 N_("Small Font"),
3107 N_("This font is used for any small font request. For "
3108 "example, it is used for display the building lists "
3109 "in the city dialog, the Economy report or the Units "
3110 "report."),
3112 "Sans 9", font_changed_callback),
3113 GEN_FONT_OPTION(gui_gtk4_font_comment_label, "comment_label",
3114 N_("Comment Label"),
3115 N_("This font is used to display comment labels, such as "
3116 "in the governor page of the city dialogs."),
3118 "Sans Italic 9", font_changed_callback),
3119 GEN_FONT_OPTION(gui_gtk4_font_city_names, "city_names",
3120 N_("City Names"),
3121 N_("This font is used to the display the city names "
3122 "on the map."),
3124 "Sans Bold 10", NULL),
3125 GEN_FONT_OPTION(gui_gtk4_font_city_productions, "city_productions",
3126 N_("City Productions"),
3127 N_("This font is used to display the city production "
3128 "on the map."),
3130 "Serif 10", NULL),
3131 GEN_FONT_OPTION(gui_gtk4_font_reqtree_text, "reqtree_text",
3132 N_("Requirement Tree"),
3133 N_("This font is used to the display the requirement tree "
3134 "in the Research report."),
3136 "Serif 10", NULL),
3137
3138 /* gui-sdl client specific options.
3139 * These are still kept just so users can migrate them to sdl2-client */
3140 GEN_BOOL_OPTION(gui_sdl_fullscreen, NULL, NULL,
3142 GEN_VIDEO_OPTION(gui_sdl_screen, NULL, NULL,
3143 COC_INTERFACE, GUI_SDL, 640, 480, NULL),
3144 GEN_BOOL_OPTION(gui_sdl_do_cursor_animation, NULL, NULL,
3146 GEN_BOOL_OPTION(gui_sdl_use_color_cursors, NULL, NULL,
3148
3149 /* gui-sdl2 client specific options. */
3150 GEN_BOOL_OPTION(gui_sdl2_fullscreen, N_("Fullscreen"),
3151 N_("If this option is set the client will use the "
3152 "whole screen area for drawing."),
3154 GEN_VIDEO_OPTION(gui_sdl2_screen, N_("Screen resolution"),
3155 N_("This option controls the resolution of the "
3156 "selected screen."),
3157 COC_INTERFACE, GUI_SDL2, 640, 480, NULL),
3158 GEN_BOOL_OPTION(gui_sdl2_swrenderer, N_("Use software rendering"),
3159 N_("Usually hardware rendering is used when possible. "
3160 "With this option set, software rendering is always used."),
3162 GEN_BOOL_OPTION(gui_sdl2_do_cursor_animation, N_("Do cursor animation"),
3163 N_("If this option is disabled, the cursor will "
3164 "always be displayed as static."),
3166 GEN_BOOL_OPTION(gui_sdl2_use_color_cursors, N_("Use color cursors"),
3167 N_("If this option is disabled, the cursor will "
3168 "always be displayed in black and white."),
3170 GEN_FONT_OPTION(gui_sdl2_font_city_names, "FONT_CITY_NAME",
3171 N_("City Names"),
3172 N_("The size of font used to the display the city names "
3173 "on the map."),
3175 "10", font_changed_callback),
3176 GEN_FONT_OPTION(gui_sdl2_font_city_productions, "FONT_CITY_PROD",
3177 N_("City Productions"),
3178 N_("The size of font used to the display the city "
3179 "production names on the map."),
3181 "10", font_changed_callback),
3182 GEN_BOOL_OPTION(gui_sdl2_use_theme_font_size, N_("Use theme defined font size"),
3183 N_("Disable this to override base font size set by theme "
3184 "by the setting below."),
3186 GEN_INT_OPTION(gui_sdl2_font_size, N_("Base Font Size"),
3187 N_("Base Font Size. All the fonts' sizes are defined relative "
3188 "to this. This option has effect only if theme font sizes "
3189 "option is disabled."),
3190 COC_FONT, GUI_SDL2, 10, 6, 50, NULL),
3191
3192 /* gui-sdl3 client specific options. */
3193 GEN_BOOL_OPTION(gui_sdl3_fullscreen, N_("Fullscreen"),
3194 N_("If this option is set the client will use the "
3195 "whole screen area for drawing."),
3197 GEN_VIDEO_OPTION(gui_sdl3_screen, N_("Screen resolution"),
3198 N_("This option controls the resolution of the "
3199 "selected screen."),
3200 COC_INTERFACE, GUI_SDL3, 640, 480, NULL),
3201 GEN_BOOL_OPTION(gui_sdl3_do_cursor_animation, N_("Do cursor animation"),
3202 N_("If this option is disabled, the cursor will "
3203 "always be displayed as static."),
3205 GEN_BOOL_OPTION(gui_sdl3_use_color_cursors, N_("Use color cursors"),
3206 N_("If this option is disabled, the cursor will "
3207 "always be displayed in black and white."),
3209 GEN_FONT_OPTION(gui_sdl3_font_city_names, "FONT_CITY_NAME",
3210 N_("City Names"),
3211 N_("The size of font used to the display the city names "
3212 "on the map."),
3214 "10", font_changed_callback),
3215 GEN_FONT_OPTION(gui_sdl3_font_city_productions, "FONT_CITY_PROD",
3216 N_("City Productions"),
3217 N_("The size of font used to the display the city "
3218 "production names on the map."),
3220 "10", font_changed_callback),
3221 GEN_BOOL_OPTION(gui_sdl3_use_theme_font_size, N_("Use theme defined font size"),
3222 N_("Disable this to override base font size set by theme "
3223 "by the setting below."),
3225 GEN_INT_OPTION(gui_sdl3_font_size, N_("Base Font Size"),
3226 N_("Base Font Size. All the fonts' sizes are defined relative "
3227 "to this. This option has effect only if theme font sizes "
3228 "option is disabled."),
3229 COC_FONT, GUI_SDL3, 10, 6, 50, NULL),
3230
3231 /* gui-qt client specific options. */
3232 GEN_BOOL_OPTION(gui_qt_fullscreen, N_("Fullscreen"),
3233 N_("If this option is set the client will use the "
3234 "whole screen area for drawing."),
3236 GEN_BOOL_OPTION(gui_qt_show_titlebar, N_("Show titlebar"),
3237 N_("If this option is set the client will show a titlebar. "
3238 "If disabled, then no titlebar will be shown, and "
3239 "minimize/maximize/etc buttons will be placed on the "
3240 "menu bar."),
3242 GEN_FONT_OPTION(gui_qt_font_default, "default_font",
3243 N_("Default font"),
3244 N_("This is default font"),
3246 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3247 GEN_FONT_OPTION(gui_qt_font_notify_label, "notify_label",
3248 N_("Notify Label"),
3249 N_("This font is used to display server reports such "
3250 "as the demographic report or historian publications."),
3252 "Monospace,9,-1,5,75,0,0,0,0,0", font_changed_callback),
3253 GEN_FONT_OPTION(gui_qt_font_help_label, "help_label",
3254 N_("Help Label"),
3255 N_("This font is used to display the help labels in the "
3256 "help window."),
3258 "Sans Serif,9,-1,5,50,0,0,0,0,0", font_changed_callback),
3259 GEN_FONT_OPTION(gui_qt_font_help_text, "help_text",
3260 N_("Help Text"),
3261 N_("This font is used to display the help body text in "
3262 "the help window."),
3264 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3265 GEN_FONT_OPTION(gui_qt_font_chatline, "chatline",
3266 N_("Chatline Area"),
3267 N_("This font is used to display the text in the "
3268 "chatline area."),
3270 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3271 GEN_FONT_OPTION(gui_qt_font_city_names, "city_names",
3272 N_("City Names"),
3273 N_("This font is used to the display the city names "
3274 "on the map."),
3276 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3277 GEN_FONT_OPTION(gui_qt_font_city_productions, "city_productions",
3278 N_("City Productions"),
3279 N_("This font is used to display the city production "
3280 "on the map."),
3282 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3283 GEN_FONT_OPTION(gui_qt_font_reqtree_text, "reqtree_text",
3284 N_("Requirement Tree"),
3285 N_("This font is used to the display the requirement tree "
3286 "in the Research report."),
3288 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3289 GEN_BOOL_OPTION(gui_qt_show_preview, N_("Show savegame information"),
3290 N_("If this option is set the client will show "
3291 "information and map preview of current savegame."),
3293 GEN_BOOL_OPTION(gui_qt_sidebar_left, N_("Sidebar position"),
3294 N_("If this option is set, the sidebar will be to the left "
3295 "of the map, otherwise to the right."),
3297 GEN_STR_OPTION(gui_qt_wakeup_text,
3298 N_("Wake up sequence"),
3299 N_("String which will trigger sound in pregame page; "
3300 "%1 stands for username."),
3301 COC_INTERFACE, GUI_QT, "Wake up %1", NULL, 0),
3302 GEN_BOOL_OPTION(gui_qt_svgflags, N_("SVG flags features"),
3304 N_("Enable svgflags features, such as bigger flags "
3305 "on the diplomacy dialog. Change to this comes "
3306 "to an effect on next client start."),
3307#else /* FREECIV_SVG_FLAGS */
3308 N_("Enable svgflags features, such as bigger flags "
3309 "on the diplomacy dialog. This has no effect on "
3310 "this freeciv build, as the svg support has not "
3311 "been built in."),
3312#endif /* FREECIV_SVG_FLAGS */
3314};
3316
3317/* Iteration loop, including invalid options for the current gui type. */
3318#define client_options_iterate_all(poption) \
3319{ \
3320 const struct client_option *const poption##_max = \
3321 client_options + client_options_num; \
3322 struct client_option *client_##poption = client_options; \
3323 struct option *poption; \
3324 for (; client_##poption < poption##_max; client_##poption++) { \
3325 poption = OPTION(client_##poption);
3326
3327#define client_options_iterate_all_end \
3328 } \
3329}
3330
3331
3332/************************************************************************/
3335static struct client_option *
3337{
3338 const struct client_option *const max =
3340 const enum gui_type our_type = get_gui_type();
3341
3342 while (poption < max
3343 && poption->specific != GUI_STUB
3344 && poption->specific != our_type) {
3345 poption++;
3346 }
3347
3348 return (poption < max ? poption : NULL);
3349}
3350
3351/************************************************************************/
3355{
3356 if (0 > id || id > client_options_num) {
3357 return NULL;
3358 }
3359 return OPTION(client_options + id);
3360}
3361
3362/************************************************************************/
3369
3370/************************************************************************/
3374{
3375 return COC_MAX;
3376}
3377
3378/************************************************************************/
3381static const char *client_optset_category_name(int category)
3382{
3383 switch (category) {
3384 case COC_GRAPHICS:
3385 return _("Graphics");
3386 case COC_OVERVIEW:
3387 /* TRANS: Options section for overview map (mini-map) */
3388 return Q_("?map:Overview");
3389 case COC_SOUND:
3390 return _("Sound");
3391 case COC_INTERFACE:
3392 return _("Interface");
3393 case COC_MAPIMG:
3394 return _("Map Image");
3395 case COC_NETWORK:
3396 return _("Network");
3397 case COC_FONT:
3398 return _("Font");
3399 case COC_MAX:
3400 break;
3401 }
3402
3403 log_error("%s: invalid option category number %d.",
3404 __FUNCTION__, category);
3405 return NULL;
3406}
3407
3408/************************************************************************/
3411static int client_option_number(const struct option *poption)
3412{
3414}
3415
3416/************************************************************************/
3419static const char *client_option_name(const struct option *poption)
3420{
3421 return CLIENT_OPTION(poption)->name;
3422}
3423
3424/************************************************************************/
3427static const char *client_option_description(const struct option *poption)
3428{
3429 return _(CLIENT_OPTION(poption)->description);
3430}
3431
3432/************************************************************************/
3435static const char *client_option_help_text(const struct option *poption)
3436{
3437 return _(CLIENT_OPTION(poption)->help_text);
3438}
3439
3440/************************************************************************/
3443static int client_option_category(const struct option *poption)
3444{
3445 return CLIENT_OPTION(poption)->category;
3446}
3447
3448/************************************************************************/
3452{
3453 return TRUE;
3454}
3455
3456/************************************************************************/
3459static struct option *client_option_next(const struct option *poption)
3460{
3462}
3463
3464/************************************************************************/
3467static bool client_option_bool_get(const struct option *poption)
3468{
3469 return *(CLIENT_OPTION(poption)->boolean.pvalue);
3470}
3471
3472/************************************************************************/
3475static bool client_option_bool_def(const struct option *poption)
3476{
3477 return CLIENT_OPTION(poption)->boolean.def;
3478}
3479
3480/************************************************************************/
3484static bool client_option_bool_set(struct option *poption, bool val)
3485{
3487
3488 if (*pcoption->boolean.pvalue == val) {
3489 return FALSE;
3490 }
3491
3492 *pcoption->boolean.pvalue = val;
3493 return TRUE;
3494}
3495
3496/************************************************************************/
3499static int client_option_int_get(const struct option *poption)
3500{
3501 return *(CLIENT_OPTION(poption)->integer.pvalue);
3502}
3503
3504/************************************************************************/
3507static int client_option_int_def(const struct option *poption)
3508{
3509 return CLIENT_OPTION(poption)->integer.def;
3510}
3511
3512/************************************************************************/
3515static int client_option_int_min(const struct option *poption)
3516{
3517 return CLIENT_OPTION(poption)->integer.min;
3518}
3519
3520/************************************************************************/
3523static int client_option_int_max(const struct option *poption)
3524{
3525 return CLIENT_OPTION(poption)->integer.max;
3526}
3527
3528/************************************************************************/
3532static bool client_option_int_set(struct option *poption, int val)
3533{
3535
3537 || val > pcoption->integer.max
3538 || *pcoption->integer.pvalue == val) {
3539 return FALSE;
3540 }
3541
3542 *pcoption->integer.pvalue = val;
3543 return TRUE;
3544}
3545
3546/************************************************************************/
3549static const char *client_option_str_get(const struct option *poption)
3550{
3551 return CLIENT_OPTION(poption)->string.pvalue;
3552}
3553
3554/************************************************************************/
3557static const char *client_option_str_def(const struct option *poption)
3558{
3559 return CLIENT_OPTION(poption)->string.def;
3560}
3561
3562/************************************************************************/
3566static const struct strvec *
3568{
3569 return (CLIENT_OPTION(poption)->string.val_accessor
3570 ? CLIENT_OPTION(poption)->string.val_accessor(poption) : NULL);
3571}
3572
3573/************************************************************************/
3577static bool client_option_str_set(struct option *poption, const char *str)
3578{
3580
3581 if (strlen(str) >= pcoption->string.size
3582 || 0 == strcmp(pcoption->string.pvalue, str)) {
3583 return FALSE;
3584 }
3585
3586 fc_strlcpy(pcoption->string.pvalue, str, pcoption->string.size);
3587 return TRUE;
3588}
3589
3590/************************************************************************/
3593static int client_option_enum_get(const struct option *poption)
3594{
3595 return *(CLIENT_OPTION(poption)->enumerator.pvalue);
3596}
3597
3598/************************************************************************/
3601static int client_option_enum_def(const struct option *poption)
3602{
3603 return CLIENT_OPTION(poption)->enumerator.def;
3604}
3605
3606/************************************************************************/
3610static const struct strvec *
3612{
3613 return CLIENT_OPTION(poption)->enumerator.pretty_names;
3614}
3615
3616/************************************************************************/
3620static bool client_option_enum_set(struct option *poption, int val)
3621{
3623
3624 if (*pcoption->enumerator.pvalue == val
3625 || 0 > val
3626 || val >= strvec_size(pcoption->enumerator.support_names)) {
3627 return FALSE;
3628 }
3629
3630 *pcoption->enumerator.pvalue = val;
3631 return TRUE;
3632}
3633
3634/************************************************************************/
3640 int val)
3641{
3642 const struct strvec *names = CLIENT_OPTION(data)->enumerator.support_names;
3643
3644 return (0 <= val && val < strvec_size(names)
3645 ? strvec_get(names, val) : NULL);
3646}
3647
3648#if 0 /* There's no bitwise options currently */
3649/************************************************************************/
3652static unsigned client_option_bitwise_get(const struct option *poption)
3653{
3654 return *(CLIENT_OPTION(poption)->bitwise.pvalue);
3655}
3656
3657/************************************************************************/
3660static unsigned client_option_bitwise_def(const struct option *poption)
3661{
3662 return CLIENT_OPTION(poption)->bitwise.def;
3663}
3664
3665/************************************************************************/
3669static const struct strvec *
3671{
3672 return CLIENT_OPTION(poption)->bitwise.pretty_names;
3673}
3674
3675/************************************************************************/
3679static bool client_option_bitwise_set(struct option *poption, unsigned val)
3680{
3682
3683 if (*pcoption->bitwise.pvalue == val) {
3684 return FALSE;
3685 }
3686
3687 *pcoption->bitwise.pvalue = val;
3688 return TRUE;
3689}
3690#endif /* 0 */
3691
3692/************************************************************************/
3698 int val)
3699{
3700 const struct strvec *names = CLIENT_OPTION(data)->bitwise.support_names;
3701
3702 return (0 <= val && val < strvec_size(names)
3703 ? strvec_get(names, val) : NULL);
3704}
3705
3706/************************************************************************/
3709static const char *client_option_font_get(const struct option *poption)
3710{
3711 return CLIENT_OPTION(poption)->font.pvalue;
3712}
3713
3714/************************************************************************/
3717static const char *client_option_font_def(const struct option *poption)
3718{
3719 return CLIENT_OPTION(poption)->font.def;
3720}
3721
3722/************************************************************************/
3725static const char *client_option_font_target(const struct option *poption)
3726{
3727 return CLIENT_OPTION(poption)->font.target;
3728}
3729
3730/************************************************************************/
3734static bool client_option_font_set(struct option *poption, const char *font)
3735{
3737
3738 if (strlen(font) >= pcoption->font.size
3739 || 0 == strcmp(pcoption->font.pvalue, font)) {
3740 return FALSE;
3741 }
3742
3743 fc_strlcpy(pcoption->font.pvalue, font, pcoption->font.size);
3744 return TRUE;
3745}
3746
3747/************************************************************************/
3751{
3752 return *CLIENT_OPTION(poption)->color.pvalue;
3753}
3754
3755/************************************************************************/
3759{
3760 return CLIENT_OPTION(poption)->color.def;
3761}
3762
3763/************************************************************************/
3768 struct ft_color color)
3769{
3770 struct ft_color *pcolor = CLIENT_OPTION(poption)->color.pvalue;
3771 bool changed = FALSE;
3772
3773#define color_set(color_tgt, color) \
3774 if (NULL == color_tgt) { \
3775 if (NULL != color) { \
3776 color_tgt = fc_strdup(color); \
3777 changed = TRUE; \
3778 } \
3779 } else { \
3780 if (NULL == color) { \
3781 free((void *) color_tgt); \
3782 color_tgt = NULL; \
3783 changed = TRUE; \
3784 } else if (0 != strcmp(color_tgt, color)) { \
3785 free((void *) color_tgt); \
3786 color_tgt = fc_strdup(color); \
3787 changed = TRUE; \
3788 } \
3789 }
3790
3791 color_set(pcolor->foreground, color.foreground);
3792 color_set(pcolor->background, color.background);
3793
3794#undef color_set
3795
3796 return changed;
3797}
3798
3799/************************************************************************/
3802static struct video_mode
3804{
3805 return *CLIENT_OPTION(poption)->video_mode.pvalue;
3806}
3807
3808/************************************************************************/
3811static struct video_mode
3816
3817/************************************************************************/
3822 struct video_mode mode)
3823{
3825
3826 if (0 == memcmp(&mode, pcoption->video_mode.pvalue,
3827 sizeof(struct video_mode))) {
3828 return FALSE;
3829 }
3830
3831 *pcoption->video_mode.pvalue = mode;
3832 return TRUE;
3833}
3834
3835/************************************************************************/
3839 struct section_file *sf)
3840{
3843
3844 switch (option_type(poption)) {
3845 case OT_BOOLEAN:
3846 {
3847 bool value;
3848 const char *pname = option_name(poption);
3849 const char *old_paths = "draw_roads_rails";
3850
3851 if (!strcmp("draw_paths", pname)) {
3852 /* Renamed in freeciv-3.2 */
3853 if (secfile_lookup_bool(sf, &value, "client.draw_paths")
3854 && option_bool_set(poption, value)) {
3855 return TRUE;
3856 }
3857
3858 /* Try by old name. */
3859 pname = old_paths;
3860 }
3861
3862 return (secfile_lookup_bool(sf, &value, "client.%s",
3863 pname)
3864 && option_bool_set(poption, value));
3865 }
3866 case OT_INTEGER:
3867 {
3868 int value;
3869
3870 return (secfile_lookup_int(sf, &value, "client.%s",
3872 && option_int_set(poption, value));
3873 }
3874 case OT_STRING:
3875 {
3876 const char *string;
3877
3878 return ((string = secfile_lookup_str(sf, "client.%s",
3880 && option_str_set(poption, string));
3881 }
3882 case OT_ENUM:
3883 {
3884 int value;
3885
3886 return (secfile_lookup_enum_data(sf, &value, FALSE,
3888 poption, "client.%s",
3890 && option_enum_set_int(poption, value));
3891 }
3892 case OT_BITWISE:
3893 {
3894 int value;
3895
3896 return (secfile_lookup_enum_data(sf, &value, TRUE,
3898 poption, "client.%s",
3900 && option_bitwise_set(poption, value));
3901 }
3902 case OT_FONT:
3903 {
3904 const char *string;
3905
3906 return ((string = secfile_lookup_str(sf, "client.%s",
3908 && option_font_set(poption, string));
3909 }
3910 case OT_COLOR:
3911 {
3912 struct ft_color color;
3913
3914 return ((color.foreground =
3915 secfile_lookup_str(sf, "client.%s.foreground",
3917 && (color.background =
3918 secfile_lookup_str(sf, "client.%s.background",
3921 }
3922 case OT_VIDEO_MODE:
3923 {
3924 struct video_mode mode;
3925
3926 return (secfile_lookup_int(sf, &mode.width, "client.%s.width",
3928 && secfile_lookup_int(sf, &mode.height, "client.%s.height",
3930 && option_video_mode_set(poption, mode));
3931 }
3932 }
3933 return FALSE;
3934}
3935
3936/************************************************************************/
3940 struct section_file *sf)
3941{
3943 fc_assert_ret(NULL != sf);
3944
3945 switch (option_type(poption)) {
3946 case OT_BOOLEAN:
3948 "client.%s", option_name(poption));
3949 break;
3950 case OT_INTEGER:
3952 "client.%s", option_name(poption));
3953 break;
3954 case OT_STRING:
3956 "client.%s", option_name(poption));
3957 break;
3958 case OT_ENUM:
3961 "client.%s", option_name(poption));
3962 break;
3963 case OT_BITWISE:
3966 "client.%s", option_name(poption));
3967 break;
3968 case OT_FONT:
3970 "client.%s", option_name(poption));
3971 break;
3972 case OT_COLOR:
3973 {
3975
3976 secfile_insert_str(sf, color.foreground, "client.%s.foreground",
3978 secfile_insert_str(sf, color.background, "client.%s.background",
3980 }
3981 break;
3982 case OT_VIDEO_MODE:
3983 {
3985
3986 secfile_insert_int(sf, mode.width, "client.%s.width",
3988 secfile_insert_int(sf, mode.height, "client.%s.height",
3990 }
3991 break;
3992 }
3993}
3994
3995
3996/****************************************************************************
3997 Server options variables.
3998****************************************************************************/
4001
4003static int server_options_num = 0;
4004
4005
4006/****************************************************************************
4007 Server option set.
4008****************************************************************************/
4009static struct option *server_optset_option_by_number(int id);
4010static struct option *server_optset_option_first(void);
4011static int server_optset_category_number(void);
4012static const char *server_optset_category_name(int category);
4013
4016 .option_first = server_optset_option_first,
4017 .category_number = server_optset_category_number,
4018 .category_name = server_optset_category_name
4019};
4021
4022
4023/****************************************************************************
4024 Virtuals tables for the client options.
4025****************************************************************************/
4026static int server_option_number(const struct option *poption);
4027static const char *server_option_name(const struct option *poption);
4028static const char *server_option_description(const struct option *poption);
4029static const char *server_option_help_text(const struct option *poption);
4030static int server_option_category(const struct option *poption);
4031static bool server_option_is_changeable(const struct option *poption);
4032static struct option *server_option_next(const struct option *poption);
4033
4034static const struct option_common_vtable server_option_common_vtable = {
4035 .number = server_option_number,
4036 .name = server_option_name,
4037 .description = server_option_description,
4038 .help_text = server_option_help_text,
4039 .category = server_option_category,
4040 .is_changeable = server_option_is_changeable,
4041 .next = server_option_next
4042};
4043
4044static bool server_option_bool_get(const struct option *poption);
4045static bool server_option_bool_def(const struct option *poption);
4046static bool server_option_bool_set(struct option *poption, bool val);
4047
4048static const struct option_bool_vtable server_option_bool_vtable = {
4052};
4053
4054static int server_option_int_get(const struct option *poption);
4055static int server_option_int_def(const struct option *poption);
4056static int server_option_int_min(const struct option *poption);
4057static int server_option_int_max(const struct option *poption);
4058static bool server_option_int_set(struct option *poption, int val);
4059
4060static const struct option_int_vtable server_option_int_vtable = {
4061 .get = server_option_int_get,
4062 .def = server_option_int_def,
4063 .minimum = server_option_int_min,
4064 .maximum = server_option_int_max,
4066};
4067
4068static const char *server_option_str_get(const struct option *poption);
4069static const char *server_option_str_def(const struct option *poption);
4070static const struct strvec *
4072static bool server_option_str_set(struct option *poption, const char *str);
4073
4074static const struct option_str_vtable server_option_str_vtable = {
4075 .get = server_option_str_get,
4076 .def = server_option_str_def,
4077 .values = server_option_str_values,
4079};
4080
4081static int server_option_enum_get(const struct option *poption);
4082static int server_option_enum_def(const struct option *poption);
4083static const struct strvec *
4085static bool server_option_enum_set(struct option *poption, int val);
4086
4087static const struct option_enum_vtable server_option_enum_vtable = {
4090 .values = server_option_enum_pretty,
4092 .cmp = strcmp
4093};
4094
4095static unsigned server_option_bitwise_get(const struct option *poption);
4096static unsigned server_option_bitwise_def(const struct option *poption);
4097static const struct strvec *
4099static bool server_option_bitwise_set(struct option *poption, unsigned val);
4100
4101static const struct option_bitwise_vtable server_option_bitwise_vtable = {
4106};
4107
4108/****************************************************************************
4109 Derived class server option, inheriting from base class option.
4110****************************************************************************/
4112 struct option base_option; /* Base structure, must be the first! */
4113
4114 char *name; /* Short name - used as an identifier */
4115 char *description; /* One-line description */
4116 char *help_text; /* Paragraph-length help text */
4117 unsigned char category;
4122
4123 union {
4124 /* OT_BOOLEAN type option. */
4125 struct {
4126 bool value;
4127 bool def;
4128 } boolean;
4129 /* OT_INTEGER type option. */
4130 struct {
4132 int def, min, max;
4133 } integer;
4134 /* OT_STRING type option. */
4135 struct {
4136 char *value;
4137 char *def;
4138 } string;
4139 /* OT_ENUM type option. */
4140 struct {
4141 int value;
4142 int def;
4144 struct strvec *pretty_names; /* untranslated */
4145 } enumerator;
4146 /* OT_BITWISE type option. */
4147 struct {
4148 unsigned value;
4149 unsigned def;
4150 struct strvec *support_names;
4151 struct strvec *pretty_names; /* untranslated */
4152 } bitwise;
4153 };
4154};
4155
4156#define SERVER_OPTION(poption) ((struct server_option *) (poption))
4157
4158static void desired_settable_option_send(struct option *poption);
4159
4160
4161/************************************************************************/
4171
4172/************************************************************************/
4176{
4177 option_gui_remove(&(poption->base_option));
4178
4179 switch (poption->base_option.type) {
4180 case OT_STRING:
4181 if (NULL != poption->string.value) {
4182 FC_FREE(poption->string.value);
4183 }
4184 if (NULL != poption->string.def) {
4185 FC_FREE(poption->string.def);
4186 }
4187 break;
4188
4189 case OT_ENUM:
4190 if (NULL != poption->enumerator.support_names) {
4191 strvec_destroy(poption->enumerator.support_names);
4192 poption->enumerator.support_names = NULL;
4193 }
4194 if (NULL != poption->enumerator.pretty_names) {
4195 strvec_destroy(poption->enumerator.pretty_names);
4196 poption->enumerator.pretty_names = NULL;
4197 }
4198 break;
4199
4200 case OT_BITWISE:
4201 if (NULL != poption->bitwise.support_names) {
4202 strvec_destroy(poption->bitwise.support_names);
4203 poption->bitwise.support_names = NULL;
4204 }
4205 if (NULL != poption->bitwise.pretty_names) {
4206 strvec_destroy(poption->bitwise.pretty_names);
4207 poption->bitwise.pretty_names = NULL;
4208 }
4209 break;
4210
4211 case OT_BOOLEAN:
4212 case OT_INTEGER:
4213 case OT_FONT:
4214 case OT_COLOR:
4215 case OT_VIDEO_MODE:
4216 break;
4217 }
4218
4219 if (NULL != poption->name) {
4220 FC_FREE(poption->name);
4221 }
4222 if (NULL != poption->description) {
4223 FC_FREE(poption->description);
4224 }
4225 if (NULL != poption->help_text) {
4226 FC_FREE(poption->help_text);
4227 }
4228}
4229
4230/************************************************************************/
4234{
4235 int i;
4236
4237 /* Don't keep this dialog open. */
4239
4240 /* Free the options themselves. */
4241 if (NULL != server_options) {
4242 for (i = 0; i < server_options_num; i++) {
4244 }
4247 }
4248
4249 /* Free the categories. */
4251 for (i = 0; i < server_options_categories_num; i++) {
4254 }
4255 }
4258 }
4259}
4260
4261/************************************************************************/
4265 (const struct packet_server_setting_control *packet)
4266{
4267 int i;
4268
4269 /* This packet should be received only once. */
4274
4275 /* Allocate server option categories. */
4276 if (0 < packet->categories_num) {
4280 sizeof(*server_options_categories));
4281
4282 for (i = 0; i < server_options_categories_num; i++) {
4283 /* NB: Translate now. */
4285 }
4286 }
4287
4288 /* Allocate server options. */
4289 if (0 < packet->settings_num) {
4292 }
4293}
4294
4295/************************************************************************/
4299 (const struct packet_server_setting_const *packet)
4300{
4303
4305
4306 fc_assert(NULL == psoption->name);
4307 psoption->name = fc_strdup(packet->name);
4308 fc_assert(NULL == psoption->description);
4309 /* NB: Translate now. */
4310 psoption->description = fc_strdup(_(packet->short_help));
4311 fc_assert(NULL == psoption->help_text);
4312 /* NB: Translate now. */
4313 psoption->help_text = fc_strdup(_(packet->extra_help));
4314 psoption->category = packet->category;
4315}
4316
4317/****************************************************************************
4318 Common part of handle_server_setting_*() functions. See below.
4319****************************************************************************/
4320#define handle_server_setting_common(psoption, packet) \
4321 psoption->is_changeable = packet->is_changeable; \
4322 psoption->setdef = packet->setdef; \
4323 if (psoption->is_visible != packet->is_visible) { \
4324 if (psoption->is_visible) { \
4325 need_gui_remove = TRUE; \
4326 } else if (packet->is_visible) { \
4327 need_gui_add = TRUE; \
4328 } \
4329 psoption->is_visible = packet->is_visible; \
4330 } \
4331 \
4332 /* Keep this list of conditions in sync with one in \
4333 resend_desired_settable_options() */ \
4334 if (!psoption->desired_sent \
4335 && psoption->is_visible \
4336 && psoption->is_changeable \
4337 && gui_options.send_desired_settings \
4338 && is_server_running() \
4339 && packet->initial_setting) { \
4340 /* Only send our private settings if we are running \
4341 * on a forked local server, i.e. started by the \
4342 * client with the "Start New Game" button. \
4343 * Do now override settings that are already saved to savegame \
4344 * and now loaded. */ \
4345 desired_settable_option_send(OPTION(poption)); \
4346 dsend_packet_sync_serial(&client.conn, ++sync_serial); \
4347 psoption->desired_sent = TRUE; \
4348 } \
4349 \
4350 /* Update the GUI. */ \
4351 if (need_gui_remove) { \
4352 option_gui_remove(poption); \
4353 } else if (need_gui_add) { \
4354 option_gui_add(poption); \
4355 } else { \
4356 option_gui_update(poption); \
4358
4359/************************************************************************/
4363 (const struct packet_server_setting_bool *packet)
4364{
4367 bool need_gui_remove = FALSE;
4368 bool need_gui_add = FALSE;
4369
4371
4372 if (NULL == poption->common_vtable) {
4373 /* Not initialized yet. */
4374 poption->poptset = server_optset;
4375 poption->common_vtable = &server_option_common_vtable;
4376 poption->type = OT_BOOLEAN;
4377 poption->bool_vtable = &server_option_bool_vtable;
4378 }
4380 "Server setting \"%s\" (nb %d) has type %s (%d), "
4381 "expected %s (%d)",
4383 option_type_name(poption->type), poption->type,
4385
4386 if (packet->is_visible) {
4387 psoption->boolean.value = packet->val;
4388 psoption->boolean.def = packet->default_val;
4389 }
4390
4393
4394/************************************************************************/
4398 (const struct packet_server_setting_int *packet)
4399{
4402 bool need_gui_remove = FALSE;
4403 bool need_gui_add = FALSE;
4404
4406
4407 if (NULL == poption->common_vtable) {
4408 /* Not initialized yet. */
4409 poption->poptset = server_optset;
4410 poption->common_vtable = &server_option_common_vtable;
4411 poption->type = OT_INTEGER;
4412 poption->int_vtable = &server_option_int_vtable;
4413 }
4415 "Server setting \"%s\" (nb %d) has type %s (%d), "
4416 "expected %s (%d)",
4418 option_type_name(poption->type), poption->type,
4420
4421 if (packet->is_visible) {
4422 psoption->integer.value = packet->val;
4423 psoption->integer.def = packet->default_val;
4424 psoption->integer.min = packet->min_val;
4425 psoption->integer.max = packet->max_val;
4426 }
4427
4430
4431/************************************************************************/
4435 (const struct packet_server_setting_str *packet)
4436{
4439 bool need_gui_remove = FALSE;
4440 bool need_gui_add = FALSE;
4441
4443
4444 if (NULL == poption->common_vtable) {
4445 /* Not initialized yet. */
4446 poption->poptset = server_optset;
4447 poption->common_vtable = &server_option_common_vtable;
4448 poption->type = OT_STRING;
4449 poption->str_vtable = &server_option_str_vtable;
4450 }
4452 "Server setting \"%s\" (nb %d) has type %s (%d), "
4453 "expected %s (%d)",
4455 option_type_name(poption->type), poption->type,
4457
4458 if (packet->is_visible) {
4459 if (NULL == psoption->string.value) {
4460 psoption->string.value = fc_strdup(packet->val);
4461 } else if (0 != strcmp(packet->val, psoption->string.value)) {
4462 free(psoption->string.value);
4463 psoption->string.value = fc_strdup(packet->val);
4464 }
4465 if (NULL == psoption->string.def) {
4466 psoption->string.def = fc_strdup(packet->default_val);
4467 } else if (0 != strcmp(packet->default_val, psoption->string.def)) {
4468 free(psoption->string.def);
4469 psoption->string.def = fc_strdup(packet->default_val);
4470 }
4471 }
4472
4475
4476/************************************************************************/
4480 (const struct packet_server_setting_enum *packet)
4481{
4484 bool need_gui_remove = FALSE;
4485 bool need_gui_add = FALSE;
4486
4488
4489 if (NULL == poption->common_vtable) {
4490 /* Not initialized yet. */
4491 poption->poptset = server_optset;
4492 poption->common_vtable = &server_option_common_vtable;
4493 poption->type = OT_ENUM;
4494 poption->enum_vtable = &server_option_enum_vtable;
4495 }
4497 "Server setting \"%s\" (nb %d) has type %s (%d), "
4498 "expected %s (%d)",
4500 option_type_name(poption->type), poption->type,
4502
4503 if (packet->is_visible) {
4504 int i;
4505
4506 psoption->enumerator.value = packet->val;
4507 psoption->enumerator.def = packet->default_val;
4508
4509 if (NULL == psoption->enumerator.support_names) {
4510 /* First time we get this packet. */
4511 fc_assert(NULL == psoption->enumerator.pretty_names);
4512 psoption->enumerator.support_names = strvec_new();
4513 strvec_reserve(psoption->enumerator.support_names, packet->values_num);
4514 psoption->enumerator.pretty_names = strvec_new();
4515 strvec_reserve(psoption->enumerator.pretty_names, packet->values_num);
4516 for (i = 0; i < packet->values_num; i++) {
4517 strvec_set(psoption->enumerator.support_names, i,
4518 packet->support_names[i]);
4519 /* Store untranslated string from server. */
4520 strvec_set(psoption->enumerator.pretty_names, i,
4521 packet->pretty_names[i]);
4522 }
4523 } else if (strvec_size(psoption->enumerator.support_names)
4524 != packet->values_num) {
4525 fc_assert(strvec_size(psoption->enumerator.support_names)
4526 == strvec_size(psoption->enumerator.pretty_names));
4527 /* The number of values have changed, we need to reset the list
4528 * of possible values. */
4529 strvec_reserve(psoption->enumerator.support_names, packet->values_num);
4530 strvec_reserve(psoption->enumerator.pretty_names, packet->values_num);
4531 for (i = 0; i < packet->values_num; i++) {
4532 strvec_set(psoption->enumerator.support_names, i,
4533 packet->support_names[i]);
4534 /* Store untranslated string from server. */
4535 strvec_set(psoption->enumerator.pretty_names, i,
4536 packet->pretty_names[i]);
4537 }
4540 } else {
4541 /* Check if a value changed, then we need to reset the list
4542 * of possible values. */
4543 const char *str;
4544
4545 for (i = 0; i < packet->values_num; i++) {
4546 str = strvec_get(psoption->enumerator.pretty_names, i);
4547 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4548 /* Store untranslated string from server. */
4549 strvec_set(psoption->enumerator.pretty_names, i,
4550 packet->pretty_names[i]);
4553 }
4554 /* Support names are not visible, we don't need to check if it
4555 * has changed. */
4556 strvec_set(psoption->enumerator.support_names, i,
4557 packet->support_names[i]);
4558 }
4559 }
4560 }
4561
4564
4565/************************************************************************/
4569 (const struct packet_server_setting_bitwise *packet)
4570{
4573 bool need_gui_remove = FALSE;
4574 bool need_gui_add = FALSE;
4575
4577
4578 if (NULL == poption->common_vtable) {
4579 /* Not initialized yet. */
4580 poption->poptset = server_optset;
4581 poption->common_vtable = &server_option_common_vtable;
4582 poption->type = OT_BITWISE;
4583 poption->bitwise_vtable = &server_option_bitwise_vtable;
4584 }
4586 "Server setting \"%s\" (nb %d) has type %s (%d), "
4587 "expected %s (%d)",
4589 option_type_name(poption->type), poption->type,
4591
4592 if (packet->is_visible) {
4593 int i;
4594
4595 psoption->bitwise.value = packet->val;
4596 psoption->bitwise.def = packet->default_val;
4597
4598 if (NULL == psoption->bitwise.support_names) {
4599 /* First time we get this packet. */
4600 fc_assert(NULL == psoption->bitwise.pretty_names);
4601 psoption->bitwise.support_names = strvec_new();
4602 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4603 psoption->bitwise.pretty_names = strvec_new();
4604 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4605 for (i = 0; i < packet->bits_num; i++) {
4606 strvec_set(psoption->bitwise.support_names, i,
4607 packet->support_names[i]);
4608 /* Store untranslated string from server. */
4609 strvec_set(psoption->bitwise.pretty_names, i,
4610 packet->pretty_names[i]);
4611 }
4612 } else if (strvec_size(psoption->bitwise.support_names)
4613 != packet->bits_num) {
4614 fc_assert(strvec_size(psoption->bitwise.support_names)
4615 == strvec_size(psoption->bitwise.pretty_names));
4616 /* The number of values have changed, we need to reset the list
4617 * of possible values. */
4618 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4619 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4620 for (i = 0; i < packet->bits_num; i++) {
4621 strvec_set(psoption->bitwise.support_names, i,
4622 packet->support_names[i]);
4623 /* Store untranslated string from server. */
4624 strvec_set(psoption->bitwise.pretty_names, i,
4625 packet->pretty_names[i]);
4626 }
4629 } else {
4630 /* Check if a value changed, then we need to reset the list
4631 * of possible values. */
4632 const char *str;
4633
4634 for (i = 0; i < packet->bits_num; i++) {
4635 str = strvec_get(psoption->bitwise.pretty_names, i);
4636 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4637 /* Store untranslated string from server. */
4638 strvec_set(psoption->bitwise.pretty_names, i,
4639 packet->pretty_names[i]);
4642 }
4643 /* Support names are not visible, we don't need to check if it
4644 * has changed. */
4645 strvec_set(psoption->bitwise.support_names, i,
4646 packet->support_names[i]);
4647 }
4648 }
4649 }
4650
4652}
4654/************************************************************************/
4657static struct server_option *
4659{
4660 if (server_options != NULL) {
4661 const struct server_option *const max =
4663
4665 poption++;
4666 }
4667
4668 return (poption < max ? poption : NULL);
4669 }
4670
4671 return NULL;
4673
4674/************************************************************************/
4678{
4679 if (0 > id || id > server_options_num) {
4680 return NULL;
4681 }
4682 return OPTION(server_options + id);
4684
4685/************************************************************************/
4689{
4692
4693/************************************************************************/
4697{
4700
4701/************************************************************************/
4704const char *server_optset_category_name(int category)
4705{
4706 if (0 > category || category >= server_options_categories_num) {
4707 return NULL;
4708 }
4709
4710 return server_options_categories[category];
4712
4713/************************************************************************/
4716static int server_option_number(const struct option *poption)
4717{
4720
4721/************************************************************************/
4724static const char *server_option_name(const struct option *poption)
4725{
4726 return SERVER_OPTION(poption)->name;
4728
4729/************************************************************************/
4732static const char *server_option_description(const struct option *poption)
4733{
4734 return SERVER_OPTION(poption)->description;
4736
4737/************************************************************************/
4740static const char *server_option_help_text(const struct option *poption)
4741{
4742 return SERVER_OPTION(poption)->help_text;
4744
4745/************************************************************************/
4748static int server_option_category(const struct option *poption)
4749{
4750 return SERVER_OPTION(poption)->category;
4752
4753/************************************************************************/
4756static bool server_option_is_changeable(const struct option *poption)
4757{
4758 return SERVER_OPTION(poption)->is_changeable;
4760
4761/************************************************************************/
4764static struct option *server_option_next(const struct option *poption)
4765{
4768
4769/************************************************************************/
4772static bool server_option_bool_get(const struct option *poption)
4773{
4774 return SERVER_OPTION(poption)->boolean.value;
4776
4777/************************************************************************/
4780static bool server_option_bool_def(const struct option *poption)
4781{
4782 return SERVER_OPTION(poption)->boolean.def;
4783}
4785/************************************************************************/
4789static bool server_option_bool_set(struct option *poption, bool val)
4790{
4792
4793 if (psoption->boolean.value == val) {
4794 return FALSE;
4795 }
4796
4797 send_chat_printf("/set %s %s", psoption->name,
4798 val ? "enabled" : "disabled");
4800
4801 return TRUE;
4803
4804/************************************************************************/
4807static int server_option_int_get(const struct option *poption)
4808{
4809 return SERVER_OPTION(poption)->integer.value;
4811
4812/************************************************************************/
4815static int server_option_int_def(const struct option *poption)
4816{
4817 return SERVER_OPTION(poption)->integer.def;
4819
4820/************************************************************************/
4823static int server_option_int_min(const struct option *poption)
4824{
4825 return SERVER_OPTION(poption)->integer.min;
4827
4828/************************************************************************/
4831static int server_option_int_max(const struct option *poption)
4832{
4833 return SERVER_OPTION(poption)->integer.max;
4834}
4836/************************************************************************/
4840static bool server_option_int_set(struct option *poption, int val)
4841{
4843
4845 || val > psoption->integer.max
4846 || psoption->integer.value == val) {
4847 return FALSE;
4848 }
4849
4850 send_chat_printf("/set %s %d", psoption->name, val);
4852
4853 return TRUE;
4855
4856/************************************************************************/
4859static const char *server_option_str_get(const struct option *poption)
4860{
4861 return SERVER_OPTION(poption)->string.value;
4863
4864/************************************************************************/
4867static const char *server_option_str_def(const struct option *poption)
4868{
4869 return SERVER_OPTION(poption)->string.def;
4870}
4871
4872/************************************************************************/
4876static const struct strvec *
4878{
4879 return NULL;
4880}
4882/************************************************************************/
4886static bool server_option_str_set(struct option *poption, const char *str)
4887{
4889
4890 if (0 == strcmp(psoption->string.value, str)) {
4891 return FALSE;
4892 }
4893
4894 send_chat_printf("/set %s \"%s\"", psoption->name, str);
4896
4897 return TRUE;
4899
4900/************************************************************************/
4903static int server_option_enum_get(const struct option *poption)
4904{
4905 return SERVER_OPTION(poption)->enumerator.value;
4907
4908/************************************************************************/
4911static int server_option_enum_def(const struct option *poption)
4912{
4913 return SERVER_OPTION(poption)->enumerator.def;
4914}
4915
4916/************************************************************************/
4920static const struct strvec *
4922{
4923 return SERVER_OPTION(poption)->enumerator.pretty_names;
4924}
4926/************************************************************************/
4930static bool server_option_enum_set(struct option *poption, int val)
4931{
4933 const char *name;
4934
4935 if (val == psoption->enumerator.value
4936 || !(name = strvec_get(psoption->enumerator.support_names, val))) {
4937 return FALSE;
4938 }
4939
4940 send_chat_printf("/set %s \"%s\"", psoption->name, name);
4942
4943 return TRUE;
4944}
4946/************************************************************************/
4950static void server_option_enum_support_name(const struct option *poption,
4951 const char **pvalue,
4952 const char **pdefault)
4953{
4955 const struct strvec *values = psoption->enumerator.support_names;
4956
4957 if (NULL != pvalue) {
4958 *pvalue = strvec_get(values, psoption->enumerator.value);
4959 }
4960 if (NULL != pdefault) {
4961 *pdefault = strvec_get(values, psoption->enumerator.def);
4962 }
4964
4965/************************************************************************/
4968static unsigned server_option_bitwise_get(const struct option *poption)
4969{
4970 return SERVER_OPTION(poption)->bitwise.value;
4972
4973/************************************************************************/
4976static unsigned server_option_bitwise_def(const struct option *poption)
4977{
4978 return SERVER_OPTION(poption)->bitwise.def;
4979}
4980
4981/************************************************************************/
4985static const struct strvec *
4987{
4988 return SERVER_OPTION(poption)->bitwise.pretty_names;
4990
4991/************************************************************************/
4994static void server_option_bitwise_support_base(const struct strvec *values,
4995 unsigned val,
4996 char *buf, size_t buf_len)
4997{
4998 int bit;
4999
5000 buf[0] = '\0';
5001 for (bit = 0; bit < strvec_size(values); bit++) {
5002 if ((1 << bit) & val) {
5003 if ('\0' != buf[0]) {
5004 fc_strlcat(buf, "|", buf_len);
5005 }
5006 fc_strlcat(buf, strvec_get(values, bit), buf_len);
5007 }
5008 }
5009}
5011/************************************************************************/
5015static bool server_option_bitwise_set(struct option *poption, unsigned val)
5016{
5018 char name[MAX_LEN_MSG];
5019
5020 if (val == psoption->bitwise.value) {
5021 return FALSE;
5022 }
5023
5024 server_option_bitwise_support_base(psoption->bitwise.support_names, val,
5025 name, sizeof(name));
5026 send_chat_printf("/set %s \"%s\"", psoption->name, name);
5028
5029 return TRUE;
5030}
5032/************************************************************************/
5036static void server_option_bitwise_support_name(const struct option *poption,
5037 char *val_buf, size_t val_len,
5038 char *def_buf, size_t def_len)
5039{
5041 const struct strvec *values = psoption->bitwise.support_names;
5042
5043 if (NULL != val_buf && 0 < val_len) {
5044 server_option_bitwise_support_base(values, psoption->bitwise.value,
5045 val_buf, val_len);
5046 }
5047 if (NULL != def_buf && 0 < def_len) {
5048 server_option_bitwise_support_base(values, psoption->bitwise.def,
5049 def_buf, def_len);
5050 }
5052
5053
5057
5059/************************************************************************/
5063static void message_options_init(void)
5064{
5065 int none[] = {
5071 };
5072 int out_only[] = {
5075 };
5076 int all[] = {
5078 };
5079 int i;
5080
5081 for (i = 0; i <= event_type_max(); i++) {
5082 /* Include possible undefined values. */
5084 }
5085 for (i = 0; i < ARRAY_SIZE(none); i++) {
5086 messages_where[none[i]] = 0;
5087 }
5088 for (i = 0; i < ARRAY_SIZE(out_only); i++) {
5090 }
5091 for (i = 0; i < ARRAY_SIZE(all); i++) {
5093 }
5094
5095 events_init();
5097
5098/************************************************************************/
5101static void message_options_free(void)
5102{
5103 events_free();
5104}
5106/************************************************************************/
5110static void message_options_load(struct section_file *file,
5111 const char *prefix)
5112{
5113 enum event_type event;
5114 int i, num_events;
5115 const char *p;
5116
5117 if (!secfile_lookup_int(file, &num_events, "messages.count")) {
5118 /* version < 2.2 */
5119 /* Order of the events in 2.1. */
5120 const enum event_type old_events[] = {
5149 };
5150 const size_t old_events_num = ARRAY_SIZE(old_events);
5151
5152 for (i = 0; i < old_events_num; i++) {
5155 "%s.message_where_%02d", prefix, i);
5156 }
5157 return;
5158 }
5159
5160 for (i = 0; i < num_events; i++) {
5161 p = secfile_lookup_str(file, "messages.event%d.name", i);
5162 if (NULL == p) {
5163 log_error("Corruption in file %s: %s",
5164 secfile_name(file), secfile_error());
5165 continue;
5166 }
5167 /* Compatibility: Before 3.0 E_UNIT_WIN_DEF was called E_UNIT_WIN. */
5168 if (!fc_strcasecmp("E_UNIT_WIN", p)) {
5169 log_deprecation(_("Deprecated event type E_UNIT_WIN in client options."));
5170 p = "E_UNIT_WIN_DEF";
5171 }
5172 event = event_type_by_name(p, strcmp);
5173 if (!event_type_is_valid(event)) {
5174 log_error("Event not supported: %s", p);
5175 continue;
5176 }
5177
5179 "messages.event%d.where", i)) {
5180 log_error("Corruption in file %s: %s",
5181 secfile_name(file), secfile_error());
5182 }
5183 }
5184}
5186/************************************************************************/
5190static void message_options_save(struct section_file *file,
5191 const char *prefix)
5192{
5193 enum event_type event;
5194 int i = 0;
5195
5196 for (event = event_type_begin(); event != event_type_end();
5197 event = event_type_next(event)) {
5199 "messages.event%d.name", i);
5201 "messages.event%d.where", i);
5202 i++;
5203 }
5204
5205 secfile_insert_int(file, i, "messages.count");
5207
5208/************************************************************************/
5211static void load_cma_preset(struct section_file *file, int i)
5212{
5213 struct cm_parameter parameter;
5214 const char *name =
5215 secfile_lookup_str_default(file, "preset",
5216 "cma.preset%d.name", i);
5217
5218 /* Init correct default values even for the fields that are not
5219 * loaded below. */
5220 cm_init_parameter(&parameter);
5221
5223 parameter.minimal_surplus[o] =
5224 secfile_lookup_int_default(file, 0, "cma.preset%d.minsurp%d", i, o);
5225 parameter.factor[o] =
5226 secfile_lookup_int_default(file, 0, "cma.preset%d.factor%d", i, o);
5228 parameter.require_happy =
5229 secfile_lookup_bool_default(file, FALSE, "cma.preset%d.reqhappy", i);
5230 parameter.happy_factor =
5231 secfile_lookup_int_default(file, 0, "cma.preset%d.happyfactor", i);
5232 parameter.allow_disorder = FALSE;
5233 parameter.allow_specialists = TRUE;
5234
5235 cmafec_preset_add(name, &parameter);
5237
5238/************************************************************************/
5241static void save_cma_preset(struct section_file *file, int i)
5242{
5243 const struct cm_parameter *const pparam = cmafec_preset_get_parameter(i);
5245
5246 secfile_insert_str(file, name, "cma.preset%d.name", i);
5247
5249 secfile_insert_int(file, pparam->minimal_surplus[o],
5250 "cma.preset%d.minsurp%d", i, o);
5251 secfile_insert_int(file, pparam->factor[o],
5252 "cma.preset%d.factor%d", i, o);
5254 secfile_insert_bool(file, pparam->require_happy,
5255 "cma.preset%d.reqhappy", i);
5256 secfile_insert_int(file, pparam->happy_factor,
5257 "cma.preset%d.happyfactor", i);
5259
5260/************************************************************************/
5263static void save_cma_presets(struct section_file *file)
5264{
5265 int i;
5266
5268 _("If you add a preset by hand,"
5269 " also update \"number_of_presets\""),
5270 "cma.number_of_presets");
5271 for (i = 0; i < cmafec_preset_num(); i++) {
5273 }
5276/* Old rc file name. */
5277#define OLD_OPTION_FILE_NAME ".civclientrc"
5278/* New rc file name. */
5279#define MID_OPTION_FILE_NAME ".freeciv-client-rc-%d.%d"
5280#define NEW_OPTION_FILE_NAME "freeciv-client-rc-%d.%d"
5282/* The first version the new option name appeared (2.6). */
5283#define FIRST_MAJOR_NEW_OPTION_FILE_NAME 2
5284#define FIRST_MINOR_NEW_OPTION_FILE_NAME 6
5285/* The first version the mid option name appeared (2.2). */
5286#define FIRST_MAJOR_MID_OPTION_FILE_NAME 2
5287#define FIRST_MINOR_MID_OPTION_FILE_NAME 2
5288/* The first version the new boolean values appeared (2.3). */
5289#define FIRST_MAJOR_NEW_BOOLEAN 2
5290#define FIRST_MINOR_NEW_BOOLEAN 3
5291
5292/************************************************************************/
5299static const char *get_current_option_file_name(void)
5300{
5301 static char name_buffer[256];
5302 const char *name;
5303
5304 name = getenv("FREECIV_OPT");
5305
5306 if (name) {
5308 } else {
5309#ifdef OPTION_FILE_NAME
5311#else
5313 if (!name) {
5314 log_error(_("Cannot find freeciv storage directory"));
5315 return NULL;
5316 }
5320#endif /* OPTION_FILE_NAME */
5321 }
5322 log_verbose("settings file is %s", name_buffer);
5323 return name_buffer;
5324}
5325
5326/************************************************************************/
5334static const char *get_last_option_file_name(bool *allow_digital_boolean)
5335{
5336 static char name_buffer[256];
5337 const char *name;
5338 static int last_minors[] = {
5339 0, /* There was no 0.x releases */
5340 14, /* 1.14 */
5341 6 /* 2.6 */
5342 };
5343
5344#if MINOR_VERSION >= 90
5346#else
5348#endif
5349
5350 *allow_digital_boolean = FALSE;
5351 name = getenv("FREECIV_OPT");
5352 if (name) {
5354 } else {
5355#ifdef OPTION_FILE_NAME
5357#else
5358 int major, minor;
5359 struct stat buf;
5360
5362 if (name == NULL) {
5363 log_error(_("Cannot find freeciv storage directory"));
5364
5365 return NULL;
5366 }
5367
5373 : minor >= 0); minor--) {
5376 if (0 == fc_stat(name_buffer, &buf)) {
5379 log_normal(_("Didn't find '%s' option file, "
5380 "loading from '%s' instead."),
5382 name_buffer + strlen(name) + 1);
5383 }
5384
5385 return name_buffer;
5386 }
5387 }
5388 minor = last_minors[major - 1];
5389 }
5390
5391 /* Older versions had options file in user home directory */
5392 name = user_home_dir();
5393 if (name == NULL) {
5394 log_error(_("Cannot find your home directory"));
5395
5396 return NULL;
5397 }
5398
5399 /* minor having max value of FIRST_MINOR_NEW_OPTION_FILE_NAME
5400 * works since MID versioning scheme was used within major version 2
5401 * only (2.2 - 2.6) so the last minor is bigger than any earlier minor. */
5405 minor--) {
5408 if (0 == fc_stat(name_buffer, &buf)) {
5409 log_normal(_("Didn't find '%s' option file, "
5410 "loading from '%s' instead."),
5412 name_buffer + strlen(name) + 1);
5413
5415 *allow_digital_boolean = TRUE;
5416 }
5417 return name_buffer;
5418 }
5419 }
5420
5421 /* Try with the old one. */
5424 if (0 == fc_stat(name_buffer, &buf)) {
5425 log_normal(_("Didn't find '%s' option file, "
5426 "loading from '%s' instead."),
5429 *allow_digital_boolean = TRUE;
5430 return name_buffer;
5431 } else {
5432 return NULL;
5433 }
5434#endif /* OPTION_FILE_NAME */
5435 }
5436 log_verbose("settings file is %s", name_buffer);
5437 return name_buffer;
5438}
5439#undef OLD_OPTION_FILE_NAME
5440#undef MID_OPTION_FILE_NAME
5441#undef NEW_OPTION_FILE_NAME
5442#undef FIRST_MAJOR_NEW_OPTION_FILE_NAME
5443#undef FIRST_MINOR_NEW_OPTION_FILE_NAME
5444#undef FIRST_MAJOR_MID_OPTION_FILE_NAME
5445#undef FIRST_MINOR_MID_OPTION_FILE_NAME
5446#undef FIRST_MINOR_NEW_BOOLEAN
5449/****************************************************************************
5450 Desired settable options.
5451****************************************************************************/
5452#define SPECHASH_TAG settable_options
5453#define SPECHASH_ASTR_KEY_TYPE
5454#define SPECHASH_ASTR_DATA_TYPE
5455#include "spechash.h"
5456#define settable_options_hash_iterate(hash, name, value) \
5457 TYPED_HASH_ITERATE(const char *, const char *, hash, name, value)
5458#define settable_options_hash_iterate_end HASH_ITERATE_END
5459
5461
5462/************************************************************************/
5465static void settable_options_load(struct section_file *sf)
5466{
5467 char buf[64];
5468 const struct section *psection;
5469 const struct entry_list *entries;
5470 const char *string;
5471 bool bval;
5472 int ival;
5473
5475
5477
5478 psection = secfile_section_by_name(sf, "server");
5479 if (NULL == psection) {
5480 /* Does not exist! */
5481 return;
5482 }
5483
5484 entries = section_entries(psection);
5486 string = NULL;
5487 switch (entry_type_get(pentry)) {
5488 case ENTRY_BOOL:
5489 if (entry_bool_get(pentry, &bval)) {
5490 fc_strlcpy(buf, bval ? "enabled" : "disabled", sizeof(buf));
5491 string = buf;
5492 }
5493 break;
5494
5495 case ENTRY_INT:
5496 if (entry_int_get(pentry, &ival)) {
5497 fc_snprintf(buf, sizeof(buf), "%d", ival);
5498 string = buf;
5499 }
5500 break;
5501
5502 case ENTRY_STR:
5503 (void) entry_str_get(pentry, &string);
5504 break;
5505
5506 case ENTRY_FLOAT:
5508 /* Not supported yet */
5509 break;
5510 case ENTRY_LONG_COMMENT:
5512 break;
5513 case ENTRY_ILLEGAL:
5515 break;
5516 }
5517
5518 if (NULL == string) {
5519 log_error("Entry type variant of \"%s.%s\" is not supported.",
5520 section_name(psection), entry_name(pentry));
5521 continue;
5522 }
5523
5525 string);
5528
5529/************************************************************************/
5532static void settable_options_save(struct section_file *sf)
5533{
5535
5537 if (!fc_strcasecmp(name, "gameseed") || !fc_strcasecmp(name, "mapseed")) {
5538 /* Do not save mapseed or gameseed. */
5539 continue;
5540 }
5541 if (!fc_strcasecmp(name, "topology")) {
5542 /* client_start_server() sets topology based on tileset. Don't store
5543 * its choice. The tileset is already stored. Storing topology leads
5544 * to all sort of breakage:
5545 * - it breaks ruleset default topology.
5546 * - it interacts badly with tileset ruleset change, ruleset tileset
5547 * change and topology tileset change.
5548 * - its value is probably based on what tileset was loaded when
5549 * client_start_server() decided to set topology, not on player
5550 * choice.
5551 */
5552 continue;
5553 }
5554 secfile_insert_str(sf, value, "server.%s", name);
5556}
5558/************************************************************************/
5563{
5564 char val_buf[1024], def_buf[1024];
5565 const char *value, *def_val;
5566
5568
5571
5572 if (srv->setdef != SETDEF_CHANGED) {
5573 /* Some level default - do not store */
5576 } else {
5577 value = NULL;
5578 def_val = NULL;
5579 switch (option_type(poption)) {
5580 case OT_BOOLEAN:
5581 fc_strlcpy(val_buf, option_bool_get(poption) ? "enabled" : "disabled",
5582 sizeof(val_buf));
5583 value = val_buf;
5584 fc_strlcpy(def_buf, option_bool_def(poption) ? "enabled" : "disabled",
5585 sizeof(def_buf));
5586 def_val = def_buf;
5587 break;
5588 case OT_INTEGER:
5590 value = val_buf;
5592 def_val = def_buf;
5593 break;
5594 case OT_STRING:
5597 break;
5598 case OT_ENUM:
5600 break;
5601 case OT_BITWISE:
5603 def_buf, sizeof(def_buf));
5604 value = val_buf;
5605 def_val = def_buf;
5606 break;
5607 case OT_FONT:
5608 case OT_COLOR:
5609 case OT_VIDEO_MODE:
5610 break;
5611 }
5612
5613 if (NULL == value || NULL == def_val) {
5614 log_error("Option type %s (%d) not supported for '%s'.",
5617 continue;
5618 }
5619
5622 }
5624}
5626/************************************************************************/
5631 const char *op_value,
5632 bool allow_replace)
5633{
5635
5636 if (allow_replace) {
5638 } else {
5640 }
5641}
5643/************************************************************************/
5647static bool settable_option_upgrade_value(const struct option *poption,
5648 int old_value,
5649 char *buf, size_t buf_len)
5650{
5651 const char *name = option_name(poption);
5652
5653#define SETTING_CASE(ARG_name, ...) \
5654 if (0 == strcmp(ARG_name, name)) { \
5655 static const char *values[] = { __VA_ARGS__ }; \
5656 if (0 <= old_value && old_value < ARRAY_SIZE(values) \
5657 && NULL != values[old_value]) { \
5658 fc_strlcpy(buf, values[old_value], buf_len); \
5659 return TRUE; \
5660 } else { \
5661 return FALSE; \
5662 } \
5663 }
5664
5665 SETTING_CASE("topology", "", "WRAPX", "WRAPY", "WRAPX|WRAPY", "ISO",
5666 "WRAPX|ISO", "WRAPY|ISO", "WRAPX|WRAPY|ISO", "HEX",
5667 "WRAPX|HEX", "WRAPY|HEX", "WRAPX|WRAPY|HEX", "ISO|HEX",
5668 "WRAPX|ISO|HEX", "WRAPY|ISO|HEX", "WRAPX|WRAPY|ISO|HEX");
5669 SETTING_CASE("generator", NULL, "RANDOM", "FRACTAL", "ISLAND");
5670 SETTING_CASE("startpos", "DEFAULT", "SINGLE", "2or3", "ALL", "VARIABLE");
5671 SETTING_CASE("borders", "DISABLED", "ENABLED", "SEE_INSIDE", "EXPAND");
5672 SETTING_CASE("diplomacy", "ALL", "HUMAN", "AI", "TEAM", "DISABLED");
5673 SETTING_CASE("citynames", "NO_RESTRICTIONS", "PLAYER_UNIQUE",
5674 "GLOBAL_UNIQUE", "NO_STEALING");
5675 SETTING_CASE("barbarians", "DISABLED", "HUTS_ONLY", "NORMAL", "FREQUENT",
5676 "HORDES");
5677 SETTING_CASE("phasemode", "ALL", "PLAYER", "TEAM");
5678 SETTING_CASE("compresstype", "PLAIN", "LIBZ", "BZIP2");
5679
5680#undef SETTING_CASE
5681 return FALSE;
5683
5684/************************************************************************/
5687static void desired_settable_option_send(struct option *poption)
5688{
5689 char *desired;
5690 int value;
5691
5693
5696 /* No change explicitly desired. */
5697 return;
5698 }
5699
5700 switch (option_type(poption)) {
5701 case OT_BOOLEAN:
5702 if ((0 == fc_strcasecmp("enabled", desired)
5703 || (str_to_int(desired, &value) && 1 == value))
5704 && !option_bool_get(poption)) {
5705 send_chat_printf("/set %s enabled", option_name(poption));
5706 } else if ((0 == fc_strcasecmp("disabled", desired)
5707 || (str_to_int(desired, &value) && 0 == value))
5709 send_chat_printf("/set %s disabled", option_name(poption));
5710 }
5711 return;
5712 case OT_INTEGER:
5714 send_chat_printf("/set %s %d", option_name(poption), value);
5715 }
5716 return;
5717 case OT_STRING:
5718 if (0 != strcmp(desired, option_str_get(poption))) {
5719 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5720 }
5721 return;
5722 case OT_ENUM:
5723 {
5724 char desired_buf[256];
5725 const char *value_str;
5726
5727 /* Handle old values. */
5728 if (str_to_int(desired, &value)
5730 sizeof(desired_buf))) {
5732 }
5733
5735 if (0 != strcmp(desired, value_str)) {
5736 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5737 }
5738 }
5739 return;
5740 case OT_BITWISE:
5741 {
5742 char desired_buf[256], value_buf[256];
5743
5744 /* Handle old values. */
5745 if (str_to_int(desired, &value)
5747 sizeof(desired_buf))) {
5749 }
5750
5752 sizeof(value_buf), NULL, 0);
5753 if (0 != strcmp(desired, value_buf)) {
5754 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5755 }
5756 }
5757 return;
5758 case OT_FONT:
5759 case OT_COLOR:
5760 case OT_VIDEO_MODE:
5761 break;
5762 }
5763
5764 log_error("Option type %s (%d) not supported for '%s'.",
5767}
5769/************************************************************************/
5774{
5777 (void) value; /* Silence compiler warning about unused variable */
5779
5780 if (poption != NULL) {
5782
5783 /* We only sent the option if it has been sent already in the past.
5784 * Otherwise we leave it for that "initial" sending functionality
5785 * to send it. That has the benefit that the initial send (can) check
5786 * that server is not currently using value from the savegame that
5787 * we should not override */
5788 if (psoption->desired_sent) {
5789 /* Keep this list of conditions in sync with one in
5790 * handle_server_setting_common()
5791 * For lacking initial_setting check here, see comment above about
5792 * checking psoption->desired_sent. */
5793 if (psoption->is_visible
5794 && psoption->is_changeable) {
5797 }
5798 }
5799 }
5801 }
5802}
5803
5804
5805/****************************************************************************
5806 City and player report dialog options.
5807****************************************************************************/
5808#define SPECHASH_TAG dialog_options
5809#define SPECHASH_ASTR_KEY_TYPE
5810#define SPECHASH_IDATA_TYPE bool
5811#define SPECHASH_UDATA_TO_IDATA FC_INT_TO_PTR
5812#define SPECHASH_IDATA_TO_UDATA FC_PTR_TO_INT
5813#define SPECHASH_VPTR_TO_IDATA FC_PTR_TO_INT
5814#include "spechash.h"
5815#define dialog_options_hash_iterate(hash, column, visible) \
5816 TYPED_HASH_ITERATE(const char *, intptr_t, hash, column, visible)
5817#define dialog_options_hash_iterate_end HASH_ITERATE_END
5818
5820
5821/************************************************************************/
5824static void options_dialogs_load(struct section_file *sf)
5825{
5826 const struct entry_list *entries;
5827 const char *prefixes[] = { "player_dlg_", "city_report_", NULL };
5828 const char **prefix;
5829 bool visible;
5830
5832
5834
5835 if (NULL != entries) {
5837 for (prefix = prefixes; NULL != *prefix; prefix++) {
5838 if (!fc_strncmp(*prefix, entry_name(pentry), strlen(*prefix))
5839 && secfile_lookup_bool(sf, &visible, "client.%s",
5840 entry_name(pentry))) {
5843 break;
5844 }
5845 }
5847 }
5849
5850/************************************************************************/
5853static void options_dialogs_save(struct section_file *sf)
5854{
5856
5859 secfile_insert_bool(sf, visible, "client.%s", column);
5861}
5862
5863/************************************************************************/
5868void options_dialogs_update(void)
5869{
5870 char buf[64];
5871 int i;
5872
5874
5875 /* Player report dialog options. */
5876 for (i = 1; i < num_player_dlg_columns; i++) {
5877 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5878 player_dlg_columns[i].tagname);
5881 }
5882
5883 /* City report dialog options. */
5884 for (i = 0; i < num_city_report_spec(); i++) {
5885 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5889 }
5890}
5892/************************************************************************/
5896void options_dialogs_set(void)
5897{
5898 char buf[64];
5899 bool visible;
5900 int i;
5901
5903
5904 /* Player report dialog options. */
5905 for (i = 1; i < num_player_dlg_columns; i++) {
5906 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5907 player_dlg_columns[i].tagname);
5910 }
5911 }
5912
5913 /* City report dialog options. */
5914 for (i = 0; i < num_city_report_spec(); i++) {
5915 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5919 }
5920 }
5921}
5922
5923/************************************************************************/
5929void options_load(void)
5930{
5931 struct section_file *sf;
5933 int i, num;
5934 const char *name;
5935 const char *const prefix = "client";
5936 const char *str;
5937
5939 if (!name) {
5940 log_normal(_("Didn't find the option file. Creating a new one."));
5944 return;
5945 }
5946 if (!(sf = secfile_load(name, TRUE))) {
5947 log_debug("Error loading option file '%s':\n%s", name, secfile_error());
5948 /* Try to create the rc file */
5949 sf = secfile_new(TRUE);
5950 secfile_insert_str(sf, VERSION_STRING, "client.version");
5951
5954 save_cma_presets(sf);
5955
5956 /* FIXME: need better messages */
5957 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
5958 log_error(_("Save failed, cannot write to file %s"), name);
5959 } else {
5960 log_normal(_("Saved settings to file %s"), name);
5961 }
5962 secfile_destroy(sf);
5964 return;
5965 }
5967
5968 /* A "secret" option for the lazy. TODO: make this saveable */
5970 secfile_lookup_str_default(sf, "", "%s.password", prefix));
5971
5974 "%s.save_options_on_exit", prefix);
5977 "%s.fullscreen_mode", prefix);
5978
5979 /* Settings migrations */
5982 "%s.migration_gtk3_from_gtk2", prefix);
5985 "%s.migration_gtk3_22_from_gtk3", prefix);
5988 "%s.migration_gtk4_from_gtk3_22", prefix);
5991 "%s.migration_sdl2_from_sdl", prefix);
5994 "%s.migration_sdl3_from_sdl2", prefix);
5997 "%s.migration_gtk2_from_2_5", prefix);
6000 "%s.migration_gtk3_from_2_5", prefix);
6003 "%s.migration_qt_from_2_5", prefix);
6004
6005 /* Flag values */
6008 "%s.flag_qt_default_fonts_set", prefix);
6011 "%s.flag_sdl2_default_screen_size_set", prefix);
6014 "%s.flag_sdl3_default_screen_size_set", prefix);
6015
6016 /* These are not gui-enabled yet */
6018 = secfile_lookup_bool_default(sf, FALSE, "%s.zoom_set", prefix);
6021 "%s.zoom_default_level", prefix);
6022
6025 "%s.gui_qt_show_relations_panel", prefix);
6028 "%s.gui_qt_show_techs_panel", prefix);
6031 "%s.gui_qt_show_wonders_panel", prefix);
6032
6033 /* default_tileset_name present until freeciv-3.2 */
6034 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_name");
6035 if (str == NULL) {
6037 "client.default_topology");
6038 } else {
6040 }
6041 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_overhead_name");
6042 if (str != NULL) {
6044 }
6045 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_iso_name");
6046 if (str != NULL) {
6048 }
6049
6050 /* Backwards compatibility for removed options replaced by entirely "new"
6051 * options. The equivalent "new" option will override these, if set. */
6052
6053 /* Renamed in 2.6 */
6055 "%s.popup_caravan_arrival", prefix);
6056
6057 /* Load all the regular options */
6061
6062 /* More backwards compatibility, for removed options that had been
6063 * folded into then-existing options. Here, the backwards-compatibility
6064 * behavior overrides the "destination" option. */
6065
6066 /* Removed in 2.4 */
6068 "%s.do_combat_animation", prefix)) {
6070 }
6071
6072 message_options_load(sf, prefix);
6074
6075 /* Load cma presets. If cma.number_of_presets doesn't exist, don't load
6076 * any, the order here should be reversed to keep the order the same */
6077 if (secfile_lookup_int(sf, &num, "cma.number_of_presets")) {
6078 for (i = num - 1; i >= 0; i--) {
6079 load_cma_preset(sf, i);
6080 }
6081 } else {
6083 }
6084
6087
6088 secfile_destroy(sf);
6091
6092/************************************************************************/
6096 const char *msg, ...)
6097{
6098 va_list args;
6099
6100 va_start(args, msg);
6102 va_end(args);
6104
6105/************************************************************************/
6109{
6110 if (!has_capability("unignoresync", client.conn.capability)) {
6111 /* It's possible that the server never replies to the sync request.
6112 * We can't risk that saving never happens, so save what we have,
6113 * like freeciv < 3.2 always did. */
6115 options_save(log_cb);
6116
6117 return;
6118 }
6119
6120 if (reply_serial >= sync_serial) {
6121 /* We've already got reply to the latest options sync request */
6122 log_debug("Options save immediate (%d vs %d)", sync_serial, reply_serial);
6124 options_save(log_cb);
6125 } else {
6126 log_debug("Options save queued (%d vs %d)", sync_serial, reply_serial);
6127 queue_save = TRUE;
6128 queued_cb = log_cb;
6129 }
6131
6132/************************************************************************/
6135void options_sync_reply(int serial)
6136{
6137 reply_serial = serial;
6138
6140 log_debug("Pop queued options saving.");
6143 }
6145
6146/************************************************************************/
6150{
6151 struct section_file *sf;
6152 const char *name = get_current_option_file_name();
6153 char dir_name[2048];
6154 int i;
6155
6156 queue_save = FALSE;
6157
6158 if (log_cb == NULL) {
6159 /* Default callback */
6161 }
6162
6163 if (!name) {
6164 log_cb(LOG_ERROR, _("Save failed, cannot find a filename."));
6165 return;
6166 }
6167
6168 sf = secfile_new(TRUE);
6169 secfile_insert_str(sf, VERSION_STRING, "client.version");
6170
6172 "client.save_options_on_exit");
6174 "deprecated", "client.fullscreen_mode");
6175
6176 /* Migrations */
6178 "client.migration_gtk3_from_gtk2");
6180 "client.migration_gtk3_22_from_gtk3");
6182 "client.migration_gtk4_from_gtk3_22");
6184 "client.migration_sdl2_from_sdl");
6186 "client.migration_sdl3_from_sdl2");
6188 "client.migration_gtk2_from_2_5");
6190 "client.migration_gtk3_from_2_5");
6192 "client.migration_qt_from_2_5");
6193
6194 /* Flag */
6196 "client.flag_qt_default_fonts_set");
6198 "client.flag_sdl2_default_screen_size_set");
6200 "client.flag_sdl3_default_screen_size_set");
6201
6202 /* gui-enabled options */
6207 /* Once options have been migrated from a client that no longer exist to a newer client,
6208 * there's no use for those settings of dropped client any more, so no point in saving them. */
6210 }
6212
6213 /* These are not gui-enabled yet. */
6214 secfile_insert_bool(sf, gui_options.zoom_set, "client.zoom_set");
6216 "client.zoom_default_level");
6217
6219 "client.gui_qt_show_relations_panel");
6221 "client.gui_qt_show_techs_panel");
6223 "client.gui_qt_show_wonders_panel");
6224
6225 if (tileset != NULL) {
6227 "client.default_topology");
6228 } else {
6230 "client.default_topology");
6231 }
6232
6233 message_options_save(sf, "client");
6235
6236 /* Server settings */
6237 save_cma_presets(sf);
6239
6240 /* Insert global worklists */
6242
6243 /* Directory name */
6245 for (i = strlen(dir_name) - 1 ; dir_name[i] != DIR_SEPARATOR_CHAR && i >= 0; i--) {
6246 /* Nothing */
6247 }
6248
6249 if (i > 0) {
6250 dir_name[i] = '\0';
6251 if (!make_dir(dir_name)) {
6252 log_cb(LOG_ERROR, _("Saving options failed, cannot create directory %s"),
6253 dir_name);
6254 secfile_destroy(sf);
6255 return;
6256 }
6257 }
6258
6259 /* Save to disk */
6260 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
6261 log_cb(LOG_ERROR, _("Saving options failed, cannot write to file %s"), name);
6262 } else {
6263 log_cb(LOG_VERBOSE, _("Saved options to file %s"), name);
6264 }
6265 secfile_destroy(sf);
6267
6268/************************************************************************/
6271static void options_init_names(const struct copt_val_name *(*acc)(int),
6272 struct strvec **support, struct strvec **pretty)
6273{
6274 int val;
6275 const struct copt_val_name *name;
6276
6278 *support = strvec_new();
6279 *pretty = strvec_new();
6280 for (val = 0; (name = acc(val)); val++) {
6281 strvec_append(*support, name->support);
6282 strvec_append(*pretty, name->pretty);
6283 }
6285
6286/************************************************************************/
6289void options_init(void)
6290{
6294
6297
6300
6301 switch (option_type(poption)) {
6302 case OT_INTEGER:
6309
6310 log_error("option %s has default value of %d, which is "
6311 "out of its range [%d; %d], changing to %d.",
6314 new_default);
6315 *((int *) &(pcoption->integer.def)) = new_default;
6316 }
6317 break;
6318
6319 case OT_STRING:
6321 /* Hack to get a default value. */
6322 *((const char **) &(pcoption->string.def)) =
6324 }
6325
6326 if (NULL == option_str_def(poption)) {
6327 const struct strvec *values = option_str_values(poption);
6328
6329 if (NULL == values || strvec_size(values) == 0) {
6330 log_error("Invalid NULL default string for option %s.",
6332 } else {
6333 *((const char **) &(pcoption->string.def)) =
6334 strvec_get(values, 0);
6335 }
6336 }
6337 break;
6338
6339 case OT_ENUM:
6340 fc_assert(NULL == pcoption->enumerator.support_names);
6341 fc_assert(NULL == pcoption->enumerator.pretty_names);
6342 options_init_names(pcoption->enumerator.name_accessor,
6343 &pcoption->enumerator.support_names,
6344 &pcoption->enumerator.pretty_names);
6345 fc_assert(NULL != pcoption->enumerator.support_names);
6346 fc_assert(NULL != pcoption->enumerator.pretty_names);
6347 break;
6348
6349 case OT_BITWISE:
6350 fc_assert(NULL == pcoption->bitwise.support_names);
6351 fc_assert(NULL == pcoption->bitwise.pretty_names);
6352 options_init_names(pcoption->bitwise.name_accessor,
6353 &pcoption->bitwise.support_names,
6354 &pcoption->bitwise.pretty_names);
6355 fc_assert(NULL != pcoption->bitwise.support_names);
6356 fc_assert(NULL != pcoption->bitwise.pretty_names);
6357 break;
6358
6359 case OT_COLOR:
6360 {
6361 /* Duplicate the string pointers. */
6362 struct ft_color *pcolor = pcoption->color.pvalue;
6363
6364 if (NULL != pcolor->foreground) {
6365 pcolor->foreground = fc_strdup(pcolor->foreground);
6366 }
6367 if (NULL != pcolor->background) {
6368 pcolor->background = fc_strdup(pcolor->background);
6369 }
6370 }
6371 break;
6372
6373 case OT_BOOLEAN:
6374 case OT_FONT:
6375 case OT_VIDEO_MODE:
6376 break;
6377 }
6378
6379 /* Set to default. */
6383
6384/************************************************************************/
6387void options_free(void)
6388{
6391
6393
6394 switch (option_type(poption)) {
6395 case OT_ENUM:
6396 fc_assert_action(NULL != pcoption->enumerator.support_names, break);
6397 strvec_destroy(pcoption->enumerator.support_names);
6398 pcoption->enumerator.support_names = NULL;
6399 fc_assert_action(NULL != pcoption->enumerator.pretty_names, break);
6400 strvec_destroy(pcoption->enumerator.pretty_names);
6401 pcoption->enumerator.pretty_names = NULL;
6402 break;
6403
6404 case OT_BITWISE:
6405 fc_assert_action(NULL != pcoption->bitwise.support_names, break);
6406 strvec_destroy(pcoption->bitwise.support_names);
6407 pcoption->bitwise.support_names = NULL;
6408 fc_assert_action(NULL != pcoption->bitwise.pretty_names, break);
6409 strvec_destroy(pcoption->bitwise.pretty_names);
6410 pcoption->bitwise.pretty_names = NULL;
6411 break;
6412
6413 case OT_BOOLEAN:
6414 case OT_INTEGER:
6415 case OT_STRING:
6416 case OT_FONT:
6417 case OT_COLOR:
6418 case OT_VIDEO_MODE:
6419 break;
6420 }
6422
6423 if (NULL != settable_options_hash) {
6426 }
6427
6428 if (NULL != dialog_options_hash) {
6431 }
6432
6435}
6437/************************************************************************/
6441static void reqtree_show_icons_callback(struct option *poption)
6442{
6445
6446/************************************************************************/
6449static void view_option_changed_callback(struct option *poption)
6450{
6451 menus_init();
6454
6455/************************************************************************/
6458static void manual_turn_done_callback(struct option *poption)
6459{
6461
6463 struct player *pplayer = client_player();
6464
6465 if (pplayer != NULL && is_ai(pplayer)
6466 && can_end_turn()) {
6468 }
6469 }
6471
6472/****************************************************************************
6473 Callback for changing music volume
6474****************************************************************************/
6475static void sound_volume_callback(struct option *poption)
6476{
6479
6480/************************************************************************/
6483static void voteinfo_bar_callback(struct option *poption)
6484{
6487
6488/************************************************************************/
6491static void font_changed_callback(struct option *poption)
6492{
6496
6497/************************************************************************/
6500static void mapimg_changed_callback(struct option *poption)
6501{
6503#ifndef FREECIV_NDEBUG
6504 bool success;
6505#endif
6506
6507 log_normal("Error setting the value for %s (%s). Restoring the default "
6508 "value.", option_name(poption), mapimg_error());
6509
6510 /* Reset the value to the default value. */
6511#ifndef FREECIV_NDEBUG
6512 success =
6513#endif
6515
6517 "Failed to reset the option \"%s\".",
6519#ifndef FREECIV_NDEBUG
6520 success =
6521#endif
6523
6525 "Failed to restore mapimg definition for option \"%s\".",
6527 }
6529
6530/************************************************************************/
6533static void game_music_enable_callback(struct option *poption)
6534{
6535 if (client_state() == C_S_RUNNING) {
6538 } else {
6540 }
6541 }
6543
6544/************************************************************************/
6547static void menu_music_enable_callback(struct option *poption)
6548{
6549 if (client_state() != C_S_RUNNING) {
6551 start_menu_music("music_menu", NULL);
6552 } else {
6554 }
6555 }
6557
6558/************************************************************************/
6561bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
6562{
6563 return (2 < fc_snprintf(buf, buf_len, "%dx%d", mode->width, mode->height));
6565
6566/************************************************************************/
6569bool string_to_video_mode(const char *buf, struct video_mode *mode)
6570{
6571 return (2 == sscanf(buf, "%dx%d", &mode->width, &mode->height));
6573
6574/************************************************************************/
6577static const struct strvec *get_mapimg_format_list(const struct option *poption)
6578{
6579 return mapimg_get_format_list();
6581
6582/************************************************************************/
6585const char *tileset_name_for_topology(int topology_id)
6586{
6587 const char *tsn = NULL;
6588
6589 switch (topology_id & (TF_ISO | TF_HEX)) {
6590 case 0:
6591 case TF_ISO:
6593 break;
6594 case TF_HEX:
6596 break;
6597 case TF_ISO | TF_HEX:
6599 break;
6600 }
6601
6602 if (tsn == NULL) {
6604 }
6605
6606 return tsn;
6608
6609/************************************************************************/
6612void option_set_default_ts(struct tileset *t)
6613{
6614 const char *optname = "<not set>";
6615 struct option *opt;
6616
6617 switch (tileset_topo_index(t)) {
6618 case TS_TOPO_SQUARE:
6619 /* Overhead */
6620 optname = "default_tileset_square_name";
6621 break;
6622 case TS_TOPO_HEX:
6623 /* Hex */
6624 optname = "default_tileset_hex_name";
6625 break;
6626 case TS_TOPO_ISOHEX:
6627 /* Isohex */
6628 optname = "default_tileset_isohex_name";
6629 break;
6630 }
6631
6633
6634 if (opt == NULL) {
6635 log_error("Unknown option name \"%s\" in option_set_default_ts()", optname);
6636 return;
6637 }
6638
6639 /* Do not call option_str_set() since we don't want option changed callback
6640 * to reload this tileset. */
6641 opt->str_vtable->set(opt, tileset_basename(t));
6644
6645/************************************************************************/
6648static bool is_ts_option_unset(const char *optname)
6649{
6650 struct option *opt;
6651 const char *val;
6652
6654
6655 if (opt == NULL) {
6656 return TRUE;
6657 }
6658
6659 val = opt->str_vtable->get(opt);
6660
6661 if (val == NULL || val[0] == '\0') {
6662 return TRUE;
6663 }
6664
6665 return FALSE;
6667
6668/************************************************************************/
6671void fill_topo_ts_default(void)
6672{
6673 if (is_ts_option_unset("default_tileset_square_name")) {
6674 if (gui_options.default_tileset_iso_name[0] != '\0') {
6678 } else if (gui_options.default_tileset_overhead_name[0] != '\0') {
6682 } else {
6683 log_debug("Setting tileset for square topologies.");
6685 }
6686 }
6687 if (is_ts_option_unset("default_tileset_hex_name")) {
6688 log_debug("Setting tileset for hex topology.");
6690 }
6691 if (is_ts_option_unset("default_tileset_isohex_name")) {
6692 log_debug("Setting tileset for isohex topology.");
6694 }
6695}
struct @126::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
bool has_capability(const char *cap, const char *capstr)
Definition capability.c:77
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:845
#define output_type_iterate_end
Definition city.h:851
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:1408
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:75
#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:2077
void options_extra_init(void)
Definition gui_main.c:2479
static GtkTextBuffer * help_text
Definition helpdlg.c:71
void option_gui_remove(struct option *poption)
Definition optiondlg.c:1054
void option_dialog_popdown(const struct option_set *poptset)
Definition optiondlg.c:999
void option_gui_update(struct option *poption)
Definition optiondlg.c:1026
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:37
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret(condition)
Definition log.h:191
#define log_verbose(message,...)
Definition log.h:109
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_msg(condition, message,...)
Definition log.h:205
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define fc_assert_action(condition, action)
Definition log.h:187
#define log_debug(message,...)
Definition log.h:115
#define log_normal(message,...)
Definition log.h:107
log_level
Definition log.h:28
@ LOG_ERROR
Definition log.h:30
@ LOG_VERBOSE
Definition log.h:33
#define log_error(message,...)
Definition log.h:103
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:235
void update_turn_done_button_state(void)
bool can_end_turn(void)
bool mapimg_initialised(void)
Definition mapimg.c:1555
const struct strvec * mapimg_get_format_list(void)
Definition mapimg.c:1153
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:3365
void handle_server_setting_const(const struct packet_server_setting_const *packet)
Definition options.c:4299
void handle_server_setting_int(const struct packet_server_setting_int *packet)
Definition options.c:4393
static int server_option_int_max(const struct option *poption)
Definition options.c:4826
static bool client_option_font_set(struct option *poption, const char *font)
Definition options.c:3734
unsigned option_bitwise_mask(const struct option *poption)
Definition options.c:1100
void fill_topo_ts_default(void)
Definition options.c:6666
#define FIRST_MAJOR_MID_OPTION_FILE_NAME
Definition options.c:5281
#define client_options_iterate_all_end
Definition options.c:3327
static const struct strvec * server_option_str_values(const struct option *poption)
Definition options.c:4872
static int client_option_enum_get(const struct option *poption)
Definition options.c:3593
void resend_desired_settable_options(void)
Definition options.c:5768
const struct strvec * option_str_values(const struct option *poption)
Definition options.c:919
static void desired_settable_option_send(struct option *poption)
Definition options.c:5682
static const char * client_option_name(const struct option *poption)
Definition options.c:3419
static int sync_serial
Definition options.c:403
static unsigned server_option_bitwise_def(const struct option *poption)
Definition options.c:4971
#define FIRST_MAJOR_NEW_OPTION_FILE_NAME
Definition options.c:5278
static const struct option_video_mode_vtable client_option_video_mode_vtable
Definition options.c:1410
#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd)
Definition options.c:1587
static struct dialog_options_hash * dialog_options_hash
Definition options.c:5814
static bool queue_save
Definition options.c:405
void option_changed(struct option *poption)
Definition options.c:752
static void menu_music_enable_callback(struct option *poption)
Definition options.c:6542
static bool options_fully_initialized
Definition options.c:401
static const struct option_str_vtable client_option_str_vtable
Definition options.c:1344
static int reply_serial
Definition options.c:404
unsigned option_bitwise_def(const struct option *poption)
Definition options.c:1089
int option_enum_str_to_int(const struct option *poption, const char *str)
Definition options.c:947
static const char * client_option_description(const struct option *poption)
Definition options.c:3427
int option_int_min(const struct option *poption)
Definition options.c:860
static void option_save_output_window_callback(enum log_level lvl, const char *msg,...)
Definition options.c:6090
static void message_options_save(struct section_file *file, const char *prefix)
Definition options.c:5185
bool option_bool_def(const struct option *poption)
Definition options.c:812
static struct option * client_option_next(const struct option *poption)
Definition options.c:3459
static const char * server_option_name(const struct option *poption)
Definition options.c:4719
const char * option_font_def(const struct option *poption)
Definition options.c:1156
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6580
static const struct copt_val_name * gui_gtk_message_chat_location_name(int value)
Definition options.c:1843
static bool server_option_str_set(struct option *poption, const char *str)
Definition options.c:4881
static const struct copt_val_name * gui_popup_tech_help_name(int value)
Definition options.c:1863
struct option * optset_option_first(const struct option_set *poptset)
Definition options.c:451
static const char * server_optset_category_name(int category)
Definition options.c:4699
const struct option_set * server_optset
Definition options.c:4020
static void view_option_changed_callback(struct option *poption)
Definition options.c:6444
static const char * client_option_font_target(const struct option *poption)
Definition options.c:3725
static void server_option_enum_support_name(const struct option *poption, const char **pvalue, const char **pdefault)
Definition options.c:4945
#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb)
Definition options.c:1549
static const char * server_option_description(const struct option *poption)
Definition options.c:4727
static unsigned server_option_bitwise_get(const struct option *poption)
Definition options.c:4963
static bool client_option_is_changeable(const struct option *poption)
Definition options.c:3451
static int server_option_int_min(const struct option *poption)
Definition options.c:4818
static const char * client_optset_category_name(int category)
Definition options.c:3381
static struct option * server_option_next(const struct option *poption)
Definition options.c:4759
static struct client_option client_options[]
Definition options.c:1890
#define SERVER_OPTION(poption)
Definition options.c:4156
#define OLD_OPTION_FILE_NAME
Definition options.c:5272
static void settable_options_save(struct section_file *sf)
Definition options.c:5527
static bool server_option_bool_get(const struct option *poption)
Definition options.c:4767
bool option_reset(struct option *poption)
Definition options.c:713
void options_free(void)
Definition options.c:6382
const char * option_description(const struct option *poption)
Definition options.c:642
const char * option_help_text(const struct option *poption)
Definition options.c:652
#define settable_options_hash_iterate_end
Definition options.c:5453
static const char * client_option_font_get(const struct option *poption)
Definition options.c:3709
static int server_option_enum_def(const struct option *poption)
Definition options.c:4906
static int server_option_int_def(const struct option *poption)
Definition options.c:4810
#define client_options_iterate_all(poption)
Definition options.c:3318
static int client_option_int_min(const struct option *poption)
Definition options.c:3515
static int server_options_categories_num
Definition options.c:4002
const char * option_enum_get_str(const struct option *poption)
Definition options.c:996
static struct ft_color client_option_color_def(const struct option *poption)
Definition options.c:3758
static const struct strvec * client_option_enum_pretty_names(const struct option *poption)
Definition options.c:3611
static bool server_option_enum_set(struct option *poption, int val)
Definition options.c:4925
static void save_cma_presets(struct section_file *file)
Definition options.c:5258
struct ft_color option_color_get(const struct option *poption)
Definition options.c:1194
static struct video_mode client_option_video_mode_def(const struct option *poption)
Definition options.c:3812
static int client_option_int_get(const struct option *poption)
Definition options.c:3499
static char ** server_options_categories
Definition options.c:3999
int option_enum_get_int(const struct option *poption)
Definition options.c:984
static void settable_options_load(struct section_file *sf)
Definition options.c:5460
int option_number(const struct option *poption)
Definition options.c:622
static struct option * server_optset_option_first(void)
Definition options.c:4683
static struct settable_options_hash * settable_options_hash
Definition options.c:5455
int option_category(const struct option *poption)
Definition options.c:672
static struct server_option * server_options
Definition options.c:4000
static const struct option_int_vtable server_option_int_vtable
Definition options.c:4060
static void options_dialogs_save(struct section_file *sf)
Definition options.c:5848
static struct option_set client_optset_static
Definition options.c:1278
void options_sync_reply(int serial)
Definition options.c:6130
static bool client_option_color_set(struct option *poption, struct ft_color color)
Definition options.c:3767
#define dialog_options_hash_iterate_end
Definition options.c:5812
static void save_cma_preset(struct section_file *file, int i)
Definition options.c:5236
static int client_optset_category_number(void)
Definition options.c:3373
static const char * client_option_str_def(const struct option *poption)
Definition options.c:3557
static bool client_option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:3821
void handle_server_setting_bitwise(const struct packet_server_setting_bitwise *packet)
Definition options.c:4564
static const struct option_font_vtable client_option_font_vtable
Definition options.c:1385
static bool client_option_enum_set(struct option *poption, int val)
Definition options.c:3620
void desired_settable_option_update(const char *op_name, const char *op_value, bool allow_replace)
Definition options.c:5625
void option_set_default_ts(struct tileset *t)
Definition options.c:6607
bool option_str_set(struct option *poption, const char *str)
Definition options.c:930
void handle_server_setting_bool(const struct packet_server_setting_bool *packet)
Definition options.c:4358
static const struct strvec * client_option_str_values(const struct option *poption)
Definition options.c:3567
const struct option_set * client_optset
Definition options.c:1284
static const struct option_bool_vtable server_option_bool_vtable
Definition options.c:4048
static const struct option_bitwise_vtable server_option_bitwise_vtable
Definition options.c:4101
const char * option_name(const struct option *poption)
Definition options.c:632
static const char * client_option_help_text(const struct option *poption)
Definition options.c:3435
static void message_options_init(void)
Definition options.c:5058
static int client_option_number(const struct option *poption)
Definition options.c:3411
void handle_server_setting_str(const struct packet_server_setting_str *packet)
Definition options.c:4430
int option_int_get(const struct option *poption)
Definition options.c:838
static void client_option_save(struct option *poption, struct section_file *sf)
Definition options.c:3939
void options_init(void)
Definition options.c:6284
static int client_option_int_def(const struct option *poption)
Definition options.c:3507
static int server_option_category(const struct option *poption)
Definition options.c:4743
#define FIRST_MINOR_MID_OPTION_FILE_NAME
Definition options.c:5282
static const struct option_enum_vtable client_option_enum_vtable
Definition options.c:1357
static const struct option_str_vtable server_option_str_vtable
Definition options.c:4074
static int server_options_num
Definition options.c:4003
#define handle_server_setting_common(psoption, packet)
Definition options.c:4320
static const struct option_color_vtable client_option_color_vtable
Definition options.c:1397
bool option_enum_set_str(struct option *poption, const char *str)
Definition options.c:1061
static const struct strvec * server_option_enum_pretty(const struct option *poption)
Definition options.c:4916
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:5031
bool option_color_set(struct option *poption, struct ft_color color)
Definition options.c:1217
#define SETTING_CASE(ARG_name,...)
static struct video_mode client_option_video_mode_get(const struct option *poption)
Definition options.c:3803
static bool is_ts_option_unset(const char *optname)
Definition options.c:6643
void option_set_changed_callback(struct option *poption, void(*callback)(struct option *))
Definition options.c:741
#define OPTION(poption)
Definition options.c:567
#define NEW_OPTION_FILE_NAME
Definition options.c:5275
static bool server_option_bool_set(struct option *poption, bool val)
Definition options.c:4784
bool option_bool_set(struct option *poption, bool val)
Definition options.c:823
bool option_is_changeable(const struct option *poption)
Definition options.c:693
#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb)
Definition options.c:1665
bool option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:1257
#define MID_OPTION_FILE_NAME
Definition options.c:5274
static int server_option_number(const struct option *poption)
Definition options.c:4711
#define dialog_options_hash_iterate(hash, column, visible)
Definition options.c:5810
#define FIRST_MINOR_NEW_BOOLEAN
Definition options.c:5285
static const char * server_option_str_get(const struct option *poption)
Definition options.c:4854
#define settable_options_hash_iterate(hash, name, value)
Definition options.c:5451
void option_set_gui_data(struct option *poption, void *data)
Definition options.c:771
#define FIRST_MINOR_NEW_OPTION_FILE_NAME
Definition options.c:5279
#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1513
const char * option_str_get(const struct option *poption)
Definition options.c:897
struct option * optset_option_by_number(const struct option_set *poptset, int id)
Definition options.c:424
static bool client_option_bool_get(const struct option *poption)
Definition options.c:3467
void * option_get_gui_data(const struct option *poption)
Definition options.c:781
static const char * server_option_str_def(const struct option *poption)
Definition options.c:4862
static const struct option_common_vtable client_option_common_vtable
Definition options.c:1304
static bool settable_option_upgrade_value(const struct option *poption, int old_value, char *buf, size_t buf_len)
Definition options.c:5642
const struct strvec * option_enum_values(const struct option *poption)
Definition options.c:1033
static const struct strvec * get_mapimg_format_list(const struct option *poption)
Definition options.c:6572
static void sound_volume_callback(struct option *poption)
Definition options.c:6470
bool option_enum_set_int(struct option *poption, int val)
Definition options.c:1044
bool option_bool_get(const struct option *poption)
Definition options.c:801
int optset_category_number(const struct option_set *poptset)
Definition options.c:461
#define color_set(color_tgt, color)
static bool client_option_bool_def(const struct option *poption)
Definition options.c:3475
static const struct strvec * server_option_bitwise_pretty(const struct option *poption)
Definition options.c:4981
void server_options_init(void)
Definition options.c:4164
enum option_type option_type(const struct option *poption)
Definition options.c:662
static int client_option_enum_def(const struct option *poption)
Definition options.c:3601
const char * option_enum_int_to_str(const struct option *poption, int val)
Definition options.c:969
void options_dialogs_update(void)
Definition options.c:5863
int option_get_cb_data(const struct option *poption)
Definition options.c:791
bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
Definition options.c:6556
static void options_dialogs_load(struct section_file *sf)
Definition options.c:5819
const struct option_set * option_optset(const struct option *poption)
Definition options.c:612
void server_options_free(void)
Definition options.c:4233
struct video_mode option_video_mode_get(const struct option *poption)
Definition options.c:1232
static int server_option_enum_get(const struct option *poption)
Definition options.c:4898
struct option * option_next(const struct option *poption)
Definition options.c:703
static struct option * client_optset_option_by_number(int id)
Definition options.c:3354
static void font_changed_callback(struct option *poption)
Definition options.c:6486
const char * option_str_def(const struct option *poption)
Definition options.c:908
const char * optset_category_name(const struct option_set *poptset, int category)
Definition options.c:471
int option_int_max(const struct option *poption)
Definition options.c:871
#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, odef_bg, ocb)
Definition options.c:1780
const char * option_enum_def_str(const struct option *poption)
Definition options.c:1020
void options_load(void)
Definition options.c:5924
static const char * client_option_str_get(const struct option *poption)
Definition options.c:3549
static option_save_log_callback queued_cb
Definition options.c:406
static const struct option_common_vtable server_option_common_vtable
Definition options.c:4034
static int server_optset_category_number(void)
Definition options.c:4691
static bool client_option_bool_set(struct option *poption, bool val)
Definition options.c:3484
static const char * server_option_help_text(const struct option *poption)
Definition options.c:4735
static const struct option_bool_vtable client_option_bool_vtable
Definition options.c:1318
static bool client_option_load(struct option *poption, struct section_file *sf)
Definition options.c:3838
bool option_font_set(struct option *poption, const char *font)
Definition options.c:1178
static bool server_option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:5010
const char * option_font_target(const struct option *poption)
Definition options.c:1167
static const char * client_option_enum_secfile_str(secfile_data_t data, int val)
Definition options.c:3639
static struct server_option * server_option_next_valid(struct server_option *poption)
Definition options.c:4653
static void server_option_bitwise_support_base(const struct strvec *values, unsigned val, char *buf, size_t buf_len)
Definition options.c:4989
void queue_options_save(option_save_log_callback log_cb)
Definition options.c:6103
static void voteinfo_bar_callback(struct option *poption)
Definition options.c:6478
static struct option * server_optset_option_by_number(int id)
Definition options.c:4672
void options_save(option_save_log_callback log_cb)
Definition options.c:6144
static void message_options_free(void)
Definition options.c:5096
static const struct option_enum_vtable server_option_enum_vtable
Definition options.c:4087
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6564
const struct strvec * option_bitwise_values(const struct option *poption)
Definition options.c:1117
static bool server_option_int_set(struct option *poption, int val)
Definition options.c:4835
int messages_where[E_COUNT]
Definition options.c:5051
static void message_options_load(struct section_file *file, const char *prefix)
Definition options.c:5105
struct client_options gui_options
Definition options.c:72
static void server_option_free(struct server_option *poption)
Definition options.c:4175
#define CLIENT_OPTION(poption)
Definition options.c:1495
#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1744
static struct option_set server_optset_static
Definition options.c:4014
void handle_server_setting_control(const struct packet_server_setting_control *packet)
Definition options.c:4265
static void mapimg_changed_callback(struct option *poption)
Definition options.c:6495
bool option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:1128
static int server_option_int_get(const struct option *poption)
Definition options.c:4802
static void manual_turn_done_callback(struct option *poption)
Definition options.c:6453
static void reqtree_show_icons_callback(struct option *poption)
Definition options.c:6436
const char * option_font_get(const struct option *poption)
Definition options.c:1145
void desired_settable_options_update(void)
Definition options.c:5557
static void load_cma_preset(struct section_file *file, int i)
Definition options.c:5206
static bool client_option_str_set(struct option *poption, const char *str)
Definition options.c:3577
void handle_server_setting_enum(const struct packet_server_setting_enum *packet)
Definition options.c:4475
struct ft_color option_color_def(const struct option *poption)
Definition options.c:1205
static int client_option_int_max(const struct option *poption)
Definition options.c:3523
#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd)
Definition options.c:1628
client_option_category
Definition options.c:1416
@ COC_MAX
Definition options.c:1424
@ COC_SOUND
Definition options.c:1419
@ COC_NETWORK
Definition options.c:1422
@ COC_INTERFACE
Definition options.c:1420
@ COC_GRAPHICS
Definition options.c:1417
@ COC_OVERVIEW
Definition options.c:1418
@ COC_FONT
Definition options.c:1423
@ COC_MAPIMG
Definition options.c:1421
unsigned option_bitwise_get(const struct option *poption)
Definition options.c:1078
static bool server_option_is_changeable(const struct option *poption)
Definition options.c:4751
static struct ft_color client_option_color_get(const struct option *poption)
Definition options.c:3750
int option_enum_def_int(const struct option *poption)
Definition options.c:1008
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:435
static const int client_options_num
Definition options.c:3315
static bool client_option_int_set(struct option *poption, int val)
Definition options.c:3532
void options_dialogs_set(void)
Definition options.c:5891
bool option_int_set(struct option *poption, int val)
Definition options.c:882
static struct client_option * client_option_next_valid(struct client_option *poption)
Definition options.c:3336
static const char * client_option_bitwise_secfile_str(secfile_data_t data, int val)
Definition options.c:3697
#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, odef_height, ocb)
Definition options.c:1815
static const struct option_int_vtable client_option_int_vtable
Definition options.c:1330
static const char * client_option_font_def(const struct option *poption)
Definition options.c:3717
static const char * get_last_option_file_name(bool *allow_digital_boolean)
Definition options.c:5329
const char * option_category_name(const struct option *poption)
Definition options.c:682
static void game_music_enable_callback(struct option *poption)
Definition options.c:6528
static const char * get_current_option_file_name(void)
Definition options.c:5294
int option_int_def(const struct option *poption)
Definition options.c:849
static void options_init_names(const struct copt_val_name *(*acc)(int), struct strvec **support, struct strvec **pretty)
Definition options.c:6266
struct video_mode option_video_mode_def(const struct option *poption)
Definition options.c:1244
static bool server_option_bool_def(const struct option *poption)
Definition options.c:4775
#define GUI_GTK3_CITYDLG_DEFAULT_XSIZE
Definition options.h:604
#define GUI_GTK3_22_GOV_RANGE_MIN_DEFAULT
Definition options.h:629
#define MW_POPUP
Definition options.h:582
#define GUI_GTK3_CITYDLG_MAX_YSIZE
Definition options.h:610
#define GUI_GTK3_22_GOV_RANGE_MIN_MIN
Definition options.h:630
#define GUI_GTK3_GOV_RANGE_MIN_DEFAULT
Definition options.h:612
#define GUI_GTK4_GOV_RANGE_MIN_MAX
Definition options.h:648
#define GUI_GTK3_22_CITYDLG_MIN_YSIZE
Definition options.h:626
#define GUI_GTK4_CITYDLG_MAX_XSIZE
Definition options.h:640
#define GUI_GTK4_GOV_RANGE_MIN_DEFAULT
Definition options.h:646
#define GUI_GTK3_GOV_RANGE_MAX_DEFAULT
Definition options.h:616
void(* option_save_log_callback)(enum log_level lvl, const char *msg,...)
Definition options.h:445
#define GUI_GTK4_CITYDLG_DEFAULT_XSIZE
Definition options.h:638
#define FC_SDL3_DEFAULT_THEME_NAME
Definition options.h:392
#define GUI_GTK2_CITYDLG_DEFAULT_YSIZE
Definition options.h:596
#define FC_GTK3_22_DEFAULT_THEME_NAME
Definition options.h:300
#define GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE
Definition options.h:621
#define FC_QT_DEFAULT_THEME_NAME
Definition options.h:404
#define GUI_GTK3_CITYDLG_MIN_YSIZE
Definition options.h:609
#define GUI_GTK3_CITYDLG_MIN_XSIZE
Definition options.h:605
#define GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE
Definition options.h:625
#define GUI_GTK4_CITYDLG_MIN_YSIZE
Definition options.h:643
#define DEFAULT_FOLLOWTAG_OPTION
Definition options.h:30
#define GUI_GTK2_CITYDLG_MIN_YSIZE
Definition options.h:597
#define options_iterate(poptset, poption)
Definition options.h:553
#define GUI_GTK2_CITYDLG_MAX_XSIZE
Definition options.h:594
#define GUI_DEFAULT_CHAT_LOGFILE
Definition options.h:589
#define GUI_GTK3_GOV_RANGE_MAX_MAX
Definition options.h:618
#define GUI_GTK4_CITYDLG_MIN_XSIZE
Definition options.h:639
#define GUI_GTK3_22_GOV_RANGE_MAX_DEFAULT
Definition options.h:633
#define DEFAULT_METASERVER_OPTION
Definition options.h:29
#define GUI_GTK3_CITYDLG_DEFAULT_YSIZE
Definition options.h:608
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:623
#define GUI_GTK3_22_GOV_RANGE_MAX_MIN
Definition options.h:634
#define GUI_GTK3_GOV_RANGE_MIN_MIN
Definition options.h:613
#define GUI_GTK3_GOV_RANGE_MIN_MAX
Definition options.h:614
#define GUI_GTK3_22_CITYDLG_MIN_XSIZE
Definition options.h:622
#define GUI_GTK4_GOV_RANGE_MAX_DEFAULT
Definition options.h:650
#define MAJOR_NEW_OPTION_FILE_NAME
Definition options.h:38
#define GUI_GTK3_GOV_RANGE_MAX_MIN
Definition options.h:617
@ GUI_POPUP_TECH_HELP_RULESET
Definition options.h:77
#define GUI_GTK2_CITYDLG_MAX_YSIZE
Definition options.h:598
@ GUI_GTK_MSGCHAT_SEPARATE
Definition options.h:68
#define GUI_DEFAULT_MAPIMG_FILENAME
Definition options.h:654
#define GUI_GTK3_22_CITYDLG_MAX_YSIZE
Definition options.h:627
#define GUI_GTK4_GOV_RANGE_MIN_MIN
Definition options.h:647
#define GUI_GTK4_CITYDLG_MAX_YSIZE
Definition options.h:644
#define MW_OUTPUT
Definition options.h:580
#define GUI_GTK4_CITYDLG_DEFAULT_YSIZE
Definition options.h:642
#define options_iterate_end
Definition options.h:558
#define GUI_GTK4_GOV_RANGE_MAX_MAX
Definition options.h:652
#define MW_MESSAGES
Definition options.h:581
#define FC_GTK4_DEFAULT_THEME_NAME
Definition options.h:336
#define GUI_GTK3_22_GOV_RANGE_MIN_MAX
Definition options.h:631
#define MINOR_NEW_OPTION_FILE_NAME
Definition options.h:42
#define GUI_GTK2_CITYDLG_DEFAULT_XSIZE
Definition options.h:592
#define FC_SDL2_DEFAULT_THEME_NAME
Definition options.h:379
#define GUI_GTK3_22_GOV_RANGE_MAX_MAX
Definition options.h:635
#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_GTK3_CITYDLG_MAX_XSIZE
Definition options.h:606
#define GUI_GTK4_GOV_RANGE_MAX_MIN
Definition options.h:651
#define GUI_GTK2_CITYDLG_MIN_XSIZE
Definition options.h:593
void overview_redraw_callback(struct option *option)
int dsend_packet_sync_serial(struct connection *pc, int serial)
#define is_ai(plr)
Definition player.h:230
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:50
void secfile_allow_digital_boolean(struct section_file *secfile, bool allow_digital_boolean)
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:634
bool str_to_int(const char *str, int *pint)
Definition shared.c:517
bool make_dir(const char *pathname)
Definition shared.c:1782
char * freeciv_storage_dir(void)
Definition shared.c:678
#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 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:1448
const unsigned def
Definition options.c:1471
struct client_option::@209::@216 font
enum gui_type specific
Definition options.c:1437
const char * description
Definition options.c:1434
const char *const def
Definition options.c:1454
struct ft_color *const pvalue
Definition options.c:1484
struct client_option::@209::@212 integer
struct video_mode *const pvalue
Definition options.c:1489
const size_t size
Definition options.c:1453
char *const pvalue
Definition options.c:1452
const int max
Definition options.c:1448
const bool def
Definition options.c:1443
const char *const target
Definition options.c:1480
bool *const pvalue
Definition options.c:1442
struct option base_option
Definition options.c:1431
struct client_option::@209::@213 string
const char * help_text
Definition options.c:1435
unsigned *const pvalue
Definition options.c:1470
enum client_option_category category
Definition options.c:1436
int *const pvalue
Definition options.c:1447
const char * name
Definition options.c:1433
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:420
char default_tileset_iso_name[512]
Definition options.h:132
bool gui_qt_show_techs_panel
Definition options.h:421
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:422
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
char capability[MAX_LEN_CAPSTR]
Definition connection.h:171
const char * support
Definition options.c:1287
const char * pretty
Definition options.c:1289
int(* number)(const struct option *)
Definition options.c:491
int(* category)(const struct option *)
Definition options.c:495
bool(* is_changeable)(const struct option *)
Definition options.c:496
struct option *(* option_by_number)(int)
Definition options.c:414
struct option *(* option_first)(void)
Definition options.c:415
const char *(* category_name)(int)
Definition options.c:418
int(* category_number)(void)
Definition options.c:417
const struct option::@207::option_str_vtable * str_vtable
const struct option::option_common_vtable * common_vtable
const struct option::@207::option_bool_vtable * bool_vtable
const struct option::@207::option_int_vtable * int_vtable
const struct option::@207::option_enum_vtable * enum_vtable
const struct option::@207::option_font_vtable * font_vtable
enum option_type type
Definition options.c:487
const struct option_set * poptset
Definition options.c:485
const struct option::@207::option_video_mode_vtable * video_mode_vtable
const struct option::@207::option_bitwise_vtable * bitwise_vtable
const struct option::@207::option_color_vtable * color_vtable
int callback_data
Definition options.c:561
void(* changed_callback)(struct option *option)
Definition options.c:559
void * gui_data
Definition options.c:564
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:4143
unsigned value
Definition options.c:4148
char * help_text
Definition options.c:4116
char * name
Definition options.c:4114
bool is_visible
Definition options.c:4120
char * description
Definition options.c:4115
unsigned char category
Definition options.c:4117
struct strvec * pretty_names
Definition options.c:4144
enum setting_default_level setdef
Definition options.c:4121
unsigned def
Definition options.c:4149
bool is_changeable
Definition options.c:4119
struct server_option::@219::@222 integer
char * value
Definition options.c:4136
struct option base_option
Definition options.c:4112
bool desired_sent
Definition options.c:4118
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:974
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:791
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
size_t fc_strlcat(char *dest, const char *src, size_t n)
Definition support.c:836
int fc_stat(const char *filename, struct stat *buf)
Definition support.c:576
#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:1296
const struct strvec * get_tileset_list(const struct option *poption)
Definition tilespec.c:1103
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:704
void tilespec_reread_callback(struct option *poption)
Definition tilespec.c:1509
int tileset_topo_index(struct tileset *t)
Definition tilespec.c:7563
#define TS_TOPO_ISOHEX
Definition tilespec.h:455
#define TS_TOPO_HEX
Definition tilespec.h:454
#define TS_TOPO_SQUARE
Definition tilespec.h:453