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 "deprecations.h"
25#include "fcintl.h"
26#include "ioz.h"
27#include "log.h"
28#include "mem.h"
29#include "registry.h"
30#include "shared.h"
31#include "string_vector.h"
32#include "support.h"
33
34/* common */
35#include "events.h"
36#include "version.h"
37
38/* client/agents */
39#include "cma_fec.h"
40
41/* client/include */
42#include "chatline_g.h"
43#include "dialogs_g.h"
44#include "gui_main_g.h"
45#include "menu_g.h"
46#include "optiondlg_g.h"
47#include "repodlgs_g.h"
48#include "voteinfo_bar_g.h"
49
50/* client */
51#include "audio.h"
52#include "cityrepdata.h"
53#include "client_main.h"
54#include "climisc.h"
55#include "connectdlg_common.h"
56#include "global_worklist.h"
57#include "mapctrl_common.h"
58#include "mapview_common.h"
59#include "music.h"
60#include "overview_common.h"
61#include <packhand_gen.h> /* <> so looked from the build directory first. */
62#include "plrdlg_common.h"
63#include "repodlgs_common.h"
64#include "servers.h"
65#include "themes_common.h"
66#include "tilespec.h"
67
68#include "options.h"
69
70
74 .default_user_name = "\0",
75 .default_server_host = "localhost",
76 .default_server_port = DEFAULT_SOCK_PORT,
77 .default_metaserver = DEFAULT_METASERVER_OPTION,
78 .default_tileset_square_name = "\0",
79 .default_tileset_hex_name = "\0",
80 .default_tileset_isohex_name = "\0",
81 .default_sound_set_name = "stdsounds",
82 .default_music_set_name = "stdmusic",
83 .default_sound_plugin_name = "\0",
84 .default_chat_logfile = GUI_DEFAULT_CHAT_LOGFILE,
85 .default_topology = TS_TOPO_ISOHEX,
86
87 .followtag_override = DEFAULT_FOLLOWTAG_OPTION,
88
89 .save_options_on_exit = TRUE,
90
91 .use_prev_server = FALSE,
92 .heartbeat_enabled = FALSE,
93 .send_desired_settings = TRUE,
94
96 .first_boot = FALSE,
97 .default_tileset_name = "\0",
98 .default_tileset_overhead_name = "\0",
99 .default_tileset_iso_name = "\0",
100 .gui_gtk3_migrated_from_gtk2 = FALSE,
101 .gui_gtk3_22_migrated_from_gtk3 = FALSE,
102 .gui_gtk4_migrated_from_gtk3_22 = FALSE,
103 .gui_sdl2_migrated_from_sdl = FALSE,
104 .gui_sdl3_migrated_from_sdl2 = FALSE,
105 .gui_gtk2_migrated_from_2_5 = FALSE,
106 .gui_gtk3_migrated_from_2_5 = FALSE,
107 .gui_qt_migrated_from_2_5 = FALSE,
108
109 .migrate_fullscreen = FALSE,
110
113 .gui_qt_default_fonts_set = FALSE,
114 .gui_sdl2_default_screen_size_set = FALSE,
115 .gui_sdl3_default_screen_size_set = FALSE,
116
119 .solid_color_behind_units = FALSE,
120 .sound_bell_at_new_turn = FALSE,
121 .smooth_move_unit_msec = 30,
122 .smooth_center_slide_msec = 200,
123 .smooth_combat_step_msec = 10,
124 .ai_manual_turn_done = TRUE,
125 .auto_center_on_unit = TRUE,
126 .auto_center_on_automated = TRUE,
127 .auto_center_on_combat = FALSE,
128 .auto_center_each_turn = TRUE,
129 .wakeup_focus = TRUE,
130 .goto_into_unknown = TRUE,
131 .center_when_popup_city = TRUE,
132 .show_previous_turn_messages = TRUE,
133 .concise_city_production = FALSE,
134 .auto_turn_done = FALSE,
135 .meta_accelerators = TRUE,
136 .ask_city_name = TRUE,
137 .popup_new_cities = TRUE,
138 .popup_actor_arrival = TRUE,
139 .popup_attack_actions = TRUE,
140 .popup_last_move_to_allied = TRUE,
141 .keyboardless_goto = TRUE,
142 .enable_cursor_changes = TRUE,
143 .separate_unit_selection = FALSE,
144 .unit_selection_clears_orders = TRUE,
145 .highlight_our_names = FT_COLOR("#000000", "#FFFF00"),
146
147 .voteinfo_bar_use = TRUE,
148 .voteinfo_bar_always_show = FALSE,
149 .voteinfo_bar_hide_when_not_player = FALSE,
150 .voteinfo_bar_new_at_front = FALSE,
151
152 .autoaccept_tileset_suggestion = FALSE,
153 .autoaccept_soundset_suggestion = FALSE,
154 .autoaccept_musicset_suggestion = FALSE,
155
156 .sound_enable_effects = TRUE,
157 .sound_enable_menu_music = TRUE,
158 .sound_enable_game_music = TRUE,
159 .sound_effects_volume = 100,
160 .silent_when_not_in_focus = FALSE,
161
162 /* This option is currently set by the client - not by the user. */
163 .update_city_text_in_refresh_tile = TRUE,
164
165 .draw_city_outlines = TRUE,
166 .draw_city_output = FALSE,
167 .draw_map_grid = FALSE,
168 .draw_city_names = TRUE,
169 .draw_city_growth = TRUE,
170 .draw_city_productions = TRUE,
171 .draw_city_buycost = FALSE,
172 .draw_city_trade_routes = FALSE,
173 .draw_terrain = TRUE,
174 .draw_coastline = FALSE,
175 .draw_paths = TRUE,
176 .draw_irrigation = TRUE,
177 .draw_mines = TRUE,
178 .draw_fortress_airbase = TRUE,
179 .draw_specials = TRUE,
180 .draw_huts = TRUE,
181 .draw_pollution = TRUE,
182 .draw_cities = TRUE,
183 .draw_units = TRUE,
184 .draw_focus_unit = FALSE,
185 .draw_fog_of_war = TRUE,
186 .draw_borders = TRUE,
187 .draw_native = FALSE,
188 .draw_full_citybar = TRUE,
189 .draw_unit_shields = TRUE,
190 .draw_unit_stack_size = TRUE,
191 .player_dlg_show_dead_players = TRUE,
192 .reqtree_show_icons = TRUE,
193 .reqtree_curved_lines = FALSE,
194
195/* Options for map images */
196/* .mapimg_format, */
197 .mapimg_zoom = 2,
198/* See the definition of MAPIMG_LAYER in mapimg.h. */
199 .mapimg_layer = {
200 FALSE, /* a - MAPIMG_LAYER_AREA */
201 TRUE, /* b - MAPIMG_LAYER_BORDERS */
202 TRUE, /* c - MAPIMG_LAYER_CITIES */
203 TRUE, /* f - MAPIMG_LAYER_FOGOFWAR */
204 TRUE, /* k - MAPIMG_LAYER_KNOWLEDGE */
205 TRUE, /* t - MAPIMG_LAYER_TERRAIN */
206 TRUE /* u - MAPIMG_LAYER_UNITS */
207 },
208/* .mapimg_filename, */
209
210 .zoom_set = FALSE,
211 .zoom_default_level = 1.0,
212
213/* gui-gtk-2.0 client specific options.
214 * These are still kept just so users can migrate them to gtk3-client */
215 .gui_gtk2_map_scrollbars = FALSE,
216 .gui_gtk2_dialogs_on_top = TRUE,
217 .gui_gtk2_show_task_icons = TRUE,
218 .gui_gtk2_enable_tabs = TRUE,
219 .gui_gtk2_better_fog = TRUE,
220 .gui_gtk2_show_chat_message_time = FALSE,
221 .gui_gtk2_new_messages_go_to_top = FALSE,
222 .gui_gtk2_show_message_window_buttons = TRUE,
223 .gui_gtk2_metaserver_tab_first = FALSE,
224 .gui_gtk2_allied_chat_only = FALSE,
225 .gui_gtk2_mouse_over_map_focus = FALSE,
226 .gui_gtk2_chatline_autocompletion = TRUE,
227 .gui_gtk2_citydlg_xsize = GUI_GTK2_CITYDLG_DEFAULT_XSIZE,
228 .gui_gtk2_citydlg_ysize = GUI_GTK2_CITYDLG_DEFAULT_YSIZE,
229 .gui_gtk2_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
230 .gui_gtk2_font_city_label = "Monospace 8",
231 .gui_gtk2_font_notify_label = "Monospace Bold 9",
232 .gui_gtk2_font_spaceship_label = "Monospace 8",
233 .gui_gtk2_font_help_label = "Sans Bold 10",
234 .gui_gtk2_font_help_link = "Sans 9",
235 .gui_gtk2_font_help_text = "Monospace 8",
236 .gui_gtk2_font_chatline = "Monospace 8",
237 .gui_gtk2_font_beta_label = "Sans Italic 10",
238 .gui_gtk2_font_small = "Sans 9",
239 .gui_gtk2_font_comment_label = "Sans Italic 9",
240 .gui_gtk2_font_city_names = "Sans Bold 10",
241 .gui_gtk2_font_city_productions = "Serif 10",
242 .gui_gtk2_font_reqtree_text = "Serif 10",
243
244/* gui-gtk-3.0 client specific options. */
245 .gui_gtk3_fullscreen = FALSE,
246 .gui_gtk3_map_scrollbars = FALSE,
247 .gui_gtk3_dialogs_on_top = TRUE,
248 .gui_gtk3_show_task_icons = TRUE,
249 .gui_gtk3_enable_tabs = TRUE,
250 .gui_gtk3_show_chat_message_time = FALSE,
251 .gui_gtk3_new_messages_go_to_top = FALSE,
252 .gui_gtk3_show_message_window_buttons = TRUE,
253 .gui_gtk3_metaserver_tab_first = FALSE,
254 .gui_gtk3_allied_chat_only = FALSE,
255 .gui_gtk3_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
256 .gui_gtk3_small_display_layout = FALSE,
257 .gui_gtk3_mouse_over_map_focus = FALSE,
258 .gui_gtk3_chatline_autocompletion = TRUE,
259 .gui_gtk3_citydlg_xsize = GUI_GTK3_CITYDLG_DEFAULT_XSIZE,
260 .gui_gtk3_citydlg_ysize = GUI_GTK3_CITYDLG_DEFAULT_YSIZE,
261 .gui_gtk3_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
262 .gui_gtk3_governor_range_min = -20,
263 .gui_gtk3_governor_range_max = 20,
264 .gui_gtk3_font_city_label = "Monospace 8",
265 .gui_gtk3_font_notify_label = "Monospace Bold 9",
266 .gui_gtk3_font_spaceship_label = "Monospace 8",
267 .gui_gtk3_font_help_label = "Sans Bold 10",
268 .gui_gtk3_font_help_link = "Sans 9",
269 .gui_gtk3_font_help_text = "Monospace 8",
270 .gui_gtk3_font_chatline = "Monospace 8",
271 .gui_gtk3_font_beta_label = "Sans Italic 10",
272 .gui_gtk3_font_small = "Sans 9",
273 .gui_gtk3_font_comment_label = "Sans Italic 9",
274 .gui_gtk3_font_city_names = "Sans Bold 10",
275 .gui_gtk3_font_city_productions = "Serif 10",
276 .gui_gtk3_font_reqtree_text = "Serif 10",
277
278/* gui-gtk-3.22 client specific options. */
279 .gui_gtk3_22_default_theme_name = FC_GTK3_22_DEFAULT_THEME_NAME,
280 .gui_gtk3_22_fullscreen = FALSE,
281 .gui_gtk3_22_map_scrollbars = FALSE,
282 .gui_gtk3_22_dialogs_on_top = TRUE,
283 .gui_gtk3_22_show_task_icons = TRUE,
284 .gui_gtk3_22_enable_tabs = TRUE,
285 .gui_gtk3_22_show_chat_message_time = FALSE,
286 .gui_gtk3_22_new_messages_go_to_top = FALSE,
287 .gui_gtk3_22_show_message_window_buttons = TRUE,
288 .gui_gtk3_22_metaserver_tab_first = FALSE,
289 .gui_gtk3_22_allied_chat_only = FALSE,
290 .gui_gtk3_22_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
291 .gui_gtk3_22_small_display_layout = FALSE,
292 .gui_gtk3_22_mouse_over_map_focus = FALSE,
293 .gui_gtk3_22_chatline_autocompletion = TRUE,
294 .gui_gtk3_22_citydlg_xsize = GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE,
295 .gui_gtk3_22_citydlg_ysize = GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE,
296 .gui_gtk3_22_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
297 .gui_gtk3_22_governor_range_min = -20,
298 .gui_gtk3_22_governor_range_max = 20,
299 .gui_gtk3_22_font_city_label = "Monospace 8",
300 .gui_gtk3_22_font_notify_label = "Monospace Bold 9",
301 .gui_gtk3_22_font_spaceship_label = "Monospace 8",
302 .gui_gtk3_22_font_help_label = "Sans Bold 10",
303 .gui_gtk3_22_font_help_link = "Sans 9",
304 .gui_gtk3_22_font_help_text = "Monospace 8",
305 .gui_gtk3_22_font_chatline = "Monospace 8",
306 .gui_gtk3_22_font_beta_label = "Sans Italic 10",
307 .gui_gtk3_22_font_small = "Sans 9",
308 .gui_gtk3_22_font_comment_label = "Sans Italic 9",
309 .gui_gtk3_22_font_city_names = "Sans Bold 10",
310 .gui_gtk3_22_font_city_productions = "Serif 10",
311 .gui_gtk3_22_font_reqtree_text = "Serif 10",
312
313/* gui-gtk-4.0 client specific options. */
314 .gui_gtk4_default_theme_name = FC_GTK4_DEFAULT_THEME_NAME,
315 .gui_gtk4_fullscreen = FALSE,
316 .gui_gtk4_map_scrollbars = FALSE,
317 .gui_gtk4_dialogs_on_top = TRUE,
318 .gui_gtk4_show_task_icons = TRUE,
319 .gui_gtk4_enable_tabs = TRUE,
320 .gui_gtk4_show_chat_message_time = FALSE,
321 .gui_gtk4_new_messages_go_to_top = FALSE,
322 .gui_gtk4_show_message_window_buttons = TRUE,
323 .gui_gtk4_metaserver_tab_first = FALSE,
324 .gui_gtk4_allied_chat_only = FALSE,
325 .gui_gtk4_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
326 .gui_gtk4_small_display_layout = FALSE,
327 .gui_gtk4_mouse_over_map_focus = FALSE,
328 .gui_gtk4_chatline_autocompletion = TRUE,
329 .gui_gtk4_citydlg_xsize = GUI_GTK4_CITYDLG_DEFAULT_XSIZE,
330 .gui_gtk4_citydlg_ysize = GUI_GTK4_CITYDLG_DEFAULT_YSIZE,
331 .gui_gtk4_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
332 .gui_gtk4_governor_range_min = -20,
333 .gui_gtk4_governor_range_max = 20,
334 .gui_gtk4_font_city_label = "Monospace 8",
335 .gui_gtk4_font_notify_label = "Monospace Bold 9",
336 .gui_gtk4_font_spaceship_label = "Monospace 8",
337 .gui_gtk4_font_help_label = "Sans Bold 10",
338 .gui_gtk4_font_help_link = "Sans 9",
339 .gui_gtk4_font_help_text = "Monospace 8",
340 .gui_gtk4_font_chatline = "Monospace 8",
341 .gui_gtk4_font_beta_label = "Sans Italic 10",
342 .gui_gtk4_font_small = "Sans 9",
343 .gui_gtk4_font_comment_label = "Sans Italic 9",
344 .gui_gtk4_font_city_names = "Sans Bold 10",
345 .gui_gtk4_font_city_productions = "Serif 10",
346 .gui_gtk4_font_reqtree_text = "Serif 10",
347
348/* gui-sdl client specific options. */
349 .gui_sdl_fullscreen = FALSE,
350 .gui_sdl_screen = VIDEO_MODE(640, 480),
351 .gui_sdl_do_cursor_animation = TRUE,
352 .gui_sdl_use_color_cursors = TRUE,
353
354/* gui-sdl2 client specific options. */
355 .gui_sdl2_default_theme_name = FC_SDL2_DEFAULT_THEME_NAME,
356 .gui_sdl2_fullscreen = FALSE,
357 .gui_sdl2_screen = VIDEO_MODE(640, 480),
358 .gui_sdl2_swrenderer = FALSE,
359 .gui_sdl2_do_cursor_animation = TRUE,
360 .gui_sdl2_use_color_cursors = TRUE,
361 .gui_sdl2_font_city_names = "10",
362 .gui_sdl2_font_city_productions = "10",
363 .gui_sdl2_use_theme_font_size = TRUE,
364 .gui_sdl2_font_size = 10,
365
366/* gui-sdl3 client specific options. */
367 .gui_sdl3_default_theme_name = FC_SDL2_DEFAULT_THEME_NAME,
368 .gui_sdl3_fullscreen = FALSE,
369 .gui_sdl3_screen = VIDEO_MODE(640, 480),
370 .gui_sdl3_do_cursor_animation = TRUE,
371 .gui_sdl3_use_color_cursors = TRUE,
372 .gui_sdl3_font_city_names = "10",
373 .gui_sdl3_font_city_productions = "10",
374 .gui_sdl3_use_theme_font_size = TRUE,
375 .gui_sdl3_font_size = 10,
376
377/* gui-qt client specific options. */
378 .gui_qt_fullscreen = FALSE,
379 .gui_qt_show_preview = TRUE,
380 .gui_qt_sidebar_left = TRUE,
381 .gui_qt_default_theme_name = FC_QT_DEFAULT_THEME_NAME,
382 .gui_qt_font_default = "Sans Serif,10,-1,5,75,0,0,0,0,0",
383 .gui_qt_font_notify_label = "Monospace,8,-1,5,75,0,0,0,0,0",
384 .gui_qt_font_help_label = "Sans Serif,9,-1,5,50,0,0,0,0,0",
385 .gui_qt_font_help_text = "Monospace,8,-1,5,50,0,0,0,0,0",
386 .gui_qt_font_chatline = "Monospace,8,-1,5,50,0,0,0,0,0",
387 .gui_qt_font_city_names = "Sans Serif,10,-1,5,75,0,0,0,0,0",
388 .gui_qt_font_city_productions = "Sans Serif,10,-1,5,50,1,0,0,0,0",
389 .gui_qt_font_reqtree_text = "Sans Serif,10,-1,5,50,1,0,0,0,0",
390 .gui_qt_show_titlebar = TRUE,
391 .gui_qt_wakeup_text = "Wake up %1",
392 .gui_qt_show_relations_panel = TRUE,
393 .gui_qt_show_techs_panel = TRUE,
394 .gui_qt_show_wonders_panel = TRUE,
395 .gui_qt_svgflags = TRUE
396};
397
398/* Set to TRUE after the first call to options_init(), to avoid the usage
399 * of non-initialized datas when calling the changed callback. */
401
402static int sync_serial = 0;
403
404static const struct strvec *get_mapimg_format_list(const struct option *poption);
405
406/****************************************************************************
407 Option set structure.
408****************************************************************************/
410 struct option * (*option_by_number) (int);
411 struct option * (*option_first) (void);
412
414 const char * (*category_name) (int);
415};
416
417/************************************************************************/
421 int id)
422{
424
425 return poptset->option_by_number(id);
426}
427
428/************************************************************************/
432 const char *name)
433{
435
437 if (0 == strcmp(option_name(poption), name)) {
438 return poption;
439 }
441 return NULL;
442}
443
444/************************************************************************/
448{
450
451 return poptset->option_first();
452}
453
454/************************************************************************/
458{
460
461 return poptset->category_number();
462}
463
464/************************************************************************/
467const char *optset_category_name(const struct option_set *poptset,
468 int category)
469{
471
472 return poptset->category_name(category);
473}
474
475
476/****************************************************************************
477 The base class for options.
478****************************************************************************/
479struct option {
480 /* A link to the option set. */
481 const struct option_set *poptset;
482 /* Type of the option. */
484
485 /* Common accessors. */
486 const struct option_common_vtable {
487 int (*number) (const struct option *);
488 const char * (*name) (const struct option *);
489 const char * (*description) (const struct option *);
490 const char * (*help_text) (const struct option *);
491 int (*category) (const struct option *);
492 bool (*is_changeable) (const struct option *);
493 struct option * (*next) (const struct option *);
495 /* Specific typed accessors. */
496 union {
497 /* Specific boolean accessors (OT_BOOLEAN == type). */
498 const struct option_bool_vtable {
499 bool (*get) (const struct option *);
500 bool (*def) (const struct option *);
501 bool (*set) (struct option *, bool);
503 /* Specific integer accessors (OT_INTEGER == type). */
504 const struct option_int_vtable {
505 int (*get) (const struct option *);
506 int (*def) (const struct option *);
507 int (*minimum) (const struct option *);
508 int (*maximum) (const struct option *);
509 bool (*set) (struct option *, int);
511 /* Specific string accessors (OT_STRING == type). */
512 const struct option_str_vtable {
513 const char * (*get) (const struct option *);
514 const char * (*def) (const struct option *);
515 const struct strvec * (*values) (const struct option *);
516 bool (*set) (struct option *, const char *);
518 /* Specific enum accessors (OT_ENUM == type). */
519 const struct option_enum_vtable {
520 int (*get) (const struct option *);
521 int (*def) (const struct option *);
522 const struct strvec * (*values) (const struct option *);
523 bool (*set) (struct option *, int);
524 int (*cmp) (const char *, const char *);
526 /* Specific bitwise accessors (OT_BITWISE == type). */
527 const struct option_bitwise_vtable {
528 unsigned (*get) (const struct option *);
529 unsigned (*def) (const struct option *);
530 const struct strvec * (*values) (const struct option *);
531 bool (*set) (struct option *, unsigned);
533 /* Specific font accessors (OT_FONT == type). */
534 const struct option_font_vtable {
535 const char * (*get) (const struct option *);
536 const char * (*def) (const struct option *);
537 const char * (*target) (const struct option *);
538 bool (*set) (struct option *, const char *);
540 /* Specific color accessors (OT_COLOR == type). */
541 const struct option_color_vtable {
542 struct ft_color (*get) (const struct option *);
543 struct ft_color (*def) (const struct option *);
544 bool (*set) (struct option *, struct ft_color);
546 /* Specific video mode accessors (OT_VIDEO_MODE == type). */
547 const struct option_video_mode_vtable {
548 struct video_mode (*get) (const struct option *);
549 struct video_mode (*def) (const struct option *);
550 bool (*set) (struct option *, struct video_mode);
552 };
553
554 /* Called after the value changed. */
556
558
559 /* Volatile. */
560 void *gui_data;
561};
562
563#define OPTION(poption) ((struct option *) (poption))
564
565#define OPTION_INIT(optset, spec_type, spec_table_var, common_table, \
566 spec_table, changed_cb, cb_data) { \
567 .poptset = optset, \
568 .type = spec_type, \
569 .common_vtable = &common_table, \
570 INIT_BRACE_BEGIN \
571 .spec_table_var = &spec_table \
572 INIT_BRACE_END, \
573 .changed_callback = changed_cb, \
574 .callback_data = cb_data, \
575 .gui_data = NULL \
576}
577#define OPTION_BOOL_INIT(optset, common_table, bool_table, changed_cb) \
578 OPTION_INIT(optset, OT_BOOLEAN, bool_vtable, common_table, bool_table, \
579 changed_cb, 0)
580#define OPTION_INT_INIT(optset, common_table, int_table, changed_cb) \
581 OPTION_INIT(optset, OT_INTEGER, int_vtable, common_table, int_table, \
582 changed_cb, 0)
583#define OPTION_STR_INIT(optset, common_table, str_table, changed_cb, cb_data) \
584 OPTION_INIT(optset, OT_STRING, str_vtable, common_table, str_table, \
585 changed_cb, cb_data)
586#define OPTION_ENUM_INIT(optset, common_table, enum_table, changed_cb) \
587 OPTION_INIT(optset, OT_ENUM, enum_vtable, common_table, enum_table, \
588 changed_cb, 0)
589#define OPTION_BITWISE_INIT(optset, common_table, bitwise_table, \
590 changed_cb) \
591 OPTION_INIT(optset, OT_BITWISE, bitwise_vtable, common_table, \
592 bitwise_table, changed_cb, 0)
593#define OPTION_FONT_INIT(optset, common_table, font_table, changed_cb) \
594 OPTION_INIT(optset, OT_FONT, font_vtable, common_table, font_table, \
595 changed_cb, 0)
596#define OPTION_COLOR_INIT(optset, common_table, color_table, changed_cb) \
597 OPTION_INIT(optset, OT_COLOR, color_vtable, common_table, color_table, \
598 changed_cb, 0)
599#define OPTION_VIDEO_MODE_INIT(optset, common_table, video_mode_table, \
600 changed_cb) \
601 OPTION_INIT(optset, OT_VIDEO_MODE, video_mode_vtable, common_table, \
602 video_mode_table, changed_cb, 0)
603
604
605/************************************************************************/
608const struct option_set *option_optset(const struct option *poption)
609{
611
612 return poption->poptset;
613}
614
615/************************************************************************/
618int option_number(const struct option *poption)
619{
621
622 return poption->common_vtable->number(poption);
623}
624
625/************************************************************************/
628const char *option_name(const struct option *poption)
629{
631
632 return poption->common_vtable->name(poption);
633}
634
635/************************************************************************/
638const char *option_description(const struct option *poption)
639{
641
642 return poption->common_vtable->description(poption);
643}
644
645/************************************************************************/
648const char *option_help_text(const struct option *poption)
649{
651
652 return poption->common_vtable->help_text(poption);
653}
654
655/************************************************************************/
659{
661
662 return poption->type;
663}
664
665/************************************************************************/
669{
671
672 return poption->common_vtable->category(poption);
673}
674
675/************************************************************************/
678const char *option_category_name(const struct option *poption)
679{
681
682 return optset_category_name(poption->poptset,
683 poption->common_vtable->category(poption));
684}
685
686/************************************************************************/
690{
692
693 return poption->common_vtable->is_changeable(poption);
694}
695
696/************************************************************************/
699struct option *option_next(const struct option *poption)
700{
702
703 return poption->common_vtable->next(poption);
704}
705
706/************************************************************************/
733
734/************************************************************************/
738 void (*callback) (struct option *))
739{
741
742 poption->changed_callback = callback;
743}
744
745/************************************************************************/
749{
751
753 /* Prevent to use non-initialized datas. */
754 return;
755 }
756
757 if (poption->changed_callback) {
758 poption->changed_callback(poption);
759 }
760
762}
763
764/************************************************************************/
767void option_set_gui_data(struct option *poption, void *data)
768{
770
771 poption->gui_data = data;
772}
773
774/************************************************************************/
778{
780
781 return poption->gui_data;
782}
783
784/************************************************************************/
788{
790
791 return poption->callback_data;
792}
793
794/************************************************************************/
797bool option_bool_get(const struct option *poption)
798{
801
802 return poption->bool_vtable->get(poption);
803}
804
805/************************************************************************/
808bool option_bool_def(const struct option *poption)
809{
812
813 return poption->bool_vtable->def(poption);
814}
815
816/************************************************************************/
819bool option_bool_set(struct option *poption, bool val)
820{
823
824 if (poption->bool_vtable->set(poption, val)) {
826 return TRUE;
827 }
828 return FALSE;
829}
830
831/************************************************************************/
834int option_int_get(const struct option *poption)
835{
838
839 return poption->int_vtable->get(poption);
840}
841
842/************************************************************************/
845int option_int_def(const struct option *poption)
846{
849
850 return poption->int_vtable->def(poption);
851}
852
853/************************************************************************/
856int option_int_min(const struct option *poption)
857{
860
861 return poption->int_vtable->minimum(poption);
862}
863
864/************************************************************************/
867int option_int_max(const struct option *poption)
868{
871
872 return poption->int_vtable->maximum(poption);
873}
874
875/************************************************************************/
878bool option_int_set(struct option *poption, int val)
879{
882
883 if (poption->int_vtable->set(poption, val)) {
885 return TRUE;
886 }
887 return FALSE;
888}
889
890/************************************************************************/
893const char *option_str_get(const struct option *poption)
894{
897
898 return poption->str_vtable->get(poption);
899}
900
901/************************************************************************/
904const char *option_str_def(const struct option *poption)
905{
908
909 return poption->str_vtable->def(poption);
910}
911
912/************************************************************************/
915const struct strvec *option_str_values(const struct option *poption)
916{
919
920 return poption->str_vtable->values(poption);
921}
922
923/************************************************************************/
926bool option_str_set(struct option *poption, const char *str)
927{
931
932 if (poption->str_vtable->set(poption, str)) {
934 return TRUE;
935 }
936 return FALSE;
937}
938
939/************************************************************************/
943int option_enum_str_to_int(const struct option *poption, const char *str)
944{
945 const struct strvec *values;
946 int val;
947
949 fc_assert_ret_val(OT_ENUM == poption->type, -1);
950 values = poption->enum_vtable->values(poption);
951 fc_assert_ret_val(NULL != values, -1);
952
953 for (val = 0; val < strvec_size(values); val++) {
954 if (0 == poption->enum_vtable->cmp(strvec_get(values, val), str)) {
955 return val;
956 }
957 }
958 return -1;
959}
960
961/************************************************************************/
965const char *option_enum_int_to_str(const struct option *poption, int val)
966{
967 const struct strvec *values;
968
971 values = poption->enum_vtable->values(poption);
972 fc_assert_ret_val(NULL != values, NULL);
973
974 return strvec_get(values, val);
975}
976
977/************************************************************************/
981{
983 fc_assert_ret_val(OT_ENUM == poption->type, -1);
984
985 return poption->enum_vtable->get(poption);
986}
987
988/************************************************************************/
992const char *option_enum_get_str(const struct option *poption)
993{
996
997 return strvec_get(poption->enum_vtable->values(poption),
998 poption->enum_vtable->get(poption));
999}
1000
1001/************************************************************************/
1005{
1007 fc_assert_ret_val(OT_ENUM == poption->type, -1);
1008
1009 return poption->enum_vtable->def(poption);
1010}
1011
1012/************************************************************************/
1016const char *option_enum_def_str(const struct option *poption)
1017{
1020
1021 return strvec_get(poption->enum_vtable->values(poption),
1022 poption->enum_vtable->def(poption));
1023}
1024
1025/************************************************************************/
1029const struct strvec *option_enum_values(const struct option *poption)
1030{
1033
1034 return poption->enum_vtable->values(poption);
1035}
1036
1037/************************************************************************/
1040bool option_enum_set_int(struct option *poption, int val)
1041{
1044
1045 if (poption->enum_vtable->set(poption, val)) {
1047 return TRUE;
1048 }
1049 return FALSE;
1050}
1051
1052/************************************************************************/
1057bool option_enum_set_str(struct option *poption, const char *str)
1058{
1062
1063 if (poption->enum_vtable->set(poption,
1066 return TRUE;
1067 }
1068 return FALSE;
1069}
1070
1071/************************************************************************/
1074unsigned option_bitwise_get(const struct option *poption)
1075{
1078
1079 return poption->bitwise_vtable->get(poption);
1080}
1081
1082/************************************************************************/
1085unsigned option_bitwise_def(const struct option *poption)
1086{
1089
1090 return poption->bitwise_vtable->def(poption);
1091}
1092
1093/************************************************************************/
1096unsigned option_bitwise_mask(const struct option *poption)
1097{
1098 const struct strvec *values;
1099
1102
1103 values = poption->bitwise_vtable->values(poption);
1104 fc_assert_ret_val(NULL != values, 0);
1105
1106 return (1 << strvec_size(values)) - 1;
1107}
1108
1109/************************************************************************/
1113const struct strvec *option_bitwise_values(const struct option *poption)
1114{
1117
1118 return poption->bitwise_vtable->values(poption);
1119}
1120
1121/************************************************************************/
1124bool option_bitwise_set(struct option *poption, unsigned val)
1125{
1128
1129 if (0 != (val & ~option_bitwise_mask(poption))
1130 || !poption->bitwise_vtable->set(poption, val)) {
1131 return FALSE;
1132 }
1133
1135 return TRUE;
1136}
1137
1138/************************************************************************/
1141const char *option_font_get(const struct option *poption)
1142{
1145
1146 return poption->font_vtable->get(poption);
1147}
1148
1149/************************************************************************/
1152const char *option_font_def(const struct option *poption)
1153{
1156
1157 return poption->font_vtable->def(poption);
1158}
1159
1160/************************************************************************/
1163const char *option_font_target(const struct option *poption)
1164{
1167
1168 return poption->font_vtable->target(poption);
1169}
1170
1171/************************************************************************/
1174bool option_font_set(struct option *poption, const char *font)
1175{
1178 fc_assert_ret_val(NULL != font, FALSE);
1179
1180 if (poption->font_vtable->set(poption, font)) {
1182 return TRUE;
1183 }
1184 return FALSE;
1185}
1186
1187/************************************************************************/
1197
1198/************************************************************************/
1208
1209/************************************************************************/
1214{
1217
1218 if (poption->color_vtable->set(poption, color)) {
1220 return TRUE;
1221 }
1222 return FALSE;
1223}
1224
1225/************************************************************************/
1229{
1232 video_mode_construct(-1, -1));
1233
1234 return poption->video_mode_vtable->get(poption);
1235}
1236
1237/************************************************************************/
1241{
1244 video_mode_construct(-1, -1));
1245
1246 return poption->video_mode_vtable->def(poption);
1247}
1248
1249/************************************************************************/
1254{
1257
1258 if (poption->video_mode_vtable->set(poption, mode)) {
1260 return TRUE;
1261 }
1262 return FALSE;
1263}
1264
1265
1266/****************************************************************************
1267 Client option set.
1268****************************************************************************/
1269static struct option *client_optset_option_by_number(int id);
1270static struct option *client_optset_option_first(void);
1271static int client_optset_category_number(void);
1272static const char *client_optset_category_name(int category);
1273
1276 .option_first = client_optset_option_first,
1277 .category_number = client_optset_category_number,
1278 .category_name = client_optset_category_name
1279};
1281
1283 const char *support; /* Untranslated long support name, used
1284 * for saving. */
1285 const char *pretty; /* Translated, used to display to the
1286 * users. */
1287};
1288
1289/****************************************************************************
1290 Virtuals tables for the client options.
1291****************************************************************************/
1292static int client_option_number(const struct option *poption);
1293static const char *client_option_name(const struct option *poption);
1294static const char *client_option_description(const struct option *poption);
1295static const char *client_option_help_text(const struct option *poption);
1296static int client_option_category(const struct option *poption);
1297static bool client_option_is_changeable(const struct option *poption);
1298static struct option *client_option_next(const struct option *poption);
1299
1300static const struct option_common_vtable client_option_common_vtable = {
1301 .number = client_option_number,
1302 .name = client_option_name,
1303 .description = client_option_description,
1304 .help_text = client_option_help_text,
1305 .category = client_option_category,
1306 .is_changeable = client_option_is_changeable,
1307 .next = client_option_next
1308};
1309
1310static bool client_option_bool_get(const struct option *poption);
1311static bool client_option_bool_def(const struct option *poption);
1312static bool client_option_bool_set(struct option *poption, bool val);
1313
1314static const struct option_bool_vtable client_option_bool_vtable = {
1318};
1319
1320static int client_option_int_get(const struct option *poption);
1321static int client_option_int_def(const struct option *poption);
1322static int client_option_int_min(const struct option *poption);
1323static int client_option_int_max(const struct option *poption);
1324static bool client_option_int_set(struct option *poption, int val);
1325
1326static const struct option_int_vtable client_option_int_vtable = {
1327 .get = client_option_int_get,
1328 .def = client_option_int_def,
1329 .minimum = client_option_int_min,
1330 .maximum = client_option_int_max,
1332};
1333
1334static const char *client_option_str_get(const struct option *poption);
1335static const char *client_option_str_def(const struct option *poption);
1336static const struct strvec *
1338static bool client_option_str_set(struct option *poption, const char *str);
1339
1340static const struct option_str_vtable client_option_str_vtable = {
1341 .get = client_option_str_get,
1342 .def = client_option_str_def,
1343 .values = client_option_str_values,
1345};
1346
1347static int client_option_enum_get(const struct option *poption);
1348static int client_option_enum_def(const struct option *poption);
1349static const struct strvec *
1351static bool client_option_enum_set(struct option *poption, int val);
1352
1353static const struct option_enum_vtable client_option_enum_vtable = {
1358 .cmp = fc_strcasecmp
1359};
1360
1361#if 0 /* There's no bitwise options currently */
1362static unsigned client_option_bitwise_get(const struct option *poption);
1363static unsigned client_option_bitwise_def(const struct option *poption);
1364static const struct strvec *
1366static bool client_option_bitwise_set(struct option *poption, unsigned val);
1367
1368static const struct option_bitwise_vtable client_option_bitwise_vtable = {
1373};
1374#endif /* 0 */
1375
1376static const char *client_option_font_get(const struct option *poption);
1377static const char *client_option_font_def(const struct option *poption);
1378static const char *client_option_font_target(const struct option *poption);
1379static bool client_option_font_set(struct option *poption, const char *font);
1380
1381static const struct option_font_vtable client_option_font_vtable = {
1384 .target = client_option_font_target,
1386};
1387
1390static bool client_option_color_set(struct option *poption,
1391 struct ft_color color);
1392
1393static const struct option_color_vtable client_option_color_vtable = {
1397};
1398
1399static struct video_mode
1401static struct video_mode
1403static bool client_option_video_mode_set(struct option *poption,
1404 struct video_mode mode);
1405
1406static const struct option_video_mode_vtable client_option_video_mode_vtable = {
1410};
1411
1422
1423/****************************************************************************
1424 Derived class client option, inherinting of base class option.
1425****************************************************************************/
1427 struct option base_option; /* Base structure, must be the first! */
1428
1429 const char *name; /* Short name - used as an identifier */
1430 const char *description; /* One-line description */
1431 const char *help_text; /* Paragraph-length help text */
1433 enum gui_type specific; /* GUI_STUB for common options. */
1434
1435 union {
1436 /* OT_BOOLEAN type option. */
1437 struct {
1438 bool *const pvalue;
1439 const bool def;
1440 } boolean;
1441 /* OT_INTEGER type option. */
1442 struct {
1443 int *const pvalue;
1444 const int def, min, max;
1445 } integer;
1446 /* OT_STRING type option. */
1447 struct {
1448 char *const pvalue;
1449 const size_t size;
1450 const char *const def;
1451 /*
1452 * A function to return a string vector of possible string values,
1453 * or NULL for none.
1454 */
1455 const struct strvec *(*const val_accessor) (const struct option *);
1456 } string;
1457 /* OT_ENUM type option. */
1458 struct {
1459 int *const pvalue;
1460 const int def;
1461 struct strvec *support_names, *pretty_names; /* untranslated */
1462 const struct copt_val_name * (*const name_accessor) (int value);
1463 } enumerator;
1464 /* OT_BITWISE type option. */
1465 struct {
1466 unsigned *const pvalue;
1467 const unsigned def;
1468 struct strvec *support_names, *pretty_names; /* untranslated */
1469 const struct copt_val_name * (*const name_accessor) (int value);
1470 } bitwise;
1471 /* OT_FONT type option. */
1472 struct {
1473 char *const pvalue;
1474 const size_t size;
1475 const char *const def;
1476 const char *const target;
1477 } font;
1478 /* OT_COLOR type option. */
1479 struct {
1480 struct ft_color *const pvalue;
1481 const struct ft_color def;
1483 /* OT_VIDEO_MODE type option. */
1484 struct {
1485 struct video_mode *const pvalue;
1486 const struct video_mode def;
1488 };
1489};
1490
1491#define CLIENT_OPTION(poption) ((struct client_option *) (poption))
1492
1493/*
1494 * Generate a client option of type OT_BOOLEAN.
1495 *
1496 * oname: The option data. Note it is used as name to be loaded or saved.
1497 * So, you shouldn't change the name of this variable in any case.
1498 * odesc: A short description of the client option. Should be used with the
1499 * N_() macro.
1500 * ohelp: The help text for the client option. Should be used with the N_()
1501 * macro.
1502 * ocat: The client_option_class of this client option.
1503 * ospec: A gui_type enumerator which determine for what particular client
1504 * gui this option is for. Sets to GUI_STUB for common options.
1505 * odef: The default value of this client option (FALSE or TRUE).
1506 * ocb: A callback function of type void (*)(struct option *) called when
1507 * the option changed.
1508 */
1509#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb) \
1510{ \
1511 .base_option = OPTION_BOOL_INIT(&client_optset_static, \
1512 client_option_common_vtable, \
1513 client_option_bool_vtable, ocb), \
1514 .name = #oname, \
1515 .description = odesc, \
1516 .help_text = ohelp, \
1517 .category = ocat, \
1518 .specific = ospec, \
1519 INIT_BRACE_BEGIN \
1520 .boolean = { \
1521 .pvalue = &gui_options.oname, \
1522 .def = odef, \
1523 } \
1524 INIT_BRACE_END \
1525}
1526
1527/*
1528 * Generate a client option of type OT_INTEGER.
1529 *
1530 * oname: The option data. Note it is used as name to be loaded or saved.
1531 * So, you shouldn't change the name of this variable in any case.
1532 * odesc: A short description of the client option. Should be used with the
1533 * N_() macro.
1534 * ohelp: The help text for the client option. Should be used with the N_()
1535 * macro.
1536 * ocat: The client_option_class of this client option.
1537 * ospec: A gui_type enumerator which determine for what particular client
1538 * gui this option is for. Sets to GUI_STUB for common options.
1539 * odef: The default value of this client option.
1540 * omin: The minimal value of this client option.
1541 * omax: The maximal value of this client option.
1542 * ocb: A callback function of type void (*)(struct option *) called when
1543 * the option changed.
1544 */
1545#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb) \
1546{ \
1547 .base_option = OPTION_INT_INIT(&client_optset_static, \
1548 client_option_common_vtable, \
1549 client_option_int_vtable, ocb), \
1550 .name = #oname, \
1551 .description = odesc, \
1552 .help_text = ohelp, \
1553 .category = ocat, \
1554 .specific = ospec, \
1555 INIT_BRACE_BEGIN \
1556 .integer = { \
1557 .pvalue = &gui_options.oname, \
1558 .def = odef, \
1559 .min = omin, \
1560 .max = omax \
1561 } \
1562 INIT_BRACE_END \
1563}
1564
1565/*
1566 * Generate a client option of type OT_STRING.
1567 *
1568 * oname: The option data. Note it is used as name to be loaded or saved.
1569 * So, you shouldn't change the name of this variable in any case.
1570 * Be sure to pass the array variable and not a pointer to it because
1571 * the size is calculated with sizeof().
1572 * odesc: A short description of the client option. Should be used with the
1573 * N_() macro.
1574 * ohelp: The help text for the client option. Should be used with the N_()
1575 * macro.
1576 * ocat: The client_option_class of this client option.
1577 * ospec: A gui_type enumerator which determines for what particular client
1578 * gui this option is for. Set to GUI_STUB for common options.
1579 * odef: The default string for this client option.
1580 * ocb: A callback function of type void (*)(struct option *) called when
1581 * the option changed.
1582 */
1583#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd) \
1584{ \
1585 .base_option = OPTION_STR_INIT(&client_optset_static, \
1586 client_option_common_vtable, \
1587 client_option_str_vtable, ocb, cbd), \
1588 .name = #oname, \
1589 .description = odesc, \
1590 .help_text = ohelp, \
1591 .category = ocat, \
1592 .specific = ospec, \
1593 INIT_BRACE_BEGIN \
1594 .string = { \
1595 .pvalue = gui_options.oname, \
1596 .size = sizeof(gui_options.oname), \
1597 .def = odef, \
1598 .val_accessor = NULL \
1599 } \
1600 INIT_BRACE_END \
1601}
1602
1603/*
1604 * Generate a client option of type OT_STRING with a string accessor
1605 * function.
1606 *
1607 * oname: The option data. Note it is used as name to be loaded or saved.
1608 * So, you shouldn't change the name of this variable in any case.
1609 * Be sure to pass the array variable and not a pointer to it because
1610 * the size is calculated with sizeof().
1611 * odesc: A short description of the client option. Should be used with the
1612 * N_() macro.
1613 * ohelp: The help text for the client option. Should be used with the N_()
1614 * macro.
1615 * ocat: The client_option_class of this client option.
1616 * ospec: A gui_type enumerator which determine for what particular client
1617 * gui this option is for. Sets to GUI_STUB for common options.
1618 * odef: The default string for this client option.
1619 * oacc: The string accessor where to find the allowed values of type
1620 * 'const struct strvec * (*) (void)'.
1621 * ocb: A callback function of type void (*)(struct option *) called when
1622 * the option changed.
1623 */
1624#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd) \
1625{ \
1626 .base_option = OPTION_STR_INIT(&client_optset_static, \
1627 client_option_common_vtable, \
1628 client_option_str_vtable, ocb, cbd), \
1629 .name = #oname, \
1630 .description = odesc, \
1631 .help_text = ohelp, \
1632 .category = ocat, \
1633 .specific = ospec, \
1634 INIT_BRACE_BEGIN \
1635 .string = { \
1636 .pvalue = gui_options.oname, \
1637 .size = sizeof(gui_options.oname), \
1638 .def = odef, \
1639 .val_accessor = oacc \
1640 } \
1641 INIT_BRACE_END \
1642}
1643
1644/*
1645 * Generate a client option of type OT_ENUM.
1646 *
1647 * oname: The option data. Note it is used as name to be loaded or saved.
1648 * So, you shouldn't change the name of this variable in any case.
1649 * odesc: A short description of the client option. Should be used with the
1650 * N_() macro.
1651 * ohelp: The help text for the client option. Should be used with the N_()
1652 * macro.
1653 * ocat: The client_option_class of this client option.
1654 * ospec: A gui_type enumerator which determine for what particular client
1655 * gui this option is for. Sets to GUI_STUB for common options.
1656 * odef: The default value for this client option.
1657 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1658 * ocb: A callback function of type void (*) (struct option *) called when
1659 * the option changed.
1660 */
1661#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb) \
1662{ \
1663 .base_option = OPTION_ENUM_INIT(&client_optset_static, \
1664 client_option_common_vtable, \
1665 client_option_enum_vtable, ocb), \
1666 .name = #oname, \
1667 .description = odesc, \
1668 .help_text = ohelp, \
1669 .category = ocat, \
1670 .specific = ospec, \
1671 INIT_BRACE_BEGIN \
1672 .enumerator = { \
1673 .pvalue = (int *) &gui_options.oname, \
1674 .def = odef, \
1675 .support_names = NULL, /* Set in options_init(). */ \
1676 .pretty_names = NULL, \
1677 .name_accessor = oacc \
1678 } \
1679 INIT_BRACE_END \
1680}
1681
1682/*
1683 * Generate a client option of type OT_BITWISE.
1684 *
1685 * oname: The option data. Note it is used as name to be loaded or saved.
1686 * So, you shouldn't change the name of this variable in any case.
1687 * odesc: A short description of the client option. Should be used with the
1688 * N_() macro.
1689 * ohelp: The help text for the client option. Should be used with the N_()
1690 * macro.
1691 * ocat: The client_option_class of this client option.
1692 * ospec: A gui_type enumerator which determine for what particular client
1693 * gui this option is for. Sets to GUI_STUB for common options.
1694 * odef: The default value for this client option.
1695 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1696 * ocb: A callback function of type void (*) (struct option *) called when
1697 * the option changed.
1698 */
1699#define GEN_BITWISE_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, \
1700 ocb) \
1701{ \
1702 .base_option = OPTION_BITWISE_INIT(&client_optset_static, \
1703 client_option_common_vtable, \
1704 client_option_bitwise_vtable, ocb), \
1705 .name = #oname, \
1706 .description = odesc, \
1707 .help_text = ohelp, \
1708 .category = ocat, \
1709 .specific = ospec, \
1710 INIT_BRACE_BEGIN \
1711 .bitwise = { \
1712 .pvalue = &gui_options.oname, \
1713 .def = odef, \
1714 .support_names = NULL, /* Set in options_init(). */ \
1715 .pretty_names = NULL, \
1716 .name_accessor = oacc \
1717 } \
1718 INIT_BRACE_END \
1719}
1720
1721/*
1722 * Generate a client option of type OT_FONT.
1723 *
1724 * oname: The option data. Note it is used as name to be loaded or saved.
1725 * So, you shouldn't change the name of this variable in any case.
1726 * Be sure to pass the array variable and not a pointer to it because
1727 * the size is calculated with sizeof().
1728 * otgt: The target widget style.
1729 * odesc: A short description of the client option. Should be used with the
1730 * N_() macro.
1731 * ohelp: The help text for the client option. Should be used with the N_()
1732 * macro.
1733 * ocat: The client_option_class of this client option.
1734 * ospec: A gui_type enumerator which determine for what particular client
1735 * gui this option is for. Sets to GUI_STUB for common options.
1736 * odef: The default string for this client option.
1737 * ocb: A callback function of type void (*)(struct option *) called when
1738 * the option changed.
1739 */
1740#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb) \
1741{ \
1742 .base_option = OPTION_FONT_INIT(&client_optset_static, \
1743 client_option_common_vtable, \
1744 client_option_font_vtable, ocb), \
1745 .name = #oname, \
1746 .description = odesc, \
1747 .help_text = ohelp, \
1748 .category = ocat, \
1749 .specific = ospec, \
1750 INIT_BRACE_BEGIN \
1751 .font = { \
1752 .pvalue = gui_options.oname, \
1753 .size = sizeof(gui_options.oname), \
1754 .def = odef, \
1755 .target = otgt, \
1756 } \
1757 INIT_BRACE_END \
1758}
1759
1760/*
1761 * Generate a client option of type OT_COLOR.
1762 *
1763 * oname: The option data. Note it is used as name to be loaded or saved.
1764 * So, you shouldn't change the name of this variable in any case.
1765 * odesc: A short description of the client option. Should be used with the
1766 * N_() macro.
1767 * ohelp: The help text for the client option. Should be used with the N_()
1768 * macro.
1769 * ocat: The client_option_class of this client option.
1770 * ospec: A gui_type enumerator which determine for what particular client
1771 * gui this option is for. Sets to GUI_STUB for common options.
1772 * odef_fg, odef_bg: The default values for this client option.
1773 * ocb: A callback function of type void (*)(struct option *) called when
1774 * the option changed.
1775 */
1776#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, \
1777 odef_bg, ocb) \
1778{ \
1779 .base_option = OPTION_COLOR_INIT(&client_optset_static, \
1780 client_option_common_vtable, \
1781 client_option_color_vtable, ocb), \
1782 .name = #oname, \
1783 .description = odesc, \
1784 .help_text = ohelp, \
1785 .category = ocat, \
1786 .specific = ospec, \
1787 INIT_BRACE_BEGIN \
1788 .color = { \
1789 .pvalue = &gui_options.oname, \
1790 .def = FT_COLOR(odef_fg, odef_bg) \
1791 } \
1792 INIT_BRACE_END \
1793}
1794
1795/*
1796 * Generate a client option of type OT_VIDEO_MODE.
1797 *
1798 * oname: The option data. Note it is used as name to be loaded or saved.
1799 * So, you shouldn't change the name of this variable in any case.
1800 * odesc: A short description of the client option. Should be used with the
1801 * N_() macro.
1802 * ohelp: The help text for the client option. Should be used with the N_()
1803 * macro.
1804 * ocat: The client_option_class of this client option.
1805 * ospec: A gui_type enumerator which determine for what particular client
1806 * gui this option is for. Sets to GUI_STUB for common options.
1807 * odef_width, odef_height: The default values for this client option.
1808 * ocb: A callback function of type void (*)(struct option *) called when
1809 * the option changed.
1810 */
1811#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, \
1812 odef_height, ocb) \
1813{ \
1814 .base_option = OPTION_VIDEO_MODE_INIT(&client_optset_static, \
1815 client_option_common_vtable, \
1816 client_option_video_mode_vtable, \
1817 ocb), \
1818 .name = #oname, \
1819 .description = odesc, \
1820 .help_text = ohelp, \
1821 .category = ocat, \
1822 .specific = ospec, \
1823 INIT_BRACE_BEGIN \
1824 .video_mode = { \
1825 .pvalue = &gui_options.oname, \
1826 .def = VIDEO_MODE(odef_width, odef_height) \
1827 } \
1828 INIT_BRACE_END \
1829}
1830
1831/****************************************************************************
1832 Enumerator name accessors.
1833****************************************************************************/
1834
1835/************************************************************************/
1838static const struct copt_val_name
1840{
1841 /* Order must match enum GUI_GTK_MSGCHAT_* */
1842 static const struct copt_val_name names[] = {
1843 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1844 { "SPLIT", N_("Split") },
1845 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1846 { "SEPARATE", N_("Separate") },
1847 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1848 { "MERGED", N_("Merged") }
1849 };
1850
1851 return (0 <= value && value < ARRAY_SIZE(names)
1852 ? names + value : NULL);
1853}
1854
1855/************************************************************************/
1858static const struct copt_val_name
1860{
1861 /* Order must match enum GUI_POPUP_TECH_HELP_* */
1862 static const struct copt_val_name names[] = {
1863 /* TRANS: enum value for 'gui_popup_tech_help' */
1864 { "ENABLED", N_("Enabled") },
1865 /* TRANS: enum value for 'gui_popup_tech_help' */
1866 { "DISABLED", N_("Disabled") },
1867 /* TRANS: enum value for 'gui_popup_tech_help' */
1868 { "RULESET", N_("Ruleset") }
1869 };
1870
1871 return (0 <= value && value < ARRAY_SIZE(names)
1872 ? names + value : NULL);
1873}
1874
1875/* Some changed callbacks. */
1876static void reqtree_show_icons_callback(struct option *poption);
1877static void view_option_changed_callback(struct option *poption);
1878static void manual_turn_done_callback(struct option *poption);
1879static void voteinfo_bar_callback(struct option *poption);
1880static void font_changed_callback(struct option *poption);
1881static void mapimg_changed_callback(struct option *poption);
1882static void game_music_enable_callback(struct option *poption);
1883static void menu_music_enable_callback(struct option *poption);
1884static void sound_volume_callback(struct option *poption);
1885
1887 GEN_STR_OPTION(default_user_name,
1888 N_("Login name"),
1889 N_("This is the default login username that will be used "
1890 "in the connection dialogs or with the -a command-line "
1891 "parameter."),
1893 GEN_BOOL_OPTION(use_prev_server, N_("Default to previously used server"),
1894 N_("Automatically update \"Server\" and \"Server port\" "
1895 "options to match your latest connection, so by "
1896 "default you connect to the same server you used "
1897 "on the previous run. You should enable "
1898 "saving options on exit too, so that the automatic "
1899 "updates to the options get saved too."),
1901 GEN_STR_OPTION(default_server_host,
1902 N_("Server"),
1903 N_("This is the default server hostname that will be used "
1904 "in the connection dialogs or with the -a command-line "
1905 "parameter."),
1906 COC_NETWORK, GUI_STUB, "localhost", NULL, 0),
1907 GEN_INT_OPTION(default_server_port,
1908 N_("Server port"),
1909 N_("This is the default server port that will be used "
1910 "in the connection dialogs or with the -a command-line "
1911 "parameter."),
1913 GEN_STR_OPTION(default_metaserver,
1914 N_("Metaserver"),
1915 N_("The metaserver is a host that the client contacts to "
1916 "find out about games on the internet. Don't change "
1917 "this from its default value unless you know what "
1918 "you're doing."),
1920 GEN_BOOL_OPTION(heartbeat_enabled,
1921 N_("Send heartbeat messages to the server"),
1922 N_("Periodically send an empty heartbeat message to the "
1923 "server to probe whether the connection is still up. "
1924 "This can help to make it obvious when the server has "
1925 "cut the connection due to a connectivity outage, if "
1926 "the client would otherwise sit idle for a long period."),
1928 GEN_STR_OPTION(followtag_override,
1929 N_("Followtag override"),
1930 /* TRANS: Leave 'builtin' untranslated */
1931 N_("Followtag determines which kind of new freeciv versions' "
1932 "availability gets checked from the metaserver. Special "
1933 "value 'builtin' means that value builtin to the client "
1934 "gets used."),
1936 GEN_BOOL_OPTION(send_desired_settings,
1937 N_("Send desired settings to the server"),
1938 N_("In single-player mode client usually sends user's "
1939 "desired server settings to the server it has "
1940 "launched internally. By disabling this option one "
1941 "can prevent such override of server settings from "
1942 "other sources, such as settings balanced for a "
1943 "custom ruleset."),
1945 GEN_STR_LIST_OPTION(default_sound_set_name,
1946 N_("Soundset"),
1947 N_("This is the soundset that will be used. Changing "
1948 "this is the same as using the -S command-line "
1949 "parameter. Use modpack installer utility to install "
1950 "additional soundsets."),
1951 COC_SOUND, GUI_STUB, "stdsounds", get_soundset_list, NULL, 0),
1952 GEN_STR_LIST_OPTION(default_music_set_name,
1953 N_("Musicset"),
1954 N_("This is the musicset that will be used. Changing "
1955 "this is the same as using the -m command-line "
1956 "parameter. Use modpack installer utility to install "
1957 "additional musicsets."),
1958 COC_SOUND, GUI_STUB, "stdmusic", get_musicset_list,
1960 GEN_STR_LIST_OPTION(default_sound_plugin_name,
1961 N_("Sound plugin"),
1962 N_("If you have a problem with sound, try changing "
1963 "the sound plugin. The new plugin won't take "
1964 "effect until you restart Freeciv. Changing this "
1965 "is the same as using the -P command-line option."),
1967 GEN_STR_OPTION(default_chat_logfile,
1968 N_("The chat log file"),
1969 N_("The name of the chat log file."),
1971 /* gui_gtk3_22/4_default_theme_name and gui_sdl2/3_default_theme_name are
1972 * different settings to avoid client crash after loading the
1973 * style for the other gui. Keeps 5 different options! */
1974 GEN_STR_LIST_OPTION(gui_gtk3_22_default_theme_name, N_("Theme"),
1975 N_("By changing this option you change the "
1976 "active theme."),
1979 GEN_STR_LIST_OPTION(gui_gtk4_default_theme_name, N_("Theme"),
1980 N_("By changing this option you change the "
1981 "active theme."),
1984 GEN_STR_LIST_OPTION(gui_sdl2_default_theme_name, N_("Theme"),
1985 N_("By changing this option you change the "
1986 "active theme."),
1989 GEN_STR_LIST_OPTION(gui_sdl3_default_theme_name, N_("Theme"),
1990 N_("By changing this option you change the "
1991 "active theme."),
1994 GEN_STR_LIST_OPTION(gui_qt_default_theme_name, N_("Theme"),
1995 N_("By changing this option you change the "
1996 "active theme."),
1999
2000 /* It's important to give empty string instead of NULL as as default
2001 * value. For NULL value it would default to assigning first value
2002 * from the tileset list returned by get_tileset_list() as default
2003 * tileset. We don't want default tileset assigned at all here, but
2004 * leave it to tilespec code that can handle tileset priority. */
2005 GEN_STR_LIST_OPTION(default_tileset_square_name, N_("Tileset (Square)"),
2006 N_("Select the tileset used with Square based maps. "
2007 "This may change the currently active tileset, if "
2008 "you are playing on such a map, in which "
2009 "case this is the same as using the -t "
2010 "command-line parameter. "
2011 "Use modpack installer utility to install "
2012 "additional tilesets."),
2015 GEN_STR_LIST_OPTION(default_tileset_hex_name, N_("Tileset (Hex)"),
2016 N_("Select the tileset used with Hex maps. "
2017 "This may change the currently active tileset, if "
2018 "you are playing on such a map, in which "
2019 "case this is the same as using the -t "
2020 "command-line parameter. "
2021 "Use modpack installer utility to install "
2022 "additional tilesets."),
2025 GEN_STR_LIST_OPTION(default_tileset_isohex_name, N_("Tileset (Iso-Hex)"),
2026 N_("Select the tileset used with Iso-Hex maps. "
2027 "This may change the currently active tileset, if "
2028 "you are playing on such a map, in which "
2029 "case this is the same as using the -t "
2030 "command-line parameter."
2031 "Use modpack installer utility to install "
2032 "additional tilesets."),
2035
2036 GEN_BOOL_OPTION(draw_city_outlines, N_("Draw city outlines"),
2037 N_("Setting this option will draw a line at the city "
2038 "workable limit."),
2041 GEN_BOOL_OPTION(draw_city_output, N_("Draw city output"),
2042 N_("Setting this option will draw city output for every "
2043 "citizen."),
2046 GEN_BOOL_OPTION(draw_map_grid, N_("Draw the map grid"),
2047 N_("Setting this option will draw a grid over the map."),
2050 GEN_BOOL_OPTION(draw_full_citybar, N_("Draw the city bar"),
2051 N_("Setting this option will display a 'city bar' "
2052 "containing useful information beneath each city. "
2053 "Disabling this option will display only the city's "
2054 "name and, optionally, production."),
2057 GEN_BOOL_OPTION(draw_city_names, N_("Draw the city names"),
2058 N_("Setting this option will draw the names of the cities "
2059 "on the map."),
2062 GEN_BOOL_OPTION(draw_city_growth, N_("Draw the city growth"),
2063 N_("Setting this option will draw in how many turns the "
2064 "cities will grow or shrink."),
2067 GEN_BOOL_OPTION(draw_city_productions, N_("Draw the city productions"),
2068 N_("Setting this option will draw what the cities are "
2069 "currently building on the map."),
2072 GEN_BOOL_OPTION(draw_city_buycost, N_("Draw the city buy costs"),
2073 N_("Setting this option will draw how much gold is "
2074 "needed to buy the production of the cities."),
2077 GEN_BOOL_OPTION(draw_city_trade_routes, N_("Draw the city trade routes"),
2078 N_("Setting this option will draw trade route lines "
2079 "between cities which have trade routes."),
2082 GEN_BOOL_OPTION(draw_terrain, N_("Draw the terrain"),
2083 N_("Setting this option will draw the terrain."),
2086 GEN_BOOL_OPTION(draw_coastline, N_("Draw the coast line"),
2087 N_("Setting this option will draw a line to separate the "
2088 "land from the ocean."),
2091 GEN_BOOL_OPTION(draw_paths, N_("Draw the paths"),
2092 N_("Setting this option will draw all kind of paths "
2093 "on the map."),
2096 GEN_BOOL_OPTION(draw_irrigation, N_("Draw the irrigation"),
2097 N_("Setting this option will draw the irrigation systems "
2098 "on the map."),
2101 GEN_BOOL_OPTION(draw_mines, N_("Draw the mines"),
2102 N_("Setting this option will draw the mines on the map."),
2105 GEN_BOOL_OPTION(draw_fortress_airbase, N_("Draw the bases"),
2106 N_("Setting this option will draw the bases on the map."),
2109 GEN_BOOL_OPTION(draw_specials, N_("Draw the resources"),
2110 N_("Setting this option will draw the resources on the "
2111 "map."),
2114 GEN_BOOL_OPTION(draw_huts, N_("Draw the huts"),
2115 N_("Setting this option will draw the huts on the "
2116 "map."),
2119 GEN_BOOL_OPTION(draw_pollution, N_("Draw the pollution/nuclear fallout"),
2120 N_("Setting this option will draw pollution and "
2121 "nuclear fallout on the map."),
2124 GEN_BOOL_OPTION(draw_cities, N_("Draw the cities"),
2125 N_("Setting this option will draw the cities on the map."),
2128 GEN_BOOL_OPTION(draw_units, N_("Draw the units"),
2129 N_("Setting this option will draw the units on the map."),
2132 GEN_BOOL_OPTION(solid_color_behind_units,
2133 N_("Solid unit background color"),
2134 N_("Setting this option will cause units on the map "
2135 "view to be drawn with a solid background color "
2136 "instead of the flag backdrop."),
2139 GEN_BOOL_OPTION(draw_unit_shields, N_("Draw shield graphics for units"),
2140 N_("Setting this option will draw a shield icon "
2141 "as the flags on units. If unset, the full flag will "
2142 "be drawn."),
2144 GEN_BOOL_OPTION(draw_unit_stack_size, N_("Draw size of the unit stacks"),
2145 N_("Setting this option will draw a numbers indicating "
2146 "size of the unit stacks. Not all clients support "
2147 "this."),
2149 GEN_BOOL_OPTION(draw_focus_unit, N_("Draw the units in focus"),
2150 N_("Setting this option will cause the currently focused "
2151 "unit(s) to always be drawn, even if units are not "
2152 "otherwise being drawn (for instance if 'Draw the units' "
2153 "is unset)."),
2156 GEN_BOOL_OPTION(draw_fog_of_war, N_("Draw the fog of war"),
2157 N_("Setting this option will draw the fog of war."),
2160 GEN_BOOL_OPTION(draw_borders, N_("Draw the borders"),
2161 N_("Setting this option will draw the national borders."),
2164 GEN_BOOL_OPTION(draw_native, N_("Draw whether tiles are native to "
2165 "selected unit"),
2166 N_("Setting this option will highlight tiles that the "
2167 "currently selected unit cannot enter unaided due to "
2168 "non-native terrain. (If multiple units are selected, "
2169 "only tiles that all of them can enter are indicated.)"),
2172 GEN_BOOL_OPTION(player_dlg_show_dead_players,
2173 N_("Show dead players in Nations report"),
2174 N_("This option controls whether defeated nations are "
2175 "shown on the Nations report page."),
2178 GEN_BOOL_OPTION(sound_bell_at_new_turn, N_("Sound bell at new turn"),
2179 N_("Set this option to have a \"bell\" event be generated "
2180 "at the start of a new turn. You can control the "
2181 "behavior of the \"bell\" event by editing the message "
2182 "options."),
2184 GEN_INT_OPTION(smooth_move_unit_msec,
2185 N_("Unit movement animation time (milliseconds)"),
2186 N_("This option controls how long unit \"animation\" takes "
2187 "when a unit moves on the map view. Set it to 0 to "
2188 "disable animation entirely."),
2189 COC_GRAPHICS, GUI_STUB, 30, 0, 2000, NULL),
2190 GEN_INT_OPTION(smooth_center_slide_msec,
2191 N_("Mapview recentering time (milliseconds)"),
2192 N_("When the map view is recentered, it will slide "
2193 "smoothly over the map to its new position. This "
2194 "option controls how long this slide lasts. Set it to "
2195 "0 to disable mapview sliding entirely."),
2196 COC_GRAPHICS, GUI_STUB, 200, 0, 5000, NULL),
2197 GEN_INT_OPTION(smooth_combat_step_msec,
2198 N_("Combat animation step time (milliseconds)"),
2199 N_("This option controls the speed of combat animation "
2200 "between units on the mapview. Set it to 0 to disable "
2201 "animation entirely."),
2202 COC_GRAPHICS, GUI_STUB, 10, 0, 100, NULL),
2203 GEN_BOOL_OPTION(reqtree_show_icons,
2204 N_("Show icons in the technology tree"),
2205 N_("Setting this option will display icons "
2206 "on the technology tree diagram. Turning "
2207 "this option off makes the technology tree "
2208 "more compact."),
2210 GEN_BOOL_OPTION(reqtree_curved_lines,
2211 N_("Use curved lines in the technology tree"),
2212 N_("Setting this option make the technology tree "
2213 "diagram use curved lines to show technology "
2214 "relations. Turning this option off causes "
2215 "the lines to be drawn straight."),
2218 GEN_COLOR_OPTION(highlight_our_names,
2219 N_("Color to highlight your player/user name"),
2220 N_("If set, your player and user name in the new chat "
2221 "messages will be highlighted using this color as "
2222 "background. If not set, it will just not highlight "
2223 "anything."),
2224 COC_GRAPHICS, GUI_STUB, "#000000", "#FFFF00", NULL),
2225 GEN_BOOL_OPTION(ai_manual_turn_done, N_("Manual Turn Done in AI mode"),
2226 N_("Disable this option if you do not want to "
2227 "press the Turn Done button manually when watching "
2228 "an AI player."),
2230 GEN_BOOL_OPTION(auto_center_on_unit, N_("Auto center on units"),
2231 N_("Set this option to have the active unit centered "
2232 "automatically when the unit focus changes."),
2234 GEN_BOOL_OPTION(auto_center_on_automated, N_("Show automated units"),
2235 N_("Disable this option if you do not want to see "
2236 "automated units autocentered and animated."),
2238 GEN_BOOL_OPTION(auto_center_on_combat, N_("Auto center on combat"),
2239 N_("Set this option to have any combat be centered "
2240 "automatically. Disabling this will speed up the time "
2241 "between turns but may cause you to miss combat "
2242 "entirely."),
2244 GEN_BOOL_OPTION(auto_center_each_turn, N_("Auto center on new turn"),
2245 N_("Set this option to have the client automatically "
2246 "recenter the map on a suitable location at the "
2247 "start of each turn."),
2249 GEN_BOOL_OPTION(wakeup_focus, N_("Focus on awakened units"),
2250 N_("Set this option to have newly awoken units be "
2251 "focused automatically."),
2253 GEN_BOOL_OPTION(keyboardless_goto, N_("Keyboardless goto"),
2254 N_("If this option is set then a goto may be initiated "
2255 "by left-clicking and then holding down the mouse "
2256 "button while dragging the mouse onto a different "
2257 "tile."),
2259 GEN_BOOL_OPTION(goto_into_unknown, N_("Allow goto into the unknown"),
2260 N_("Setting this option will make the game consider "
2261 "moving into unknown tiles. If not, then goto routes "
2262 "will detour around or be blocked by unknown tiles."),
2264 GEN_BOOL_OPTION(center_when_popup_city, N_("Center map when popup city"),
2265 N_("Setting this option makes the mapview center on a "
2266 "city when its city dialog is popped up."),
2268 GEN_BOOL_OPTION(show_previous_turn_messages, N_("Show messages from previous turn"),
2269 N_("Message Window shows messages also from previous turn. "
2270 "This makes sure you don't miss messages received in the end of "
2271 "the turn, just before the window gets cleared."),
2273 GEN_BOOL_OPTION(concise_city_production, N_("Concise city production"),
2274 N_("Set this option to make the city production (as shown "
2275 "in the city dialog) to be more compact."),
2277 GEN_BOOL_OPTION(auto_turn_done, N_("End turn when done moving"),
2278 N_("Setting this option makes your turn end automatically "
2279 "when all your units are done moving."),
2281 GEN_BOOL_OPTION(ask_city_name, N_("Prompt for city names"),
2282 N_("Disabling this option will make the names of newly "
2283 "founded cities be chosen automatically by the server."),
2285 GEN_BOOL_OPTION(popup_new_cities, N_("Pop up city dialog for new cities"),
2286 N_("Setting this option will pop up a newly-founded "
2287 "city's city dialog automatically."),
2289 GEN_BOOL_OPTION(popup_actor_arrival, N_("Pop up caravan and spy actions"),
2290 N_("If this option is enabled, when a unit arrives at "
2291 "a city where it can perform an action like "
2292 "establishing a trade route, helping build a wonder, or "
2293 "establishing an embassy, a window will pop up asking "
2294 "which action should be performed. "
2295 "Disabling this option means you will have to do the "
2296 "action manually by pressing either 'r' (for a trade "
2297 "route), 'b' (for building a wonder) or 'd' (for a "
2298 "spy action) when the unit is in the city."),
2300 GEN_BOOL_OPTION(popup_attack_actions, N_("Pop up attack questions"),
2301 N_("If this option is enabled, when a unit arrives at a "
2302 "target it can attack, a window will pop up asking "
2303 "which action should be performed even if an attack "
2304 "action is legal and no other interesting action are. "
2305 "This allows you to change your mind or to select an "
2306 "uninteresting action."),
2308 GEN_BOOL_OPTION(popup_last_move_to_allied,
2309 /* TODO: Rename option ..._last_... to match _final_ in
2310 * the descriptions.
2311 * Changes options file format, needs migration
2312 * when loading old version. */
2313 N_("Pop up actions when final move to allied tile"),
2314 N_("If this option is enabled the final move in a unit's"
2315 " orders to a tile with allied units or cities it can"
2316 " perform an action to is interpreted as an attempted"
2317 " action. This makes the action selection dialog pop up"
2318 " while the unit is at the adjacent tile."
2319 " This can, in cases where the action requires that"
2320 " the actor unit has moves left, save a turn."
2321 " The down side is that the unit remains adjacent to"
2322 " rather than inside the protection of an allied city"
2323 " or unit stack."),
2325 GEN_BOOL_OPTION(enable_cursor_changes, N_("Enable cursor changing"),
2326 N_("This option controls whether the client should "
2327 "try to change the mouse cursor depending on what "
2328 "is being pointed at, as well as to indicate "
2329 "changes in the client or server state."),
2331 GEN_BOOL_OPTION(separate_unit_selection, N_("Select cities before units"),
2332 N_("If this option is enabled, when both cities and "
2333 "units are present in the selection rectangle, only "
2334 "cities will be selected. See the help on Controls."),
2336 GEN_BOOL_OPTION(unit_selection_clears_orders,
2337 N_("Clear unit orders on selection"),
2338 N_("Enabling this option will cause unit orders to be "
2339 "cleared as soon as one or more units are selected. If "
2340 "this option is disabled, busy units will not stop "
2341 "their current activity when selected. Giving them "
2342 "new orders will clear their current ones; pressing "
2343 "<space> once will clear their orders and leave them "
2344 "selected, and pressing <space> a second time will "
2345 "dismiss them."),
2347 GEN_BOOL_OPTION(voteinfo_bar_use, N_("Enable vote bar"),
2348 N_("If this option is turned on, the vote bar will be "
2349 "displayed to show vote information."),
2351 GEN_BOOL_OPTION(voteinfo_bar_always_show,
2352 N_("Always display the vote bar"),
2353 N_("If this option is turned on, the vote bar will never "
2354 "be hidden, even if there is no running vote."),
2356 GEN_BOOL_OPTION(voteinfo_bar_hide_when_not_player,
2357 N_("Do not show vote bar if not a player"),
2358 N_("If this option is enabled, the client won't show the "
2359 "vote bar if you are not a player."),
2361 GEN_BOOL_OPTION(voteinfo_bar_new_at_front, N_("Set new votes at front"),
2362 N_("If this option is enabled, then new votes will go "
2363 "to the front of the vote list."),
2365 GEN_BOOL_OPTION(autoaccept_tileset_suggestion,
2366 N_("Autoaccept tileset suggestions"),
2367 N_("If this option is enabled, any tileset suggested by "
2368 "the ruleset is automatically used; otherwise you "
2369 "are prompted to change tileset."),
2371
2372 GEN_BOOL_OPTION(sound_enable_effects,
2373 N_("Enable sound effects"),
2374 N_("Play sound effects, assuming there's suitable "
2375 "sound plugin and soundset with the sounds."),
2377 GEN_BOOL_OPTION(sound_enable_game_music,
2378 N_("Enable in-game music"),
2379 N_("Play music during the game, assuming there's suitable "
2380 "sound plugin and musicset with in-game tracks."),
2382 GEN_BOOL_OPTION(sound_enable_menu_music,
2383 N_("Enable menu music"),
2384 N_("Play music while not in actual game, "
2385 "assuming there's suitable "
2386 "sound plugin and musicset with menu music tracks."),
2388 GEN_BOOL_OPTION(silent_when_not_in_focus,
2389 N_("Silent when not in focus"),
2390 N_("Fade all sound out when the client is not in focus. "
2391 "Not all clients support this."),
2393 GEN_INT_OPTION(sound_effects_volume,
2394 N_("Sound volume"),
2395 N_("Volume scale from 0-100"),
2396 COC_SOUND, GUI_STUB, 100,
2397 0, 100,
2399
2400 GEN_BOOL_OPTION(autoaccept_soundset_suggestion,
2401 N_("Autoaccept soundset suggestions"),
2402 N_("If this option is enabled, any soundset suggested by "
2403 "the ruleset is automatically used."),
2405 GEN_BOOL_OPTION(autoaccept_musicset_suggestion,
2406 N_("Autoaccept musicset suggestions"),
2407 N_("If this option is enabled, any musicset suggested by "
2408 "the ruleset is automatically used."),
2410
2412 N_("Background layer"),
2413 N_("The background layer of the overview shows just "
2414 "ocean and land."),
2417 N_("Terrain relief map layer"),
2418 N_("The relief layer shows all terrains on the map."),
2421 N_("Borders layer"),
2422 N_("The borders layer of the overview shows which tiles "
2423 "are owned by each player."),
2426 N_("Borders layer on ocean tiles"),
2427 N_("The borders layer of the overview are drawn on "
2428 "ocean tiles as well (this may look ugly with many "
2429 "islands). This option is only of interest if you "
2430 "have set the option \"Borders layer\" already."),
2433 N_("Units layer"),
2434 N_("Enabling this will draw units on the overview."),
2437 N_("Cities layer"),
2438 N_("Enabling this will draw cities on the overview."),
2441 N_("Overview fog of war"),
2442 N_("Enabling this will show fog of war on the "
2443 "overview."),
2445
2446 /* options for map images */
2447 GEN_STR_LIST_OPTION(mapimg_format,
2448 N_("Image format"),
2449 N_("The image toolkit and file format used for "
2450 "map images."),
2452 NULL, 0),
2453 GEN_INT_OPTION(mapimg_zoom,
2454 N_("Zoom factor for map images"),
2455 N_("The magnification used for map images."),
2457 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_AREA],
2458 N_("Show area within borders"),
2459 N_("If set, the territory of each nation is shown "
2460 "on the saved image."),
2463 N_("Show borders"),
2464 N_("If set, the border of each nation is shown on the "
2465 "saved image."),
2468 N_("Show cities"),
2469 N_("If set, cities are shown on the saved image."),
2472 N_("Show fog of war"),
2473 N_("If set, the extent of fog of war is shown on the "
2474 "saved image."),
2477 N_("Show full terrain"),
2478 N_("If set, terrain relief is shown with different colors "
2479 "in the saved image; otherwise, only land and water are "
2480 "distinguished."),
2482 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_UNITS],
2483 N_("Show units"),
2484 N_("If set, units are shown in the saved image."),
2486 GEN_STR_OPTION(mapimg_filename,
2487 N_("Map image file name"),
2488 N_("The base part of the filename for saved map images. "
2489 "A string identifying the game turn and map options will "
2490 "be appended."),
2492
2493 /* gui-gtk-2.0 client specific options.
2494 * These are still kept just so users can migrate them to later gtk-clients */
2495 GEN_BOOL_OPTION(gui_gtk2_map_scrollbars, NULL, NULL,
2497 GEN_BOOL_OPTION(gui_gtk2_dialogs_on_top, NULL, NULL,
2499 GEN_BOOL_OPTION(gui_gtk2_show_task_icons, NULL, NULL,
2501 GEN_BOOL_OPTION(gui_gtk2_enable_tabs, NULL, NULL,
2503 GEN_BOOL_OPTION(gui_gtk2_better_fog, NULL, NULL,
2506 GEN_BOOL_OPTION(gui_gtk2_show_chat_message_time, NULL, NULL,
2508 GEN_BOOL_OPTION(gui_gtk2_new_messages_go_to_top, NULL, NULL,
2510 GEN_BOOL_OPTION(gui_gtk2_show_message_window_buttons, NULL, NULL,
2512 GEN_BOOL_OPTION(gui_gtk2_metaserver_tab_first, NULL, NULL,
2514 GEN_BOOL_OPTION(gui_gtk2_allied_chat_only, NULL, NULL,
2516 GEN_BOOL_OPTION(gui_gtk2_mouse_over_map_focus, NULL, NULL,
2518 GEN_BOOL_OPTION(gui_gtk2_chatline_autocompletion, NULL, NULL,
2520 GEN_INT_OPTION(gui_gtk2_citydlg_xsize, NULL, NULL,
2523 NULL),
2524 GEN_INT_OPTION(gui_gtk2_citydlg_ysize, NULL, NULL,
2527 NULL),
2528 GEN_ENUM_OPTION(gui_gtk2_popup_tech_help, NULL, NULL,
2532 GEN_FONT_OPTION(gui_gtk2_font_city_label, "city_label",
2533 NULL, NULL,
2535 "Monospace 8", font_changed_callback),
2536 GEN_FONT_OPTION(gui_gtk2_font_notify_label, "notify_label",
2537 NULL, NULL,
2539 "Monospace Bold 9", font_changed_callback),
2540 GEN_FONT_OPTION(gui_gtk2_font_spaceship_label, "spaceship_label",
2541 NULL, NULL,
2543 "Monospace 8", font_changed_callback),
2544 GEN_FONT_OPTION(gui_gtk2_font_help_label, "help_label",
2545 NULL, NULL,
2547 "Sans Bold 10", font_changed_callback),
2548 GEN_FONT_OPTION(gui_gtk2_font_help_link, "help_link",
2549 NULL, NULL,
2551 "Sans 9", font_changed_callback),
2552 GEN_FONT_OPTION(gui_gtk2_font_help_text, "help_text",
2553 NULL, NULL,
2555 "Monospace 8", font_changed_callback),
2556 GEN_FONT_OPTION(gui_gtk2_font_chatline, "chatline",
2557 NULL, NULL,
2559 "Monospace 8", font_changed_callback),
2560 GEN_FONT_OPTION(gui_gtk2_font_beta_label, "beta_label",
2561 NULL, NULL,
2563 "Sans Italic 10", font_changed_callback),
2564 GEN_FONT_OPTION(gui_gtk2_font_small, "small_font",
2565 NULL, NULL,
2567 "Sans 9", NULL),
2568 GEN_FONT_OPTION(gui_gtk2_font_comment_label, "comment_label",
2569 NULL, NULL,
2571 "Sans Italic 9", font_changed_callback),
2572 GEN_FONT_OPTION(gui_gtk2_font_city_names, "city_names",
2573 NULL, NULL,
2575 "Sans Bold 10", NULL),
2576 GEN_FONT_OPTION(gui_gtk2_font_city_productions, "city_productions",
2577 NULL, NULL,
2579 "Serif 10", NULL),
2580 GEN_FONT_OPTION(gui_gtk2_font_reqtree_text, "reqtree_text",
2581 NULL, NULL,
2583 "Serif 10", NULL),
2584
2585 /* gui-gtk-3.0 client specific options.
2586 * These are still kept just so users can migrate them to later gtk-clients */
2587 GEN_BOOL_OPTION(gui_gtk3_fullscreen, NULL, NULL,
2589 GEN_BOOL_OPTION(gui_gtk3_map_scrollbars, N_("Show map scrollbars"),
2590 N_("Disable this option to hide the scrollbars on the "
2591 "map view."),
2593 GEN_BOOL_OPTION(gui_gtk3_dialogs_on_top, NULL, NULL,
2595 GEN_BOOL_OPTION(gui_gtk3_show_task_icons, NULL, NULL,
2597 GEN_BOOL_OPTION(gui_gtk3_enable_tabs, NULL, NULL,
2599 GEN_BOOL_OPTION(gui_gtk3_show_chat_message_time, NULL, NULL,
2601 GEN_BOOL_OPTION(gui_gtk3_new_messages_go_to_top, NULL, NULL,
2603 GEN_BOOL_OPTION(gui_gtk3_show_message_window_buttons, NULL, NULL,
2605 GEN_BOOL_OPTION(gui_gtk3_metaserver_tab_first, NULL, NULL,
2607 GEN_BOOL_OPTION(gui_gtk3_allied_chat_only, NULL, NULL,
2609 GEN_ENUM_OPTION(gui_gtk3_message_chat_location, NULL, NULL,
2613 GEN_BOOL_OPTION(gui_gtk3_small_display_layout, NULL, NULL,
2615 GEN_BOOL_OPTION(gui_gtk3_mouse_over_map_focus, NULL, NULL,
2617 GEN_BOOL_OPTION(gui_gtk3_chatline_autocompletion, NULL, NULL,
2619 GEN_INT_OPTION(gui_gtk3_citydlg_xsize, NULL, NULL,
2622 NULL),
2623 GEN_INT_OPTION(gui_gtk3_citydlg_ysize, NULL, NULL,
2626 NULL),
2627 GEN_ENUM_OPTION(gui_gtk3_popup_tech_help, NULL, NULL,
2631 GEN_INT_OPTION(gui_gtk3_governor_range_min, NULL, NULL,
2634 NULL),
2635 GEN_INT_OPTION(gui_gtk3_governor_range_max, NULL, NULL,
2638 NULL),
2639 GEN_FONT_OPTION(gui_gtk3_font_city_label, "city_label",
2640 NULL, NULL,
2642 "Monospace 8", font_changed_callback),
2643 GEN_FONT_OPTION(gui_gtk3_font_notify_label, "notify_label",
2644 NULL, NULL,
2646 "Monospace Bold 9", font_changed_callback),
2647 GEN_FONT_OPTION(gui_gtk3_font_spaceship_label, "spaceship_label",
2648 NULL, NULL,
2650 "Monospace 8", font_changed_callback),
2651 GEN_FONT_OPTION(gui_gtk3_font_help_label, "help_label",
2652 NULL, NULL,
2654 "Sans Bold 10", font_changed_callback),
2655 GEN_FONT_OPTION(gui_gtk3_font_help_link, "help_link",
2656 NULL, NULL,
2658 "Sans 9", font_changed_callback),
2659 GEN_FONT_OPTION(gui_gtk3_font_help_text, "help_text",
2660 NULL, NULL,
2662 "Monospace 8", font_changed_callback),
2663 GEN_FONT_OPTION(gui_gtk3_font_chatline, "chatline",
2664 NULL, NULL,
2666 "Monospace 8", font_changed_callback),
2667 GEN_FONT_OPTION(gui_gtk3_font_beta_label, "beta_label",
2668 NULL, NULL,
2670 "Sans Italic 10", font_changed_callback),
2671 GEN_FONT_OPTION(gui_gtk3_font_small, "small_font",
2672 NULL, NULL,
2674 "Sans 9", NULL),
2675 GEN_FONT_OPTION(gui_gtk3_font_comment_label, "comment_label",
2676 NULL, NULL,
2678 "Sans Italic 9", font_changed_callback),
2679 GEN_FONT_OPTION(gui_gtk3_font_city_names, "city_names",
2680 NULL, NULL,
2682 "Sans Bold 10", NULL),
2683 GEN_FONT_OPTION(gui_gtk3_font_city_productions, "city_productions",
2684 NULL, NULL,
2686 "Serif 10", NULL),
2687 GEN_FONT_OPTION(gui_gtk3_font_reqtree_text, "reqtree_text",
2688 NULL, NULL,
2690 "Serif 10", NULL),
2691
2692 /* gui-gtk-3.22 client specific options. */
2693 GEN_BOOL_OPTION(gui_gtk3_22_fullscreen, N_("Fullscreen"),
2694 N_("If this option is set the client will use the "
2695 "whole screen area for drawing."),
2697 GEN_BOOL_OPTION(gui_gtk3_22_map_scrollbars, N_("Show map scrollbars"),
2698 N_("Disable this option to hide the scrollbars on the "
2699 "map view."),
2701 GEN_BOOL_OPTION(gui_gtk3_22_dialogs_on_top, N_("Keep dialogs on top"),
2702 N_("If this option is set then dialog windows will always "
2703 "remain in front of the main Freeciv window. "
2704 "Disabling this has no effect in fullscreen mode."),
2706 GEN_BOOL_OPTION(gui_gtk3_22_show_task_icons, N_("Show worklist task icons"),
2707 N_("Disabling this will turn off the unit and building "
2708 "icons in the worklist dialog and the production "
2709 "tab of the city dialog."),
2711 GEN_BOOL_OPTION(gui_gtk3_22_enable_tabs, N_("Enable status report tabs"),
2712 N_("If this option is enabled then report dialogs will "
2713 "be shown as separate tabs rather than in popup "
2714 "dialogs."),
2716 GEN_BOOL_OPTION(gui_gtk3_22_show_chat_message_time,
2717 N_("Show time for each chat message"),
2718 N_("If this option is enabled then all chat messages "
2719 "will be prefixed by a time string of the form "
2720 "[hour:minute:second]."),
2722 GEN_BOOL_OPTION(gui_gtk3_22_new_messages_go_to_top,
2723 N_("New message events go to top of list"),
2724 N_("If this option is enabled, new events in the "
2725 "message window will appear at the top of the list, "
2726 "rather than being appended at the bottom."),
2728 GEN_BOOL_OPTION(gui_gtk3_22_show_message_window_buttons,
2729 N_("Show extra message window buttons"),
2730 N_("If this option is enabled, there will be two "
2731 "buttons displayed in the message window for "
2732 "inspecting a city and going to a location. If this "
2733 "option is disabled, these buttons will not appear "
2734 "(you can still double-click with the left mouse "
2735 "button or right-click on a row to inspect or goto "
2736 "respectively). This option will only take effect "
2737 "once the message window is closed and reopened."),
2739 GEN_BOOL_OPTION(gui_gtk3_22_metaserver_tab_first,
2740 N_("Metaserver tab first in network page"),
2741 N_("If this option is enabled, the metaserver tab will "
2742 "be the first notebook tab in the network page. This "
2743 "option requires a restart in order to take effect."),
2745 GEN_BOOL_OPTION(gui_gtk3_22_allied_chat_only,
2746 N_("Plain chat messages are sent to allies only"),
2747 N_("If this option is enabled, then plain messages "
2748 "typed into the chat entry while the game is "
2749 "running will only be sent to your allies. "
2750 "Otherwise plain messages will be sent as "
2751 "public chat messages. To send a public chat "
2752 "message with this option enabled, prefix the "
2753 "message with a single colon ':'. This option "
2754 "can also be set using a toggle button beside "
2755 "the chat entry (only visible in multiplayer "
2756 "games)."),
2758 GEN_ENUM_OPTION(gui_gtk3_22_message_chat_location,
2759 N_("Messages and Chat reports location"),
2760 /* TRANS: The strings used in the UI for 'Split' etc are
2761 * tagged 'gui_gtk2/gtk3/gtk4_message_chat_location' */
2762 N_("Controls where the Messages and Chat reports "
2763 "appear relative to the main view containing the map.\n"
2764 "'Split' allows all three to be seen simultaneously, "
2765 "which is best for multiplayer, but requires a large "
2766 "window to be usable.\n"
2767 "'Separate' puts Messages and Chat in a notebook "
2768 "separate from the main view, so that one of them "
2769 "can always be seen alongside the main view.\n"
2770 "'Merged' makes the Messages and Chat reports into "
2771 "tabs alongside the map and other reports; this "
2772 "allows a larger map view on small screens.\n"
2773 "This option requires a restart in order to take "
2774 "effect."), COC_INTERFACE, GUI_GTK3_22,
2777 GEN_BOOL_OPTION(gui_gtk3_22_small_display_layout,
2778 N_("Arrange widgets for small displays"),
2779 N_("If this option is enabled, widgets in the main "
2780 "window will be arranged so that they take up the "
2781 "least amount of total screen space. Specifically, "
2782 "the left panel containing the overview, player "
2783 "status, and the unit information box will be "
2784 "extended over the entire left side of the window. "
2785 "This option requires a restart in order to take "
2786 "effect."), COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2787 GEN_BOOL_OPTION(gui_gtk3_22_mouse_over_map_focus,
2788 N_("Mouse over the map widget selects it automatically"),
2789 N_("If this option is enabled, then the map will be "
2790 "focused when the mouse hovers over it."),
2792 GEN_BOOL_OPTION(gui_gtk3_22_chatline_autocompletion,
2793 N_("Player or user name autocompletion"),
2794 N_("If this option is turned on, the tabulation key "
2795 "will be used in the chatline to complete the word you "
2796 "are typing with the name of a player or a user."),
2798 GEN_INT_OPTION(gui_gtk3_22_citydlg_xsize,
2799 N_("Width of the city dialog"),
2800 N_("This value is only used if the width of the city "
2801 "dialog is saved."),
2804 NULL),
2805 GEN_INT_OPTION(gui_gtk3_22_citydlg_ysize,
2806 N_("Height of the city dialog"),
2807 N_("This value is only used if the height of the city "
2808 "dialog is saved."),
2811 NULL),
2812 GEN_ENUM_OPTION(gui_gtk3_22_popup_tech_help,
2813 N_("Popup tech help when gained"),
2814 N_("Controls if tech help should be opened when "
2815 "new tech has been gained.\n"
2816 "'Ruleset' means that behavior suggested by "
2817 "current ruleset is used."), COC_INTERFACE, GUI_GTK3_22,
2820 GEN_INT_OPTION(gui_gtk3_22_governor_range_min,
2821 N_("Minimum surplus for a governor"),
2822 N_("The lower limit of the range for requesting surpluses "
2823 "from the governor."),
2826 NULL),
2827 GEN_INT_OPTION(gui_gtk3_22_governor_range_max,
2828 N_("Maximum surplus for a governor"),
2829 N_("The higher limit of the range for requesting surpluses "
2830 "from the governor."),
2833 NULL),
2834 GEN_FONT_OPTION(gui_gtk3_22_font_city_label, "city_label",
2835 N_("City Label"),
2836 N_("This font is used to display the city labels on city "
2837 "dialogs."),
2839 "Monospace 8", font_changed_callback),
2840 GEN_FONT_OPTION(gui_gtk3_22_font_notify_label, "notify_label",
2841 N_("Notify Label"),
2842 N_("This font is used to display server reports such "
2843 "as the demographic report or historian publications."),
2845 "Monospace Bold 9", font_changed_callback),
2846 GEN_FONT_OPTION(gui_gtk3_22_font_spaceship_label, "spaceship_label",
2847 N_("Spaceship Label"),
2848 N_("This font is used to display the spaceship widgets."),
2850 "Monospace 8", font_changed_callback),
2851 GEN_FONT_OPTION(gui_gtk3_22_font_help_label, "help_label",
2852 N_("Help Label"),
2853 N_("This font is used to display the help headers in the "
2854 "help window."),
2856 "Sans Bold 10", font_changed_callback),
2857 GEN_FONT_OPTION(gui_gtk3_22_font_help_link, "help_link",
2858 N_("Help Link"),
2859 N_("This font is used to display the help links in the "
2860 "help window."),
2862 "Sans 9", font_changed_callback),
2863 GEN_FONT_OPTION(gui_gtk3_22_font_help_text, "help_text",
2864 N_("Help Text"),
2865 N_("This font is used to display the help body text in "
2866 "the help window."),
2868 "Monospace 8", font_changed_callback),
2869 GEN_FONT_OPTION(gui_gtk3_22_font_chatline, "chatline",
2870 N_("Chatline Area"),
2871 N_("This font is used to display the text in the "
2872 "chatline area."),
2874 "Monospace 8", font_changed_callback),
2875 GEN_FONT_OPTION(gui_gtk3_22_font_beta_label, "beta_label",
2876 N_("Beta Label"),
2877 N_("This font is used to display the beta label."),
2879 "Sans Italic 10", font_changed_callback),
2880 GEN_FONT_OPTION(gui_gtk3_22_font_small, "small_font",
2881 N_("Small Font"),
2882 N_("This font is used for any small font request. For "
2883 "example, it is used for display the building lists "
2884 "in the city dialog, the Economy report or the Units "
2885 "report."),
2887 "Sans 9", font_changed_callback),
2888 GEN_FONT_OPTION(gui_gtk3_22_font_comment_label, "comment_label",
2889 N_("Comment Label"),
2890 N_("This font is used to display comment labels, such as "
2891 "in the governor page of the city dialogs."),
2893 "Sans Italic 9", font_changed_callback),
2894 GEN_FONT_OPTION(gui_gtk3_22_font_city_names, "city_names",
2895 N_("City Names"),
2896 N_("This font is used to the display the city names "
2897 "on the map."),
2899 "Sans Bold 10", NULL),
2900 GEN_FONT_OPTION(gui_gtk3_22_font_city_productions, "city_productions",
2901 N_("City Productions"),
2902 N_("This font is used to display the city production "
2903 "on the map."),
2905 "Serif 10", NULL),
2906 GEN_FONT_OPTION(gui_gtk3_22_font_reqtree_text, "reqtree_text",
2907 N_("Requirement Tree"),
2908 N_("This font is used to the display the requirement tree "
2909 "in the Research report."),
2911 "Serif 10", NULL),
2912
2913 /* gui-gtk-4.0 client specific options. */
2914 GEN_BOOL_OPTION(gui_gtk4_fullscreen, N_("Fullscreen"),
2915 N_("If this option is set the client will use the "
2916 "whole screen area for drawing."),
2918 GEN_BOOL_OPTION(gui_gtk4_map_scrollbars, N_("Show map scrollbars"),
2919 N_("Disable this option to hide the scrollbars on the "
2920 "map view."),
2922 GEN_BOOL_OPTION(gui_gtk4_dialogs_on_top, N_("Keep dialogs on top"),
2923 N_("If this option is set then dialog windows will always "
2924 "remain in front of the main Freeciv window. "
2925 "Disabling this has no effect in fullscreen mode."),
2927 GEN_BOOL_OPTION(gui_gtk4_show_task_icons, N_("Show worklist task icons"),
2928 N_("Disabling this will turn off the unit and building "
2929 "icons in the worklist dialog and the production "
2930 "tab of the city dialog."),
2932 GEN_BOOL_OPTION(gui_gtk4_enable_tabs, N_("Enable status report tabs"),
2933 N_("If this option is enabled then report dialogs will "
2934 "be shown as separate tabs rather than in popup "
2935 "dialogs."),
2937 GEN_BOOL_OPTION(gui_gtk4_show_chat_message_time,
2938 N_("Show time for each chat message"),
2939 N_("If this option is enabled then all chat messages "
2940 "will be prefixed by a time string of the form "
2941 "[hour:minute:second]."),
2943 GEN_BOOL_OPTION(gui_gtk4_new_messages_go_to_top,
2944 N_("New message events go to top of list"),
2945 N_("If this option is enabled, new events in the "
2946 "message window will appear at the top of the list, "
2947 "rather than being appended at the bottom."),
2949 GEN_BOOL_OPTION(gui_gtk4_show_message_window_buttons,
2950 N_("Show extra message window buttons"),
2951 N_("If this option is enabled, there will be two "
2952 "buttons displayed in the message window for "
2953 "inspecting a city and going to a location. If this "
2954 "option is disabled, these buttons will not appear "
2955 "(you can still double-click with the left mouse "
2956 "button or right-click on a row to inspect or goto "
2957 "respectively). This option will only take effect "
2958 "once the message window is closed and reopened."),
2960 GEN_BOOL_OPTION(gui_gtk4_metaserver_tab_first,
2961 N_("Metaserver tab first in network page"),
2962 N_("If this option is enabled, the metaserver tab will "
2963 "be the first notebook tab in the network page. This "
2964 "option requires a restart in order to take effect."),
2966 GEN_BOOL_OPTION(gui_gtk4_allied_chat_only,
2967 N_("Plain chat messages are sent to allies only"),
2968 N_("If this option is enabled, then plain messages "
2969 "typed into the chat entry while the game is "
2970 "running will only be sent to your allies. "
2971 "Otherwise plain messages will be sent as "
2972 "public chat messages. To send a public chat "
2973 "message with this option enabled, prefix the "
2974 "message with a single colon ':'. This option "
2975 "can also be set using a toggle button beside "
2976 "the chat entry (only visible in multiplayer "
2977 "games)."),
2979 GEN_ENUM_OPTION(gui_gtk4_message_chat_location,
2980 N_("Messages and Chat reports location"),
2981 /* TRANS: The strings used in the UI for 'Split' etc are
2982 * tagged 'gui_gtk2/gtk3/gtk4_message_chat_location' */
2983 N_("Controls where the Messages and Chat reports "
2984 "appear relative to the main view containing the map.\n"
2985 "'Split' allows all three to be seen simultaneously, "
2986 "which is best for multiplayer, but requires a large "
2987 "window to be usable.\n"
2988 "'Separate' puts Messages and Chat in a notebook "
2989 "separate from the main view, so that one of them "
2990 "can always be seen alongside the main view.\n"
2991 "'Merged' makes the Messages and Chat reports into "
2992 "tabs alongside the map and other reports; this "
2993 "allows a larger map view on small screens.\n"
2994 "This option requires a restart in order to take "
2995 "effect."), COC_INTERFACE, GUI_GTK4,
2998 GEN_BOOL_OPTION(gui_gtk4_small_display_layout,
2999 N_("Arrange widgets for small displays"),
3000 N_("If this option is enabled, widgets in the main "
3001 "window will be arranged so that they take up the "
3002 "least amount of total screen space. Specifically, "
3003 "the left panel containing the overview, player "
3004 "status, and the unit information box will be "
3005 "extended over the entire left side of the window. "
3006 "This option requires a restart in order to take "
3007 "effect."), COC_INTERFACE, GUI_GTK4, FALSE, NULL),
3008 GEN_BOOL_OPTION(gui_gtk4_mouse_over_map_focus,
3009 N_("Mouse over the map widget selects it automatically"),
3010 N_("If this option is enabled, then the map will be "
3011 "focused when the mouse hovers over it."),
3013 GEN_BOOL_OPTION(gui_gtk4_chatline_autocompletion,
3014 N_("Player or user name autocompletion"),
3015 N_("If this option is turned on, the tabulation key "
3016 "will be used in the chatline to complete the word you "
3017 "are typing with the name of a player or a user."),
3019 GEN_INT_OPTION(gui_gtk4_citydlg_xsize,
3020 N_("Width of the city dialog"),
3021 N_("This value is only used if the width of the city "
3022 "dialog is saved."),
3025 NULL),
3026 GEN_INT_OPTION(gui_gtk4_citydlg_ysize,
3027 N_("Height of the city dialog"),
3028 N_("This value is only used if the height of the city "
3029 "dialog is saved."),
3032 NULL),
3033 GEN_ENUM_OPTION(gui_gtk4_popup_tech_help,
3034 N_("Popup tech help when gained"),
3035 N_("Controls if tech help should be opened when "
3036 "new tech has been gained.\n"
3037 "'Ruleset' means that behavior suggested by "
3038 "current ruleset is used."), COC_INTERFACE, GUI_GTK4,
3041 GEN_INT_OPTION(gui_gtk4_governor_range_min,
3042 N_("Minimum surplus for a governor"),
3043 N_("The lower limit of the range for requesting surpluses "
3044 "from the governor."),
3047 NULL),
3048 GEN_INT_OPTION(gui_gtk4_governor_range_max,
3049 N_("Maximum surplus for a governor"),
3050 N_("The higher limit of the range for requesting surpluses "
3051 "from the governor."),
3054 NULL),
3055 GEN_FONT_OPTION(gui_gtk4_font_city_label, "city_label",
3056 N_("City Label"),
3057 N_("This font is used to display the city labels on city "
3058 "dialogs."),
3060 "Monospace 8", font_changed_callback),
3061 GEN_FONT_OPTION(gui_gtk4_font_notify_label, "notify_label",
3062 N_("Notify Label"),
3063 N_("This font is used to display server reports such "
3064 "as the demographic report or historian publications."),
3066 "Monospace Bold 9", font_changed_callback),
3067 GEN_FONT_OPTION(gui_gtk4_font_spaceship_label, "spaceship_label",
3068 N_("Spaceship Label"),
3069 N_("This font is used to display the spaceship widgets."),
3071 "Monospace 8", font_changed_callback),
3072 GEN_FONT_OPTION(gui_gtk4_font_help_label, "help_label",
3073 N_("Help Label"),
3074 N_("This font is used to display the help headers in the "
3075 "help window."),
3077 "Sans Bold 10", font_changed_callback),
3078 GEN_FONT_OPTION(gui_gtk4_font_help_link, "help_link",
3079 N_("Help Link"),
3080 N_("This font is used to display the help links in the "
3081 "help window."),
3083 "Sans 9", font_changed_callback),
3084 GEN_FONT_OPTION(gui_gtk4_font_help_text, "help_text",
3085 N_("Help Text"),
3086 N_("This font is used to display the help body text in "
3087 "the help window."),
3089 "Monospace 8", font_changed_callback),
3090 GEN_FONT_OPTION(gui_gtk4_font_chatline, "chatline",
3091 N_("Chatline Area"),
3092 N_("This font is used to display the text in the "
3093 "chatline area."),
3095 "Monospace 8", font_changed_callback),
3096 GEN_FONT_OPTION(gui_gtk4_font_beta_label, "beta_label",
3097 N_("Beta Label"),
3098 N_("This font is used to display the beta label."),
3100 "Sans Italic 10", font_changed_callback),
3101 GEN_FONT_OPTION(gui_gtk4_font_small, "small_font",
3102 N_("Small Font"),
3103 N_("This font is used for any small font request. For "
3104 "example, it is used for display the building lists "
3105 "in the city dialog, the Economy report or the Units "
3106 "report."),
3108 "Sans 9", font_changed_callback),
3109 GEN_FONT_OPTION(gui_gtk4_font_comment_label, "comment_label",
3110 N_("Comment Label"),
3111 N_("This font is used to display comment labels, such as "
3112 "in the governor page of the city dialogs."),
3114 "Sans Italic 9", font_changed_callback),
3115 GEN_FONT_OPTION(gui_gtk4_font_city_names, "city_names",
3116 N_("City Names"),
3117 N_("This font is used to the display the city names "
3118 "on the map."),
3120 "Sans Bold 10", NULL),
3121 GEN_FONT_OPTION(gui_gtk4_font_city_productions, "city_productions",
3122 N_("City Productions"),
3123 N_("This font is used to display the city production "
3124 "on the map."),
3126 "Serif 10", NULL),
3127 GEN_FONT_OPTION(gui_gtk4_font_reqtree_text, "reqtree_text",
3128 N_("Requirement Tree"),
3129 N_("This font is used to the display the requirement tree "
3130 "in the Research report."),
3132 "Serif 10", NULL),
3133
3134 /* gui-sdl client specific options.
3135 * These are still kept just so users can migrate them to sdl2-client */
3136 GEN_BOOL_OPTION(gui_sdl_fullscreen, NULL, NULL,
3138 GEN_VIDEO_OPTION(gui_sdl_screen, NULL, NULL,
3139 COC_INTERFACE, GUI_SDL, 640, 480, NULL),
3140 GEN_BOOL_OPTION(gui_sdl_do_cursor_animation, NULL, NULL,
3142 GEN_BOOL_OPTION(gui_sdl_use_color_cursors, NULL, NULL,
3144
3145 /* gui-sdl2 client specific options. */
3146 GEN_BOOL_OPTION(gui_sdl2_fullscreen, N_("Fullscreen"),
3147 N_("If this option is set the client will use the "
3148 "whole screen area for drawing."),
3150 GEN_VIDEO_OPTION(gui_sdl2_screen, N_("Screen resolution"),
3151 N_("This option controls the resolution of the "
3152 "selected screen."),
3153 COC_INTERFACE, GUI_SDL2, 640, 480, NULL),
3154 GEN_BOOL_OPTION(gui_sdl2_swrenderer, N_("Use software rendering"),
3155 N_("Usually hardware rendering is used when possible. "
3156 "With this option set, software rendering is always used."),
3158 GEN_BOOL_OPTION(gui_sdl2_do_cursor_animation, N_("Do cursor animation"),
3159 N_("If this option is disabled, the cursor will "
3160 "always be displayed as static."),
3162 GEN_BOOL_OPTION(gui_sdl2_use_color_cursors, N_("Use color cursors"),
3163 N_("If this option is disabled, the cursor will "
3164 "always be displayed in black and white."),
3166 GEN_FONT_OPTION(gui_sdl2_font_city_names, "FONT_CITY_NAME",
3167 N_("City Names"),
3168 N_("The size of font used to the display the city names "
3169 "on the map."),
3171 "10", font_changed_callback),
3172 GEN_FONT_OPTION(gui_sdl2_font_city_productions, "FONT_CITY_PROD",
3173 N_("City Productions"),
3174 N_("The size of font used to the display the city "
3175 "production names on the map."),
3177 "10", font_changed_callback),
3178 GEN_BOOL_OPTION(gui_sdl2_use_theme_font_size, N_("Use theme defined font size"),
3179 N_("Disable this to override base font size set by theme "
3180 "by the setting below."),
3182 GEN_INT_OPTION(gui_sdl2_font_size, N_("Base Font Size"),
3183 N_("Base Font Size. All the fonts' sizes are defined relative "
3184 "to this. This option has effect only if theme font sizes "
3185 "option is disabled."),
3186 COC_FONT, GUI_SDL2, 10, 6, 50, NULL),
3187
3188 /* gui-sdl3 client specific options. */
3189 GEN_BOOL_OPTION(gui_sdl3_fullscreen, N_("Fullscreen"),
3190 N_("If this option is set the client will use the "
3191 "whole screen area for drawing."),
3193 GEN_VIDEO_OPTION(gui_sdl3_screen, N_("Screen resolution"),
3194 N_("This option controls the resolution of the "
3195 "selected screen."),
3196 COC_INTERFACE, GUI_SDL3, 640, 480, NULL),
3197 GEN_BOOL_OPTION(gui_sdl3_do_cursor_animation, N_("Do cursor animation"),
3198 N_("If this option is disabled, the cursor will "
3199 "always be displayed as static."),
3201 GEN_BOOL_OPTION(gui_sdl3_use_color_cursors, N_("Use color cursors"),
3202 N_("If this option is disabled, the cursor will "
3203 "always be displayed in black and white."),
3205 GEN_FONT_OPTION(gui_sdl3_font_city_names, "FONT_CITY_NAME",
3206 N_("City Names"),
3207 N_("The size of font used to the display the city names "
3208 "on the map."),
3210 "10", font_changed_callback),
3211 GEN_FONT_OPTION(gui_sdl3_font_city_productions, "FONT_CITY_PROD",
3212 N_("City Productions"),
3213 N_("The size of font used to the display the city "
3214 "production names on the map."),
3216 "10", font_changed_callback),
3217 GEN_BOOL_OPTION(gui_sdl3_use_theme_font_size, N_("Use theme defined font size"),
3218 N_("Disable this to override base font size set by theme "
3219 "by the setting below."),
3221 GEN_INT_OPTION(gui_sdl3_font_size, N_("Base Font Size"),
3222 N_("Base Font Size. All the fonts' sizes are defined relative "
3223 "to this. This option has effect only if theme font sizes "
3224 "option is disabled."),
3225 COC_FONT, GUI_SDL3, 10, 6, 50, NULL),
3226
3227 /* gui-qt client specific options. */
3228 GEN_BOOL_OPTION(gui_qt_fullscreen, N_("Fullscreen"),
3229 N_("If this option is set the client will use the "
3230 "whole screen area for drawing."),
3232 GEN_BOOL_OPTION(gui_qt_show_titlebar, N_("Show titlebar"),
3233 N_("If this option is set the client will show a titlebar. "
3234 "If disabled, then no titlebar will be shown, and "
3235 "minimize/maximize/etc buttons will be placed on the "
3236 "menu bar."),
3238 GEN_FONT_OPTION(gui_qt_font_default, "default_font",
3239 N_("Default font"),
3240 N_("This is default font"),
3242 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3243 GEN_FONT_OPTION(gui_qt_font_notify_label, "notify_label",
3244 N_("Notify Label"),
3245 N_("This font is used to display server reports such "
3246 "as the demographic report or historian publications."),
3248 "Monospace,9,-1,5,75,0,0,0,0,0", font_changed_callback),
3249 GEN_FONT_OPTION(gui_qt_font_help_label, "help_label",
3250 N_("Help Label"),
3251 N_("This font is used to display the help labels in the "
3252 "help window."),
3254 "Sans Serif,9,-1,5,50,0,0,0,0,0", font_changed_callback),
3255 GEN_FONT_OPTION(gui_qt_font_help_text, "help_text",
3256 N_("Help Text"),
3257 N_("This font is used to display the help body text in "
3258 "the help window."),
3260 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3261 GEN_FONT_OPTION(gui_qt_font_chatline, "chatline",
3262 N_("Chatline Area"),
3263 N_("This font is used to display the text in the "
3264 "chatline area."),
3266 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3267 GEN_FONT_OPTION(gui_qt_font_city_names, "city_names",
3268 N_("City Names"),
3269 N_("This font is used to the display the city names "
3270 "on the map."),
3272 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3273 GEN_FONT_OPTION(gui_qt_font_city_productions, "city_productions",
3274 N_("City Productions"),
3275 N_("This font is used to display the city production "
3276 "on the map."),
3278 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3279 GEN_FONT_OPTION(gui_qt_font_reqtree_text, "reqtree_text",
3280 N_("Requirement Tree"),
3281 N_("This font is used to the display the requirement tree "
3282 "in the Research report."),
3284 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3285 GEN_BOOL_OPTION(gui_qt_show_preview, N_("Show savegame information"),
3286 N_("If this option is set the client will show "
3287 "information and map preview of current savegame."),
3289 GEN_BOOL_OPTION(gui_qt_sidebar_left, N_("Sidebar position"),
3290 N_("If this option is set, the sidebar will be to the left "
3291 "of the map, otherwise to the right."),
3293 GEN_STR_OPTION(gui_qt_wakeup_text,
3294 N_("Wake up sequence"),
3295 N_("String which will trigger sound in pregame page; "
3296 "%1 stands for username."),
3297 COC_INTERFACE, GUI_QT, "Wake up %1", NULL, 0),
3298 GEN_BOOL_OPTION(gui_qt_svgflags, N_("SVG flags features"),
3300 N_("Enable svgflags features, such as bigger flags "
3301 "on the diplomacy dialog. Change to this comes "
3302 "to an effect on next client start."),
3303#else /* FREECIV_SVG_FLAGS */
3304 N_("Enable svgflags features, such as bigger flags "
3305 "on the diplomacy dialog. This has no effect on "
3306 "this freeciv build, as the svg support has not "
3307 "been built in."),
3308#endif /* FREECIV_SVG_FLAGS */
3310};
3312
3313/* Iteration loop, including invalid options for the current gui type. */
3314#define client_options_iterate_all(poption) \
3315{ \
3316 const struct client_option *const poption##_max = \
3317 client_options + client_options_num; \
3318 struct client_option *client_##poption = client_options; \
3319 struct option *poption; \
3320 for (; client_##poption < poption##_max; client_##poption++) { \
3321 poption = OPTION(client_##poption);
3322
3323#define client_options_iterate_all_end \
3324 } \
3325}
3326
3327
3328/************************************************************************/
3331static struct client_option *
3333{
3334 const struct client_option *const max =
3336 const enum gui_type our_type = get_gui_type();
3337
3338 while (poption < max
3339 && poption->specific != GUI_STUB
3340 && poption->specific != our_type) {
3341 poption++;
3342 }
3343
3344 return (poption < max ? poption : NULL);
3345}
3346
3347/************************************************************************/
3351{
3352 if (0 > id || id > client_options_num) {
3353 return NULL;
3354 }
3355 return OPTION(client_options + id);
3356}
3357
3358/************************************************************************/
3365
3366/************************************************************************/
3370{
3371 return COC_MAX;
3372}
3373
3374/************************************************************************/
3377static const char *client_optset_category_name(int category)
3378{
3379 switch (category) {
3380 case COC_GRAPHICS:
3381 return _("Graphics");
3382 case COC_OVERVIEW:
3383 /* TRANS: Options section for overview map (mini-map) */
3384 return Q_("?map:Overview");
3385 case COC_SOUND:
3386 return _("Sound");
3387 case COC_INTERFACE:
3388 return _("Interface");
3389 case COC_MAPIMG:
3390 return _("Map Image");
3391 case COC_NETWORK:
3392 return _("Network");
3393 case COC_FONT:
3394 return _("Font");
3395 case COC_MAX:
3396 break;
3397 }
3398
3399 log_error("%s: invalid option category number %d.",
3400 __FUNCTION__, category);
3401 return NULL;
3402}
3403
3404/************************************************************************/
3407static int client_option_number(const struct option *poption)
3408{
3410}
3411
3412/************************************************************************/
3415static const char *client_option_name(const struct option *poption)
3416{
3417 return CLIENT_OPTION(poption)->name;
3418}
3419
3420/************************************************************************/
3423static const char *client_option_description(const struct option *poption)
3424{
3425 return _(CLIENT_OPTION(poption)->description);
3426}
3427
3428/************************************************************************/
3431static const char *client_option_help_text(const struct option *poption)
3432{
3433 return _(CLIENT_OPTION(poption)->help_text);
3434}
3435
3436/************************************************************************/
3439static int client_option_category(const struct option *poption)
3440{
3441 return CLIENT_OPTION(poption)->category;
3442}
3443
3444/************************************************************************/
3448{
3449 return TRUE;
3450}
3451
3452/************************************************************************/
3455static struct option *client_option_next(const struct option *poption)
3456{
3458}
3459
3460/************************************************************************/
3463static bool client_option_bool_get(const struct option *poption)
3464{
3465 return *(CLIENT_OPTION(poption)->boolean.pvalue);
3466}
3467
3468/************************************************************************/
3471static bool client_option_bool_def(const struct option *poption)
3472{
3473 return CLIENT_OPTION(poption)->boolean.def;
3474}
3475
3476/************************************************************************/
3480static bool client_option_bool_set(struct option *poption, bool val)
3481{
3483
3484 if (*pcoption->boolean.pvalue == val) {
3485 return FALSE;
3486 }
3487
3488 *pcoption->boolean.pvalue = val;
3489 return TRUE;
3490}
3491
3492/************************************************************************/
3495static int client_option_int_get(const struct option *poption)
3496{
3497 return *(CLIENT_OPTION(poption)->integer.pvalue);
3498}
3499
3500/************************************************************************/
3503static int client_option_int_def(const struct option *poption)
3504{
3505 return CLIENT_OPTION(poption)->integer.def;
3506}
3507
3508/************************************************************************/
3511static int client_option_int_min(const struct option *poption)
3512{
3513 return CLIENT_OPTION(poption)->integer.min;
3514}
3515
3516/************************************************************************/
3519static int client_option_int_max(const struct option *poption)
3520{
3521 return CLIENT_OPTION(poption)->integer.max;
3522}
3523
3524/************************************************************************/
3528static bool client_option_int_set(struct option *poption, int val)
3529{
3531
3533 || val > pcoption->integer.max
3534 || *pcoption->integer.pvalue == val) {
3535 return FALSE;
3536 }
3537
3538 *pcoption->integer.pvalue = val;
3539 return TRUE;
3540}
3541
3542/************************************************************************/
3545static const char *client_option_str_get(const struct option *poption)
3546{
3547 return CLIENT_OPTION(poption)->string.pvalue;
3548}
3549
3550/************************************************************************/
3553static const char *client_option_str_def(const struct option *poption)
3554{
3555 return CLIENT_OPTION(poption)->string.def;
3556}
3557
3558/************************************************************************/
3562static const struct strvec *
3564{
3565 return (CLIENT_OPTION(poption)->string.val_accessor
3566 ? CLIENT_OPTION(poption)->string.val_accessor(poption) : NULL);
3567}
3568
3569/************************************************************************/
3573static bool client_option_str_set(struct option *poption, const char *str)
3574{
3576
3577 if (strlen(str) >= pcoption->string.size
3578 || 0 == strcmp(pcoption->string.pvalue, str)) {
3579 return FALSE;
3580 }
3581
3582 fc_strlcpy(pcoption->string.pvalue, str, pcoption->string.size);
3583 return TRUE;
3584}
3585
3586/************************************************************************/
3589static int client_option_enum_get(const struct option *poption)
3590{
3591 return *(CLIENT_OPTION(poption)->enumerator.pvalue);
3592}
3593
3594/************************************************************************/
3597static int client_option_enum_def(const struct option *poption)
3598{
3599 return CLIENT_OPTION(poption)->enumerator.def;
3600}
3601
3602/************************************************************************/
3606static const struct strvec *
3608{
3609 return CLIENT_OPTION(poption)->enumerator.pretty_names;
3610}
3611
3612/************************************************************************/
3616static bool client_option_enum_set(struct option *poption, int val)
3617{
3619
3620 if (*pcoption->enumerator.pvalue == val
3621 || 0 > val
3622 || val >= strvec_size(pcoption->enumerator.support_names)) {
3623 return FALSE;
3624 }
3625
3626 *pcoption->enumerator.pvalue = val;
3627 return TRUE;
3628}
3629
3630/************************************************************************/
3636 int val)
3637{
3638 const struct strvec *names = CLIENT_OPTION(data)->enumerator.support_names;
3639
3640 return (0 <= val && val < strvec_size(names)
3641 ? strvec_get(names, val) : NULL);
3642}
3643
3644#if 0 /* There's no bitwise options currently */
3645/************************************************************************/
3648static unsigned client_option_bitwise_get(const struct option *poption)
3649{
3650 return *(CLIENT_OPTION(poption)->bitwise.pvalue);
3651}
3652
3653/************************************************************************/
3656static unsigned client_option_bitwise_def(const struct option *poption)
3657{
3658 return CLIENT_OPTION(poption)->bitwise.def;
3659}
3660
3661/************************************************************************/
3665static const struct strvec *
3667{
3668 return CLIENT_OPTION(poption)->bitwise.pretty_names;
3669}
3670
3671/************************************************************************/
3675static bool client_option_bitwise_set(struct option *poption, unsigned val)
3676{
3678
3679 if (*pcoption->bitwise.pvalue == val) {
3680 return FALSE;
3681 }
3682
3683 *pcoption->bitwise.pvalue = val;
3684 return TRUE;
3685}
3686#endif /* 0 */
3687
3688/************************************************************************/
3694 int val)
3695{
3696 const struct strvec *names = CLIENT_OPTION(data)->bitwise.support_names;
3697
3698 return (0 <= val && val < strvec_size(names)
3699 ? strvec_get(names, val) : NULL);
3700}
3701
3702/************************************************************************/
3705static const char *client_option_font_get(const struct option *poption)
3706{
3707 return CLIENT_OPTION(poption)->font.pvalue;
3708}
3709
3710/************************************************************************/
3713static const char *client_option_font_def(const struct option *poption)
3714{
3715 return CLIENT_OPTION(poption)->font.def;
3716}
3717
3718/************************************************************************/
3721static const char *client_option_font_target(const struct option *poption)
3722{
3723 return CLIENT_OPTION(poption)->font.target;
3724}
3725
3726/************************************************************************/
3730static bool client_option_font_set(struct option *poption, const char *font)
3731{
3733
3734 if (strlen(font) >= pcoption->font.size
3735 || 0 == strcmp(pcoption->font.pvalue, font)) {
3736 return FALSE;
3737 }
3738
3739 fc_strlcpy(pcoption->font.pvalue, font, pcoption->font.size);
3740 return TRUE;
3741}
3742
3743/************************************************************************/
3747{
3748 return *CLIENT_OPTION(poption)->color.pvalue;
3749}
3750
3751/************************************************************************/
3755{
3756 return CLIENT_OPTION(poption)->color.def;
3757}
3758
3759/************************************************************************/
3764 struct ft_color color)
3765{
3766 struct ft_color *pcolor = CLIENT_OPTION(poption)->color.pvalue;
3767 bool changed = FALSE;
3768
3769#define color_set(color_tgt, color) \
3770 if (NULL == color_tgt) { \
3771 if (NULL != color) { \
3772 color_tgt = fc_strdup(color); \
3773 changed = TRUE; \
3774 } \
3775 } else { \
3776 if (NULL == color) { \
3777 free((void *) color_tgt); \
3778 color_tgt = NULL; \
3779 changed = TRUE; \
3780 } else if (0 != strcmp(color_tgt, color)) { \
3781 free((void *) color_tgt); \
3782 color_tgt = fc_strdup(color); \
3783 changed = TRUE; \
3784 } \
3785 }
3786
3787 color_set(pcolor->foreground, color.foreground);
3788 color_set(pcolor->background, color.background);
3789
3790#undef color_set
3791
3792 return changed;
3793}
3794
3795/************************************************************************/
3798static struct video_mode
3800{
3801 return *CLIENT_OPTION(poption)->video_mode.pvalue;
3802}
3803
3804/************************************************************************/
3807static struct video_mode
3812
3813/************************************************************************/
3818 struct video_mode mode)
3819{
3821
3822 if (0 == memcmp(&mode, pcoption->video_mode.pvalue,
3823 sizeof(struct video_mode))) {
3824 return FALSE;
3825 }
3826
3827 *pcoption->video_mode.pvalue = mode;
3828 return TRUE;
3829}
3830
3831/************************************************************************/
3835 struct section_file *sf)
3836{
3839
3840 switch (option_type(poption)) {
3841 case OT_BOOLEAN:
3842 {
3843 bool value;
3844 const char *pname = option_name(poption);
3845 const char *old_paths = "draw_roads_rails";
3846
3847 if (!strcmp("draw_paths", pname)) {
3848 /* Renamed in freeciv-3.2 */
3849 if (secfile_lookup_bool(sf, &value, "client.draw_paths")
3850 && option_bool_set(poption, value)) {
3851 return TRUE;
3852 }
3853
3854 /* Try by old name. */
3855 pname = old_paths;
3856 }
3857
3858 return (secfile_lookup_bool(sf, &value, "client.%s",
3859 pname)
3860 && option_bool_set(poption, value));
3861 }
3862 case OT_INTEGER:
3863 {
3864 int value;
3865
3866 return (secfile_lookup_int(sf, &value, "client.%s",
3868 && option_int_set(poption, value));
3869 }
3870 case OT_STRING:
3871 {
3872 const char *string;
3873
3874 return ((string = secfile_lookup_str(sf, "client.%s",
3876 && option_str_set(poption, string));
3877 }
3878 case OT_ENUM:
3879 {
3880 int value;
3881
3882 return (secfile_lookup_enum_data(sf, &value, FALSE,
3884 poption, "client.%s",
3886 && option_enum_set_int(poption, value));
3887 }
3888 case OT_BITWISE:
3889 {
3890 int value;
3891
3892 return (secfile_lookup_enum_data(sf, &value, TRUE,
3894 poption, "client.%s",
3896 && option_bitwise_set(poption, value));
3897 }
3898 case OT_FONT:
3899 {
3900 const char *string;
3901
3902 return ((string = secfile_lookup_str(sf, "client.%s",
3904 && option_font_set(poption, string));
3905 }
3906 case OT_COLOR:
3907 {
3908 struct ft_color color;
3909
3910 return ((color.foreground =
3911 secfile_lookup_str(sf, "client.%s.foreground",
3913 && (color.background =
3914 secfile_lookup_str(sf, "client.%s.background",
3917 }
3918 case OT_VIDEO_MODE:
3919 {
3920 struct video_mode mode;
3921
3922 return (secfile_lookup_int(sf, &mode.width, "client.%s.width",
3924 && secfile_lookup_int(sf, &mode.height, "client.%s.height",
3926 && option_video_mode_set(poption, mode));
3927 }
3928 }
3929 return FALSE;
3930}
3931
3932/************************************************************************/
3936 struct section_file *sf)
3937{
3939 fc_assert_ret(NULL != sf);
3940
3941 switch (option_type(poption)) {
3942 case OT_BOOLEAN:
3944 "client.%s", option_name(poption));
3945 break;
3946 case OT_INTEGER:
3948 "client.%s", option_name(poption));
3949 break;
3950 case OT_STRING:
3952 "client.%s", option_name(poption));
3953 break;
3954 case OT_ENUM:
3957 "client.%s", option_name(poption));
3958 break;
3959 case OT_BITWISE:
3962 "client.%s", option_name(poption));
3963 break;
3964 case OT_FONT:
3966 "client.%s", option_name(poption));
3967 break;
3968 case OT_COLOR:
3969 {
3971
3972 secfile_insert_str(sf, color.foreground, "client.%s.foreground",
3974 secfile_insert_str(sf, color.background, "client.%s.background",
3976 }
3977 break;
3978 case OT_VIDEO_MODE:
3979 {
3981
3982 secfile_insert_int(sf, mode.width, "client.%s.width",
3984 secfile_insert_int(sf, mode.height, "client.%s.height",
3986 }
3987 break;
3988 }
3989}
3990
3991
3992/****************************************************************************
3993 Server options variables.
3994****************************************************************************/
3997
3999static int server_options_num = 0;
4000
4001
4002/****************************************************************************
4003 Server option set.
4004****************************************************************************/
4005static struct option *server_optset_option_by_number(int id);
4006static struct option *server_optset_option_first(void);
4007static int server_optset_category_number(void);
4008static const char *server_optset_category_name(int category);
4009
4012 .option_first = server_optset_option_first,
4013 .category_number = server_optset_category_number,
4014 .category_name = server_optset_category_name
4015};
4017
4018
4019/****************************************************************************
4020 Virtuals tables for the client options.
4021****************************************************************************/
4022static int server_option_number(const struct option *poption);
4023static const char *server_option_name(const struct option *poption);
4024static const char *server_option_description(const struct option *poption);
4025static const char *server_option_help_text(const struct option *poption);
4026static int server_option_category(const struct option *poption);
4027static bool server_option_is_changeable(const struct option *poption);
4028static struct option *server_option_next(const struct option *poption);
4029
4030static const struct option_common_vtable server_option_common_vtable = {
4031 .number = server_option_number,
4032 .name = server_option_name,
4033 .description = server_option_description,
4034 .help_text = server_option_help_text,
4035 .category = server_option_category,
4036 .is_changeable = server_option_is_changeable,
4037 .next = server_option_next
4038};
4039
4040static bool server_option_bool_get(const struct option *poption);
4041static bool server_option_bool_def(const struct option *poption);
4042static bool server_option_bool_set(struct option *poption, bool val);
4043
4044static const struct option_bool_vtable server_option_bool_vtable = {
4048};
4049
4050static int server_option_int_get(const struct option *poption);
4051static int server_option_int_def(const struct option *poption);
4052static int server_option_int_min(const struct option *poption);
4053static int server_option_int_max(const struct option *poption);
4054static bool server_option_int_set(struct option *poption, int val);
4055
4056static const struct option_int_vtable server_option_int_vtable = {
4057 .get = server_option_int_get,
4058 .def = server_option_int_def,
4059 .minimum = server_option_int_min,
4060 .maximum = server_option_int_max,
4062};
4063
4064static const char *server_option_str_get(const struct option *poption);
4065static const char *server_option_str_def(const struct option *poption);
4066static const struct strvec *
4068static bool server_option_str_set(struct option *poption, const char *str);
4069
4070static const struct option_str_vtable server_option_str_vtable = {
4071 .get = server_option_str_get,
4072 .def = server_option_str_def,
4073 .values = server_option_str_values,
4075};
4076
4077static int server_option_enum_get(const struct option *poption);
4078static int server_option_enum_def(const struct option *poption);
4079static const struct strvec *
4081static bool server_option_enum_set(struct option *poption, int val);
4082
4083static const struct option_enum_vtable server_option_enum_vtable = {
4086 .values = server_option_enum_pretty,
4088 .cmp = strcmp
4089};
4090
4091static unsigned server_option_bitwise_get(const struct option *poption);
4092static unsigned server_option_bitwise_def(const struct option *poption);
4093static const struct strvec *
4095static bool server_option_bitwise_set(struct option *poption, unsigned val);
4096
4097static const struct option_bitwise_vtable server_option_bitwise_vtable = {
4102};
4103
4104/****************************************************************************
4105 Derived class server option, inheriting from base class option.
4106****************************************************************************/
4108 struct option base_option; /* Base structure, must be the first! */
4109
4110 char *name; /* Short name - used as an identifier */
4111 char *description; /* One-line description */
4112 char *help_text; /* Paragraph-length help text */
4113 unsigned char category;
4118
4119 union {
4120 /* OT_BOOLEAN type option. */
4121 struct {
4122 bool value;
4123 bool def;
4124 } boolean;
4125 /* OT_INTEGER type option. */
4126 struct {
4128 int def, min, max;
4129 } integer;
4130 /* OT_STRING type option. */
4131 struct {
4132 char *value;
4133 char *def;
4134 } string;
4135 /* OT_ENUM type option. */
4136 struct {
4137 int value;
4138 int def;
4140 struct strvec *pretty_names; /* untranslated */
4141 } enumerator;
4142 /* OT_BITWISE type option. */
4143 struct {
4144 unsigned value;
4145 unsigned def;
4146 struct strvec *support_names;
4147 struct strvec *pretty_names; /* untranslated */
4148 } bitwise;
4149 };
4150};
4151
4152#define SERVER_OPTION(poption) ((struct server_option *) (poption))
4153
4154static void desired_settable_option_send(struct option *poption);
4155
4156
4157/************************************************************************/
4167
4168/************************************************************************/
4172{
4173 option_gui_remove(&(poption->base_option));
4174
4175 switch (poption->base_option.type) {
4176 case OT_STRING:
4177 if (NULL != poption->string.value) {
4178 FC_FREE(poption->string.value);
4179 }
4180 if (NULL != poption->string.def) {
4181 FC_FREE(poption->string.def);
4182 }
4183 break;
4184
4185 case OT_ENUM:
4186 if (NULL != poption->enumerator.support_names) {
4187 strvec_destroy(poption->enumerator.support_names);
4188 poption->enumerator.support_names = NULL;
4189 }
4190 if (NULL != poption->enumerator.pretty_names) {
4191 strvec_destroy(poption->enumerator.pretty_names);
4192 poption->enumerator.pretty_names = NULL;
4193 }
4194 break;
4195
4196 case OT_BITWISE:
4197 if (NULL != poption->bitwise.support_names) {
4198 strvec_destroy(poption->bitwise.support_names);
4199 poption->bitwise.support_names = NULL;
4200 }
4201 if (NULL != poption->bitwise.pretty_names) {
4202 strvec_destroy(poption->bitwise.pretty_names);
4203 poption->bitwise.pretty_names = NULL;
4204 }
4205 break;
4206
4207 case OT_BOOLEAN:
4208 case OT_INTEGER:
4209 case OT_FONT:
4210 case OT_COLOR:
4211 case OT_VIDEO_MODE:
4212 break;
4213 }
4214
4215 if (NULL != poption->name) {
4216 FC_FREE(poption->name);
4217 }
4218 if (NULL != poption->description) {
4219 FC_FREE(poption->description);
4220 }
4221 if (NULL != poption->help_text) {
4222 FC_FREE(poption->help_text);
4223 }
4224}
4225
4226/************************************************************************/
4230{
4231 int i;
4232
4233 /* Don't keep this dialog open. */
4235
4236 /* Free the options themselves. */
4237 if (NULL != server_options) {
4238 for (i = 0; i < server_options_num; i++) {
4240 }
4243 }
4244
4245 /* Free the categories. */
4247 for (i = 0; i < server_options_categories_num; i++) {
4250 }
4251 }
4254 }
4255}
4256
4257/************************************************************************/
4261 (const struct packet_server_setting_control *packet)
4262{
4263 int i;
4264
4265 /* This packet should be received only once. */
4270
4271 /* Allocate server option categories. */
4272 if (0 < packet->categories_num) {
4276 sizeof(*server_options_categories));
4277
4278 for (i = 0; i < server_options_categories_num; i++) {
4279 /* NB: Translate now. */
4281 }
4282 }
4283
4284 /* Allocate server options. */
4285 if (0 < packet->settings_num) {
4288 }
4289}
4290
4291/************************************************************************/
4295 (const struct packet_server_setting_const *packet)
4296{
4299
4301
4302 fc_assert(NULL == psoption->name);
4303 psoption->name = fc_strdup(packet->name);
4304 fc_assert(NULL == psoption->description);
4305 /* NB: Translate now. */
4306 psoption->description = fc_strdup(_(packet->short_help));
4307 fc_assert(NULL == psoption->help_text);
4308 /* NB: Translate now. */
4309 psoption->help_text = fc_strdup(_(packet->extra_help));
4310 psoption->category = packet->category;
4311}
4312
4313/****************************************************************************
4314 Common part of handle_server_setting_*() functions. See below.
4315****************************************************************************/
4316#define handle_server_setting_common(psoption, packet) \
4317 psoption->is_changeable = packet->is_changeable; \
4318 psoption->setdef = packet->setdef; \
4319 if (psoption->is_visible != packet->is_visible) { \
4320 if (psoption->is_visible) { \
4321 need_gui_remove = TRUE; \
4322 } else if (packet->is_visible) { \
4323 need_gui_add = TRUE; \
4324 } \
4325 psoption->is_visible = packet->is_visible; \
4326 } \
4327 \
4328 /* Keep this list of conditions in sync with one in \
4329 resend_desired_settable_options() */ \
4330 if (!psoption->desired_sent \
4331 && psoption->is_visible \
4332 && psoption->is_changeable \
4333 && gui_options.send_desired_settings \
4334 && is_server_running() \
4335 && packet->initial_setting) { \
4336 /* Only send our private settings if we are running \
4337 * on a forked local server, i.e. started by the \
4338 * client with the "Start New Game" button. \
4339 * Do now override settings that are already saved to savegame \
4340 * and now loaded. */ \
4341 desired_settable_option_send(OPTION(poption)); \
4342 dsend_packet_sync_serial(&client.conn, ++sync_serial); \
4343 psoption->desired_sent = TRUE; \
4344 } \
4345 \
4346 /* Update the GUI. */ \
4347 if (need_gui_remove) { \
4348 option_gui_remove(poption); \
4349 } else if (need_gui_add) { \
4350 option_gui_add(poption); \
4351 } else { \
4352 option_gui_update(poption); \
4354
4355/************************************************************************/
4359 (const struct packet_server_setting_bool *packet)
4360{
4363 bool need_gui_remove = FALSE;
4364 bool need_gui_add = FALSE;
4365
4367
4368 if (NULL == poption->common_vtable) {
4369 /* Not initialized yet. */
4370 poption->poptset = server_optset;
4371 poption->common_vtable = &server_option_common_vtable;
4372 poption->type = OT_BOOLEAN;
4373 poption->bool_vtable = &server_option_bool_vtable;
4374 }
4376 "Server setting \"%s\" (nb %d) has type %s (%d), "
4377 "expected %s (%d)",
4379 option_type_name(poption->type), poption->type,
4381
4382 if (packet->is_visible) {
4383 psoption->boolean.value = packet->val;
4384 psoption->boolean.def = packet->default_val;
4385 }
4386
4389
4390/************************************************************************/
4394 (const struct packet_server_setting_int *packet)
4395{
4398 bool need_gui_remove = FALSE;
4399 bool need_gui_add = FALSE;
4400
4402
4403 if (NULL == poption->common_vtable) {
4404 /* Not initialized yet. */
4405 poption->poptset = server_optset;
4406 poption->common_vtable = &server_option_common_vtable;
4407 poption->type = OT_INTEGER;
4408 poption->int_vtable = &server_option_int_vtable;
4409 }
4411 "Server setting \"%s\" (nb %d) has type %s (%d), "
4412 "expected %s (%d)",
4414 option_type_name(poption->type), poption->type,
4416
4417 if (packet->is_visible) {
4418 psoption->integer.value = packet->val;
4419 psoption->integer.def = packet->default_val;
4420 psoption->integer.min = packet->min_val;
4421 psoption->integer.max = packet->max_val;
4422 }
4423
4426
4427/************************************************************************/
4431 (const struct packet_server_setting_str *packet)
4432{
4435 bool need_gui_remove = FALSE;
4436 bool need_gui_add = FALSE;
4437
4439
4440 if (NULL == poption->common_vtable) {
4441 /* Not initialized yet. */
4442 poption->poptset = server_optset;
4443 poption->common_vtable = &server_option_common_vtable;
4444 poption->type = OT_STRING;
4445 poption->str_vtable = &server_option_str_vtable;
4446 }
4448 "Server setting \"%s\" (nb %d) has type %s (%d), "
4449 "expected %s (%d)",
4451 option_type_name(poption->type), poption->type,
4453
4454 if (packet->is_visible) {
4455 if (NULL == psoption->string.value) {
4456 psoption->string.value = fc_strdup(packet->val);
4457 } else if (0 != strcmp(packet->val, psoption->string.value)) {
4458 free(psoption->string.value);
4459 psoption->string.value = fc_strdup(packet->val);
4460 }
4461 if (NULL == psoption->string.def) {
4462 psoption->string.def = fc_strdup(packet->default_val);
4463 } else if (0 != strcmp(packet->default_val, psoption->string.def)) {
4464 free(psoption->string.def);
4465 psoption->string.def = fc_strdup(packet->default_val);
4466 }
4467 }
4468
4471
4472/************************************************************************/
4476 (const struct packet_server_setting_enum *packet)
4477{
4480 bool need_gui_remove = FALSE;
4481 bool need_gui_add = FALSE;
4482
4484
4485 if (NULL == poption->common_vtable) {
4486 /* Not initialized yet. */
4487 poption->poptset = server_optset;
4488 poption->common_vtable = &server_option_common_vtable;
4489 poption->type = OT_ENUM;
4490 poption->enum_vtable = &server_option_enum_vtable;
4491 }
4493 "Server setting \"%s\" (nb %d) has type %s (%d), "
4494 "expected %s (%d)",
4496 option_type_name(poption->type), poption->type,
4498
4499 if (packet->is_visible) {
4500 int i;
4501
4502 psoption->enumerator.value = packet->val;
4503 psoption->enumerator.def = packet->default_val;
4504
4505 if (NULL == psoption->enumerator.support_names) {
4506 /* First time we get this packet. */
4507 fc_assert(NULL == psoption->enumerator.pretty_names);
4508 psoption->enumerator.support_names = strvec_new();
4509 strvec_reserve(psoption->enumerator.support_names, packet->values_num);
4510 psoption->enumerator.pretty_names = strvec_new();
4511 strvec_reserve(psoption->enumerator.pretty_names, packet->values_num);
4512 for (i = 0; i < packet->values_num; i++) {
4513 strvec_set(psoption->enumerator.support_names, i,
4514 packet->support_names[i]);
4515 /* Store untranslated string from server. */
4516 strvec_set(psoption->enumerator.pretty_names, i,
4517 packet->pretty_names[i]);
4518 }
4519 } else if (strvec_size(psoption->enumerator.support_names)
4520 != packet->values_num) {
4521 fc_assert(strvec_size(psoption->enumerator.support_names)
4522 == strvec_size(psoption->enumerator.pretty_names));
4523 /* The number of values have changed, we need to reset the list
4524 * of possible values. */
4525 strvec_reserve(psoption->enumerator.support_names, packet->values_num);
4526 strvec_reserve(psoption->enumerator.pretty_names, packet->values_num);
4527 for (i = 0; i < packet->values_num; i++) {
4528 strvec_set(psoption->enumerator.support_names, i,
4529 packet->support_names[i]);
4530 /* Store untranslated string from server. */
4531 strvec_set(psoption->enumerator.pretty_names, i,
4532 packet->pretty_names[i]);
4533 }
4536 } else {
4537 /* Check if a value changed, then we need to reset the list
4538 * of possible values. */
4539 const char *str;
4540
4541 for (i = 0; i < packet->values_num; i++) {
4542 str = strvec_get(psoption->enumerator.pretty_names, i);
4543 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4544 /* Store untranslated string from server. */
4545 strvec_set(psoption->enumerator.pretty_names, i,
4546 packet->pretty_names[i]);
4549 }
4550 /* Support names are not visible, we don't need to check if it
4551 * has changed. */
4552 strvec_set(psoption->enumerator.support_names, i,
4553 packet->support_names[i]);
4554 }
4555 }
4556 }
4557
4560
4561/************************************************************************/
4565 (const struct packet_server_setting_bitwise *packet)
4566{
4569 bool need_gui_remove = FALSE;
4570 bool need_gui_add = FALSE;
4571
4573
4574 if (NULL == poption->common_vtable) {
4575 /* Not initialized yet. */
4576 poption->poptset = server_optset;
4577 poption->common_vtable = &server_option_common_vtable;
4578 poption->type = OT_BITWISE;
4579 poption->bitwise_vtable = &server_option_bitwise_vtable;
4580 }
4582 "Server setting \"%s\" (nb %d) has type %s (%d), "
4583 "expected %s (%d)",
4585 option_type_name(poption->type), poption->type,
4587
4588 if (packet->is_visible) {
4589 int i;
4590
4591 psoption->bitwise.value = packet->val;
4592 psoption->bitwise.def = packet->default_val;
4593
4594 if (NULL == psoption->bitwise.support_names) {
4595 /* First time we get this packet. */
4596 fc_assert(NULL == psoption->bitwise.pretty_names);
4597 psoption->bitwise.support_names = strvec_new();
4598 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4599 psoption->bitwise.pretty_names = strvec_new();
4600 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4601 for (i = 0; i < packet->bits_num; i++) {
4602 strvec_set(psoption->bitwise.support_names, i,
4603 packet->support_names[i]);
4604 /* Store untranslated string from server. */
4605 strvec_set(psoption->bitwise.pretty_names, i,
4606 packet->pretty_names[i]);
4607 }
4608 } else if (strvec_size(psoption->bitwise.support_names)
4609 != packet->bits_num) {
4610 fc_assert(strvec_size(psoption->bitwise.support_names)
4611 == strvec_size(psoption->bitwise.pretty_names));
4612 /* The number of values have changed, we need to reset the list
4613 * of possible values. */
4614 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4615 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4616 for (i = 0; i < packet->bits_num; i++) {
4617 strvec_set(psoption->bitwise.support_names, i,
4618 packet->support_names[i]);
4619 /* Store untranslated string from server. */
4620 strvec_set(psoption->bitwise.pretty_names, i,
4621 packet->pretty_names[i]);
4622 }
4625 } else {
4626 /* Check if a value changed, then we need to reset the list
4627 * of possible values. */
4628 const char *str;
4629
4630 for (i = 0; i < packet->bits_num; i++) {
4631 str = strvec_get(psoption->bitwise.pretty_names, i);
4632 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4633 /* Store untranslated string from server. */
4634 strvec_set(psoption->bitwise.pretty_names, i,
4635 packet->pretty_names[i]);
4638 }
4639 /* Support names are not visible, we don't need to check if it
4640 * has changed. */
4641 strvec_set(psoption->bitwise.support_names, i,
4642 packet->support_names[i]);
4643 }
4644 }
4645 }
4646
4648}
4650/************************************************************************/
4653static struct server_option *
4655{
4656 if (server_options != NULL) {
4657 const struct server_option *const max =
4659
4661 poption++;
4662 }
4663
4664 return (poption < max ? poption : NULL);
4665 }
4666
4667 return NULL;
4669
4670/************************************************************************/
4674{
4675 if (0 > id || id > server_options_num) {
4676 return NULL;
4677 }
4678 return OPTION(server_options + id);
4680
4681/************************************************************************/
4685{
4688
4689/************************************************************************/
4693{
4696
4697/************************************************************************/
4700const char *server_optset_category_name(int category)
4701{
4702 if (0 > category || category >= server_options_categories_num) {
4703 return NULL;
4704 }
4705
4706 return server_options_categories[category];
4708
4709/************************************************************************/
4712static int server_option_number(const struct option *poption)
4713{
4716
4717/************************************************************************/
4720static const char *server_option_name(const struct option *poption)
4721{
4722 return SERVER_OPTION(poption)->name;
4724
4725/************************************************************************/
4728static const char *server_option_description(const struct option *poption)
4729{
4730 return SERVER_OPTION(poption)->description;
4732
4733/************************************************************************/
4736static const char *server_option_help_text(const struct option *poption)
4737{
4738 return SERVER_OPTION(poption)->help_text;
4740
4741/************************************************************************/
4744static int server_option_category(const struct option *poption)
4745{
4746 return SERVER_OPTION(poption)->category;
4748
4749/************************************************************************/
4752static bool server_option_is_changeable(const struct option *poption)
4753{
4754 return SERVER_OPTION(poption)->is_changeable;
4756
4757/************************************************************************/
4760static struct option *server_option_next(const struct option *poption)
4761{
4764
4765/************************************************************************/
4768static bool server_option_bool_get(const struct option *poption)
4769{
4770 return SERVER_OPTION(poption)->boolean.value;
4772
4773/************************************************************************/
4776static bool server_option_bool_def(const struct option *poption)
4777{
4778 return SERVER_OPTION(poption)->boolean.def;
4779}
4781/************************************************************************/
4785static bool server_option_bool_set(struct option *poption, bool val)
4786{
4788
4789 if (psoption->boolean.value == val) {
4790 return FALSE;
4791 }
4792
4793 send_chat_printf("/set %s %s", psoption->name,
4794 val ? "enabled" : "disabled");
4795 return TRUE;
4797
4798/************************************************************************/
4801static int server_option_int_get(const struct option *poption)
4802{
4803 return SERVER_OPTION(poption)->integer.value;
4805
4806/************************************************************************/
4809static int server_option_int_def(const struct option *poption)
4810{
4811 return SERVER_OPTION(poption)->integer.def;
4813
4814/************************************************************************/
4817static int server_option_int_min(const struct option *poption)
4818{
4819 return SERVER_OPTION(poption)->integer.min;
4821
4822/************************************************************************/
4825static int server_option_int_max(const struct option *poption)
4826{
4827 return SERVER_OPTION(poption)->integer.max;
4828}
4830/************************************************************************/
4834static bool server_option_int_set(struct option *poption, int val)
4835{
4837
4839 || val > psoption->integer.max
4840 || psoption->integer.value == val) {
4841 return FALSE;
4842 }
4843
4844 send_chat_printf("/set %s %d", psoption->name, val);
4845 return TRUE;
4847
4848/************************************************************************/
4851static const char *server_option_str_get(const struct option *poption)
4852{
4853 return SERVER_OPTION(poption)->string.value;
4855
4856/************************************************************************/
4859static const char *server_option_str_def(const struct option *poption)
4860{
4861 return SERVER_OPTION(poption)->string.def;
4862}
4863
4864/************************************************************************/
4868static const struct strvec *
4870{
4871 return NULL;
4872}
4874/************************************************************************/
4878static bool server_option_str_set(struct option *poption, const char *str)
4879{
4881
4882 if (0 == strcmp(psoption->string.value, str)) {
4883 return FALSE;
4884 }
4885
4886 send_chat_printf("/set %s \"%s\"", psoption->name, str);
4887 return TRUE;
4889
4890/************************************************************************/
4893static int server_option_enum_get(const struct option *poption)
4894{
4895 return SERVER_OPTION(poption)->enumerator.value;
4897
4898/************************************************************************/
4901static int server_option_enum_def(const struct option *poption)
4902{
4903 return SERVER_OPTION(poption)->enumerator.def;
4904}
4905
4906/************************************************************************/
4910static const struct strvec *
4912{
4913 return SERVER_OPTION(poption)->enumerator.pretty_names;
4914}
4916/************************************************************************/
4920static bool server_option_enum_set(struct option *poption, int val)
4921{
4923 const char *name;
4924
4925 if (val == psoption->enumerator.value
4926 || !(name = strvec_get(psoption->enumerator.support_names, val))) {
4927 return FALSE;
4928 }
4929
4930 send_chat_printf("/set %s \"%s\"", psoption->name, name);
4931 return TRUE;
4932}
4934/************************************************************************/
4938static void server_option_enum_support_name(const struct option *poption,
4939 const char **pvalue,
4940 const char **pdefault)
4941{
4943 const struct strvec *values = psoption->enumerator.support_names;
4944
4945 if (NULL != pvalue) {
4946 *pvalue = strvec_get(values, psoption->enumerator.value);
4947 }
4948 if (NULL != pdefault) {
4949 *pdefault = strvec_get(values, psoption->enumerator.def);
4950 }
4952
4953/************************************************************************/
4956static unsigned server_option_bitwise_get(const struct option *poption)
4957{
4958 return SERVER_OPTION(poption)->bitwise.value;
4960
4961/************************************************************************/
4964static unsigned server_option_bitwise_def(const struct option *poption)
4965{
4966 return SERVER_OPTION(poption)->bitwise.def;
4967}
4968
4969/************************************************************************/
4973static const struct strvec *
4975{
4976 return SERVER_OPTION(poption)->bitwise.pretty_names;
4978
4979/************************************************************************/
4982static void server_option_bitwise_support_base(const struct strvec *values,
4983 unsigned val,
4984 char *buf, size_t buf_len)
4985{
4986 int bit;
4987
4988 buf[0] = '\0';
4989 for (bit = 0; bit < strvec_size(values); bit++) {
4990 if ((1 << bit) & val) {
4991 if ('\0' != buf[0]) {
4992 fc_strlcat(buf, "|", buf_len);
4993 }
4994 fc_strlcat(buf, strvec_get(values, bit), buf_len);
4995 }
4996 }
4997}
4999/************************************************************************/
5003static bool server_option_bitwise_set(struct option *poption, unsigned val)
5004{
5006 char name[MAX_LEN_MSG];
5007
5008 if (val == psoption->bitwise.value) {
5009 return FALSE;
5010 }
5011
5012 server_option_bitwise_support_base(psoption->bitwise.support_names, val,
5013 name, sizeof(name));
5014 send_chat_printf("/set %s \"%s\"", psoption->name, name);
5015 return TRUE;
5016}
5018/************************************************************************/
5022static void server_option_bitwise_support_name(const struct option *poption,
5023 char *val_buf, size_t val_len,
5024 char *def_buf, size_t def_len)
5025{
5027 const struct strvec *values = psoption->bitwise.support_names;
5028
5029 if (NULL != val_buf && 0 < val_len) {
5030 server_option_bitwise_support_base(values, psoption->bitwise.value,
5031 val_buf, val_len);
5032 }
5033 if (NULL != def_buf && 0 < def_len) {
5034 server_option_bitwise_support_base(values, psoption->bitwise.def,
5035 def_buf, def_len);
5036 }
5038
5039
5043
5045/************************************************************************/
5049static void message_options_init(void)
5050{
5051 int none[] = {
5057 };
5058 int out_only[] = {
5061 };
5062 int all[] = {
5064 };
5065 int i;
5066
5067 for (i = 0; i <= event_type_max(); i++) {
5068 /* Include possible undefined values. */
5070 }
5071 for (i = 0; i < ARRAY_SIZE(none); i++) {
5072 messages_where[none[i]] = 0;
5073 }
5074 for (i = 0; i < ARRAY_SIZE(out_only); i++) {
5076 }
5077 for (i = 0; i < ARRAY_SIZE(all); i++) {
5079 }
5080
5081 events_init();
5083
5084/************************************************************************/
5087static void message_options_free(void)
5088{
5089 events_free();
5090}
5092/************************************************************************/
5096static void message_options_load(struct section_file *file,
5097 const char *prefix)
5098{
5099 enum event_type event;
5100 int i, num_events;
5101 const char *p;
5102
5103 if (!secfile_lookup_int(file, &num_events, "messages.count")) {
5104 /* version < 2.2 */
5105 /* Order of the events in 2.1. */
5106 const enum event_type old_events[] = {
5135 };
5136 const size_t old_events_num = ARRAY_SIZE(old_events);
5137
5138 for (i = 0; i < old_events_num; i++) {
5141 "%s.message_where_%02d", prefix, i);
5142 }
5143 return;
5144 }
5145
5146 for (i = 0; i < num_events; i++) {
5147 p = secfile_lookup_str(file, "messages.event%d.name", i);
5148 if (NULL == p) {
5149 log_error("Corruption in file %s: %s",
5150 secfile_name(file), secfile_error());
5151 continue;
5152 }
5153 /* Compatibility: Before 3.0 E_UNIT_WIN_DEF was called E_UNIT_WIN. */
5154 if (!fc_strcasecmp("E_UNIT_WIN", p)) {
5155 log_deprecation(_("Deprecated event type E_UNIT_WIN in client options."));
5156 p = "E_UNIT_WIN_DEF";
5157 }
5158 event = event_type_by_name(p, strcmp);
5159 if (!event_type_is_valid(event)) {
5160 log_error("Event not supported: %s", p);
5161 continue;
5162 }
5163
5165 "messages.event%d.where", i)) {
5166 log_error("Corruption in file %s: %s",
5167 secfile_name(file), secfile_error());
5168 }
5169 }
5170}
5172/************************************************************************/
5176static void message_options_save(struct section_file *file,
5177 const char *prefix)
5178{
5179 enum event_type event;
5180 int i = 0;
5181
5182 for (event = event_type_begin(); event != event_type_end();
5183 event = event_type_next(event)) {
5185 "messages.event%d.name", i);
5187 "messages.event%d.where", i);
5188 i++;
5189 }
5190
5191 secfile_insert_int(file, i, "messages.count");
5193
5194/************************************************************************/
5197static void load_cma_preset(struct section_file *file, int i)
5198{
5199 struct cm_parameter parameter;
5200 const char *name =
5201 secfile_lookup_str_default(file, "preset",
5202 "cma.preset%d.name", i);
5203
5204 /* Init correct default values even for the fields that are not
5205 * loaded below. */
5206 cm_init_parameter(&parameter);
5207
5209 parameter.minimal_surplus[o] =
5210 secfile_lookup_int_default(file, 0, "cma.preset%d.minsurp%d", i, o);
5211 parameter.factor[o] =
5212 secfile_lookup_int_default(file, 0, "cma.preset%d.factor%d", i, o);
5214 parameter.require_happy =
5215 secfile_lookup_bool_default(file, FALSE, "cma.preset%d.reqhappy", i);
5216 parameter.happy_factor =
5217 secfile_lookup_int_default(file, 0, "cma.preset%d.happyfactor", i);
5218 parameter.allow_disorder = FALSE;
5219 parameter.allow_specialists = TRUE;
5220
5221 cmafec_preset_add(name, &parameter);
5223
5224/************************************************************************/
5227static void save_cma_preset(struct section_file *file, int i)
5228{
5229 const struct cm_parameter *const pparam = cmafec_preset_get_parameter(i);
5231
5232 secfile_insert_str(file, name, "cma.preset%d.name", i);
5233
5235 secfile_insert_int(file, pparam->minimal_surplus[o],
5236 "cma.preset%d.minsurp%d", i, o);
5237 secfile_insert_int(file, pparam->factor[o],
5238 "cma.preset%d.factor%d", i, o);
5240 secfile_insert_bool(file, pparam->require_happy,
5241 "cma.preset%d.reqhappy", i);
5242 secfile_insert_int(file, pparam->happy_factor,
5243 "cma.preset%d.happyfactor", i);
5245
5246/************************************************************************/
5249static void save_cma_presets(struct section_file *file)
5250{
5251 int i;
5252
5254 _("If you add a preset by hand,"
5255 " also update \"number_of_presets\""),
5256 "cma.number_of_presets");
5257 for (i = 0; i < cmafec_preset_num(); i++) {
5259 }
5262/* Old rc file name. */
5263#define OLD_OPTION_FILE_NAME ".civclientrc"
5264/* New rc file name. */
5265#define MID_OPTION_FILE_NAME ".freeciv-client-rc-%d.%d"
5266#define NEW_OPTION_FILE_NAME "freeciv-client-rc-%d.%d"
5268/* The first version the new option name appeared (2.6). */
5269#define FIRST_MAJOR_NEW_OPTION_FILE_NAME 2
5270#define FIRST_MINOR_NEW_OPTION_FILE_NAME 6
5271/* The first version the mid option name appeared (2.2). */
5272#define FIRST_MAJOR_MID_OPTION_FILE_NAME 2
5273#define FIRST_MINOR_MID_OPTION_FILE_NAME 2
5274/* The first version the new boolean values appeared (2.3). */
5275#define FIRST_MAJOR_NEW_BOOLEAN 2
5276#define FIRST_MINOR_NEW_BOOLEAN 3
5277
5278/************************************************************************/
5285static const char *get_current_option_file_name(void)
5286{
5287 static char name_buffer[256];
5288 const char *name;
5289
5290 name = getenv("FREECIV_OPT");
5291
5292 if (name) {
5294 } else {
5295#ifdef OPTION_FILE_NAME
5297#else
5299 if (!name) {
5300 log_error(_("Cannot find freeciv storage directory"));
5301 return NULL;
5302 }
5306#endif /* OPTION_FILE_NAME */
5307 }
5308 log_verbose("settings file is %s", name_buffer);
5309 return name_buffer;
5310}
5311
5312/************************************************************************/
5320static const char *get_last_option_file_name(bool *allow_digital_boolean)
5321{
5322 static char name_buffer[256];
5323 const char *name;
5324 static int last_minors[] = {
5325 0, /* There was no 0.x releases */
5326 14, /* 1.14 */
5327 6 /* 2.6 */
5328 };
5329
5330#if MINOR_VERSION >= 90
5332#else
5334#endif
5335
5336 *allow_digital_boolean = FALSE;
5337 name = getenv("FREECIV_OPT");
5338 if (name) {
5340 } else {
5341#ifdef OPTION_FILE_NAME
5343#else
5344 int major, minor;
5345 struct stat buf;
5346
5348 if (name == NULL) {
5349 log_error(_("Cannot find freeciv storage directory"));
5350
5351 return NULL;
5352 }
5353
5359 : minor >= 0); minor--) {
5362 if (0 == fc_stat(name_buffer, &buf)) {
5365 log_normal(_("Didn't find '%s' option file, "
5366 "loading from '%s' instead."),
5368 name_buffer + strlen(name) + 1);
5369 }
5370
5371 return name_buffer;
5372 }
5373 }
5374 minor = last_minors[major - 1];
5375 }
5376
5377 /* Older versions had options file in user home directory */
5378 name = user_home_dir();
5379 if (name == NULL) {
5380 log_error(_("Cannot find your home directory"));
5381
5382 return NULL;
5383 }
5384
5385 /* minor having max value of FIRST_MINOR_NEW_OPTION_FILE_NAME
5386 * works since MID versioning scheme was used within major version 2
5387 * only (2.2 - 2.6) so the last minor is bigger than any earlier minor. */
5391 minor--) {
5394 if (0 == fc_stat(name_buffer, &buf)) {
5395 log_normal(_("Didn't find '%s' option file, "
5396 "loading from '%s' instead."),
5398 name_buffer + strlen(name) + 1);
5399
5401 *allow_digital_boolean = TRUE;
5402 }
5403 return name_buffer;
5404 }
5405 }
5406
5407 /* Try with the old one. */
5410 if (0 == fc_stat(name_buffer, &buf)) {
5411 log_normal(_("Didn't find '%s' option file, "
5412 "loading from '%s' instead."),
5415 *allow_digital_boolean = TRUE;
5416 return name_buffer;
5417 } else {
5418 return NULL;
5419 }
5420#endif /* OPTION_FILE_NAME */
5421 }
5422 log_verbose("settings file is %s", name_buffer);
5423 return name_buffer;
5424}
5425#undef OLD_OPTION_FILE_NAME
5426#undef MID_OPTION_FILE_NAME
5427#undef NEW_OPTION_FILE_NAME
5428#undef FIRST_MAJOR_NEW_OPTION_FILE_NAME
5429#undef FIRST_MINOR_NEW_OPTION_FILE_NAME
5430#undef FIRST_MAJOR_MID_OPTION_FILE_NAME
5431#undef FIRST_MINOR_MID_OPTION_FILE_NAME
5432#undef FIRST_MINOR_NEW_BOOLEAN
5435/****************************************************************************
5436 Desired settable options.
5437****************************************************************************/
5438#define SPECHASH_TAG settable_options
5439#define SPECHASH_ASTR_KEY_TYPE
5440#define SPECHASH_ASTR_DATA_TYPE
5441#include "spechash.h"
5442#define settable_options_hash_iterate(hash, name, value) \
5443 TYPED_HASH_ITERATE(const char *, const char *, hash, name, value)
5444#define settable_options_hash_iterate_end HASH_ITERATE_END
5445
5447
5448/************************************************************************/
5451static void settable_options_load(struct section_file *sf)
5452{
5453 char buf[64];
5454 const struct section *psection;
5455 const struct entry_list *entries;
5456 const char *string;
5457 bool bval;
5458 int ival;
5459
5461
5463
5464 psection = secfile_section_by_name(sf, "server");
5465 if (NULL == psection) {
5466 /* Does not exist! */
5467 return;
5468 }
5469
5470 entries = section_entries(psection);
5472 string = NULL;
5473 switch (entry_type_get(pentry)) {
5474 case ENTRY_BOOL:
5475 if (entry_bool_get(pentry, &bval)) {
5476 fc_strlcpy(buf, bval ? "enabled" : "disabled", sizeof(buf));
5477 string = buf;
5478 }
5479 break;
5480
5481 case ENTRY_INT:
5482 if (entry_int_get(pentry, &ival)) {
5483 fc_snprintf(buf, sizeof(buf), "%d", ival);
5484 string = buf;
5485 }
5486 break;
5487
5488 case ENTRY_STR:
5489 (void) entry_str_get(pentry, &string);
5490 break;
5491
5492 case ENTRY_FLOAT:
5494 /* Not supported yet */
5495 break;
5496 case ENTRY_LONG_COMMENT:
5498 break;
5499 case ENTRY_ILLEGAL:
5501 break;
5502 }
5503
5504 if (NULL == string) {
5505 log_error("Entry type variant of \"%s.%s\" is not supported.",
5506 section_name(psection), entry_name(pentry));
5507 continue;
5508 }
5509
5511 string);
5514
5515/************************************************************************/
5518static void settable_options_save(struct section_file *sf)
5519{
5521
5523 if (!fc_strcasecmp(name, "gameseed") || !fc_strcasecmp(name, "mapseed")) {
5524 /* Do not save mapseed or gameseed. */
5525 continue;
5526 }
5527 if (!fc_strcasecmp(name, "topology")) {
5528 /* client_start_server() sets topology based on tileset. Don't store
5529 * its choice. The tileset is already stored. Storing topology leads
5530 * to all sort of breakage:
5531 * - it breaks ruleset default topology.
5532 * - it interacts badly with tileset ruleset change, ruleset tileset
5533 * change and topology tileset change.
5534 * - its value is probably based on what tileset was loaded when
5535 * client_start_server() decided to set topology, not on player
5536 * choice.
5537 */
5538 continue;
5539 }
5540 secfile_insert_str(sf, value, "server.%s", name);
5542}
5544/************************************************************************/
5549{
5550 char val_buf[1024], def_buf[1024];
5551 const char *value, *def_val;
5552
5554
5557
5558 if (srv->setdef != SETDEF_CHANGED) {
5559 /* Some level default - do not store */
5562 } else {
5563 value = NULL;
5564 def_val = NULL;
5565 switch (option_type(poption)) {
5566 case OT_BOOLEAN:
5567 fc_strlcpy(val_buf, option_bool_get(poption) ? "enabled" : "disabled",
5568 sizeof(val_buf));
5569 value = val_buf;
5570 fc_strlcpy(def_buf, option_bool_def(poption) ? "enabled" : "disabled",
5571 sizeof(def_buf));
5572 def_val = def_buf;
5573 break;
5574 case OT_INTEGER:
5576 value = val_buf;
5578 def_val = def_buf;
5579 break;
5580 case OT_STRING:
5583 break;
5584 case OT_ENUM:
5586 break;
5587 case OT_BITWISE:
5589 def_buf, sizeof(def_buf));
5590 value = val_buf;
5591 def_val = def_buf;
5592 break;
5593 case OT_FONT:
5594 case OT_COLOR:
5595 case OT_VIDEO_MODE:
5596 break;
5597 }
5598
5599 if (NULL == value || NULL == def_val) {
5600 log_error("Option type %s (%d) not supported for '%s'.",
5603 continue;
5604 }
5605
5608 }
5610}
5612/************************************************************************/
5617 const char *op_value,
5618 bool allow_replace)
5619{
5621
5622 if (allow_replace) {
5624 } else {
5626 }
5627}
5629/************************************************************************/
5633static bool settable_option_upgrade_value(const struct option *poption,
5634 int old_value,
5635 char *buf, size_t buf_len)
5636{
5637 const char *name = option_name(poption);
5638
5639#define SETTING_CASE(ARG_name, ...) \
5640 if (0 == strcmp(ARG_name, name)) { \
5641 static const char *values[] = { __VA_ARGS__ }; \
5642 if (0 <= old_value && old_value < ARRAY_SIZE(values) \
5643 && NULL != values[old_value]) { \
5644 fc_strlcpy(buf, values[old_value], buf_len); \
5645 return TRUE; \
5646 } else { \
5647 return FALSE; \
5648 } \
5649 }
5650
5651 SETTING_CASE("topology", "", "WRAPX", "WRAPY", "WRAPX|WRAPY", "ISO",
5652 "WRAPX|ISO", "WRAPY|ISO", "WRAPX|WRAPY|ISO", "HEX",
5653 "WRAPX|HEX", "WRAPY|HEX", "WRAPX|WRAPY|HEX", "ISO|HEX",
5654 "WRAPX|ISO|HEX", "WRAPY|ISO|HEX", "WRAPX|WRAPY|ISO|HEX");
5655 SETTING_CASE("generator", NULL, "RANDOM", "FRACTAL", "ISLAND");
5656 SETTING_CASE("startpos", "DEFAULT", "SINGLE", "2or3", "ALL", "VARIABLE");
5657 SETTING_CASE("borders", "DISABLED", "ENABLED", "SEE_INSIDE", "EXPAND");
5658 SETTING_CASE("diplomacy", "ALL", "HUMAN", "AI", "TEAM", "DISABLED");
5659 SETTING_CASE("citynames", "NO_RESTRICTIONS", "PLAYER_UNIQUE",
5660 "GLOBAL_UNIQUE", "NO_STEALING");
5661 SETTING_CASE("barbarians", "DISABLED", "HUTS_ONLY", "NORMAL", "FREQUENT",
5662 "HORDES");
5663 SETTING_CASE("phasemode", "ALL", "PLAYER", "TEAM");
5664 SETTING_CASE("compresstype", "PLAIN", "LIBZ", "BZIP2");
5665
5666#undef SETTING_CASE
5667 return FALSE;
5669
5670/************************************************************************/
5673static void desired_settable_option_send(struct option *poption)
5674{
5675 char *desired;
5676 int value;
5677
5679
5682 /* No change explicitly desired. */
5683 return;
5684 }
5685
5686 switch (option_type(poption)) {
5687 case OT_BOOLEAN:
5688 if ((0 == fc_strcasecmp("enabled", desired)
5689 || (str_to_int(desired, &value) && 1 == value))
5690 && !option_bool_get(poption)) {
5691 send_chat_printf("/set %s enabled", option_name(poption));
5692 } else if ((0 == fc_strcasecmp("disabled", desired)
5693 || (str_to_int(desired, &value) && 0 == value))
5695 send_chat_printf("/set %s disabled", option_name(poption));
5696 }
5697 return;
5698 case OT_INTEGER:
5700 send_chat_printf("/set %s %d", option_name(poption), value);
5701 }
5702 return;
5703 case OT_STRING:
5704 if (0 != strcmp(desired, option_str_get(poption))) {
5705 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5706 }
5707 return;
5708 case OT_ENUM:
5709 {
5710 char desired_buf[256];
5711 const char *value_str;
5712
5713 /* Handle old values. */
5714 if (str_to_int(desired, &value)
5716 sizeof(desired_buf))) {
5718 }
5719
5721 if (0 != strcmp(desired, value_str)) {
5722 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5723 }
5724 }
5725 return;
5726 case OT_BITWISE:
5727 {
5728 char desired_buf[256], value_buf[256];
5729
5730 /* Handle old values. */
5731 if (str_to_int(desired, &value)
5733 sizeof(desired_buf))) {
5735 }
5736
5738 sizeof(value_buf), NULL, 0);
5739 if (0 != strcmp(desired, value_buf)) {
5740 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5741 }
5742 }
5743 return;
5744 case OT_FONT:
5745 case OT_COLOR:
5746 case OT_VIDEO_MODE:
5747 break;
5748 }
5749
5750 log_error("Option type %s (%d) not supported for '%s'.",
5753}
5755/************************************************************************/
5760{
5763 (void) value; /* Silence compiler warning about unused variable */
5765
5766 if (poption != NULL) {
5768
5769 /* We only sent the option if it has been sent already in the past.
5770 * Otherwise we leave it for that "initial" sending functionality
5771 * to send it. That has the benefit that the initial send (can) check
5772 * that server is not currently using value from the savegame that
5773 * we should not override */
5774 if (psoption->desired_sent) {
5775 /* Keep this list of conditions in sync with one in
5776 * handle_server_setting_common()
5777 * For lacking initial_setting check here, see comment above about
5778 * checking psoption->desired_sent. */
5779 if (psoption->is_visible
5780 && psoption->is_changeable) {
5783 }
5784 }
5785 }
5787 }
5788}
5789
5790
5791/****************************************************************************
5792 City and player report dialog options.
5793****************************************************************************/
5794#define SPECHASH_TAG dialog_options
5795#define SPECHASH_ASTR_KEY_TYPE
5796#define SPECHASH_IDATA_TYPE bool
5797#define SPECHASH_UDATA_TO_IDATA FC_INT_TO_PTR
5798#define SPECHASH_IDATA_TO_UDATA FC_PTR_TO_INT
5799#define SPECHASH_VPTR_TO_IDATA FC_PTR_TO_INT
5800#include "spechash.h"
5801#define dialog_options_hash_iterate(hash, column, visible) \
5802 TYPED_HASH_ITERATE(const char *, intptr_t, hash, column, visible)
5803#define dialog_options_hash_iterate_end HASH_ITERATE_END
5804
5806
5807/************************************************************************/
5810static void options_dialogs_load(struct section_file *sf)
5811{
5812 const struct entry_list *entries;
5813 const char *prefixes[] = { "player_dlg_", "city_report_", NULL };
5814 const char **prefix;
5815 bool visible;
5816
5818
5820
5821 if (NULL != entries) {
5823 for (prefix = prefixes; NULL != *prefix; prefix++) {
5824 if (!fc_strncmp(*prefix, entry_name(pentry), strlen(*prefix))
5825 && secfile_lookup_bool(sf, &visible, "client.%s",
5826 entry_name(pentry))) {
5829 break;
5830 }
5831 }
5833 }
5835
5836/************************************************************************/
5839static void options_dialogs_save(struct section_file *sf)
5840{
5842
5845 secfile_insert_bool(sf, visible, "client.%s", column);
5847}
5848
5849/************************************************************************/
5854void options_dialogs_update(void)
5855{
5856 char buf[64];
5857 int i;
5858
5860
5861 /* Player report dialog options. */
5862 for (i = 1; i < num_player_dlg_columns; i++) {
5863 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5864 player_dlg_columns[i].tagname);
5867 }
5868
5869 /* City report dialog options. */
5870 for (i = 0; i < num_city_report_spec(); i++) {
5871 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5875 }
5876}
5878/************************************************************************/
5882void options_dialogs_set(void)
5883{
5884 char buf[64];
5885 bool visible;
5886 int i;
5887
5889
5890 /* Player report dialog options. */
5891 for (i = 1; i < num_player_dlg_columns; i++) {
5892 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5893 player_dlg_columns[i].tagname);
5896 }
5897 }
5898
5899 /* City report dialog options. */
5900 for (i = 0; i < num_city_report_spec(); i++) {
5901 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5905 }
5906 }
5907}
5908
5909/************************************************************************/
5915void options_load(void)
5916{
5917 struct section_file *sf;
5919 int i, num;
5920 const char *name;
5921 const char *const prefix = "client";
5922 const char *str;
5923
5925 if (!name) {
5926 log_normal(_("Didn't find the option file. Creating a new one."));
5930 return;
5931 }
5932 if (!(sf = secfile_load(name, TRUE))) {
5933 log_debug("Error loading option file '%s':\n%s", name, secfile_error());
5934 /* Try to create the rc file */
5935 sf = secfile_new(TRUE);
5936 secfile_insert_str(sf, VERSION_STRING, "client.version");
5937
5940 save_cma_presets(sf);
5941
5942 /* FIXME: need better messages */
5943 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
5944 log_error(_("Save failed, cannot write to file %s"), name);
5945 } else {
5946 log_normal(_("Saved settings to file %s"), name);
5947 }
5948 secfile_destroy(sf);
5950 return;
5951 }
5953
5954 /* A "secret" option for the lazy. TODO: make this saveable */
5956 secfile_lookup_str_default(sf, "", "%s.password", prefix));
5957
5960 "%s.save_options_on_exit", prefix);
5963 "%s.fullscreen_mode", prefix);
5964
5965 /* Settings migrations */
5968 "%s.migration_gtk3_from_gtk2", prefix);
5971 "%s.migration_gtk3_22_from_gtk3", prefix);
5974 "%s.migration_gtk4_from_gtk3_22", prefix);
5977 "%s.migration_sdl2_from_sdl", prefix);
5980 "%s.migration_sdl3_from_sdl2", prefix);
5983 "%s.migration_gtk2_from_2_5", prefix);
5986 "%s.migration_gtk3_from_2_5", prefix);
5989 "%s.migration_qt_from_2_5", prefix);
5990
5991 /* Flag values */
5994 "%s.flag_qt_default_fonts_set", prefix);
5997 "%s.flag_sdl2_default_screen_size_set", prefix);
6000 "%s.flag_sdl3_default_screen_size_set", prefix);
6001
6002 /* These are not gui-enabled yet */
6004 = secfile_lookup_bool_default(sf, FALSE, "%s.zoom_set", prefix);
6007 "%s.zoom_default_level", prefix);
6008
6011 "%s.gui_qt_show_relations_panel", prefix);
6014 "%s.gui_qt_show_techs_panel", prefix);
6017 "%s.gui_qt_show_wonders_panel", prefix);
6018
6019 /* default_tileset_name present until freeciv-3.2 */
6020 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_name");
6021 if (str == NULL) {
6023 "client.default_topology");
6024 } else {
6026 }
6027 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_overhead_name");
6028 if (str != NULL) {
6030 }
6031 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_iso_name");
6032 if (str != NULL) {
6034 }
6035
6036 /* Backwards compatibility for removed options replaced by entirely "new"
6037 * options. The equivalent "new" option will override these, if set. */
6038
6039 /* Renamed in 2.6 */
6041 "%s.popup_caravan_arrival", prefix);
6042
6043 /* Load all the regular options */
6047
6048 /* More backwards compatibility, for removed options that had been
6049 * folded into then-existing options. Here, the backwards-compatibility
6050 * behaviour overrides the "destination" option. */
6051
6052 /* Removed in 2.4 */
6054 "%s.do_combat_animation", prefix)) {
6056 }
6057
6058 message_options_load(sf, prefix);
6060
6061 /* Load cma presets. If cma.number_of_presets doesn't exist, don't load
6062 * any, the order here should be reversed to keep the order the same */
6063 if (secfile_lookup_int(sf, &num, "cma.number_of_presets")) {
6064 for (i = num - 1; i >= 0; i--) {
6065 load_cma_preset(sf, i);
6066 }
6067 } else {
6069 }
6070
6073
6074 secfile_destroy(sf);
6077
6078/************************************************************************/
6082 const char *msg, ...)
6083{
6084 va_list args;
6085
6086 va_start(args, msg);
6088 va_end(args);
6090
6091/************************************************************************/
6095{
6096 struct section_file *sf;
6097 const char *name = get_current_option_file_name();
6098 char dir_name[2048];
6099 int i;
6100
6101 if (log_cb == NULL) {
6102 /* Default callback */
6104 }
6105
6106 if (!name) {
6107 log_cb(LOG_ERROR, _("Save failed, cannot find a filename."));
6108 return;
6109 }
6110
6111 sf = secfile_new(TRUE);
6112 secfile_insert_str(sf, VERSION_STRING, "client.version");
6113
6115 "client.save_options_on_exit");
6117 "deprecated", "client.fullscreen_mode");
6118
6119 /* Migrations */
6121 "client.migration_gtk3_from_gtk2");
6123 "client.migration_gtk3_22_from_gtk3");
6125 "client.migration_gtk4_from_gtk3_22");
6127 "client.migration_sdl2_from_sdl");
6129 "client.migration_sdl3_from_sdl2");
6131 "client.migration_gtk2_from_2_5");
6133 "client.migration_gtk3_from_2_5");
6135 "client.migration_qt_from_2_5");
6136
6137 /* Flag */
6139 "client.flag_qt_default_fonts_set");
6141 "client.flag_sdl2_default_screen_size_set");
6143 "client.flag_sdl3_default_screen_size_set");
6144
6145 /* gui-enabled options */
6150 /* Once options have been migrated from a client that no longer exist to a newer client,
6151 * there's no use for those settings of dropped client any more, so no point in saving them. */
6153 }
6155
6156 /* These are not gui-enabled yet. */
6157 secfile_insert_bool(sf, gui_options.zoom_set, "client.zoom_set");
6159 "client.zoom_default_level");
6160
6162 "client.gui_qt_show_relations_panel");
6164 "client.gui_qt_show_techs_panel");
6166 "client.gui_qt_show_wonders_panel");
6167
6168 if (tileset != NULL) {
6170 "client.default_topology");
6171 } else {
6173 "client.default_topology");
6174 }
6175
6176 message_options_save(sf, "client");
6178
6179 /* Server settings */
6180 save_cma_presets(sf);
6182
6183 /* Insert global worklists */
6185
6186 /* Directory name */
6188 for (i = strlen(dir_name) - 1 ; dir_name[i] != DIR_SEPARATOR_CHAR && i >= 0; i--) {
6189 /* Nothing */
6190 }
6191
6192 if (i > 0) {
6193 dir_name[i] = '\0';
6194 if (!make_dir(dir_name)) {
6195 log_cb(LOG_ERROR, _("Saving options failed, cannot create directory %s"),
6196 dir_name);
6197 secfile_destroy(sf);
6198 return;
6199 }
6200 }
6201
6202 /* Save to disk */
6203 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
6204 log_cb(LOG_ERROR, _("Saving options failed, cannot write to file %s"), name);
6205 } else {
6206 log_cb(LOG_VERBOSE, _("Saved options to file %s"), name);
6207 }
6208 secfile_destroy(sf);
6210
6211/************************************************************************/
6214static void options_init_names(const struct copt_val_name *(*acc)(int),
6215 struct strvec **support, struct strvec **pretty)
6216{
6217 int val;
6218 const struct copt_val_name *name;
6219
6221 *support = strvec_new();
6222 *pretty = strvec_new();
6223 for (val = 0; (name = acc(val)); val++) {
6224 strvec_append(*support, name->support);
6225 strvec_append(*pretty, name->pretty);
6226 }
6228
6229/************************************************************************/
6232void options_init(void)
6233{
6237
6240
6243
6244 switch (option_type(poption)) {
6245 case OT_INTEGER:
6252
6253 log_error("option %s has default value of %d, which is "
6254 "out of its range [%d; %d], changing to %d.",
6257 new_default);
6258 *((int *) &(pcoption->integer.def)) = new_default;
6259 }
6260 break;
6261
6262 case OT_STRING:
6264 /* Hack to get a default value. */
6265 *((const char **) &(pcoption->string.def)) =
6267 }
6268
6269 if (NULL == option_str_def(poption)) {
6270 const struct strvec *values = option_str_values(poption);
6271
6272 if (NULL == values || strvec_size(values) == 0) {
6273 log_error("Invalid NULL default string for option %s.",
6275 } else {
6276 *((const char **) &(pcoption->string.def)) =
6277 strvec_get(values, 0);
6278 }
6279 }
6280 break;
6281
6282 case OT_ENUM:
6283 fc_assert(NULL == pcoption->enumerator.support_names);
6284 fc_assert(NULL == pcoption->enumerator.pretty_names);
6285 options_init_names(pcoption->enumerator.name_accessor,
6286 &pcoption->enumerator.support_names,
6287 &pcoption->enumerator.pretty_names);
6288 fc_assert(NULL != pcoption->enumerator.support_names);
6289 fc_assert(NULL != pcoption->enumerator.pretty_names);
6290 break;
6291
6292 case OT_BITWISE:
6293 fc_assert(NULL == pcoption->bitwise.support_names);
6294 fc_assert(NULL == pcoption->bitwise.pretty_names);
6295 options_init_names(pcoption->bitwise.name_accessor,
6296 &pcoption->bitwise.support_names,
6297 &pcoption->bitwise.pretty_names);
6298 fc_assert(NULL != pcoption->bitwise.support_names);
6299 fc_assert(NULL != pcoption->bitwise.pretty_names);
6300 break;
6301
6302 case OT_COLOR:
6303 {
6304 /* Duplicate the string pointers. */
6305 struct ft_color *pcolor = pcoption->color.pvalue;
6306
6307 if (NULL != pcolor->foreground) {
6308 pcolor->foreground = fc_strdup(pcolor->foreground);
6309 }
6310 if (NULL != pcolor->background) {
6311 pcolor->background = fc_strdup(pcolor->background);
6312 }
6313 }
6314 break;
6315
6316 case OT_BOOLEAN:
6317 case OT_FONT:
6318 case OT_VIDEO_MODE:
6319 break;
6320 }
6321
6322 /* Set to default. */
6326
6327/************************************************************************/
6330void options_free(void)
6331{
6334
6336
6337 switch (option_type(poption)) {
6338 case OT_ENUM:
6339 fc_assert_action(NULL != pcoption->enumerator.support_names, break);
6340 strvec_destroy(pcoption->enumerator.support_names);
6341 pcoption->enumerator.support_names = NULL;
6342 fc_assert_action(NULL != pcoption->enumerator.pretty_names, break);
6343 strvec_destroy(pcoption->enumerator.pretty_names);
6344 pcoption->enumerator.pretty_names = NULL;
6345 break;
6346
6347 case OT_BITWISE:
6348 fc_assert_action(NULL != pcoption->bitwise.support_names, break);
6349 strvec_destroy(pcoption->bitwise.support_names);
6350 pcoption->bitwise.support_names = NULL;
6351 fc_assert_action(NULL != pcoption->bitwise.pretty_names, break);
6352 strvec_destroy(pcoption->bitwise.pretty_names);
6353 pcoption->bitwise.pretty_names = NULL;
6354 break;
6355
6356 case OT_BOOLEAN:
6357 case OT_INTEGER:
6358 case OT_STRING:
6359 case OT_FONT:
6360 case OT_COLOR:
6361 case OT_VIDEO_MODE:
6362 break;
6363 }
6365
6366 if (NULL != settable_options_hash) {
6369 }
6370
6371 if (NULL != dialog_options_hash) {
6374 }
6375
6378}
6380/************************************************************************/
6384static void reqtree_show_icons_callback(struct option *poption)
6385{
6388
6389/************************************************************************/
6392static void view_option_changed_callback(struct option *poption)
6393{
6394 menus_init();
6397
6398/************************************************************************/
6401static void manual_turn_done_callback(struct option *poption)
6402{
6404
6406 struct player *pplayer = client_player();
6407
6408 if (pplayer != NULL && is_ai(pplayer)
6409 && can_end_turn()) {
6411 }
6412 }
6414
6415/****************************************************************************
6416 Callback for changing music volume
6417****************************************************************************/
6418static void sound_volume_callback(struct option *poption)
6419{
6422
6423/************************************************************************/
6426static void voteinfo_bar_callback(struct option *poption)
6427{
6430
6431/************************************************************************/
6434static void font_changed_callback(struct option *poption)
6435{
6439
6440/************************************************************************/
6443static void mapimg_changed_callback(struct option *poption)
6444{
6446#ifndef FREECIV_NDEBUG
6447 bool success;
6448#endif
6449
6450 log_normal("Error setting the value for %s (%s). Restoring the default "
6451 "value.", option_name(poption), mapimg_error());
6452
6453 /* Reset the value to the default value. */
6454#ifndef FREECIV_NDEBUG
6455 success =
6456#endif
6458
6460 "Failed to reset the option \"%s\".",
6462#ifndef FREECIV_NDEBUG
6463 success =
6464#endif
6466
6468 "Failed to restore mapimg definition for option \"%s\".",
6470 }
6472
6473/************************************************************************/
6476static void game_music_enable_callback(struct option *poption)
6477{
6478 if (client_state() == C_S_RUNNING) {
6481 } else {
6483 }
6484 }
6486
6487/************************************************************************/
6490static void menu_music_enable_callback(struct option *poption)
6491{
6492 if (client_state() != C_S_RUNNING) {
6494 start_menu_music("music_menu", NULL);
6495 } else {
6497 }
6498 }
6500
6501/************************************************************************/
6504bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
6505{
6506 return (2 < fc_snprintf(buf, buf_len, "%dx%d", mode->width, mode->height));
6508
6509/************************************************************************/
6512bool string_to_video_mode(const char *buf, struct video_mode *mode)
6513{
6514 return (2 == sscanf(buf, "%dx%d", &mode->width, &mode->height));
6516
6517/************************************************************************/
6520static const struct strvec *get_mapimg_format_list(const struct option *poption)
6521{
6522 return mapimg_get_format_list();
6524
6525/************************************************************************/
6528const char *tileset_name_for_topology(int topology_id)
6529{
6530 const char *tsn = NULL;
6531
6532 switch (topology_id & (TF_ISO | TF_HEX)) {
6533 case 0:
6534 case TF_ISO:
6536 break;
6537 case TF_HEX:
6539 break;
6540 case TF_ISO | TF_HEX:
6542 break;
6543 }
6544
6545 if (tsn == NULL) {
6547 }
6548
6549 return tsn;
6551
6552/************************************************************************/
6555void option_set_default_ts(struct tileset *t)
6556{
6557 const char *optname = "<not set>";
6558 struct option *opt;
6559
6560 switch (tileset_topo_index(t)) {
6561 case TS_TOPO_SQUARE:
6562 /* Overhead */
6563 optname = "default_tileset_square_name";
6564 break;
6565 case TS_TOPO_HEX:
6566 /* Hex */
6567 optname = "default_tileset_hex_name";
6568 break;
6569 case TS_TOPO_ISOHEX:
6570 /* Isohex */
6571 optname = "default_tileset_isohex_name";
6572 break;
6573 }
6574
6576
6577 if (opt == NULL) {
6578 log_error("Unknown option name \"%s\" in option_set_default_ts()", optname);
6579 return;
6580 }
6581
6582 /* Do not call option_str_set() since we don't want option changed callback
6583 * to reload this tileset. */
6584 opt->str_vtable->set(opt, tileset_basename(t));
6587
6588/************************************************************************/
6591static bool is_ts_option_unset(const char *optname)
6592{
6593 struct option *opt;
6594 const char *val;
6595
6597
6598 if (opt == NULL) {
6599 return TRUE;
6600 }
6601
6602 val = opt->str_vtable->get(opt);
6603
6604 if (val == NULL || val[0] == '\0') {
6605 return TRUE;
6606 }
6607
6608 return FALSE;
6610
6611/************************************************************************/
6614void fill_topo_ts_default(void)
6615{
6616 if (is_ts_option_unset("default_tileset_square_name")) {
6617 if (gui_options.default_tileset_iso_name[0] != '\0') {
6621 } else if (gui_options.default_tileset_overhead_name[0] != '\0') {
6625 } else {
6626 log_debug("Setting tileset for square topologies.");
6628 }
6629 }
6630 if (is_ts_option_unset("default_tileset_hex_name")) {
6631 log_debug("Setting tileset for hex topology.");
6633 }
6634 if (is_ts_option_unset("default_tileset_isohex_name")) {
6635 log_debug("Setting tileset for isohex topology.");
6637 }
6638}
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
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:70
void option_gui_remove(struct option *poption)
Definition optiondlg.c:1041
void option_dialog_popdown(const struct option_set *poptset)
Definition optiondlg.c:986
void option_gui_update(struct option *poption)
Definition optiondlg.c:1013
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:3361
void handle_server_setting_const(const struct packet_server_setting_const *packet)
Definition options.c:4295
void handle_server_setting_int(const struct packet_server_setting_int *packet)
Definition options.c:4389
static int server_option_int_max(const struct option *poption)
Definition options.c:4820
static bool client_option_font_set(struct option *poption, const char *font)
Definition options.c:3730
unsigned option_bitwise_mask(const struct option *poption)
Definition options.c:1096
void fill_topo_ts_default(void)
Definition options.c:6609
#define FIRST_MAJOR_MID_OPTION_FILE_NAME
Definition options.c:5267
#define client_options_iterate_all_end
Definition options.c:3323
static const struct strvec * server_option_str_values(const struct option *poption)
Definition options.c:4864
static int client_option_enum_get(const struct option *poption)
Definition options.c:3589
void resend_desired_settable_options(void)
Definition options.c:5754
const struct strvec * option_str_values(const struct option *poption)
Definition options.c:915
static void desired_settable_option_send(struct option *poption)
Definition options.c:5668
static const char * client_option_name(const struct option *poption)
Definition options.c:3415
static int sync_serial
Definition options.c:402
static unsigned server_option_bitwise_def(const struct option *poption)
Definition options.c:4959
#define FIRST_MAJOR_NEW_OPTION_FILE_NAME
Definition options.c:5264
static const struct option_video_mode_vtable client_option_video_mode_vtable
Definition options.c:1406
#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd)
Definition options.c:1583
static struct dialog_options_hash * dialog_options_hash
Definition options.c:5800
void option_changed(struct option *poption)
Definition options.c:748
static void menu_music_enable_callback(struct option *poption)
Definition options.c:6485
static bool options_fully_initialized
Definition options.c:400
static const struct option_str_vtable client_option_str_vtable
Definition options.c:1340
unsigned option_bitwise_def(const struct option *poption)
Definition options.c:1085
int option_enum_str_to_int(const struct option *poption, const char *str)
Definition options.c:943
static const char * client_option_description(const struct option *poption)
Definition options.c:3423
int option_int_min(const struct option *poption)
Definition options.c:856
static void option_save_output_window_callback(enum log_level lvl, const char *msg,...)
Definition options.c:6076
static void message_options_save(struct section_file *file, const char *prefix)
Definition options.c:5171
bool option_bool_def(const struct option *poption)
Definition options.c:808
static struct option * client_option_next(const struct option *poption)
Definition options.c:3455
static const char * server_option_name(const struct option *poption)
Definition options.c:4715
const char * option_font_def(const struct option *poption)
Definition options.c:1152
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6523
static const struct copt_val_name * gui_gtk_message_chat_location_name(int value)
Definition options.c:1839
static bool server_option_str_set(struct option *poption, const char *str)
Definition options.c:4873
static const struct copt_val_name * gui_popup_tech_help_name(int value)
Definition options.c:1859
struct option * optset_option_first(const struct option_set *poptset)
Definition options.c:447
static const char * server_optset_category_name(int category)
Definition options.c:4695
const struct option_set * server_optset
Definition options.c:4016
static void view_option_changed_callback(struct option *poption)
Definition options.c:6387
static const char * client_option_font_target(const struct option *poption)
Definition options.c:3721
static void server_option_enum_support_name(const struct option *poption, const char **pvalue, const char **pdefault)
Definition options.c:4933
#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb)
Definition options.c:1545
static const char * server_option_description(const struct option *poption)
Definition options.c:4723
static unsigned server_option_bitwise_get(const struct option *poption)
Definition options.c:4951
static bool client_option_is_changeable(const struct option *poption)
Definition options.c:3447
static int server_option_int_min(const struct option *poption)
Definition options.c:4812
static const char * client_optset_category_name(int category)
Definition options.c:3377
static struct option * server_option_next(const struct option *poption)
Definition options.c:4755
static struct client_option client_options[]
Definition options.c:1886
#define SERVER_OPTION(poption)
Definition options.c:4152
#define OLD_OPTION_FILE_NAME
Definition options.c:5258
static void settable_options_save(struct section_file *sf)
Definition options.c:5513
static bool server_option_bool_get(const struct option *poption)
Definition options.c:4763
bool option_reset(struct option *poption)
Definition options.c:709
void options_free(void)
Definition options.c:6325
const char * option_description(const struct option *poption)
Definition options.c:638
const char * option_help_text(const struct option *poption)
Definition options.c:648
#define settable_options_hash_iterate_end
Definition options.c:5439
static const char * client_option_font_get(const struct option *poption)
Definition options.c:3705
static int server_option_enum_def(const struct option *poption)
Definition options.c:4896
static int server_option_int_def(const struct option *poption)
Definition options.c:4804
#define client_options_iterate_all(poption)
Definition options.c:3314
static int client_option_int_min(const struct option *poption)
Definition options.c:3511
static int server_options_categories_num
Definition options.c:3998
const char * option_enum_get_str(const struct option *poption)
Definition options.c:992
static struct ft_color client_option_color_def(const struct option *poption)
Definition options.c:3754
static const struct strvec * client_option_enum_pretty_names(const struct option *poption)
Definition options.c:3607
static bool server_option_enum_set(struct option *poption, int val)
Definition options.c:4915
static void save_cma_presets(struct section_file *file)
Definition options.c:5244
struct ft_color option_color_get(const struct option *poption)
Definition options.c:1190
static struct video_mode client_option_video_mode_def(const struct option *poption)
Definition options.c:3808
static int client_option_int_get(const struct option *poption)
Definition options.c:3495
static char ** server_options_categories
Definition options.c:3995
int option_enum_get_int(const struct option *poption)
Definition options.c:980
static void settable_options_load(struct section_file *sf)
Definition options.c:5446
int option_number(const struct option *poption)
Definition options.c:618
static struct option * server_optset_option_first(void)
Definition options.c:4679
static struct settable_options_hash * settable_options_hash
Definition options.c:5441
int option_category(const struct option *poption)
Definition options.c:668
static struct server_option * server_options
Definition options.c:3996
static const struct option_int_vtable server_option_int_vtable
Definition options.c:4056
static void options_dialogs_save(struct section_file *sf)
Definition options.c:5834
static struct option_set client_optset_static
Definition options.c:1274
static bool client_option_color_set(struct option *poption, struct ft_color color)
Definition options.c:3763
#define dialog_options_hash_iterate_end
Definition options.c:5798
static void save_cma_preset(struct section_file *file, int i)
Definition options.c:5222
static int client_optset_category_number(void)
Definition options.c:3369
static const char * client_option_str_def(const struct option *poption)
Definition options.c:3553
static bool client_option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:3817
void handle_server_setting_bitwise(const struct packet_server_setting_bitwise *packet)
Definition options.c:4560
static const struct option_font_vtable client_option_font_vtable
Definition options.c:1381
static bool client_option_enum_set(struct option *poption, int val)
Definition options.c:3616
void desired_settable_option_update(const char *op_name, const char *op_value, bool allow_replace)
Definition options.c:5611
void option_set_default_ts(struct tileset *t)
Definition options.c:6550
bool option_str_set(struct option *poption, const char *str)
Definition options.c:926
void handle_server_setting_bool(const struct packet_server_setting_bool *packet)
Definition options.c:4354
static const struct strvec * client_option_str_values(const struct option *poption)
Definition options.c:3563
const struct option_set * client_optset
Definition options.c:1280
static const struct option_bool_vtable server_option_bool_vtable
Definition options.c:4044
static const struct option_bitwise_vtable server_option_bitwise_vtable
Definition options.c:4097
const char * option_name(const struct option *poption)
Definition options.c:628
static const char * client_option_help_text(const struct option *poption)
Definition options.c:3431
static void message_options_init(void)
Definition options.c:5044
static int client_option_number(const struct option *poption)
Definition options.c:3407
void handle_server_setting_str(const struct packet_server_setting_str *packet)
Definition options.c:4426
int option_int_get(const struct option *poption)
Definition options.c:834
static void client_option_save(struct option *poption, struct section_file *sf)
Definition options.c:3935
void options_init(void)
Definition options.c:6227
static int client_option_int_def(const struct option *poption)
Definition options.c:3503
static int server_option_category(const struct option *poption)
Definition options.c:4739
#define FIRST_MINOR_MID_OPTION_FILE_NAME
Definition options.c:5268
static const struct option_enum_vtable client_option_enum_vtable
Definition options.c:1353
static const struct option_str_vtable server_option_str_vtable
Definition options.c:4070
static int server_options_num
Definition options.c:3999
#define handle_server_setting_common(psoption, packet)
Definition options.c:4316
static const struct option_color_vtable client_option_color_vtable
Definition options.c:1393
bool option_enum_set_str(struct option *poption, const char *str)
Definition options.c:1057
static const struct strvec * server_option_enum_pretty(const struct option *poption)
Definition options.c:4906
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:5017
bool option_color_set(struct option *poption, struct ft_color color)
Definition options.c:1213
#define SETTING_CASE(ARG_name,...)
static struct video_mode client_option_video_mode_get(const struct option *poption)
Definition options.c:3799
static bool is_ts_option_unset(const char *optname)
Definition options.c:6586
void option_set_changed_callback(struct option *poption, void(*callback)(struct option *))
Definition options.c:737
#define OPTION(poption)
Definition options.c:563
#define NEW_OPTION_FILE_NAME
Definition options.c:5261
static bool server_option_bool_set(struct option *poption, bool val)
Definition options.c:4780
bool option_bool_set(struct option *poption, bool val)
Definition options.c:819
bool option_is_changeable(const struct option *poption)
Definition options.c:689
#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb)
Definition options.c:1661
bool option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:1253
#define MID_OPTION_FILE_NAME
Definition options.c:5260
static int server_option_number(const struct option *poption)
Definition options.c:4707
#define dialog_options_hash_iterate(hash, column, visible)
Definition options.c:5796
#define FIRST_MINOR_NEW_BOOLEAN
Definition options.c:5271
static const char * server_option_str_get(const struct option *poption)
Definition options.c:4846
#define settable_options_hash_iterate(hash, name, value)
Definition options.c:5437
void option_set_gui_data(struct option *poption, void *data)
Definition options.c:767
#define FIRST_MINOR_NEW_OPTION_FILE_NAME
Definition options.c:5265
#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1509
const char * option_str_get(const struct option *poption)
Definition options.c:893
struct option * optset_option_by_number(const struct option_set *poptset, int id)
Definition options.c:420
static bool client_option_bool_get(const struct option *poption)
Definition options.c:3463
void * option_get_gui_data(const struct option *poption)
Definition options.c:777
static const char * server_option_str_def(const struct option *poption)
Definition options.c:4854
static const struct option_common_vtable client_option_common_vtable
Definition options.c:1300
static bool settable_option_upgrade_value(const struct option *poption, int old_value, char *buf, size_t buf_len)
Definition options.c:5628
const struct strvec * option_enum_values(const struct option *poption)
Definition options.c:1029
static const struct strvec * get_mapimg_format_list(const struct option *poption)
Definition options.c:6515
static void sound_volume_callback(struct option *poption)
Definition options.c:6413
bool option_enum_set_int(struct option *poption, int val)
Definition options.c:1040
bool option_bool_get(const struct option *poption)
Definition options.c:797
int optset_category_number(const struct option_set *poptset)
Definition options.c:457
#define color_set(color_tgt, color)
static bool client_option_bool_def(const struct option *poption)
Definition options.c:3471
static const struct strvec * server_option_bitwise_pretty(const struct option *poption)
Definition options.c:4969
void server_options_init(void)
Definition options.c:4160
enum option_type option_type(const struct option *poption)
Definition options.c:658
static int client_option_enum_def(const struct option *poption)
Definition options.c:3597
const char * option_enum_int_to_str(const struct option *poption, int val)
Definition options.c:965
void options_dialogs_update(void)
Definition options.c:5849
int option_get_cb_data(const struct option *poption)
Definition options.c:787
bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
Definition options.c:6499
static void options_dialogs_load(struct section_file *sf)
Definition options.c:5805
const struct option_set * option_optset(const struct option *poption)
Definition options.c:608
void server_options_free(void)
Definition options.c:4229
struct video_mode option_video_mode_get(const struct option *poption)
Definition options.c:1228
static int server_option_enum_get(const struct option *poption)
Definition options.c:4888
struct option * option_next(const struct option *poption)
Definition options.c:699
static struct option * client_optset_option_by_number(int id)
Definition options.c:3350
static void font_changed_callback(struct option *poption)
Definition options.c:6429
const char * option_str_def(const struct option *poption)
Definition options.c:904
const char * optset_category_name(const struct option_set *poptset, int category)
Definition options.c:467
int option_int_max(const struct option *poption)
Definition options.c:867
#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, odef_bg, ocb)
Definition options.c:1776
const char * option_enum_def_str(const struct option *poption)
Definition options.c:1016
void options_load(void)
Definition options.c:5910
static const char * client_option_str_get(const struct option *poption)
Definition options.c:3545
static const struct option_common_vtable server_option_common_vtable
Definition options.c:4030
static int server_optset_category_number(void)
Definition options.c:4687
static bool client_option_bool_set(struct option *poption, bool val)
Definition options.c:3480
static const char * server_option_help_text(const struct option *poption)
Definition options.c:4731
static const struct option_bool_vtable client_option_bool_vtable
Definition options.c:1314
static bool client_option_load(struct option *poption, struct section_file *sf)
Definition options.c:3834
bool option_font_set(struct option *poption, const char *font)
Definition options.c:1174
static bool server_option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:4998
const char * option_font_target(const struct option *poption)
Definition options.c:1163
static const char * client_option_enum_secfile_str(secfile_data_t data, int val)
Definition options.c:3635
static struct server_option * server_option_next_valid(struct server_option *poption)
Definition options.c:4649
static void server_option_bitwise_support_base(const struct strvec *values, unsigned val, char *buf, size_t buf_len)
Definition options.c:4977
static void voteinfo_bar_callback(struct option *poption)
Definition options.c:6421
static struct option * server_optset_option_by_number(int id)
Definition options.c:4668
void options_save(option_save_log_callback log_cb)
Definition options.c:6089
static void message_options_free(void)
Definition options.c:5082
static const struct option_enum_vtable server_option_enum_vtable
Definition options.c:4083
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6507
const struct strvec * option_bitwise_values(const struct option *poption)
Definition options.c:1113
static bool server_option_int_set(struct option *poption, int val)
Definition options.c:4829
int messages_where[E_COUNT]
Definition options.c:5037
static void message_options_load(struct section_file *file, const char *prefix)
Definition options.c:5091
struct client_options gui_options
Definition options.c:71
static void server_option_free(struct server_option *poption)
Definition options.c:4171
#define CLIENT_OPTION(poption)
Definition options.c:1491
#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1740
static struct option_set server_optset_static
Definition options.c:4010
void handle_server_setting_control(const struct packet_server_setting_control *packet)
Definition options.c:4261
static void mapimg_changed_callback(struct option *poption)
Definition options.c:6438
bool option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:1124
static int server_option_int_get(const struct option *poption)
Definition options.c:4796
static void manual_turn_done_callback(struct option *poption)
Definition options.c:6396
static void reqtree_show_icons_callback(struct option *poption)
Definition options.c:6379
const char * option_font_get(const struct option *poption)
Definition options.c:1141
void desired_settable_options_update(void)
Definition options.c:5543
static void load_cma_preset(struct section_file *file, int i)
Definition options.c:5192
static bool client_option_str_set(struct option *poption, const char *str)
Definition options.c:3573
void handle_server_setting_enum(const struct packet_server_setting_enum *packet)
Definition options.c:4471
struct ft_color option_color_def(const struct option *poption)
Definition options.c:1201
static int client_option_int_max(const struct option *poption)
Definition options.c:3519
#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd)
Definition options.c:1624
client_option_category
Definition options.c:1412
@ COC_MAX
Definition options.c:1420
@ COC_SOUND
Definition options.c:1415
@ COC_NETWORK
Definition options.c:1418
@ COC_INTERFACE
Definition options.c:1416
@ COC_GRAPHICS
Definition options.c:1413
@ COC_OVERVIEW
Definition options.c:1414
@ COC_FONT
Definition options.c:1419
@ COC_MAPIMG
Definition options.c:1417
unsigned option_bitwise_get(const struct option *poption)
Definition options.c:1074
static bool server_option_is_changeable(const struct option *poption)
Definition options.c:4747
static struct ft_color client_option_color_get(const struct option *poption)
Definition options.c:3746
int option_enum_def_int(const struct option *poption)
Definition options.c:1004
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:431
static const int client_options_num
Definition options.c:3311
static bool client_option_int_set(struct option *poption, int val)
Definition options.c:3528
void options_dialogs_set(void)
Definition options.c:5877
bool option_int_set(struct option *poption, int val)
Definition options.c:878
static struct client_option * client_option_next_valid(struct client_option *poption)
Definition options.c:3332
static const char * client_option_bitwise_secfile_str(secfile_data_t data, int val)
Definition options.c:3693
#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, odef_height, ocb)
Definition options.c:1811
static const struct option_int_vtable client_option_int_vtable
Definition options.c:1326
static const char * client_option_font_def(const struct option *poption)
Definition options.c:3713
static const char * get_last_option_file_name(bool *allow_digital_boolean)
Definition options.c:5315
const char * option_category_name(const struct option *poption)
Definition options.c:678
static void game_music_enable_callback(struct option *poption)
Definition options.c:6471
static const char * get_current_option_file_name(void)
Definition options.c:5280
int option_int_def(const struct option *poption)
Definition options.c:845
static void options_init_names(const struct copt_val_name *(*acc)(int), struct strvec **support, struct strvec **pretty)
Definition options.c:6209
struct video_mode option_video_mode_def(const struct option *poption)
Definition options.c:1240
static bool server_option_bool_def(const struct option *poption)
Definition options.c:4771
#define GUI_GTK3_CITYDLG_DEFAULT_XSIZE
Definition options.h:601
#define GUI_GTK3_22_GOV_RANGE_MIN_DEFAULT
Definition options.h:626
#define MW_POPUP
Definition options.h:579
#define GUI_GTK3_CITYDLG_MAX_YSIZE
Definition options.h:607
#define GUI_GTK3_22_GOV_RANGE_MIN_MIN
Definition options.h:627
#define GUI_GTK3_GOV_RANGE_MIN_DEFAULT
Definition options.h:609
#define GUI_GTK4_GOV_RANGE_MIN_MAX
Definition options.h:645
#define GUI_GTK3_22_CITYDLG_MIN_YSIZE
Definition options.h:623
#define GUI_GTK4_CITYDLG_MAX_XSIZE
Definition options.h:637
#define GUI_GTK4_GOV_RANGE_MIN_DEFAULT
Definition options.h:643
#define GUI_GTK3_GOV_RANGE_MAX_DEFAULT
Definition options.h:613
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:635
#define FC_SDL3_DEFAULT_THEME_NAME
Definition options.h:392
#define GUI_GTK2_CITYDLG_DEFAULT_YSIZE
Definition options.h:593
#define FC_GTK3_22_DEFAULT_THEME_NAME
Definition options.h:300
#define GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE
Definition options.h:618
#define FC_QT_DEFAULT_THEME_NAME
Definition options.h:404
#define GUI_GTK3_CITYDLG_MIN_YSIZE
Definition options.h:606
#define GUI_GTK3_CITYDLG_MIN_XSIZE
Definition options.h:602
#define GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE
Definition options.h:622
#define GUI_GTK4_CITYDLG_MIN_YSIZE
Definition options.h:640
#define DEFAULT_FOLLOWTAG_OPTION
Definition options.h:30
#define GUI_GTK2_CITYDLG_MIN_YSIZE
Definition options.h:594
#define options_iterate(poptset, poption)
Definition options.h:550
#define GUI_GTK2_CITYDLG_MAX_XSIZE
Definition options.h:591
#define GUI_DEFAULT_CHAT_LOGFILE
Definition options.h:586
#define GUI_GTK3_GOV_RANGE_MAX_MAX
Definition options.h:615
#define GUI_GTK4_CITYDLG_MIN_XSIZE
Definition options.h:636
#define GUI_GTK3_22_GOV_RANGE_MAX_DEFAULT
Definition options.h:630
#define DEFAULT_METASERVER_OPTION
Definition options.h:29
#define GUI_GTK3_CITYDLG_DEFAULT_YSIZE
Definition options.h:605
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:620
#define GUI_GTK3_22_GOV_RANGE_MAX_MIN
Definition options.h:631
#define GUI_GTK3_GOV_RANGE_MIN_MIN
Definition options.h:610
#define GUI_GTK3_GOV_RANGE_MIN_MAX
Definition options.h:611
#define GUI_GTK3_22_CITYDLG_MIN_XSIZE
Definition options.h:619
#define GUI_GTK4_GOV_RANGE_MAX_DEFAULT
Definition options.h:647
#define MAJOR_NEW_OPTION_FILE_NAME
Definition options.h:38
#define GUI_GTK3_GOV_RANGE_MAX_MIN
Definition options.h:614
@ GUI_POPUP_TECH_HELP_RULESET
Definition options.h:77
#define GUI_GTK2_CITYDLG_MAX_YSIZE
Definition options.h:595
@ GUI_GTK_MSGCHAT_SEPARATE
Definition options.h:68
#define GUI_DEFAULT_MAPIMG_FILENAME
Definition options.h:651
#define GUI_GTK3_22_CITYDLG_MAX_YSIZE
Definition options.h:624
#define GUI_GTK4_GOV_RANGE_MIN_MIN
Definition options.h:644
#define GUI_GTK4_CITYDLG_MAX_YSIZE
Definition options.h:641
#define MW_OUTPUT
Definition options.h:577
#define GUI_GTK4_CITYDLG_DEFAULT_YSIZE
Definition options.h:639
#define options_iterate_end
Definition options.h:555
#define GUI_GTK4_GOV_RANGE_MAX_MAX
Definition options.h:649
#define MW_MESSAGES
Definition options.h:578
#define FC_GTK4_DEFAULT_THEME_NAME
Definition options.h:336
#define GUI_GTK3_22_GOV_RANGE_MIN_MAX
Definition options.h:628
#define MINOR_NEW_OPTION_FILE_NAME
Definition options.h:42
#define GUI_GTK2_CITYDLG_DEFAULT_XSIZE
Definition options.h:589
#define FC_SDL2_DEFAULT_THEME_NAME
Definition options.h:379
#define GUI_GTK3_22_GOV_RANGE_MAX_MAX
Definition options.h:632
#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:603
#define GUI_GTK4_GOV_RANGE_MAX_MIN
Definition options.h:648
#define GUI_GTK2_CITYDLG_MIN_XSIZE
Definition options.h:590
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:1444
const unsigned def
Definition options.c:1467
struct client_option::@209::@216 font
enum gui_type specific
Definition options.c:1433
const char * description
Definition options.c:1430
const char *const def
Definition options.c:1450
struct ft_color *const pvalue
Definition options.c:1480
struct client_option::@209::@212 integer
struct video_mode *const pvalue
Definition options.c:1485
const size_t size
Definition options.c:1449
char *const pvalue
Definition options.c:1448
const int max
Definition options.c:1444
const bool def
Definition options.c:1439
const char *const target
Definition options.c:1476
bool *const pvalue
Definition options.c:1438
struct option base_option
Definition options.c:1427
struct client_option::@209::@213 string
const char * help_text
Definition options.c:1431
unsigned *const pvalue
Definition options.c:1466
enum client_option_category category
Definition options.c:1432
int *const pvalue
Definition options.c:1443
const char * name
Definition options.c:1429
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
const char * support
Definition options.c:1283
const char * pretty
Definition options.c:1285
int(* number)(const struct option *)
Definition options.c:487
int(* category)(const struct option *)
Definition options.c:491
bool(* is_changeable)(const struct option *)
Definition options.c:492
struct option *(* option_by_number)(int)
Definition options.c:410
struct option *(* option_first)(void)
Definition options.c:411
const char *(* category_name)(int)
Definition options.c:414
int(* category_number)(void)
Definition options.c:413
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:483
const struct option_set * poptset
Definition options.c:481
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:557
void(* changed_callback)(struct option *option)
Definition options.c:555
void * gui_data
Definition options.c:560
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:4139
unsigned value
Definition options.c:4144
char * help_text
Definition options.c:4112
char * name
Definition options.c:4110
bool is_visible
Definition options.c:4116
char * description
Definition options.c:4111
unsigned char category
Definition options.c:4113
struct strvec * pretty_names
Definition options.c:4140
enum setting_default_level setdef
Definition options.c:4117
unsigned def
Definition options.c:4145
bool is_changeable
Definition options.c:4115
struct server_option::@219::@222 integer
char * value
Definition options.c:4132
struct option base_option
Definition options.c:4108
bool desired_sent
Definition options.c:4114
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:7562
#define TS_TOPO_ISOHEX
Definition tilespec.h:455
#define TS_TOPO_HEX
Definition tilespec.h:454
#define TS_TOPO_SQUARE
Definition tilespec.h:453