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 = TRUE,
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_swrenderer = FALSE,
371 .gui_sdl3_do_cursor_animation = TRUE,
372 .gui_sdl3_use_color_cursors = TRUE,
373 .gui_sdl3_font_city_names = "10",
374 .gui_sdl3_font_city_productions = "10",
375 .gui_sdl3_use_theme_font_size = TRUE,
376 .gui_sdl3_font_size = 10,
377
378/* gui-qt client specific options. */
379 .gui_qt_fullscreen = FALSE,
380 .gui_qt_show_preview = TRUE,
381 .gui_qt_sidebar_left = TRUE,
382 .gui_qt_default_theme_name = FC_QT_DEFAULT_THEME_NAME,
383 .gui_qt_font_default = "Sans Serif,10,-1,5,75,0,0,0,0,0",
384 .gui_qt_font_notify_label = "Monospace,8,-1,5,75,0,0,0,0,0",
385 .gui_qt_font_help_label = "Sans Serif,9,-1,5,50,0,0,0,0,0",
386 .gui_qt_font_help_text = "Monospace,8,-1,5,50,0,0,0,0,0",
387 .gui_qt_font_chatline = "Monospace,8,-1,5,50,0,0,0,0,0",
388 .gui_qt_font_city_names = "Sans Serif,10,-1,5,75,0,0,0,0,0",
389 .gui_qt_font_city_productions = "Sans Serif,10,-1,5,50,1,0,0,0,0",
390 .gui_qt_font_reqtree_text = "Sans Serif,10,-1,5,50,1,0,0,0,0",
391 .gui_qt_show_titlebar = TRUE,
392 .gui_qt_wakeup_text = "Wake up %1",
393 .gui_qt_show_relations_panel = TRUE,
394 .gui_qt_show_techs_panel = TRUE,
395 .gui_qt_show_wonders_panel = TRUE,
396 .gui_qt_svgflags = TRUE
397};
398
399/* Set to TRUE after the first call to options_init(), to avoid the usage
400 * of non-initialized datas when calling the changed callback. */
402
403static const struct strvec *get_mapimg_format_list(const struct option *poption);
404
405/****************************************************************************
406 Option set structure.
407****************************************************************************/
409 struct option * (*option_by_number) (int);
410 struct option * (*option_first) (void);
411
413 const char * (*category_name) (int);
414};
415
416/************************************************************************/
420 int id)
421{
423
424 return poptset->option_by_number(id);
425}
426
427/************************************************************************/
431 const char *name)
432{
434
436 if (0 == strcmp(option_name(poption), name)) {
437 return poption;
438 }
440 return NULL;
441}
442
443/************************************************************************/
447{
449
450 return poptset->option_first();
451}
452
453/************************************************************************/
457{
459
460 return poptset->category_number();
461}
462
463/************************************************************************/
466const char *optset_category_name(const struct option_set *poptset,
467 int category)
468{
470
471 return poptset->category_name(category);
472}
473
474
475/****************************************************************************
476 The base class for options.
477****************************************************************************/
478struct option {
479 /* A link to the option set. */
480 const struct option_set *poptset;
481 /* Type of the option. */
483
484 /* Common accessors. */
485 const struct option_common_vtable {
486 int (*number) (const struct option *);
487 const char * (*name) (const struct option *);
488 const char * (*description) (const struct option *);
489 const char * (*help_text) (const struct option *);
490 int (*category) (const struct option *);
491 bool (*is_changeable) (const struct option *);
492 struct option * (*next) (const struct option *);
494 /* Specific typed accessors. */
495 union {
496 /* Specific boolean accessors (OT_BOOLEAN == type). */
497 const struct option_bool_vtable {
498 bool (*get) (const struct option *);
499 bool (*def) (const struct option *);
500 bool (*set) (struct option *, bool);
502 /* Specific integer accessors (OT_INTEGER == type). */
503 const struct option_int_vtable {
504 int (*get) (const struct option *);
505 int (*def) (const struct option *);
506 int (*minimum) (const struct option *);
507 int (*maximum) (const struct option *);
508 bool (*set) (struct option *, int);
510 /* Specific string accessors (OT_STRING == type). */
511 const struct option_str_vtable {
512 const char * (*get) (const struct option *);
513 const char * (*def) (const struct option *);
514 const struct strvec * (*values) (const struct option *);
515 bool (*set) (struct option *, const char *);
517 /* Specific enum accessors (OT_ENUM == type). */
518 const struct option_enum_vtable {
519 int (*get) (const struct option *);
520 int (*def) (const struct option *);
521 const struct strvec * (*values) (const struct option *);
522 bool (*set) (struct option *, int);
523 int (*cmp) (const char *, const char *);
525 /* Specific bitwise accessors (OT_BITWISE == type). */
526 const struct option_bitwise_vtable {
527 unsigned (*get) (const struct option *);
528 unsigned (*def) (const struct option *);
529 const struct strvec * (*values) (const struct option *);
530 bool (*set) (struct option *, unsigned);
532 /* Specific font accessors (OT_FONT == type). */
533 const struct option_font_vtable {
534 const char * (*get) (const struct option *);
535 const char * (*def) (const struct option *);
536 const char * (*target) (const struct option *);
537 bool (*set) (struct option *, const char *);
539 /* Specific color accessors (OT_COLOR == type). */
540 const struct option_color_vtable {
541 struct ft_color (*get) (const struct option *);
542 struct ft_color (*def) (const struct option *);
543 bool (*set) (struct option *, struct ft_color);
545 /* Specific video mode accessors (OT_VIDEO_MODE == type). */
546 const struct option_video_mode_vtable {
547 struct video_mode (*get) (const struct option *);
548 struct video_mode (*def) (const struct option *);
549 bool (*set) (struct option *, struct video_mode);
551 };
552
553 /* Called after the value changed. */
555
557
558 /* Volatile. */
559 void *gui_data;
560};
561
562#define OPTION(poption) ((struct option *) (poption))
563
564#define OPTION_INIT(optset, spec_type, spec_table_var, common_table, \
565 spec_table, changed_cb, cb_data) { \
566 .poptset = optset, \
567 .type = spec_type, \
568 .common_vtable = &common_table, \
569 INIT_BRACE_BEGIN \
570 .spec_table_var = &spec_table \
571 INIT_BRACE_END, \
572 .changed_callback = changed_cb, \
573 .callback_data = cb_data, \
574 .gui_data = NULL \
575}
576#define OPTION_BOOL_INIT(optset, common_table, bool_table, changed_cb) \
577 OPTION_INIT(optset, OT_BOOLEAN, bool_vtable, common_table, bool_table, \
578 changed_cb, 0)
579#define OPTION_INT_INIT(optset, common_table, int_table, changed_cb) \
580 OPTION_INIT(optset, OT_INTEGER, int_vtable, common_table, int_table, \
581 changed_cb, 0)
582#define OPTION_STR_INIT(optset, common_table, str_table, changed_cb, cb_data) \
583 OPTION_INIT(optset, OT_STRING, str_vtable, common_table, str_table, \
584 changed_cb, cb_data)
585#define OPTION_ENUM_INIT(optset, common_table, enum_table, changed_cb) \
586 OPTION_INIT(optset, OT_ENUM, enum_vtable, common_table, enum_table, \
587 changed_cb, 0)
588#define OPTION_BITWISE_INIT(optset, common_table, bitwise_table, \
589 changed_cb) \
590 OPTION_INIT(optset, OT_BITWISE, bitwise_vtable, common_table, \
591 bitwise_table, changed_cb, 0)
592#define OPTION_FONT_INIT(optset, common_table, font_table, changed_cb) \
593 OPTION_INIT(optset, OT_FONT, font_vtable, common_table, font_table, \
594 changed_cb, 0)
595#define OPTION_COLOR_INIT(optset, common_table, color_table, changed_cb) \
596 OPTION_INIT(optset, OT_COLOR, color_vtable, common_table, color_table, \
597 changed_cb, 0)
598#define OPTION_VIDEO_MODE_INIT(optset, common_table, video_mode_table, \
599 changed_cb) \
600 OPTION_INIT(optset, OT_VIDEO_MODE, video_mode_vtable, common_table, \
601 video_mode_table, changed_cb, 0)
602
603
604/************************************************************************/
607const struct option_set *option_optset(const struct option *poption)
608{
610
611 return poption->poptset;
612}
613
614/************************************************************************/
617int option_number(const struct option *poption)
618{
620
621 return poption->common_vtable->number(poption);
622}
623
624/************************************************************************/
627const char *option_name(const struct option *poption)
628{
630
631 return poption->common_vtable->name(poption);
632}
633
634/************************************************************************/
637const char *option_description(const struct option *poption)
638{
640
641 return poption->common_vtable->description(poption);
642}
643
644/************************************************************************/
647const char *option_help_text(const struct option *poption)
648{
650
651 return poption->common_vtable->help_text(poption);
652}
653
654/************************************************************************/
658{
660
661 return poption->type;
662}
663
664/************************************************************************/
668{
670
671 return poption->common_vtable->category(poption);
672}
673
674/************************************************************************/
677const char *option_category_name(const struct option *poption)
678{
680
681 return optset_category_name(poption->poptset,
682 poption->common_vtable->category(poption));
683}
684
685/************************************************************************/
689{
691
692 return poption->common_vtable->is_changeable(poption);
693}
694
695/************************************************************************/
698struct option *option_next(const struct option *poption)
699{
701
702 return poption->common_vtable->next(poption);
703}
704
705/************************************************************************/
732
733/************************************************************************/
737 void (*callback) (struct option *))
738{
740
741 poption->changed_callback = callback;
742}
743
744/************************************************************************/
748{
750
752 /* Prevent to use non-initialized datas. */
753 return;
754 }
755
756 if (poption->changed_callback) {
757 poption->changed_callback(poption);
758 }
759
761}
762
763/************************************************************************/
766void option_set_gui_data(struct option *poption, void *data)
767{
769
770 poption->gui_data = data;
771}
772
773/************************************************************************/
777{
779
780 return poption->gui_data;
781}
782
783/************************************************************************/
787{
789
790 return poption->callback_data;
791}
792
793/************************************************************************/
796bool option_bool_get(const struct option *poption)
797{
800
801 return poption->bool_vtable->get(poption);
802}
803
804/************************************************************************/
807bool option_bool_def(const struct option *poption)
808{
811
812 return poption->bool_vtable->def(poption);
813}
814
815/************************************************************************/
818bool option_bool_set(struct option *poption, bool val)
819{
822
823 if (poption->bool_vtable->set(poption, val)) {
825 return TRUE;
826 }
827 return FALSE;
828}
829
830/************************************************************************/
833int option_int_get(const struct option *poption)
834{
837
838 return poption->int_vtable->get(poption);
839}
840
841/************************************************************************/
844int option_int_def(const struct option *poption)
845{
848
849 return poption->int_vtable->def(poption);
850}
851
852/************************************************************************/
855int option_int_min(const struct option *poption)
856{
859
860 return poption->int_vtable->minimum(poption);
861}
862
863/************************************************************************/
866int option_int_max(const struct option *poption)
867{
870
871 return poption->int_vtable->maximum(poption);
872}
873
874/************************************************************************/
877bool option_int_set(struct option *poption, int val)
878{
881
882 if (poption->int_vtable->set(poption, val)) {
884 return TRUE;
885 }
886 return FALSE;
887}
888
889/************************************************************************/
892const char *option_str_get(const struct option *poption)
893{
896
897 return poption->str_vtable->get(poption);
898}
899
900/************************************************************************/
903const char *option_str_def(const struct option *poption)
904{
907
908 return poption->str_vtable->def(poption);
909}
910
911/************************************************************************/
914const struct strvec *option_str_values(const struct option *poption)
915{
918
919 return poption->str_vtable->values(poption);
920}
921
922/************************************************************************/
925bool option_str_set(struct option *poption, const char *str)
926{
930
931 if (poption->str_vtable->set(poption, str)) {
933 return TRUE;
934 }
935 return FALSE;
936}
937
938/************************************************************************/
942int option_enum_str_to_int(const struct option *poption, const char *str)
943{
944 const struct strvec *values;
945 int val;
946
948 fc_assert_ret_val(OT_ENUM == poption->type, -1);
949 values = poption->enum_vtable->values(poption);
950 fc_assert_ret_val(NULL != values, -1);
951
952 for (val = 0; val < strvec_size(values); val++) {
953 if (0 == poption->enum_vtable->cmp(strvec_get(values, val), str)) {
954 return val;
955 }
956 }
957 return -1;
958}
959
960/************************************************************************/
964const char *option_enum_int_to_str(const struct option *poption, int val)
965{
966 const struct strvec *values;
967
970 values = poption->enum_vtable->values(poption);
971 fc_assert_ret_val(NULL != values, NULL);
972
973 return strvec_get(values, val);
974}
975
976/************************************************************************/
980{
982 fc_assert_ret_val(OT_ENUM == poption->type, -1);
983
984 return poption->enum_vtable->get(poption);
985}
986
987/************************************************************************/
991const char *option_enum_get_str(const struct option *poption)
992{
995
996 return strvec_get(poption->enum_vtable->values(poption),
997 poption->enum_vtable->get(poption));
998}
999
1000/************************************************************************/
1004{
1006 fc_assert_ret_val(OT_ENUM == poption->type, -1);
1007
1008 return poption->enum_vtable->def(poption);
1009}
1010
1011/************************************************************************/
1015const char *option_enum_def_str(const struct option *poption)
1016{
1019
1020 return strvec_get(poption->enum_vtable->values(poption),
1021 poption->enum_vtable->def(poption));
1022}
1023
1024/************************************************************************/
1028const struct strvec *option_enum_values(const struct option *poption)
1029{
1032
1033 return poption->enum_vtable->values(poption);
1034}
1035
1036/************************************************************************/
1039bool option_enum_set_int(struct option *poption, int val)
1040{
1043
1044 if (poption->enum_vtable->set(poption, val)) {
1046 return TRUE;
1047 }
1048 return FALSE;
1049}
1050
1051/************************************************************************/
1056bool option_enum_set_str(struct option *poption, const char *str)
1057{
1061
1062 if (poption->enum_vtable->set(poption,
1065 return TRUE;
1066 }
1067 return FALSE;
1068}
1069
1070/************************************************************************/
1073unsigned option_bitwise_get(const struct option *poption)
1074{
1077
1078 return poption->bitwise_vtable->get(poption);
1079}
1080
1081/************************************************************************/
1084unsigned option_bitwise_def(const struct option *poption)
1085{
1088
1089 return poption->bitwise_vtable->def(poption);
1090}
1091
1092/************************************************************************/
1095unsigned option_bitwise_mask(const struct option *poption)
1096{
1097 const struct strvec *values;
1098
1101
1102 values = poption->bitwise_vtable->values(poption);
1103 fc_assert_ret_val(NULL != values, 0);
1104
1105 return (1 << strvec_size(values)) - 1;
1106}
1107
1108/************************************************************************/
1112const struct strvec *option_bitwise_values(const struct option *poption)
1113{
1116
1117 return poption->bitwise_vtable->values(poption);
1118}
1119
1120/************************************************************************/
1123bool option_bitwise_set(struct option *poption, unsigned val)
1124{
1127
1128 if (0 != (val & ~option_bitwise_mask(poption))
1129 || !poption->bitwise_vtable->set(poption, val)) {
1130 return FALSE;
1131 }
1132
1134 return TRUE;
1135}
1136
1137/************************************************************************/
1140const char *option_font_get(const struct option *poption)
1141{
1144
1145 return poption->font_vtable->get(poption);
1146}
1147
1148/************************************************************************/
1151const char *option_font_def(const struct option *poption)
1152{
1155
1156 return poption->font_vtable->def(poption);
1157}
1158
1159/************************************************************************/
1162const char *option_font_target(const struct option *poption)
1163{
1166
1167 return poption->font_vtable->target(poption);
1168}
1169
1170/************************************************************************/
1173bool option_font_set(struct option *poption, const char *font)
1174{
1177 fc_assert_ret_val(NULL != font, FALSE);
1178
1179 if (poption->font_vtable->set(poption, font)) {
1181 return TRUE;
1182 }
1183 return FALSE;
1184}
1185
1186/************************************************************************/
1196
1197/************************************************************************/
1207
1208/************************************************************************/
1213{
1216
1217 if (poption->color_vtable->set(poption, color)) {
1219 return TRUE;
1220 }
1221 return FALSE;
1222}
1223
1224/************************************************************************/
1228{
1231 video_mode_construct(-1, -1));
1232
1233 return poption->video_mode_vtable->get(poption);
1234}
1235
1236/************************************************************************/
1240{
1243 video_mode_construct(-1, -1));
1244
1245 return poption->video_mode_vtable->def(poption);
1246}
1247
1248/************************************************************************/
1253{
1256
1257 if (poption->video_mode_vtable->set(poption, mode)) {
1259 return TRUE;
1260 }
1261 return FALSE;
1262}
1263
1264
1265/****************************************************************************
1266 Client option set.
1267****************************************************************************/
1268static struct option *client_optset_option_by_number(int id);
1269static struct option *client_optset_option_first(void);
1270static int client_optset_category_number(void);
1271static const char *client_optset_category_name(int category);
1272
1275 .option_first = client_optset_option_first,
1276 .category_number = client_optset_category_number,
1277 .category_name = client_optset_category_name
1278};
1280
1282 const char *support; /* Untranslated long support name, used
1283 * for saving. */
1284 const char *pretty; /* Translated, used to display to the
1285 * users. */
1286};
1287
1288/****************************************************************************
1289 Virtuals tables for the client options.
1290****************************************************************************/
1291static int client_option_number(const struct option *poption);
1292static const char *client_option_name(const struct option *poption);
1293static const char *client_option_description(const struct option *poption);
1294static const char *client_option_help_text(const struct option *poption);
1295static int client_option_category(const struct option *poption);
1296static bool client_option_is_changeable(const struct option *poption);
1297static struct option *client_option_next(const struct option *poption);
1298
1299static const struct option_common_vtable client_option_common_vtable = {
1300 .number = client_option_number,
1301 .name = client_option_name,
1302 .description = client_option_description,
1303 .help_text = client_option_help_text,
1304 .category = client_option_category,
1305 .is_changeable = client_option_is_changeable,
1306 .next = client_option_next
1307};
1308
1309static bool client_option_bool_get(const struct option *poption);
1310static bool client_option_bool_def(const struct option *poption);
1311static bool client_option_bool_set(struct option *poption, bool val);
1312
1313static const struct option_bool_vtable client_option_bool_vtable = {
1317};
1318
1319static int client_option_int_get(const struct option *poption);
1320static int client_option_int_def(const struct option *poption);
1321static int client_option_int_min(const struct option *poption);
1322static int client_option_int_max(const struct option *poption);
1323static bool client_option_int_set(struct option *poption, int val);
1324
1325static const struct option_int_vtable client_option_int_vtable = {
1326 .get = client_option_int_get,
1327 .def = client_option_int_def,
1328 .minimum = client_option_int_min,
1329 .maximum = client_option_int_max,
1331};
1332
1333static const char *client_option_str_get(const struct option *poption);
1334static const char *client_option_str_def(const struct option *poption);
1335static const struct strvec *
1337static bool client_option_str_set(struct option *poption, const char *str);
1338
1339static const struct option_str_vtable client_option_str_vtable = {
1340 .get = client_option_str_get,
1341 .def = client_option_str_def,
1342 .values = client_option_str_values,
1344};
1345
1346static int client_option_enum_get(const struct option *poption);
1347static int client_option_enum_def(const struct option *poption);
1348static const struct strvec *
1350static bool client_option_enum_set(struct option *poption, int val);
1351
1352static const struct option_enum_vtable client_option_enum_vtable = {
1357 .cmp = fc_strcasecmp
1358};
1359
1360#if 0 /* There's no bitwise options currently */
1361static unsigned client_option_bitwise_get(const struct option *poption);
1362static unsigned client_option_bitwise_def(const struct option *poption);
1363static const struct strvec *
1365static bool client_option_bitwise_set(struct option *poption, unsigned val);
1366
1367static const struct option_bitwise_vtable client_option_bitwise_vtable = {
1372};
1373#endif /* 0 */
1374
1375static const char *client_option_font_get(const struct option *poption);
1376static const char *client_option_font_def(const struct option *poption);
1377static const char *client_option_font_target(const struct option *poption);
1378static bool client_option_font_set(struct option *poption, const char *font);
1379
1380static const struct option_font_vtable client_option_font_vtable = {
1383 .target = client_option_font_target,
1385};
1386
1389static bool client_option_color_set(struct option *poption,
1390 struct ft_color color);
1391
1392static const struct option_color_vtable client_option_color_vtable = {
1396};
1397
1398static struct video_mode
1400static struct video_mode
1402static bool client_option_video_mode_set(struct option *poption,
1403 struct video_mode mode);
1404
1405static const struct option_video_mode_vtable client_option_video_mode_vtable = {
1409};
1410
1421
1422/****************************************************************************
1423 Derived class client option, inherinting of base class option.
1424****************************************************************************/
1426 struct option base_option; /* Base structure, must be the first! */
1427
1428 const char *name; /* Short name - used as an identifier */
1429 const char *description; /* One-line description */
1430 const char *help_text; /* Paragraph-length help text */
1432 enum gui_type specific; /* GUI_STUB for common options. */
1433
1434 union {
1435 /* OT_BOOLEAN type option. */
1436 struct {
1437 bool *const pvalue;
1438 const bool def;
1439 } boolean;
1440 /* OT_INTEGER type option. */
1441 struct {
1442 int *const pvalue;
1443 const int def, min, max;
1444 } integer;
1445 /* OT_STRING type option. */
1446 struct {
1447 char *const pvalue;
1448 const size_t size;
1449 const char *const def;
1450 /*
1451 * A function to return a string vector of possible string values,
1452 * or NULL for none.
1453 */
1454 const struct strvec *(*const val_accessor) (const struct option *);
1455 } string;
1456 /* OT_ENUM type option. */
1457 struct {
1458 int *const pvalue;
1459 const int def;
1460 struct strvec *support_names, *pretty_names; /* untranslated */
1461 const struct copt_val_name * (*const name_accessor) (int value);
1462 } enumerator;
1463 /* OT_BITWISE type option. */
1464 struct {
1465 unsigned *const pvalue;
1466 const unsigned def;
1467 struct strvec *support_names, *pretty_names; /* untranslated */
1468 const struct copt_val_name * (*const name_accessor) (int value);
1469 } bitwise;
1470 /* OT_FONT type option. */
1471 struct {
1472 char *const pvalue;
1473 const size_t size;
1474 const char *const def;
1475 const char *const target;
1476 } font;
1477 /* OT_COLOR type option. */
1478 struct {
1479 struct ft_color *const pvalue;
1480 const struct ft_color def;
1482 /* OT_VIDEO_MODE type option. */
1483 struct {
1484 struct video_mode *const pvalue;
1485 const struct video_mode def;
1487 };
1488};
1489
1490#define CLIENT_OPTION(poption) ((struct client_option *) (poption))
1491
1492/*
1493 * Generate a client option of type OT_BOOLEAN.
1494 *
1495 * oname: The option data. Note it is used as name to be loaded or saved.
1496 * So, you shouldn't change the name of this variable in any case.
1497 * odesc: A short description of the client option. Should be used with the
1498 * N_() macro.
1499 * ohelp: The help text for the client option. Should be used with the N_()
1500 * macro.
1501 * ocat: The client_option_class of this client option.
1502 * ospec: A gui_type enumerator which determine for what particular client
1503 * gui this option is for. Sets to GUI_STUB for common options.
1504 * odef: The default value of this client option (FALSE or TRUE).
1505 * ocb: A callback function of type void (*)(struct option *) called when
1506 * the option changed.
1507 */
1508#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb) \
1509{ \
1510 .base_option = OPTION_BOOL_INIT(&client_optset_static, \
1511 client_option_common_vtable, \
1512 client_option_bool_vtable, ocb), \
1513 .name = #oname, \
1514 .description = odesc, \
1515 .help_text = ohelp, \
1516 .category = ocat, \
1517 .specific = ospec, \
1518 INIT_BRACE_BEGIN \
1519 .boolean = { \
1520 .pvalue = &gui_options.oname, \
1521 .def = odef, \
1522 } \
1523 INIT_BRACE_END \
1524}
1525
1526/*
1527 * Generate a client option of type OT_INTEGER.
1528 *
1529 * oname: The option data. Note it is used as name to be loaded or saved.
1530 * So, you shouldn't change the name of this variable in any case.
1531 * odesc: A short description of the client option. Should be used with the
1532 * N_() macro.
1533 * ohelp: The help text for the client option. Should be used with the N_()
1534 * macro.
1535 * ocat: The client_option_class of this client option.
1536 * ospec: A gui_type enumerator which determine for what particular client
1537 * gui this option is for. Sets to GUI_STUB for common options.
1538 * odef: The default value of this client option.
1539 * omin: The minimal value of this client option.
1540 * omax: The maximal value of this client option.
1541 * ocb: A callback function of type void (*)(struct option *) called when
1542 * the option changed.
1543 */
1544#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb) \
1545{ \
1546 .base_option = OPTION_INT_INIT(&client_optset_static, \
1547 client_option_common_vtable, \
1548 client_option_int_vtable, ocb), \
1549 .name = #oname, \
1550 .description = odesc, \
1551 .help_text = ohelp, \
1552 .category = ocat, \
1553 .specific = ospec, \
1554 INIT_BRACE_BEGIN \
1555 .integer = { \
1556 .pvalue = &gui_options.oname, \
1557 .def = odef, \
1558 .min = omin, \
1559 .max = omax \
1560 } \
1561 INIT_BRACE_END \
1562}
1563
1564/*
1565 * Generate a client option of type OT_STRING.
1566 *
1567 * oname: The option data. Note it is used as name to be loaded or saved.
1568 * So, you shouldn't change the name of this variable in any case.
1569 * Be sure to pass the array variable and not a pointer to it because
1570 * the size is calculated with sizeof().
1571 * odesc: A short description of the client option. Should be used with the
1572 * N_() macro.
1573 * ohelp: The help text for the client option. Should be used with the N_()
1574 * macro.
1575 * ocat: The client_option_class of this client option.
1576 * ospec: A gui_type enumerator which determines for what particular client
1577 * gui this option is for. Set to GUI_STUB for common options.
1578 * odef: The default string for this client option.
1579 * ocb: A callback function of type void (*)(struct option *) called when
1580 * the option changed.
1581 */
1582#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd) \
1583{ \
1584 .base_option = OPTION_STR_INIT(&client_optset_static, \
1585 client_option_common_vtable, \
1586 client_option_str_vtable, ocb, cbd), \
1587 .name = #oname, \
1588 .description = odesc, \
1589 .help_text = ohelp, \
1590 .category = ocat, \
1591 .specific = ospec, \
1592 INIT_BRACE_BEGIN \
1593 .string = { \
1594 .pvalue = gui_options.oname, \
1595 .size = sizeof(gui_options.oname), \
1596 .def = odef, \
1597 .val_accessor = NULL \
1598 } \
1599 INIT_BRACE_END \
1600}
1601
1602/*
1603 * Generate a client option of type OT_STRING with a string accessor
1604 * function.
1605 *
1606 * oname: The option data. Note it is used as name to be loaded or saved.
1607 * So, you shouldn't change the name of this variable in any case.
1608 * Be sure to pass the array variable and not a pointer to it because
1609 * the size is calculated with sizeof().
1610 * odesc: A short description of the client option. Should be used with the
1611 * N_() macro.
1612 * ohelp: The help text for the client option. Should be used with the N_()
1613 * macro.
1614 * ocat: The client_option_class of this client option.
1615 * ospec: A gui_type enumerator which determine for what particular client
1616 * gui this option is for. Sets to GUI_STUB for common options.
1617 * odef: The default string for this client option.
1618 * oacc: The string accessor where to find the allowed values of type
1619 * 'const struct strvec * (*) (void)'.
1620 * ocb: A callback function of type void (*)(struct option *) called when
1621 * the option changed.
1622 */
1623#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd) \
1624{ \
1625 .base_option = OPTION_STR_INIT(&client_optset_static, \
1626 client_option_common_vtable, \
1627 client_option_str_vtable, ocb, cbd), \
1628 .name = #oname, \
1629 .description = odesc, \
1630 .help_text = ohelp, \
1631 .category = ocat, \
1632 .specific = ospec, \
1633 INIT_BRACE_BEGIN \
1634 .string = { \
1635 .pvalue = gui_options.oname, \
1636 .size = sizeof(gui_options.oname), \
1637 .def = odef, \
1638 .val_accessor = oacc \
1639 } \
1640 INIT_BRACE_END \
1641}
1642
1643/*
1644 * Generate a client option of type OT_ENUM.
1645 *
1646 * oname: The option data. Note it is used as name to be loaded or saved.
1647 * So, you shouldn't change the name of this variable in any case.
1648 * odesc: A short description of the client option. Should be used with the
1649 * N_() macro.
1650 * ohelp: The help text for the client option. Should be used with the N_()
1651 * macro.
1652 * ocat: The client_option_class of this client option.
1653 * ospec: A gui_type enumerator which determine for what particular client
1654 * gui this option is for. Sets to GUI_STUB for common options.
1655 * odef: The default value for this client option.
1656 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1657 * ocb: A callback function of type void (*) (struct option *) called when
1658 * the option changed.
1659 */
1660#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb) \
1661{ \
1662 .base_option = OPTION_ENUM_INIT(&client_optset_static, \
1663 client_option_common_vtable, \
1664 client_option_enum_vtable, ocb), \
1665 .name = #oname, \
1666 .description = odesc, \
1667 .help_text = ohelp, \
1668 .category = ocat, \
1669 .specific = ospec, \
1670 INIT_BRACE_BEGIN \
1671 .enumerator = { \
1672 .pvalue = (int *) &gui_options.oname, \
1673 .def = odef, \
1674 .support_names = NULL, /* Set in options_init(). */ \
1675 .pretty_names = NULL, \
1676 .name_accessor = oacc \
1677 } \
1678 INIT_BRACE_END \
1679}
1680
1681/*
1682 * Generate a client option of type OT_BITWISE.
1683 *
1684 * oname: The option data. Note it is used as name to be loaded or saved.
1685 * So, you shouldn't change the name of this variable in any case.
1686 * odesc: A short description of the client option. Should be used with the
1687 * N_() macro.
1688 * ohelp: The help text for the client option. Should be used with the N_()
1689 * macro.
1690 * ocat: The client_option_class of this client option.
1691 * ospec: A gui_type enumerator which determine for what particular client
1692 * gui this option is for. Sets to GUI_STUB for common options.
1693 * odef: The default value for this client option.
1694 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1695 * ocb: A callback function of type void (*) (struct option *) called when
1696 * the option changed.
1697 */
1698#define GEN_BITWISE_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, \
1699 ocb) \
1700{ \
1701 .base_option = OPTION_BITWISE_INIT(&client_optset_static, \
1702 client_option_common_vtable, \
1703 client_option_bitwise_vtable, ocb), \
1704 .name = #oname, \
1705 .description = odesc, \
1706 .help_text = ohelp, \
1707 .category = ocat, \
1708 .specific = ospec, \
1709 INIT_BRACE_BEGIN \
1710 .bitwise = { \
1711 .pvalue = &gui_options.oname, \
1712 .def = odef, \
1713 .support_names = NULL, /* Set in options_init(). */ \
1714 .pretty_names = NULL, \
1715 .name_accessor = oacc \
1716 } \
1717 INIT_BRACE_END \
1718}
1719
1720/*
1721 * Generate a client option of type OT_FONT.
1722 *
1723 * oname: The option data. Note it is used as name to be loaded or saved.
1724 * So, you shouldn't change the name of this variable in any case.
1725 * Be sure to pass the array variable and not a pointer to it because
1726 * the size is calculated with sizeof().
1727 * otgt: The target widget style.
1728 * odesc: A short description of the client option. Should be used with the
1729 * N_() macro.
1730 * ohelp: The help text for the client option. Should be used with the N_()
1731 * macro.
1732 * ocat: The client_option_class of this client option.
1733 * ospec: A gui_type enumerator which determine for what particular client
1734 * gui this option is for. Sets to GUI_STUB for common options.
1735 * odef: The default string for this client option.
1736 * ocb: A callback function of type void (*)(struct option *) called when
1737 * the option changed.
1738 */
1739#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb) \
1740{ \
1741 .base_option = OPTION_FONT_INIT(&client_optset_static, \
1742 client_option_common_vtable, \
1743 client_option_font_vtable, ocb), \
1744 .name = #oname, \
1745 .description = odesc, \
1746 .help_text = ohelp, \
1747 .category = ocat, \
1748 .specific = ospec, \
1749 INIT_BRACE_BEGIN \
1750 .font = { \
1751 .pvalue = gui_options.oname, \
1752 .size = sizeof(gui_options.oname), \
1753 .def = odef, \
1754 .target = otgt, \
1755 } \
1756 INIT_BRACE_END \
1757}
1758
1759/*
1760 * Generate a client option of type OT_COLOR.
1761 *
1762 * oname: The option data. Note it is used as name to be loaded or saved.
1763 * So, you shouldn't change the name of this variable in any case.
1764 * odesc: A short description of the client option. Should be used with the
1765 * N_() macro.
1766 * ohelp: The help text for the client option. Should be used with the N_()
1767 * macro.
1768 * ocat: The client_option_class of this client option.
1769 * ospec: A gui_type enumerator which determine for what particular client
1770 * gui this option is for. Sets to GUI_STUB for common options.
1771 * odef_fg, odef_bg: The default values for this client option.
1772 * ocb: A callback function of type void (*)(struct option *) called when
1773 * the option changed.
1774 */
1775#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, \
1776 odef_bg, ocb) \
1777{ \
1778 .base_option = OPTION_COLOR_INIT(&client_optset_static, \
1779 client_option_common_vtable, \
1780 client_option_color_vtable, ocb), \
1781 .name = #oname, \
1782 .description = odesc, \
1783 .help_text = ohelp, \
1784 .category = ocat, \
1785 .specific = ospec, \
1786 INIT_BRACE_BEGIN \
1787 .color = { \
1788 .pvalue = &gui_options.oname, \
1789 .def = FT_COLOR(odef_fg, odef_bg) \
1790 } \
1791 INIT_BRACE_END \
1792}
1793
1794/*
1795 * Generate a client option of type OT_VIDEO_MODE.
1796 *
1797 * oname: The option data. Note it is used as name to be loaded or saved.
1798 * So, you shouldn't change the name of this variable in any case.
1799 * odesc: A short description of the client option. Should be used with the
1800 * N_() macro.
1801 * ohelp: The help text for the client option. Should be used with the N_()
1802 * macro.
1803 * ocat: The client_option_class of this client option.
1804 * ospec: A gui_type enumerator which determine for what particular client
1805 * gui this option is for. Sets to GUI_STUB for common options.
1806 * odef_width, odef_height: The default values for this client option.
1807 * ocb: A callback function of type void (*)(struct option *) called when
1808 * the option changed.
1809 */
1810#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, \
1811 odef_height, ocb) \
1812{ \
1813 .base_option = OPTION_VIDEO_MODE_INIT(&client_optset_static, \
1814 client_option_common_vtable, \
1815 client_option_video_mode_vtable, \
1816 ocb), \
1817 .name = #oname, \
1818 .description = odesc, \
1819 .help_text = ohelp, \
1820 .category = ocat, \
1821 .specific = ospec, \
1822 INIT_BRACE_BEGIN \
1823 .video_mode = { \
1824 .pvalue = &gui_options.oname, \
1825 .def = VIDEO_MODE(odef_width, odef_height) \
1826 } \
1827 INIT_BRACE_END \
1828}
1829
1830/****************************************************************************
1831 Enumerator name accessors.
1832****************************************************************************/
1833
1834/************************************************************************/
1837static const struct copt_val_name
1839{
1840 /* Order must match enum GUI_GTK_MSGCHAT_* */
1841 static const struct copt_val_name names[] = {
1842 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1843 { "SPLIT", N_("Split") },
1844 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1845 { "SEPARATE", N_("Separate") },
1846 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1847 { "MERGED", N_("Merged") }
1848 };
1849
1850 return (0 <= value && value < ARRAY_SIZE(names)
1851 ? names + value : NULL);
1852}
1853
1854/************************************************************************/
1857static const struct copt_val_name
1859{
1860 /* Order must match enum GUI_POPUP_TECH_HELP_* */
1861 static const struct copt_val_name names[] = {
1862 /* TRANS: enum value for 'gui_popup_tech_help' */
1863 { "ENABLED", N_("Enabled") },
1864 /* TRANS: enum value for 'gui_popup_tech_help' */
1865 { "DISABLED", N_("Disabled") },
1866 /* TRANS: enum value for 'gui_popup_tech_help' */
1867 { "RULESET", N_("Ruleset") }
1868 };
1869
1870 return (0 <= value && value < ARRAY_SIZE(names)
1871 ? names + value : NULL);
1872}
1873
1874/* Some changed callbacks. */
1875static void reqtree_show_icons_callback(struct option *poption);
1876static void view_option_changed_callback(struct option *poption);
1877static void manual_turn_done_callback(struct option *poption);
1878static void voteinfo_bar_callback(struct option *poption);
1879static void font_changed_callback(struct option *poption);
1880static void mapimg_changed_callback(struct option *poption);
1881static void game_music_enable_callback(struct option *poption);
1882static void menu_music_enable_callback(struct option *poption);
1883static void sound_volume_callback(struct option *poption);
1884
1886 GEN_STR_OPTION(default_user_name,
1887 N_("Login name"),
1888 N_("This is the default login username that will be used "
1889 "in the connection dialogs or with the -a command-line "
1890 "parameter."),
1892 GEN_BOOL_OPTION(use_prev_server, N_("Default to previously used server"),
1893 N_("Automatically update \"Server\" and \"Server port\" "
1894 "options to match your latest connection, so by "
1895 "default you connect to the same server you used "
1896 "on the previous run. You should enable "
1897 "saving options on exit too, so that the automatic "
1898 "updates to the options get saved too."),
1900 GEN_STR_OPTION(default_server_host,
1901 N_("Server"),
1902 N_("This is the default server hostname that will be used "
1903 "in the connection dialogs or with the -a command-line "
1904 "parameter."),
1905 COC_NETWORK, GUI_STUB, "localhost", NULL, 0),
1906 GEN_INT_OPTION(default_server_port,
1907 N_("Server port"),
1908 N_("This is the default server port that will be used "
1909 "in the connection dialogs or with the -a command-line "
1910 "parameter."),
1912 GEN_STR_OPTION(default_metaserver,
1913 N_("Metaserver"),
1914 N_("The metaserver is a host that the client contacts to "
1915 "find out about games on the internet. Don't change "
1916 "this from its default value unless you know what "
1917 "you're doing."),
1919 GEN_BOOL_OPTION(heartbeat_enabled,
1920 N_("Send heartbeat messages to the server"),
1921 N_("Periodically send an empty heartbeat message to the "
1922 "server to probe whether the connection is still up. "
1923 "This can help to make it obvious when the server has "
1924 "cut the connection due to a connectivity outage, if "
1925 "the client would otherwise sit idle for a long period."),
1927 GEN_STR_OPTION(followtag_override,
1928 N_("Followtag override"),
1929 /* TRANS: Leave 'builtin' untranslated */
1930 N_("Followtag determines which kind of new freeciv versions' "
1931 "availability gets checked from the metaserver. Special "
1932 "value 'builtin' means that value builtin to the client "
1933 "gets used."),
1935 GEN_BOOL_OPTION(send_desired_settings,
1936 N_("Send desired settings to the server"),
1937 N_("In single-player mode client usually sends user's "
1938 "desired server settings to the server it has "
1939 "launched internally. By disabling this option one "
1940 "can prevent such override of server settings from "
1941 "other sources, such as settings balanced for a "
1942 "custom ruleset."),
1944 GEN_STR_LIST_OPTION(default_sound_set_name,
1945 N_("Soundset"),
1946 N_("This is the soundset that will be used. Changing "
1947 "this is the same as using the -S command-line "
1948 "parameter. Use modpack installer utility to install "
1949 "additional soundsets."),
1950 COC_SOUND, GUI_STUB, "stdsounds", get_soundset_list, NULL, 0),
1951 GEN_STR_LIST_OPTION(default_music_set_name,
1952 N_("Musicset"),
1953 N_("This is the musicset that will be used. Changing "
1954 "this is the same as using the -m command-line "
1955 "parameter. Use modpack installer utility to install "
1956 "additional musicsets."),
1957 COC_SOUND, GUI_STUB, "stdmusic", get_musicset_list,
1959 GEN_STR_LIST_OPTION(default_sound_plugin_name,
1960 N_("Sound plugin"),
1961 N_("If you have a problem with sound, try changing "
1962 "the sound plugin. The new plugin won't take "
1963 "effect until you restart Freeciv. Changing this "
1964 "is the same as using the -P command-line option."),
1966 GEN_STR_OPTION(default_chat_logfile,
1967 N_("The chat log file"),
1968 N_("The name of the chat log file."),
1970 /* gui_gtk3_22/4_default_theme_name and gui_sdl2/3_default_theme_name are
1971 * different settings to avoid client crash after loading the
1972 * style for the other gui. Keeps 5 different options! */
1973 GEN_STR_LIST_OPTION(gui_gtk3_22_default_theme_name, N_("Theme"),
1974 N_("By changing this option you change the "
1975 "active theme."),
1978 GEN_STR_LIST_OPTION(gui_gtk4_default_theme_name, N_("Theme"),
1979 N_("By changing this option you change the "
1980 "active theme."),
1983 GEN_STR_LIST_OPTION(gui_sdl2_default_theme_name, N_("Theme"),
1984 N_("By changing this option you change the "
1985 "active theme."),
1988 GEN_STR_LIST_OPTION(gui_sdl3_default_theme_name, N_("Theme"),
1989 N_("By changing this option you change the "
1990 "active theme."),
1993 GEN_STR_LIST_OPTION(gui_qt_default_theme_name, N_("Theme"),
1994 N_("By changing this option you change the "
1995 "active theme."),
1998
1999 /* It's important to give empty string instead of NULL as as default
2000 * value. For NULL value it would default to assigning first value
2001 * from the tileset list returned by get_tileset_list() as default
2002 * tileset. We don't want default tileset assigned at all here, but
2003 * leave it to tilespec code that can handle tileset priority. */
2004 GEN_STR_LIST_OPTION(default_tileset_square_name, N_("Tileset (Square)"),
2005 N_("Select the tileset used with Square based maps. "
2006 "This may change the currently active tileset, if "
2007 "you are playing on such a map, in which "
2008 "case this is the same as using the -t "
2009 "command-line parameter. "
2010 "Use modpack installer utility to install "
2011 "additional tilesets."),
2014 GEN_STR_LIST_OPTION(default_tileset_hex_name, N_("Tileset (Hex)"),
2015 N_("Select the tileset used with Hex maps. "
2016 "This may change the currently active tileset, if "
2017 "you are playing on such a map, in which "
2018 "case this is the same as using the -t "
2019 "command-line parameter. "
2020 "Use modpack installer utility to install "
2021 "additional tilesets."),
2024 GEN_STR_LIST_OPTION(default_tileset_isohex_name, N_("Tileset (Iso-Hex)"),
2025 N_("Select the tileset used with Iso-Hex maps. "
2026 "This may change the currently active tileset, if "
2027 "you are playing on such a map, in which "
2028 "case this is the same as using the -t "
2029 "command-line parameter."
2030 "Use modpack installer utility to install "
2031 "additional tilesets."),
2034
2035 GEN_BOOL_OPTION(draw_city_outlines, N_("Draw city outlines"),
2036 N_("Setting this option will draw a line at the city "
2037 "workable limit."),
2040 GEN_BOOL_OPTION(draw_city_output, N_("Draw city output"),
2041 N_("Setting this option will draw city output for every "
2042 "citizen."),
2045 GEN_BOOL_OPTION(draw_map_grid, N_("Draw the map grid"),
2046 N_("Setting this option will draw a grid over the map."),
2049 GEN_BOOL_OPTION(draw_full_citybar, N_("Draw the city bar"),
2050 N_("Setting this option will display a 'city bar' "
2051 "containing useful information beneath each city. "
2052 "Disabling this option will display only the city's "
2053 "name and, optionally, production."),
2056 GEN_BOOL_OPTION(draw_city_names, N_("Draw the city names"),
2057 N_("Setting this option will draw the names of the cities "
2058 "on the map."),
2061 GEN_BOOL_OPTION(draw_city_growth, N_("Draw the city growth"),
2062 N_("Setting this option will draw in how many turns the "
2063 "cities will grow or shrink."),
2066 GEN_BOOL_OPTION(draw_city_productions, N_("Draw the city productions"),
2067 N_("Setting this option will draw what the cities are "
2068 "currently building on the map."),
2071 GEN_BOOL_OPTION(draw_city_buycost, N_("Draw the city buy costs"),
2072 N_("Setting this option will draw how much gold is "
2073 "needed to buy the production of the cities."),
2076 GEN_BOOL_OPTION(draw_city_trade_routes, N_("Draw the city trade routes"),
2077 N_("Setting this option will draw trade route lines "
2078 "between cities which have trade routes."),
2081 GEN_BOOL_OPTION(draw_terrain, N_("Draw the terrain"),
2082 N_("Setting this option will draw the terrain."),
2085 GEN_BOOL_OPTION(draw_coastline, N_("Draw the coast line"),
2086 N_("Setting this option will draw a line to separate the "
2087 "land from the ocean."),
2090 GEN_BOOL_OPTION(draw_paths, N_("Draw the paths"),
2091 N_("Setting this option will draw all kind of paths "
2092 "on the map."),
2095 GEN_BOOL_OPTION(draw_irrigation, N_("Draw the irrigation"),
2096 N_("Setting this option will draw the irrigation systems "
2097 "on the map."),
2100 GEN_BOOL_OPTION(draw_mines, N_("Draw the mines"),
2101 N_("Setting this option will draw the mines on the map."),
2104 GEN_BOOL_OPTION(draw_fortress_airbase, N_("Draw the bases"),
2105 N_("Setting this option will draw the bases on the map."),
2108 GEN_BOOL_OPTION(draw_specials, N_("Draw the resources"),
2109 N_("Setting this option will draw the resources on the "
2110 "map."),
2113 GEN_BOOL_OPTION(draw_huts, N_("Draw the huts"),
2114 N_("Setting this option will draw the huts on the "
2115 "map."),
2118 GEN_BOOL_OPTION(draw_pollution, N_("Draw the pollution/nuclear fallout"),
2119 N_("Setting this option will draw pollution and "
2120 "nuclear fallout on the map."),
2123 GEN_BOOL_OPTION(draw_cities, N_("Draw the cities"),
2124 N_("Setting this option will draw the cities on the map."),
2127 GEN_BOOL_OPTION(draw_units, N_("Draw the units"),
2128 N_("Setting this option will draw the units on the map."),
2131 GEN_BOOL_OPTION(solid_color_behind_units,
2132 N_("Solid unit background color"),
2133 N_("Setting this option will cause units on the map "
2134 "view to be drawn with a solid background color "
2135 "instead of the flag backdrop."),
2138 GEN_BOOL_OPTION(draw_unit_shields, N_("Draw shield graphics for units"),
2139 N_("Setting this option will draw a shield icon "
2140 "as the flags on units. If unset, the full flag will "
2141 "be drawn."),
2143 GEN_BOOL_OPTION(draw_unit_stack_size, N_("Draw size of the unit stacks"),
2144 N_("Setting this option will draw a numbers indicating "
2145 "size of the unit stacks. Not all clients support "
2146 "this."),
2148 GEN_BOOL_OPTION(draw_focus_unit, N_("Draw the units in focus"),
2149 N_("Setting this option will cause the currently focused "
2150 "unit(s) to always be drawn, even if units are not "
2151 "otherwise being drawn (for instance if 'Draw the units' "
2152 "is unset)."),
2155 GEN_BOOL_OPTION(draw_fog_of_war, N_("Draw the fog of war"),
2156 N_("Setting this option will draw the fog of war."),
2159 GEN_BOOL_OPTION(draw_borders, N_("Draw the borders"),
2160 N_("Setting this option will draw the national borders."),
2163 GEN_BOOL_OPTION(draw_native, N_("Draw whether tiles are native to "
2164 "selected unit"),
2165 N_("Setting this option will highlight tiles that the "
2166 "currently selected unit cannot enter unaided due to "
2167 "non-native terrain. (If multiple units are selected, "
2168 "only tiles that all of them can enter are indicated.)"),
2171 GEN_BOOL_OPTION(player_dlg_show_dead_players,
2172 N_("Show dead players in Nations report"),
2173 N_("This option controls whether defeated nations are "
2174 "shown on the Nations report page."),
2177 GEN_BOOL_OPTION(sound_bell_at_new_turn, N_("Sound bell at new turn"),
2178 N_("Set this option to have a \"bell\" event be generated "
2179 "at the start of a new turn. You can control the "
2180 "behavior of the \"bell\" event by editing the message "
2181 "options."),
2183 GEN_INT_OPTION(smooth_move_unit_msec,
2184 N_("Unit movement animation time (milliseconds)"),
2185 N_("This option controls how long unit \"animation\" takes "
2186 "when a unit moves on the map view. Set it to 0 to "
2187 "disable animation entirely."),
2188 COC_GRAPHICS, GUI_STUB, 30, 0, 2000, NULL),
2189 GEN_INT_OPTION(smooth_center_slide_msec,
2190 N_("Mapview recentering time (milliseconds)"),
2191 N_("When the map view is recentered, it will slide "
2192 "smoothly over the map to its new position. This "
2193 "option controls how long this slide lasts. Set it to "
2194 "0 to disable mapview sliding entirely."),
2195 COC_GRAPHICS, GUI_STUB, 200, 0, 5000, NULL),
2196 GEN_INT_OPTION(smooth_combat_step_msec,
2197 N_("Combat animation step time (milliseconds)"),
2198 N_("This option controls the speed of combat animation "
2199 "between units on the mapview. Set it to 0 to disable "
2200 "animation entirely."),
2201 COC_GRAPHICS, GUI_STUB, 10, 0, 100, NULL),
2202 GEN_BOOL_OPTION(reqtree_show_icons,
2203 N_("Show icons in the technology tree"),
2204 N_("Setting this option will display icons "
2205 "on the technology tree diagram. Turning "
2206 "this option off makes the technology tree "
2207 "more compact."),
2209 GEN_BOOL_OPTION(reqtree_curved_lines,
2210 N_("Use curved lines in the technology tree"),
2211 N_("Setting this option make the technology tree "
2212 "diagram use curved lines to show technology "
2213 "relations. Turning this option off causes "
2214 "the lines to be drawn straight."),
2217 GEN_COLOR_OPTION(highlight_our_names,
2218 N_("Color to highlight your player/user name"),
2219 N_("If set, your player and user name in the new chat "
2220 "messages will be highlighted using this color as "
2221 "background. If not set, it will just not highlight "
2222 "anything."),
2223 COC_GRAPHICS, GUI_STUB, "#000000", "#FFFF00", NULL),
2224 GEN_BOOL_OPTION(ai_manual_turn_done, N_("Manual Turn Done in AI mode"),
2225 N_("Disable this option if you do not want to "
2226 "press the Turn Done button manually when watching "
2227 "an AI player."),
2229 GEN_BOOL_OPTION(auto_center_on_unit, N_("Auto center on units"),
2230 N_("Set this option to have the active unit centered "
2231 "automatically when the unit focus changes."),
2233 GEN_BOOL_OPTION(auto_center_on_automated, N_("Show automated units"),
2234 N_("Disable this option if you do not want to see "
2235 "automated units autocentered and animated."),
2237 GEN_BOOL_OPTION(auto_center_on_combat, N_("Auto center on combat"),
2238 N_("Set this option to have any combat be centered "
2239 "automatically. Disabling this will speed up the time "
2240 "between turns but may cause you to miss combat "
2241 "entirely."),
2243 GEN_BOOL_OPTION(auto_center_each_turn, N_("Auto center on new turn"),
2244 N_("Set this option to have the client automatically "
2245 "recenter the map on a suitable location at the "
2246 "start of each turn."),
2248 GEN_BOOL_OPTION(wakeup_focus, N_("Focus on awakened units"),
2249 N_("Set this option to have newly awoken units be "
2250 "focused automatically."),
2252 GEN_BOOL_OPTION(keyboardless_goto, N_("Keyboardless goto"),
2253 N_("If this option is set then a goto may be initiated "
2254 "by left-clicking and then holding down the mouse "
2255 "button while dragging the mouse onto a different "
2256 "tile."),
2258 GEN_BOOL_OPTION(goto_into_unknown, N_("Allow goto into the unknown"),
2259 N_("Setting this option will make the game consider "
2260 "moving into unknown tiles. If not, then goto routes "
2261 "will detour around or be blocked by unknown tiles."),
2263 GEN_BOOL_OPTION(center_when_popup_city, N_("Center map when popup city"),
2264 N_("Setting this option makes the mapview center on a "
2265 "city when its city dialog is popped up."),
2267 GEN_BOOL_OPTION(show_previous_turn_messages, N_("Show messages from previous turn"),
2268 N_("Message Window shows messages also from previous turn. "
2269 "This makes sure you don't miss messages received in the end of "
2270 "the turn, just before the window gets cleared."),
2272 GEN_BOOL_OPTION(concise_city_production, N_("Concise city production"),
2273 N_("Set this option to make the city production (as shown "
2274 "in the city dialog) to be more compact."),
2276 GEN_BOOL_OPTION(auto_turn_done, N_("End turn when done moving"),
2277 N_("Setting this option makes your turn end automatically "
2278 "when all your units are done moving."),
2280 GEN_BOOL_OPTION(ask_city_name, N_("Prompt for city names"),
2281 N_("Disabling this option will make the names of newly "
2282 "founded cities be chosen automatically by the server."),
2284 GEN_BOOL_OPTION(popup_new_cities, N_("Pop up city dialog for new cities"),
2285 N_("Setting this option will pop up a newly-founded "
2286 "city's city dialog automatically."),
2288 GEN_BOOL_OPTION(popup_actor_arrival, N_("Pop up caravan and spy actions"),
2289 N_("If this option is enabled, when a unit arrives at "
2290 "a city where it can perform an action like "
2291 "establishing a trade route, helping build a wonder, or "
2292 "establishing an embassy, a window will pop up asking "
2293 "which action should be performed. "
2294 "Disabling this option means you will have to do the "
2295 "action manually by pressing either 'r' (for a trade "
2296 "route), 'b' (for building a wonder) or 'd' (for a "
2297 "spy action) when the unit is in the city."),
2299 GEN_BOOL_OPTION(popup_attack_actions, N_("Pop up attack questions"),
2300 N_("If this option is enabled, when a unit arrives at a "
2301 "target it can attack, a window will pop up asking "
2302 "which action should be performed even if an attack "
2303 "action is legal and no other interesting action are. "
2304 "This allows you to change your mind or to select an "
2305 "uninteresting action."),
2307 GEN_BOOL_OPTION(popup_last_move_to_allied,
2308 /* TODO: Rename option ..._last_... to match _final_ in
2309 * the descriptions.
2310 * Changes options file format, needs migration
2311 * when loading old version. */
2312 N_("Pop up actions when final move to allied tile"),
2313 N_("If this option is enabled the final move in a unit's"
2314 " orders to a tile with allied units or cities it can"
2315 " perform an action to is interpreted as an attempted"
2316 " action. This makes the action selection dialog pop up"
2317 " while the unit is at the adjacent tile."
2318 " This can, in cases where the action requires that"
2319 " the actor unit has moves left, save a turn."
2320 " The down side is that the unit remains adjacent to"
2321 " rather than inside the protection of an allied city"
2322 " or unit stack."),
2324 GEN_BOOL_OPTION(enable_cursor_changes, N_("Enable cursor changing"),
2325 N_("This option controls whether the client should "
2326 "try to change the mouse cursor depending on what "
2327 "is being pointed at, as well as to indicate "
2328 "changes in the client or server state."),
2330 GEN_BOOL_OPTION(separate_unit_selection, N_("Select cities before units"),
2331 N_("If this option is enabled, when both cities and "
2332 "units are present in the selection rectangle, only "
2333 "cities will be selected. See the help on Controls."),
2335 GEN_BOOL_OPTION(unit_selection_clears_orders,
2336 N_("Clear unit orders on selection"),
2337 N_("Enabling this option will cause unit orders to be "
2338 "cleared as soon as one or more units are selected. If "
2339 "this option is disabled, busy units will not stop "
2340 "their current activity when selected. Giving them "
2341 "new orders will clear their current ones; pressing "
2342 "<space> once will clear their orders and leave them "
2343 "selected, and pressing <space> a second time will "
2344 "dismiss them."),
2346 GEN_BOOL_OPTION(voteinfo_bar_use, N_("Enable vote bar"),
2347 N_("If this option is turned on, the vote bar will be "
2348 "displayed to show vote information."),
2350 GEN_BOOL_OPTION(voteinfo_bar_always_show,
2351 N_("Always display the vote bar"),
2352 N_("If this option is turned on, the vote bar will never "
2353 "be hidden, even if there is no running vote."),
2355 GEN_BOOL_OPTION(voteinfo_bar_hide_when_not_player,
2356 N_("Do not show vote bar if not a player"),
2357 N_("If this option is enabled, the client won't show the "
2358 "vote bar if you are not a player."),
2360 GEN_BOOL_OPTION(voteinfo_bar_new_at_front, N_("Set new votes at front"),
2361 N_("If this option is enabled, then new votes will go "
2362 "to the front of the vote list."),
2364 GEN_BOOL_OPTION(autoaccept_tileset_suggestion,
2365 N_("Autoaccept tileset suggestions"),
2366 N_("If this option is enabled, any tileset suggested by "
2367 "the ruleset is automatically used; otherwise you "
2368 "are prompted to change tileset."),
2370
2371 GEN_BOOL_OPTION(sound_enable_effects,
2372 N_("Enable sound effects"),
2373 N_("Play sound effects, assuming there's suitable "
2374 "sound plugin and soundset with the sounds."),
2376 GEN_BOOL_OPTION(sound_enable_game_music,
2377 N_("Enable in-game music"),
2378 N_("Play music during the game, assuming there's suitable "
2379 "sound plugin and musicset with in-game tracks."),
2381 GEN_BOOL_OPTION(sound_enable_menu_music,
2382 N_("Enable menu music"),
2383 N_("Play music while not in actual game, "
2384 "assuming there's suitable "
2385 "sound plugin and musicset with menu music tracks."),
2387 GEN_BOOL_OPTION(silent_when_not_in_focus,
2388 N_("Silent when not in focus"),
2389 N_("Fade all sound out when the client is not in focus. "
2390 "Not all clients support this."),
2392 GEN_INT_OPTION(sound_effects_volume,
2393 N_("Sound volume"),
2394 N_("Volume scale from 0-100"),
2395 COC_SOUND, GUI_STUB, 100,
2396 0, 100,
2398
2399 GEN_BOOL_OPTION(autoaccept_soundset_suggestion,
2400 N_("Autoaccept soundset suggestions"),
2401 N_("If this option is enabled, any soundset suggested by "
2402 "the ruleset is automatically used."),
2404 GEN_BOOL_OPTION(autoaccept_musicset_suggestion,
2405 N_("Autoaccept musicset suggestions"),
2406 N_("If this option is enabled, any musicset suggested by "
2407 "the ruleset is automatically used."),
2409
2411 N_("Background layer"),
2412 N_("The background layer of the overview shows just "
2413 "ocean and land."),
2416 N_("Terrain relief map layer"),
2417 N_("The relief layer shows all terrains on the map."),
2420 N_("Borders layer"),
2421 N_("The borders layer of the overview shows which tiles "
2422 "are owned by each player."),
2425 N_("Borders layer on ocean tiles"),
2426 N_("The borders layer of the overview are drawn on "
2427 "ocean tiles as well (this may look ugly with many "
2428 "islands). This option is only of interest if you "
2429 "have set the option \"Borders layer\" already."),
2432 N_("Units layer"),
2433 N_("Enabling this will draw units on the overview."),
2436 N_("Cities layer"),
2437 N_("Enabling this will draw cities on the overview."),
2440 N_("Overview fog of war"),
2441 N_("Enabling this will show fog of war on the "
2442 "overview."),
2444
2445 /* options for map images */
2446 GEN_STR_LIST_OPTION(mapimg_format,
2447 N_("Image format"),
2448 N_("The image toolkit and file format used for "
2449 "map images."),
2451 NULL, 0),
2452 GEN_INT_OPTION(mapimg_zoom,
2453 N_("Zoom factor for map images"),
2454 N_("The magnification used for map images."),
2456 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_AREA],
2457 N_("Show area within borders"),
2458 N_("If set, the territory of each nation is shown "
2459 "on the saved image."),
2462 N_("Show borders"),
2463 N_("If set, the border of each nation is shown on the "
2464 "saved image."),
2467 N_("Show cities"),
2468 N_("If set, cities are shown on the saved image."),
2471 N_("Show fog of war"),
2472 N_("If set, the extent of fog of war is shown on the "
2473 "saved image."),
2476 N_("Show full terrain"),
2477 N_("If set, terrain relief is shown with different colors "
2478 "in the saved image; otherwise, only land and water are "
2479 "distinguished."),
2481 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_UNITS],
2482 N_("Show units"),
2483 N_("If set, units are shown in the saved image."),
2485 GEN_STR_OPTION(mapimg_filename,
2486 N_("Map image file name"),
2487 N_("The base part of the filename for saved map images. "
2488 "A string identifying the game turn and map options will "
2489 "be appended."),
2491
2492 /* gui-gtk-2.0 client specific options.
2493 * These are still kept just so users can migrate them to later gtk-clients */
2494 GEN_BOOL_OPTION(gui_gtk2_map_scrollbars, NULL, NULL,
2496 GEN_BOOL_OPTION(gui_gtk2_dialogs_on_top, NULL, NULL,
2498 GEN_BOOL_OPTION(gui_gtk2_show_task_icons, NULL, NULL,
2500 GEN_BOOL_OPTION(gui_gtk2_enable_tabs, NULL, NULL,
2502 GEN_BOOL_OPTION(gui_gtk2_better_fog, NULL, NULL,
2505 GEN_BOOL_OPTION(gui_gtk2_show_chat_message_time, NULL, NULL,
2507 GEN_BOOL_OPTION(gui_gtk2_new_messages_go_to_top, NULL, NULL,
2509 GEN_BOOL_OPTION(gui_gtk2_show_message_window_buttons, NULL, NULL,
2511 GEN_BOOL_OPTION(gui_gtk2_metaserver_tab_first, NULL, NULL,
2513 GEN_BOOL_OPTION(gui_gtk2_allied_chat_only, NULL, NULL,
2515 GEN_BOOL_OPTION(gui_gtk2_mouse_over_map_focus, NULL, NULL,
2517 GEN_BOOL_OPTION(gui_gtk2_chatline_autocompletion, NULL, NULL,
2519 GEN_INT_OPTION(gui_gtk2_citydlg_xsize, NULL, NULL,
2522 NULL),
2523 GEN_INT_OPTION(gui_gtk2_citydlg_ysize, NULL, NULL,
2526 NULL),
2527 GEN_ENUM_OPTION(gui_gtk2_popup_tech_help, NULL, NULL,
2531 GEN_FONT_OPTION(gui_gtk2_font_city_label, "city_label",
2532 NULL, NULL,
2534 "Monospace 8", font_changed_callback),
2535 GEN_FONT_OPTION(gui_gtk2_font_notify_label, "notify_label",
2536 NULL, NULL,
2538 "Monospace Bold 9", font_changed_callback),
2539 GEN_FONT_OPTION(gui_gtk2_font_spaceship_label, "spaceship_label",
2540 NULL, NULL,
2542 "Monospace 8", font_changed_callback),
2543 GEN_FONT_OPTION(gui_gtk2_font_help_label, "help_label",
2544 NULL, NULL,
2546 "Sans Bold 10", font_changed_callback),
2547 GEN_FONT_OPTION(gui_gtk2_font_help_link, "help_link",
2548 NULL, NULL,
2550 "Sans 9", font_changed_callback),
2551 GEN_FONT_OPTION(gui_gtk2_font_help_text, "help_text",
2552 NULL, NULL,
2554 "Monospace 8", font_changed_callback),
2555 GEN_FONT_OPTION(gui_gtk2_font_chatline, "chatline",
2556 NULL, NULL,
2558 "Monospace 8", font_changed_callback),
2559 GEN_FONT_OPTION(gui_gtk2_font_beta_label, "beta_label",
2560 NULL, NULL,
2562 "Sans Italic 10", font_changed_callback),
2563 GEN_FONT_OPTION(gui_gtk2_font_small, "small_font",
2564 NULL, NULL,
2566 "Sans 9", NULL),
2567 GEN_FONT_OPTION(gui_gtk2_font_comment_label, "comment_label",
2568 NULL, NULL,
2570 "Sans Italic 9", font_changed_callback),
2571 GEN_FONT_OPTION(gui_gtk2_font_city_names, "city_names",
2572 NULL, NULL,
2574 "Sans Bold 10", NULL),
2575 GEN_FONT_OPTION(gui_gtk2_font_city_productions, "city_productions",
2576 NULL, NULL,
2578 "Serif 10", NULL),
2579 GEN_FONT_OPTION(gui_gtk2_font_reqtree_text, "reqtree_text",
2580 NULL, NULL,
2582 "Serif 10", NULL),
2583
2584 /* gui-gtk-3.0 client specific options.
2585 * These are still kept just so users can migrate them to later gtk-clients */
2586 GEN_BOOL_OPTION(gui_gtk3_fullscreen, NULL, NULL,
2588 GEN_BOOL_OPTION(gui_gtk3_map_scrollbars, N_("Show map scrollbars"),
2589 N_("Disable this option to hide the scrollbars on the "
2590 "map view."),
2592 GEN_BOOL_OPTION(gui_gtk3_dialogs_on_top, NULL, NULL,
2594 GEN_BOOL_OPTION(gui_gtk3_show_task_icons, NULL, NULL,
2596 GEN_BOOL_OPTION(gui_gtk3_enable_tabs, NULL, NULL,
2598 GEN_BOOL_OPTION(gui_gtk3_show_chat_message_time, NULL, NULL,
2600 GEN_BOOL_OPTION(gui_gtk3_new_messages_go_to_top, NULL, NULL,
2602 GEN_BOOL_OPTION(gui_gtk3_show_message_window_buttons, NULL, NULL,
2604 GEN_BOOL_OPTION(gui_gtk3_metaserver_tab_first, NULL, NULL,
2606 GEN_BOOL_OPTION(gui_gtk3_allied_chat_only, NULL, NULL,
2608 GEN_ENUM_OPTION(gui_gtk3_message_chat_location, NULL, NULL,
2612 GEN_BOOL_OPTION(gui_gtk3_small_display_layout, NULL, NULL,
2614 GEN_BOOL_OPTION(gui_gtk3_mouse_over_map_focus, NULL, NULL,
2616 GEN_BOOL_OPTION(gui_gtk3_chatline_autocompletion, NULL, NULL,
2618 GEN_INT_OPTION(gui_gtk3_citydlg_xsize, NULL, NULL,
2621 NULL),
2622 GEN_INT_OPTION(gui_gtk3_citydlg_ysize, NULL, NULL,
2625 NULL),
2626 GEN_ENUM_OPTION(gui_gtk3_popup_tech_help, NULL, NULL,
2630 GEN_INT_OPTION(gui_gtk3_governor_range_min, NULL, NULL,
2633 NULL),
2634 GEN_INT_OPTION(gui_gtk3_governor_range_max, NULL, NULL,
2637 NULL),
2638 GEN_FONT_OPTION(gui_gtk3_font_city_label, "city_label",
2639 NULL, NULL,
2641 "Monospace 8", font_changed_callback),
2642 GEN_FONT_OPTION(gui_gtk3_font_notify_label, "notify_label",
2643 NULL, NULL,
2645 "Monospace Bold 9", font_changed_callback),
2646 GEN_FONT_OPTION(gui_gtk3_font_spaceship_label, "spaceship_label",
2647 NULL, NULL,
2649 "Monospace 8", font_changed_callback),
2650 GEN_FONT_OPTION(gui_gtk3_font_help_label, "help_label",
2651 NULL, NULL,
2653 "Sans Bold 10", font_changed_callback),
2654 GEN_FONT_OPTION(gui_gtk3_font_help_link, "help_link",
2655 NULL, NULL,
2657 "Sans 9", font_changed_callback),
2658 GEN_FONT_OPTION(gui_gtk3_font_help_text, "help_text",
2659 NULL, NULL,
2661 "Monospace 8", font_changed_callback),
2662 GEN_FONT_OPTION(gui_gtk3_font_chatline, "chatline",
2663 NULL, NULL,
2665 "Monospace 8", font_changed_callback),
2666 GEN_FONT_OPTION(gui_gtk3_font_beta_label, "beta_label",
2667 NULL, NULL,
2669 "Sans Italic 10", font_changed_callback),
2670 GEN_FONT_OPTION(gui_gtk3_font_small, "small_font",
2671 NULL, NULL,
2673 "Sans 9", NULL),
2674 GEN_FONT_OPTION(gui_gtk3_font_comment_label, "comment_label",
2675 NULL, NULL,
2677 "Sans Italic 9", font_changed_callback),
2678 GEN_FONT_OPTION(gui_gtk3_font_city_names, "city_names",
2679 NULL, NULL,
2681 "Sans Bold 10", NULL),
2682 GEN_FONT_OPTION(gui_gtk3_font_city_productions, "city_productions",
2683 NULL, NULL,
2685 "Serif 10", NULL),
2686 GEN_FONT_OPTION(gui_gtk3_font_reqtree_text, "reqtree_text",
2687 NULL, NULL,
2689 "Serif 10", NULL),
2690
2691 /* gui-gtk-3.22 client specific options. */
2692 GEN_BOOL_OPTION(gui_gtk3_22_fullscreen, N_("Fullscreen"),
2693 N_("If this option is set the client will use the "
2694 "whole screen area for drawing."),
2696 GEN_BOOL_OPTION(gui_gtk3_22_map_scrollbars, N_("Show map scrollbars"),
2697 N_("Disable this option to hide the scrollbars on the "
2698 "map view."),
2700 GEN_BOOL_OPTION(gui_gtk3_22_dialogs_on_top, N_("Keep dialogs on top"),
2701 N_("If this option is set then dialog windows will always "
2702 "remain in front of the main Freeciv window. "
2703 "Disabling this has no effect in fullscreen mode."),
2705 GEN_BOOL_OPTION(gui_gtk3_22_show_task_icons, N_("Show worklist task icons"),
2706 N_("Disabling this will turn off the unit and building "
2707 "icons in the worklist dialog and the production "
2708 "tab of the city dialog."),
2710 GEN_BOOL_OPTION(gui_gtk3_22_enable_tabs, N_("Enable status report tabs"),
2711 N_("If this option is enabled then report dialogs will "
2712 "be shown as separate tabs rather than in popup "
2713 "dialogs."),
2715 GEN_BOOL_OPTION(gui_gtk3_22_show_chat_message_time,
2716 N_("Show time for each chat message"),
2717 N_("If this option is enabled then all chat messages "
2718 "will be prefixed by a time string of the form "
2719 "[hour:minute:second]."),
2721 GEN_BOOL_OPTION(gui_gtk3_22_new_messages_go_to_top,
2722 N_("New message events go to top of list"),
2723 N_("If this option is enabled, new events in the "
2724 "message window will appear at the top of the list, "
2725 "rather than being appended at the bottom."),
2727 GEN_BOOL_OPTION(gui_gtk3_22_show_message_window_buttons,
2728 N_("Show extra message window buttons"),
2729 N_("If this option is enabled, there will be two "
2730 "buttons displayed in the message window for "
2731 "inspecting a city and going to a location. If this "
2732 "option is disabled, these buttons will not appear "
2733 "(you can still double-click with the left mouse "
2734 "button or right-click on a row to inspect or goto "
2735 "respectively). This option will only take effect "
2736 "once the message window is closed and reopened."),
2738 GEN_BOOL_OPTION(gui_gtk3_22_metaserver_tab_first,
2739 N_("Metaserver tab first in network page"),
2740 N_("If this option is enabled, the metaserver tab will "
2741 "be the first notebook tab in the network page. This "
2742 "option requires a restart in order to take effect."),
2744 GEN_BOOL_OPTION(gui_gtk3_22_allied_chat_only,
2745 N_("Plain chat messages are sent to allies only"),
2746 N_("If this option is enabled, then plain messages "
2747 "typed into the chat entry while the game is "
2748 "running will only be sent to your allies. "
2749 "Otherwise plain messages will be sent as "
2750 "public chat messages. To send a public chat "
2751 "message with this option enabled, prefix the "
2752 "message with a single colon ':'. This option "
2753 "can also be set using a toggle button beside "
2754 "the chat entry (only visible in multiplayer "
2755 "games)."),
2757 GEN_ENUM_OPTION(gui_gtk3_22_message_chat_location,
2758 N_("Messages and Chat reports location"),
2759 /* TRANS: The strings used in the UI for 'Split' etc are
2760 * tagged 'gui_gtk2/gtk3/gtk4_message_chat_location' */
2761 N_("Controls where the Messages and Chat reports "
2762 "appear relative to the main view containing the map.\n"
2763 "'Split' allows all three to be seen simultaneously, "
2764 "which is best for multiplayer, but requires a large "
2765 "window to be usable.\n"
2766 "'Separate' puts Messages and Chat in a notebook "
2767 "separate from the main view, so that one of them "
2768 "can always be seen alongside the main view.\n"
2769 "'Merged' makes the Messages and Chat reports into "
2770 "tabs alongside the map and other reports; this "
2771 "allows a larger map view on small screens.\n"
2772 "This option requires a restart in order to take "
2773 "effect."), COC_INTERFACE, GUI_GTK3_22,
2776 GEN_BOOL_OPTION(gui_gtk3_22_small_display_layout,
2777 N_("Arrange widgets for small displays"),
2778 N_("If this option is enabled, widgets in the main "
2779 "window will be arranged so that they take up the "
2780 "least amount of total screen space. Specifically, "
2781 "the left panel containing the overview, player "
2782 "status, and the unit information box will be "
2783 "extended over the entire left side of the window. "
2784 "This option requires a restart in order to take "
2785 "effect."), COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2786 GEN_BOOL_OPTION(gui_gtk3_22_mouse_over_map_focus,
2787 N_("Mouse over the map widget selects it automatically"),
2788 N_("If this option is enabled, then the map will be "
2789 "focused when the mouse hovers over it."),
2791 GEN_BOOL_OPTION(gui_gtk3_22_chatline_autocompletion,
2792 N_("Player or user name autocompletion"),
2793 N_("If this option is turned on, the tabulation key "
2794 "will be used in the chatline to complete the word you "
2795 "are typing with the name of a player or a user."),
2797 GEN_INT_OPTION(gui_gtk3_22_citydlg_xsize,
2798 N_("Width of the city dialog"),
2799 N_("This value is only used if the width of the city "
2800 "dialog is saved."),
2803 NULL),
2804 GEN_INT_OPTION(gui_gtk3_22_citydlg_ysize,
2805 N_("Height of the city dialog"),
2806 N_("This value is only used if the height of the city "
2807 "dialog is saved."),
2810 NULL),
2811 GEN_ENUM_OPTION(gui_gtk3_22_popup_tech_help,
2812 N_("Popup tech help when gained"),
2813 N_("Controls if tech help should be opened when "
2814 "new tech has been gained.\n"
2815 "'Ruleset' means that behavior suggested by "
2816 "current ruleset is used."), COC_INTERFACE, GUI_GTK3_22,
2819 GEN_INT_OPTION(gui_gtk3_22_governor_range_min,
2820 N_("Minimum surplus for a governor"),
2821 N_("The lower limit of the range for requesting surpluses "
2822 "from the governor."),
2825 NULL),
2826 GEN_INT_OPTION(gui_gtk3_22_governor_range_max,
2827 N_("Maximum surplus for a governor"),
2828 N_("The higher limit of the range for requesting surpluses "
2829 "from the governor."),
2832 NULL),
2833 GEN_FONT_OPTION(gui_gtk3_22_font_city_label, "city_label",
2834 N_("City Label"),
2835 N_("This font is used to display the city labels on city "
2836 "dialogs."),
2838 "Monospace 8", font_changed_callback),
2839 GEN_FONT_OPTION(gui_gtk3_22_font_notify_label, "notify_label",
2840 N_("Notify Label"),
2841 N_("This font is used to display server reports such "
2842 "as the demographic report or historian publications."),
2844 "Monospace Bold 9", font_changed_callback),
2845 GEN_FONT_OPTION(gui_gtk3_22_font_spaceship_label, "spaceship_label",
2846 N_("Spaceship Label"),
2847 N_("This font is used to display the spaceship widgets."),
2849 "Monospace 8", font_changed_callback),
2850 GEN_FONT_OPTION(gui_gtk3_22_font_help_label, "help_label",
2851 N_("Help Label"),
2852 N_("This font is used to display the help headers in the "
2853 "help window."),
2855 "Sans Bold 10", font_changed_callback),
2856 GEN_FONT_OPTION(gui_gtk3_22_font_help_link, "help_link",
2857 N_("Help Link"),
2858 N_("This font is used to display the help links in the "
2859 "help window."),
2861 "Sans 9", font_changed_callback),
2862 GEN_FONT_OPTION(gui_gtk3_22_font_help_text, "help_text",
2863 N_("Help Text"),
2864 N_("This font is used to display the help body text in "
2865 "the help window."),
2867 "Monospace 8", font_changed_callback),
2868 GEN_FONT_OPTION(gui_gtk3_22_font_chatline, "chatline",
2869 N_("Chatline Area"),
2870 N_("This font is used to display the text in the "
2871 "chatline area."),
2873 "Monospace 8", font_changed_callback),
2874 GEN_FONT_OPTION(gui_gtk3_22_font_beta_label, "beta_label",
2875 N_("Beta Label"),
2876 N_("This font is used to display the beta label."),
2878 "Sans Italic 10", font_changed_callback),
2879 GEN_FONT_OPTION(gui_gtk3_22_font_small, "small_font",
2880 N_("Small Font"),
2881 N_("This font is used for any small font request. For "
2882 "example, it is used for display the building lists "
2883 "in the city dialog, the Economy report or the Units "
2884 "report."),
2886 "Sans 9", font_changed_callback),
2887 GEN_FONT_OPTION(gui_gtk3_22_font_comment_label, "comment_label",
2888 N_("Comment Label"),
2889 N_("This font is used to display comment labels, such as "
2890 "in the governor page of the city dialogs."),
2892 "Sans Italic 9", font_changed_callback),
2893 GEN_FONT_OPTION(gui_gtk3_22_font_city_names, "city_names",
2894 N_("City Names"),
2895 N_("This font is used to the display the city names "
2896 "on the map."),
2898 "Sans Bold 10", NULL),
2899 GEN_FONT_OPTION(gui_gtk3_22_font_city_productions, "city_productions",
2900 N_("City Productions"),
2901 N_("This font is used to display the city production "
2902 "on the map."),
2904 "Serif 10", NULL),
2905 GEN_FONT_OPTION(gui_gtk3_22_font_reqtree_text, "reqtree_text",
2906 N_("Requirement Tree"),
2907 N_("This font is used to the display the requirement tree "
2908 "in the Research report."),
2910 "Serif 10", NULL),
2911
2912 /* gui-gtk-4.0 client specific options. */
2913 GEN_BOOL_OPTION(gui_gtk4_fullscreen, N_("Fullscreen"),
2914 N_("If this option is set the client will use the "
2915 "whole screen area for drawing."),
2917 GEN_BOOL_OPTION(gui_gtk4_map_scrollbars, N_("Show map scrollbars"),
2918 N_("Disable this option to hide the scrollbars on the "
2919 "map view."),
2921 GEN_BOOL_OPTION(gui_gtk4_dialogs_on_top, N_("Keep dialogs on top"),
2922 N_("If this option is set then dialog windows will always "
2923 "remain in front of the main Freeciv window. "
2924 "Disabling this has no effect in fullscreen mode."),
2926 GEN_BOOL_OPTION(gui_gtk4_show_task_icons, N_("Show worklist task icons"),
2927 N_("Disabling this will turn off the unit and building "
2928 "icons in the worklist dialog and the production "
2929 "tab of the city dialog."),
2931 GEN_BOOL_OPTION(gui_gtk4_enable_tabs, N_("Enable status report tabs"),
2932 N_("If this option is enabled then report dialogs will "
2933 "be shown as separate tabs rather than in popup "
2934 "dialogs."),
2936 GEN_BOOL_OPTION(gui_gtk4_show_chat_message_time,
2937 N_("Show time for each chat message"),
2938 N_("If this option is enabled then all chat messages "
2939 "will be prefixed by a time string of the form "
2940 "[hour:minute:second]."),
2942 GEN_BOOL_OPTION(gui_gtk4_new_messages_go_to_top,
2943 N_("New message events go to top of list"),
2944 N_("If this option is enabled, new events in the "
2945 "message window will appear at the top of the list, "
2946 "rather than being appended at the bottom."),
2948 GEN_BOOL_OPTION(gui_gtk4_show_message_window_buttons,
2949 N_("Show extra message window buttons"),
2950 N_("If this option is enabled, there will be two "
2951 "buttons displayed in the message window for "
2952 "inspecting a city and going to a location. If this "
2953 "option is disabled, these buttons will not appear "
2954 "(you can still double-click with the left mouse "
2955 "button or right-click on a row to inspect or goto "
2956 "respectively). This option will only take effect "
2957 "once the message window is closed and reopened."),
2959 GEN_BOOL_OPTION(gui_gtk4_metaserver_tab_first,
2960 N_("Metaserver tab first in network page"),
2961 N_("If this option is enabled, the metaserver tab will "
2962 "be the first notebook tab in the network page. This "
2963 "option requires a restart in order to take effect."),
2965 GEN_BOOL_OPTION(gui_gtk4_allied_chat_only,
2966 N_("Plain chat messages are sent to allies only"),
2967 N_("If this option is enabled, then plain messages "
2968 "typed into the chat entry while the game is "
2969 "running will only be sent to your allies. "
2970 "Otherwise plain messages will be sent as "
2971 "public chat messages. To send a public chat "
2972 "message with this option enabled, prefix the "
2973 "message with a single colon ':'. This option "
2974 "can also be set using a toggle button beside "
2975 "the chat entry (only visible in multiplayer "
2976 "games)."),
2978 GEN_ENUM_OPTION(gui_gtk4_message_chat_location,
2979 N_("Messages and Chat reports location"),
2980 /* TRANS: The strings used in the UI for 'Split' etc are
2981 * tagged 'gui_gtk2/gtk3/gtk4_message_chat_location' */
2982 N_("Controls where the Messages and Chat reports "
2983 "appear relative to the main view containing the map.\n"
2984 "'Split' allows all three to be seen simultaneously, "
2985 "which is best for multiplayer, but requires a large "
2986 "window to be usable.\n"
2987 "'Separate' puts Messages and Chat in a notebook "
2988 "separate from the main view, so that one of them "
2989 "can always be seen alongside the main view.\n"
2990 "'Merged' makes the Messages and Chat reports into "
2991 "tabs alongside the map and other reports; this "
2992 "allows a larger map view on small screens.\n"
2993 "This option requires a restart in order to take "
2994 "effect."), COC_INTERFACE, GUI_GTK4,
2997 GEN_BOOL_OPTION(gui_gtk4_small_display_layout,
2998 N_("Arrange widgets for small displays"),
2999 N_("If this option is enabled, widgets in the main "
3000 "window will be arranged so that they take up the "
3001 "least amount of total screen space. Specifically, "
3002 "the left panel containing the overview, player "
3003 "status, and the unit information box will be "
3004 "extended over the entire left side of the window. "
3005 "This option requires a restart in order to take "
3006 "effect."), COC_INTERFACE, GUI_GTK4, FALSE, NULL),
3007 GEN_BOOL_OPTION(gui_gtk4_mouse_over_map_focus,
3008 N_("Mouse over the map widget selects it automatically"),
3009 N_("If this option is enabled, then the map will be "
3010 "focused when the mouse hovers over it."),
3012 GEN_BOOL_OPTION(gui_gtk4_chatline_autocompletion,
3013 N_("Player or user name autocompletion"),
3014 N_("If this option is turned on, the tabulation key "
3015 "will be used in the chatline to complete the word you "
3016 "are typing with the name of a player or a user."),
3018 GEN_INT_OPTION(gui_gtk4_citydlg_xsize,
3019 N_("Width of the city dialog"),
3020 N_("This value is only used if the width of the city "
3021 "dialog is saved."),
3024 NULL),
3025 GEN_INT_OPTION(gui_gtk4_citydlg_ysize,
3026 N_("Height of the city dialog"),
3027 N_("This value is only used if the height of the city "
3028 "dialog is saved."),
3031 NULL),
3032 GEN_ENUM_OPTION(gui_gtk4_popup_tech_help,
3033 N_("Popup tech help when gained"),
3034 N_("Controls if tech help should be opened when "
3035 "new tech has been gained.\n"
3036 "'Ruleset' means that behavior suggested by "
3037 "current ruleset is used."), COC_INTERFACE, GUI_GTK4,
3040 GEN_INT_OPTION(gui_gtk4_governor_range_min,
3041 N_("Minimum surplus for a governor"),
3042 N_("The lower limit of the range for requesting surpluses "
3043 "from the governor."),
3046 NULL),
3047 GEN_INT_OPTION(gui_gtk4_governor_range_max,
3048 N_("Maximum surplus for a governor"),
3049 N_("The higher limit of the range for requesting surpluses "
3050 "from the governor."),
3053 NULL),
3054 GEN_FONT_OPTION(gui_gtk4_font_city_label, "city_label",
3055 N_("City Label"),
3056 N_("This font is used to display the city labels on city "
3057 "dialogs."),
3059 "Monospace 8", font_changed_callback),
3060 GEN_FONT_OPTION(gui_gtk4_font_notify_label, "notify_label",
3061 N_("Notify Label"),
3062 N_("This font is used to display server reports such "
3063 "as the demographic report or historian publications."),
3065 "Monospace Bold 9", font_changed_callback),
3066 GEN_FONT_OPTION(gui_gtk4_font_spaceship_label, "spaceship_label",
3067 N_("Spaceship Label"),
3068 N_("This font is used to display the spaceship widgets."),
3070 "Monospace 8", font_changed_callback),
3071 GEN_FONT_OPTION(gui_gtk4_font_help_label, "help_label",
3072 N_("Help Label"),
3073 N_("This font is used to display the help headers in the "
3074 "help window."),
3076 "Sans Bold 10", font_changed_callback),
3077 GEN_FONT_OPTION(gui_gtk4_font_help_link, "help_link",
3078 N_("Help Link"),
3079 N_("This font is used to display the help links in the "
3080 "help window."),
3082 "Sans 9", font_changed_callback),
3083 GEN_FONT_OPTION(gui_gtk4_font_help_text, "help_text",
3084 N_("Help Text"),
3085 N_("This font is used to display the help body text in "
3086 "the help window."),
3088 "Monospace 8", font_changed_callback),
3089 GEN_FONT_OPTION(gui_gtk4_font_chatline, "chatline",
3090 N_("Chatline Area"),
3091 N_("This font is used to display the text in the "
3092 "chatline area."),
3094 "Monospace 8", font_changed_callback),
3095 GEN_FONT_OPTION(gui_gtk4_font_beta_label, "beta_label",
3096 N_("Beta Label"),
3097 N_("This font is used to display the beta label."),
3099 "Sans Italic 10", font_changed_callback),
3100 GEN_FONT_OPTION(gui_gtk4_font_small, "small_font",
3101 N_("Small Font"),
3102 N_("This font is used for any small font request. For "
3103 "example, it is used for display the building lists "
3104 "in the city dialog, the Economy report or the Units "
3105 "report."),
3107 "Sans 9", font_changed_callback),
3108 GEN_FONT_OPTION(gui_gtk4_font_comment_label, "comment_label",
3109 N_("Comment Label"),
3110 N_("This font is used to display comment labels, such as "
3111 "in the governor page of the city dialogs."),
3113 "Sans Italic 9", font_changed_callback),
3114 GEN_FONT_OPTION(gui_gtk4_font_city_names, "city_names",
3115 N_("City Names"),
3116 N_("This font is used to the display the city names "
3117 "on the map."),
3119 "Sans Bold 10", NULL),
3120 GEN_FONT_OPTION(gui_gtk4_font_city_productions, "city_productions",
3121 N_("City Productions"),
3122 N_("This font is used to display the city production "
3123 "on the map."),
3125 "Serif 10", NULL),
3126 GEN_FONT_OPTION(gui_gtk4_font_reqtree_text, "reqtree_text",
3127 N_("Requirement Tree"),
3128 N_("This font is used to the display the requirement tree "
3129 "in the Research report."),
3131 "Serif 10", NULL),
3132
3133 /* gui-sdl client specific options.
3134 * These are still kept just so users can migrate them to sdl2-client */
3135 GEN_BOOL_OPTION(gui_sdl_fullscreen, NULL, NULL,
3137 GEN_VIDEO_OPTION(gui_sdl_screen, NULL, NULL,
3138 COC_INTERFACE, GUI_SDL, 640, 480, NULL),
3139 GEN_BOOL_OPTION(gui_sdl_do_cursor_animation, NULL, NULL,
3141 GEN_BOOL_OPTION(gui_sdl_use_color_cursors, NULL, NULL,
3143
3144 /* gui-sdl2 client specific options. */
3145 GEN_BOOL_OPTION(gui_sdl2_fullscreen, N_("Fullscreen"),
3146 N_("If this option is set the client will use the "
3147 "whole screen area for drawing."),
3149 GEN_VIDEO_OPTION(gui_sdl2_screen, N_("Screen resolution"),
3150 N_("This option controls the resolution of the "
3151 "selected screen."),
3152 COC_INTERFACE, GUI_SDL2, 640, 480, NULL),
3153 GEN_BOOL_OPTION(gui_sdl2_swrenderer, N_("Use software rendering"),
3154 N_("Usually hardware rendering is used when possible. "
3155 "With this option set, software rendering is always used."),
3157 GEN_BOOL_OPTION(gui_sdl2_do_cursor_animation, N_("Do cursor animation"),
3158 N_("If this option is disabled, the cursor will "
3159 "always be displayed as static."),
3161 GEN_BOOL_OPTION(gui_sdl2_use_color_cursors, N_("Use color cursors"),
3162 N_("If this option is disabled, the cursor will "
3163 "always be displayed in black and white."),
3165 GEN_FONT_OPTION(gui_sdl2_font_city_names, "FONT_CITY_NAME",
3166 N_("City Names"),
3167 N_("The size of font used to the display the city names "
3168 "on the map."),
3170 "10", font_changed_callback),
3171 GEN_FONT_OPTION(gui_sdl2_font_city_productions, "FONT_CITY_PROD",
3172 N_("City Productions"),
3173 N_("The size of font used to the display the city "
3174 "production names on the map."),
3176 "10", font_changed_callback),
3177 GEN_BOOL_OPTION(gui_sdl2_use_theme_font_size, N_("Use theme defined font size"),
3178 N_("Disable this to override base font size set by theme "
3179 "by the setting below."),
3181 GEN_INT_OPTION(gui_sdl2_font_size, N_("Base Font Size"),
3182 N_("Base Font Size. All the fonts' sizes are defined relative "
3183 "to this. This option has effect only if theme font sizes "
3184 "option is disabled."),
3185 COC_FONT, GUI_SDL2, 10, 6, 50, NULL),
3186
3187 /* gui-sdl3 client specific options. */
3188 GEN_BOOL_OPTION(gui_sdl3_fullscreen, N_("Fullscreen"),
3189 N_("If this option is set the client will use the "
3190 "whole screen area for drawing."),
3192 GEN_VIDEO_OPTION(gui_sdl3_screen, N_("Screen resolution"),
3193 N_("This option controls the resolution of the "
3194 "selected screen."),
3195 COC_INTERFACE, GUI_SDL3, 640, 480, NULL),
3196 GEN_BOOL_OPTION(gui_sdl3_swrenderer, N_("Use software rendering"),
3197 N_("Usually hardware rendering is used when possible. "
3198 "With this option set, software rendering is always used."),
3200 GEN_BOOL_OPTION(gui_sdl3_do_cursor_animation, N_("Do cursor animation"),
3201 N_("If this option is disabled, the cursor will "
3202 "always be displayed as static."),
3204 GEN_BOOL_OPTION(gui_sdl3_use_color_cursors, N_("Use color cursors"),
3205 N_("If this option is disabled, the cursor will "
3206 "always be displayed in black and white."),
3208 GEN_FONT_OPTION(gui_sdl3_font_city_names, "FONT_CITY_NAME",
3209 N_("City Names"),
3210 N_("The size of font used to the display the city names "
3211 "on the map."),
3213 "10", font_changed_callback),
3214 GEN_FONT_OPTION(gui_sdl3_font_city_productions, "FONT_CITY_PROD",
3215 N_("City Productions"),
3216 N_("The size of font used to the display the city "
3217 "production names on the map."),
3219 "10", font_changed_callback),
3220 GEN_BOOL_OPTION(gui_sdl3_use_theme_font_size, N_("Use theme defined font size"),
3221 N_("Disable this to override base font size set by theme "
3222 "by the setting below."),
3224 GEN_INT_OPTION(gui_sdl3_font_size, N_("Base Font Size"),
3225 N_("Base Font Size. All the fonts' sizes are defined relative "
3226 "to this. This option has effect only if theme font sizes "
3227 "option is disabled."),
3228 COC_FONT, GUI_SDL3, 10, 6, 50, NULL),
3229
3230 /* gui-qt client specific options. */
3231 GEN_BOOL_OPTION(gui_qt_fullscreen, N_("Fullscreen"),
3232 N_("If this option is set the client will use the "
3233 "whole screen area for drawing."),
3235 GEN_BOOL_OPTION(gui_qt_show_titlebar, N_("Show titlebar"),
3236 N_("If this option is set the client will show a titlebar. "
3237 "If disabled, then no titlebar will be shown, and "
3238 "minimize/maximize/etc buttons will be placed on the "
3239 "menu bar."),
3241 GEN_FONT_OPTION(gui_qt_font_default, "default_font",
3242 N_("Default font"),
3243 N_("This is default font"),
3245 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3246 GEN_FONT_OPTION(gui_qt_font_notify_label, "notify_label",
3247 N_("Notify Label"),
3248 N_("This font is used to display server reports such "
3249 "as the demographic report or historian publications."),
3251 "Monospace,9,-1,5,75,0,0,0,0,0", font_changed_callback),
3252 GEN_FONT_OPTION(gui_qt_font_help_label, "help_label",
3253 N_("Help Label"),
3254 N_("This font is used to display the help labels in the "
3255 "help window."),
3257 "Sans Serif,9,-1,5,50,0,0,0,0,0", font_changed_callback),
3258 GEN_FONT_OPTION(gui_qt_font_help_text, "help_text",
3259 N_("Help Text"),
3260 N_("This font is used to display the help body text in "
3261 "the help window."),
3263 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3264 GEN_FONT_OPTION(gui_qt_font_chatline, "chatline",
3265 N_("Chatline Area"),
3266 N_("This font is used to display the text in the "
3267 "chatline area."),
3269 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3270 GEN_FONT_OPTION(gui_qt_font_city_names, "city_names",
3271 N_("City Names"),
3272 N_("This font is used to the display the city names "
3273 "on the map."),
3275 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3276 GEN_FONT_OPTION(gui_qt_font_city_productions, "city_productions",
3277 N_("City Productions"),
3278 N_("This font is used to display the city production "
3279 "on the map."),
3281 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3282 GEN_FONT_OPTION(gui_qt_font_reqtree_text, "reqtree_text",
3283 N_("Requirement Tree"),
3284 N_("This font is used to the display the requirement tree "
3285 "in the Research report."),
3287 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3288 GEN_BOOL_OPTION(gui_qt_show_preview, N_("Show savegame information"),
3289 N_("If this option is set the client will show "
3290 "information and map preview of current savegame."),
3292 GEN_BOOL_OPTION(gui_qt_sidebar_left, N_("Sidebar position"),
3293 N_("If this option is set, the sidebar will be to the left "
3294 "of the map, otherwise to the right."),
3296 GEN_STR_OPTION(gui_qt_wakeup_text,
3297 N_("Wake up sequence"),
3298 N_("String which will trigger sound in pregame page; "
3299 "%1 stands for username."),
3300 COC_INTERFACE, GUI_QT, "Wake up %1", NULL, 0),
3301 GEN_BOOL_OPTION(gui_qt_svgflags, N_("SVG flags features"),
3303 N_("Enable svgflags features, such as bigger flags "
3304 "on the diplomacy dialog. Change to this comes "
3305 "to an effect on next client start."),
3306#else /* FREECIV_SVG_FLAGS */
3307 N_("Enable svgflags features, such as bigger flags "
3308 "on the diplomacy dialog. This has no effect on "
3309 "this freeciv build, as the svg support has not "
3310 "been built in."),
3311#endif /* FREECIV_SVG_FLAGS */
3313};
3315
3316/* Iteration loop, including invalid options for the current gui type. */
3317#define client_options_iterate_all(poption) \
3318{ \
3319 const struct client_option *const poption##_max = \
3320 client_options + client_options_num; \
3321 struct client_option *client_##poption = client_options; \
3322 struct option *poption; \
3323 for (; client_##poption < poption##_max; client_##poption++) { \
3324 poption = OPTION(client_##poption);
3325
3326#define client_options_iterate_all_end \
3327 } \
3328}
3329
3330
3331/************************************************************************/
3334static struct client_option *
3336{
3337 const struct client_option *const max =
3339 const enum gui_type our_type = get_gui_type();
3340
3341 while (poption < max
3342 && poption->specific != GUI_STUB
3343 && poption->specific != our_type) {
3344 poption++;
3345 }
3346
3347 return (poption < max ? poption : NULL);
3348}
3349
3350/************************************************************************/
3354{
3355 if (0 > id || id > client_options_num) {
3356 return NULL;
3357 }
3358 return OPTION(client_options + id);
3359}
3360
3361/************************************************************************/
3368
3369/************************************************************************/
3373{
3374 return COC_MAX;
3375}
3376
3377/************************************************************************/
3380static const char *client_optset_category_name(int category)
3381{
3382 switch (category) {
3383 case COC_GRAPHICS:
3384 return _("Graphics");
3385 case COC_OVERVIEW:
3386 /* TRANS: Options section for overview map (mini-map) */
3387 return Q_("?map:Overview");
3388 case COC_SOUND:
3389 return _("Sound");
3390 case COC_INTERFACE:
3391 return _("Interface");
3392 case COC_MAPIMG:
3393 return _("Map Image");
3394 case COC_NETWORK:
3395 return _("Network");
3396 case COC_FONT:
3397 return _("Font");
3398 case COC_MAX:
3399 break;
3400 }
3401
3402 log_error("%s: invalid option category number %d.",
3403 __FUNCTION__, category);
3404 return NULL;
3405}
3406
3407/************************************************************************/
3410static int client_option_number(const struct option *poption)
3411{
3413}
3414
3415/************************************************************************/
3418static const char *client_option_name(const struct option *poption)
3419{
3420 return CLIENT_OPTION(poption)->name;
3421}
3422
3423/************************************************************************/
3426static const char *client_option_description(const struct option *poption)
3427{
3428 return _(CLIENT_OPTION(poption)->description);
3429}
3430
3431/************************************************************************/
3434static const char *client_option_help_text(const struct option *poption)
3435{
3436 return _(CLIENT_OPTION(poption)->help_text);
3437}
3438
3439/************************************************************************/
3442static int client_option_category(const struct option *poption)
3443{
3444 return CLIENT_OPTION(poption)->category;
3445}
3446
3447/************************************************************************/
3451{
3452 return TRUE;
3453}
3454
3455/************************************************************************/
3458static struct option *client_option_next(const struct option *poption)
3459{
3461}
3462
3463/************************************************************************/
3466static bool client_option_bool_get(const struct option *poption)
3467{
3468 return *(CLIENT_OPTION(poption)->boolean.pvalue);
3469}
3470
3471/************************************************************************/
3474static bool client_option_bool_def(const struct option *poption)
3475{
3476 return CLIENT_OPTION(poption)->boolean.def;
3477}
3478
3479/************************************************************************/
3483static bool client_option_bool_set(struct option *poption, bool val)
3484{
3486
3487 if (*pcoption->boolean.pvalue == val) {
3488 return FALSE;
3489 }
3490
3491 *pcoption->boolean.pvalue = val;
3492 return TRUE;
3493}
3494
3495/************************************************************************/
3498static int client_option_int_get(const struct option *poption)
3499{
3500 return *(CLIENT_OPTION(poption)->integer.pvalue);
3501}
3502
3503/************************************************************************/
3506static int client_option_int_def(const struct option *poption)
3507{
3508 return CLIENT_OPTION(poption)->integer.def;
3509}
3510
3511/************************************************************************/
3514static int client_option_int_min(const struct option *poption)
3515{
3516 return CLIENT_OPTION(poption)->integer.min;
3517}
3518
3519/************************************************************************/
3522static int client_option_int_max(const struct option *poption)
3523{
3524 return CLIENT_OPTION(poption)->integer.max;
3525}
3526
3527/************************************************************************/
3531static bool client_option_int_set(struct option *poption, int val)
3532{
3534
3536 || val > pcoption->integer.max
3537 || *pcoption->integer.pvalue == val) {
3538 return FALSE;
3539 }
3540
3541 *pcoption->integer.pvalue = val;
3542 return TRUE;
3543}
3544
3545/************************************************************************/
3548static const char *client_option_str_get(const struct option *poption)
3549{
3550 return CLIENT_OPTION(poption)->string.pvalue;
3551}
3552
3553/************************************************************************/
3556static const char *client_option_str_def(const struct option *poption)
3557{
3558 return CLIENT_OPTION(poption)->string.def;
3559}
3560
3561/************************************************************************/
3565static const struct strvec *
3567{
3568 return (CLIENT_OPTION(poption)->string.val_accessor
3569 ? CLIENT_OPTION(poption)->string.val_accessor(poption) : NULL);
3570}
3571
3572/************************************************************************/
3576static bool client_option_str_set(struct option *poption, const char *str)
3577{
3579
3580 if (strlen(str) >= pcoption->string.size
3581 || 0 == strcmp(pcoption->string.pvalue, str)) {
3582 return FALSE;
3583 }
3584
3585 fc_strlcpy(pcoption->string.pvalue, str, pcoption->string.size);
3586 return TRUE;
3587}
3588
3589/************************************************************************/
3592static int client_option_enum_get(const struct option *poption)
3593{
3594 return *(CLIENT_OPTION(poption)->enumerator.pvalue);
3595}
3596
3597/************************************************************************/
3600static int client_option_enum_def(const struct option *poption)
3601{
3602 return CLIENT_OPTION(poption)->enumerator.def;
3603}
3604
3605/************************************************************************/
3609static const struct strvec *
3611{
3612 return CLIENT_OPTION(poption)->enumerator.pretty_names;
3613}
3614
3615/************************************************************************/
3619static bool client_option_enum_set(struct option *poption, int val)
3620{
3622
3623 if (*pcoption->enumerator.pvalue == val
3624 || 0 > val
3625 || val >= strvec_size(pcoption->enumerator.support_names)) {
3626 return FALSE;
3627 }
3628
3629 *pcoption->enumerator.pvalue = val;
3630 return TRUE;
3631}
3632
3633/************************************************************************/
3639 int val)
3640{
3641 const struct strvec *names = CLIENT_OPTION(data)->enumerator.support_names;
3642
3643 return (0 <= val && val < strvec_size(names)
3644 ? strvec_get(names, val) : NULL);
3645}
3646
3647#if 0 /* There's no bitwise options currently */
3648/************************************************************************/
3651static unsigned client_option_bitwise_get(const struct option *poption)
3652{
3653 return *(CLIENT_OPTION(poption)->bitwise.pvalue);
3654}
3655
3656/************************************************************************/
3659static unsigned client_option_bitwise_def(const struct option *poption)
3660{
3661 return CLIENT_OPTION(poption)->bitwise.def;
3662}
3663
3664/************************************************************************/
3668static const struct strvec *
3670{
3671 return CLIENT_OPTION(poption)->bitwise.pretty_names;
3672}
3673
3674/************************************************************************/
3678static bool client_option_bitwise_set(struct option *poption, unsigned val)
3679{
3681
3682 if (*pcoption->bitwise.pvalue == val) {
3683 return FALSE;
3684 }
3685
3686 *pcoption->bitwise.pvalue = val;
3687 return TRUE;
3688}
3689#endif /* 0 */
3690
3691/************************************************************************/
3697 int val)
3698{
3699 const struct strvec *names = CLIENT_OPTION(data)->bitwise.support_names;
3700
3701 return (0 <= val && val < strvec_size(names)
3702 ? strvec_get(names, val) : NULL);
3703}
3704
3705/************************************************************************/
3708static const char *client_option_font_get(const struct option *poption)
3709{
3710 return CLIENT_OPTION(poption)->font.pvalue;
3711}
3712
3713/************************************************************************/
3716static const char *client_option_font_def(const struct option *poption)
3717{
3718 return CLIENT_OPTION(poption)->font.def;
3719}
3720
3721/************************************************************************/
3724static const char *client_option_font_target(const struct option *poption)
3725{
3726 return CLIENT_OPTION(poption)->font.target;
3727}
3728
3729/************************************************************************/
3733static bool client_option_font_set(struct option *poption, const char *font)
3734{
3736
3737 if (strlen(font) >= pcoption->font.size
3738 || 0 == strcmp(pcoption->font.pvalue, font)) {
3739 return FALSE;
3740 }
3741
3742 fc_strlcpy(pcoption->font.pvalue, font, pcoption->font.size);
3743 return TRUE;
3744}
3745
3746/************************************************************************/
3750{
3751 return *CLIENT_OPTION(poption)->color.pvalue;
3752}
3753
3754/************************************************************************/
3758{
3759 return CLIENT_OPTION(poption)->color.def;
3760}
3761
3762/************************************************************************/
3767 struct ft_color color)
3768{
3769 struct ft_color *pcolor = CLIENT_OPTION(poption)->color.pvalue;
3770 bool changed = FALSE;
3771
3772#define color_set(color_tgt, color) \
3773 if (NULL == color_tgt) { \
3774 if (NULL != color) { \
3775 color_tgt = fc_strdup(color); \
3776 changed = TRUE; \
3777 } \
3778 } else { \
3779 if (NULL == color) { \
3780 free((void *) color_tgt); \
3781 color_tgt = NULL; \
3782 changed = TRUE; \
3783 } else if (0 != strcmp(color_tgt, color)) { \
3784 free((void *) color_tgt); \
3785 color_tgt = fc_strdup(color); \
3786 changed = TRUE; \
3787 } \
3788 }
3789
3790 color_set(pcolor->foreground, color.foreground);
3791 color_set(pcolor->background, color.background);
3792
3793#undef color_set
3794
3795 return changed;
3796}
3797
3798/************************************************************************/
3801static struct video_mode
3803{
3804 return *CLIENT_OPTION(poption)->video_mode.pvalue;
3805}
3806
3807/************************************************************************/
3810static struct video_mode
3815
3816/************************************************************************/
3821 struct video_mode mode)
3822{
3824
3825 if (0 == memcmp(&mode, pcoption->video_mode.pvalue,
3826 sizeof(struct video_mode))) {
3827 return FALSE;
3828 }
3829
3830 *pcoption->video_mode.pvalue = mode;
3831 return TRUE;
3832}
3833
3834/************************************************************************/
3838 struct section_file *sf)
3839{
3842
3843 switch (option_type(poption)) {
3844 case OT_BOOLEAN:
3845 {
3846 bool value;
3847 const char *pname = option_name(poption);
3848 const char *old_paths = "draw_roads_rails";
3849
3850 if (!strcmp("draw_paths", pname)) {
3851 /* Renamed in freeciv-3.2 */
3852 if (secfile_lookup_bool(sf, &value, "client.draw_paths")
3853 && option_bool_set(poption, value)) {
3854 return TRUE;
3855 }
3856
3857 /* Try by old name. */
3858 pname = old_paths;
3859 }
3860
3861 return (secfile_lookup_bool(sf, &value, "client.%s",
3862 pname)
3863 && option_bool_set(poption, value));
3864 }
3865 case OT_INTEGER:
3866 {
3867 int value;
3868
3869 return (secfile_lookup_int(sf, &value, "client.%s",
3871 && option_int_set(poption, value));
3872 }
3873 case OT_STRING:
3874 {
3875 const char *string;
3876
3877 return ((string = secfile_lookup_str(sf, "client.%s",
3879 && option_str_set(poption, string));
3880 }
3881 case OT_ENUM:
3882 {
3883 int value;
3884
3885 return (secfile_lookup_enum_data(sf, &value, FALSE,
3887 poption, "client.%s",
3889 && option_enum_set_int(poption, value));
3890 }
3891 case OT_BITWISE:
3892 {
3893 int value;
3894
3895 return (secfile_lookup_enum_data(sf, &value, TRUE,
3897 poption, "client.%s",
3899 && option_bitwise_set(poption, value));
3900 }
3901 case OT_FONT:
3902 {
3903 const char *string;
3904
3905 return ((string = secfile_lookup_str(sf, "client.%s",
3907 && option_font_set(poption, string));
3908 }
3909 case OT_COLOR:
3910 {
3911 struct ft_color color;
3912
3913 return ((color.foreground =
3914 secfile_lookup_str(sf, "client.%s.foreground",
3916 && (color.background =
3917 secfile_lookup_str(sf, "client.%s.background",
3920 }
3921 case OT_VIDEO_MODE:
3922 {
3923 struct video_mode mode;
3924
3925 return (secfile_lookup_int(sf, &mode.width, "client.%s.width",
3927 && secfile_lookup_int(sf, &mode.height, "client.%s.height",
3929 && option_video_mode_set(poption, mode));
3930 }
3931 }
3932 return FALSE;
3933}
3934
3935/************************************************************************/
3939 struct section_file *sf)
3940{
3942 fc_assert_ret(NULL != sf);
3943
3944 switch (option_type(poption)) {
3945 case OT_BOOLEAN:
3947 "client.%s", option_name(poption));
3948 break;
3949 case OT_INTEGER:
3951 "client.%s", option_name(poption));
3952 break;
3953 case OT_STRING:
3955 "client.%s", option_name(poption));
3956 break;
3957 case OT_ENUM:
3960 "client.%s", option_name(poption));
3961 break;
3962 case OT_BITWISE:
3965 "client.%s", option_name(poption));
3966 break;
3967 case OT_FONT:
3969 "client.%s", option_name(poption));
3970 break;
3971 case OT_COLOR:
3972 {
3974
3975 secfile_insert_str(sf, color.foreground, "client.%s.foreground",
3977 secfile_insert_str(sf, color.background, "client.%s.background",
3979 }
3980 break;
3981 case OT_VIDEO_MODE:
3982 {
3984
3985 secfile_insert_int(sf, mode.width, "client.%s.width",
3987 secfile_insert_int(sf, mode.height, "client.%s.height",
3989 }
3990 break;
3991 }
3992}
3993
3994
3995/****************************************************************************
3996 Server options variables.
3997****************************************************************************/
4000
4002static int server_options_num = 0;
4003
4004
4005/****************************************************************************
4006 Server option set.
4007****************************************************************************/
4008static struct option *server_optset_option_by_number(int id);
4009static struct option *server_optset_option_first(void);
4010static int server_optset_category_number(void);
4011static const char *server_optset_category_name(int category);
4012
4015 .option_first = server_optset_option_first,
4016 .category_number = server_optset_category_number,
4017 .category_name = server_optset_category_name
4018};
4020
4021
4022/****************************************************************************
4023 Virtuals tables for the client options.
4024****************************************************************************/
4025static int server_option_number(const struct option *poption);
4026static const char *server_option_name(const struct option *poption);
4027static const char *server_option_description(const struct option *poption);
4028static const char *server_option_help_text(const struct option *poption);
4029static int server_option_category(const struct option *poption);
4030static bool server_option_is_changeable(const struct option *poption);
4031static struct option *server_option_next(const struct option *poption);
4032
4033static const struct option_common_vtable server_option_common_vtable = {
4034 .number = server_option_number,
4035 .name = server_option_name,
4036 .description = server_option_description,
4037 .help_text = server_option_help_text,
4038 .category = server_option_category,
4039 .is_changeable = server_option_is_changeable,
4040 .next = server_option_next
4041};
4042
4043static bool server_option_bool_get(const struct option *poption);
4044static bool server_option_bool_def(const struct option *poption);
4045static bool server_option_bool_set(struct option *poption, bool val);
4046
4047static const struct option_bool_vtable server_option_bool_vtable = {
4051};
4052
4053static int server_option_int_get(const struct option *poption);
4054static int server_option_int_def(const struct option *poption);
4055static int server_option_int_min(const struct option *poption);
4056static int server_option_int_max(const struct option *poption);
4057static bool server_option_int_set(struct option *poption, int val);
4058
4059static const struct option_int_vtable server_option_int_vtable = {
4060 .get = server_option_int_get,
4061 .def = server_option_int_def,
4062 .minimum = server_option_int_min,
4063 .maximum = server_option_int_max,
4065};
4066
4067static const char *server_option_str_get(const struct option *poption);
4068static const char *server_option_str_def(const struct option *poption);
4069static const struct strvec *
4071static bool server_option_str_set(struct option *poption, const char *str);
4072
4073static const struct option_str_vtable server_option_str_vtable = {
4074 .get = server_option_str_get,
4075 .def = server_option_str_def,
4076 .values = server_option_str_values,
4078};
4079
4080static int server_option_enum_get(const struct option *poption);
4081static int server_option_enum_def(const struct option *poption);
4082static const struct strvec *
4084static bool server_option_enum_set(struct option *poption, int val);
4085
4086static const struct option_enum_vtable server_option_enum_vtable = {
4089 .values = server_option_enum_pretty,
4091 .cmp = strcmp
4092};
4093
4094static unsigned server_option_bitwise_get(const struct option *poption);
4095static unsigned server_option_bitwise_def(const struct option *poption);
4096static const struct strvec *
4098static bool server_option_bitwise_set(struct option *poption, unsigned val);
4099
4100static const struct option_bitwise_vtable server_option_bitwise_vtable = {
4105};
4106
4107/****************************************************************************
4108 Derived class server option, inheriting from base class option.
4109****************************************************************************/
4111 struct option base_option; /* Base structure, must be the first! */
4112
4113 char *name; /* Short name - used as an identifier */
4114 char *description; /* One-line description */
4115 char *help_text; /* Paragraph-length help text */
4116 unsigned char category;
4121
4122 union {
4123 /* OT_BOOLEAN type option. */
4124 struct {
4125 bool value;
4126 bool def;
4127 } boolean;
4128 /* OT_INTEGER type option. */
4129 struct {
4131 int def, min, max;
4132 } integer;
4133 /* OT_STRING type option. */
4134 struct {
4135 char *value;
4136 char *def;
4137 } string;
4138 /* OT_ENUM type option. */
4139 struct {
4140 int value;
4141 int def;
4143 struct strvec *pretty_names; /* untranslated */
4144 } enumerator;
4145 /* OT_BITWISE type option. */
4146 struct {
4147 unsigned value;
4148 unsigned def;
4149 struct strvec *support_names;
4150 struct strvec *pretty_names; /* untranslated */
4151 } bitwise;
4152 };
4153};
4154
4155#define SERVER_OPTION(poption) ((struct server_option *) (poption))
4156
4157static void desired_settable_option_send(struct option *poption);
4158
4159
4160/************************************************************************/
4170
4171/************************************************************************/
4175{
4176 option_gui_remove(&(poption->base_option));
4177
4178 switch (poption->base_option.type) {
4179 case OT_STRING:
4180 if (NULL != poption->string.value) {
4181 FC_FREE(poption->string.value);
4182 }
4183 if (NULL != poption->string.def) {
4184 FC_FREE(poption->string.def);
4185 }
4186 break;
4187
4188 case OT_ENUM:
4189 if (NULL != poption->enumerator.support_names) {
4190 strvec_destroy(poption->enumerator.support_names);
4191 poption->enumerator.support_names = NULL;
4192 }
4193 if (NULL != poption->enumerator.pretty_names) {
4194 strvec_destroy(poption->enumerator.pretty_names);
4195 poption->enumerator.pretty_names = NULL;
4196 }
4197 break;
4198
4199 case OT_BITWISE:
4200 if (NULL != poption->bitwise.support_names) {
4201 strvec_destroy(poption->bitwise.support_names);
4202 poption->bitwise.support_names = NULL;
4203 }
4204 if (NULL != poption->bitwise.pretty_names) {
4205 strvec_destroy(poption->bitwise.pretty_names);
4206 poption->bitwise.pretty_names = NULL;
4207 }
4208 break;
4209
4210 case OT_BOOLEAN:
4211 case OT_INTEGER:
4212 case OT_FONT:
4213 case OT_COLOR:
4214 case OT_VIDEO_MODE:
4215 break;
4216 }
4217
4218 if (NULL != poption->name) {
4219 FC_FREE(poption->name);
4220 }
4221 if (NULL != poption->description) {
4222 FC_FREE(poption->description);
4223 }
4224 if (NULL != poption->help_text) {
4225 FC_FREE(poption->help_text);
4226 }
4227}
4228
4229/************************************************************************/
4233{
4234 int i;
4235
4236 /* Don't keep this dialog open. */
4238
4239 /* Free the options themselves. */
4240 if (NULL != server_options) {
4241 for (i = 0; i < server_options_num; i++) {
4243 }
4246 }
4247
4248 /* Free the categories. */
4250 for (i = 0; i < server_options_categories_num; i++) {
4253 }
4254 }
4257 }
4258}
4259
4260/************************************************************************/
4264 (const struct packet_server_setting_control *packet)
4265{
4266 int i;
4267
4268 /* This packet should be received only once. */
4273
4274 /* Allocate server option categories. */
4275 if (0 < packet->categories_num) {
4279 sizeof(*server_options_categories));
4280
4281 for (i = 0; i < server_options_categories_num; i++) {
4282 /* NB: Translate now. */
4284 }
4285 }
4286
4287 /* Allocate server options. */
4288 if (0 < packet->settings_num) {
4291 }
4292}
4293
4294/************************************************************************/
4298 (const struct packet_server_setting_const *packet)
4299{
4302
4304
4305 fc_assert(NULL == psoption->name);
4306 psoption->name = fc_strdup(packet->name);
4307 fc_assert(NULL == psoption->description);
4308 /* NB: Translate now. */
4309 psoption->description = fc_strdup(_(packet->short_help));
4310 fc_assert(NULL == psoption->help_text);
4311 /* NB: Translate now. */
4312 psoption->help_text = fc_strdup(_(packet->extra_help));
4313 psoption->category = packet->category;
4314}
4315
4316/****************************************************************************
4317 Common part of handle_server_setting_*() functions. See below.
4318****************************************************************************/
4319#define handle_server_setting_common(psoption, packet) \
4320 psoption->is_changeable = packet->is_changeable; \
4321 psoption->setdef = packet->setdef; \
4322 if (psoption->is_visible != packet->is_visible) { \
4323 if (psoption->is_visible) { \
4324 need_gui_remove = TRUE; \
4325 } else if (packet->is_visible) { \
4326 need_gui_add = TRUE; \
4327 } \
4328 psoption->is_visible = packet->is_visible; \
4329 } \
4330 \
4331 /* Keep this list of conditions in sync with one in \
4332 resend_desired_settable_options() */ \
4333 if (!psoption->desired_sent \
4334 && psoption->is_visible \
4335 && psoption->is_changeable \
4336 && gui_options.send_desired_settings \
4337 && is_server_running() \
4338 && packet->initial_setting) { \
4339 /* Only send our private settings if we are running \
4340 * on a forked local server, i.e. started by the \
4341 * client with the "Start New Game" button. \
4342 * Do now override settings that are already saved to savegame \
4343 * and now loaded. */ \
4344 desired_settable_option_send(OPTION(poption)); \
4345 psoption->desired_sent = TRUE; \
4346 } \
4347 \
4348 /* Update the GUI. */ \
4349 if (need_gui_remove) { \
4350 option_gui_remove(poption); \
4351 } else if (need_gui_add) { \
4352 option_gui_add(poption); \
4353 } else { \
4354 option_gui_update(poption); \
4356
4357/************************************************************************/
4361 (const struct packet_server_setting_bool *packet)
4362{
4365 bool need_gui_remove = FALSE;
4366 bool need_gui_add = FALSE;
4367
4369
4370 if (NULL == poption->common_vtable) {
4371 /* Not initialized yet. */
4372 poption->poptset = server_optset;
4373 poption->common_vtable = &server_option_common_vtable;
4374 poption->type = OT_BOOLEAN;
4375 poption->bool_vtable = &server_option_bool_vtable;
4376 }
4378 "Server setting \"%s\" (nb %d) has type %s (%d), "
4379 "expected %s (%d)",
4381 option_type_name(poption->type), poption->type,
4383
4384 if (packet->is_visible) {
4385 psoption->boolean.value = packet->val;
4386 psoption->boolean.def = packet->default_val;
4387 }
4388
4391
4392/************************************************************************/
4396 (const struct packet_server_setting_int *packet)
4397{
4400 bool need_gui_remove = FALSE;
4401 bool need_gui_add = FALSE;
4402
4404
4405 if (NULL == poption->common_vtable) {
4406 /* Not initialized yet. */
4407 poption->poptset = server_optset;
4408 poption->common_vtable = &server_option_common_vtable;
4409 poption->type = OT_INTEGER;
4410 poption->int_vtable = &server_option_int_vtable;
4411 }
4413 "Server setting \"%s\" (nb %d) has type %s (%d), "
4414 "expected %s (%d)",
4416 option_type_name(poption->type), poption->type,
4418
4419 if (packet->is_visible) {
4420 psoption->integer.value = packet->val;
4421 psoption->integer.def = packet->default_val;
4422 psoption->integer.min = packet->min_val;
4423 psoption->integer.max = packet->max_val;
4424 }
4425
4428
4429/************************************************************************/
4433 (const struct packet_server_setting_str *packet)
4434{
4437 bool need_gui_remove = FALSE;
4438 bool need_gui_add = FALSE;
4439
4441
4442 if (NULL == poption->common_vtable) {
4443 /* Not initialized yet. */
4444 poption->poptset = server_optset;
4445 poption->common_vtable = &server_option_common_vtable;
4446 poption->type = OT_STRING;
4447 poption->str_vtable = &server_option_str_vtable;
4448 }
4450 "Server setting \"%s\" (nb %d) has type %s (%d), "
4451 "expected %s (%d)",
4453 option_type_name(poption->type), poption->type,
4455
4456 if (packet->is_visible) {
4457 if (NULL == psoption->string.value) {
4458 psoption->string.value = fc_strdup(packet->val);
4459 } else if (0 != strcmp(packet->val, psoption->string.value)) {
4460 free(psoption->string.value);
4461 psoption->string.value = fc_strdup(packet->val);
4462 }
4463 if (NULL == psoption->string.def) {
4464 psoption->string.def = fc_strdup(packet->default_val);
4465 } else if (0 != strcmp(packet->default_val, psoption->string.def)) {
4466 free(psoption->string.def);
4467 psoption->string.def = fc_strdup(packet->default_val);
4468 }
4469 }
4470
4473
4474/************************************************************************/
4478 (const struct packet_server_setting_enum *packet)
4479{
4482 bool need_gui_remove = FALSE;
4483 bool need_gui_add = FALSE;
4484
4486
4487 if (NULL == poption->common_vtable) {
4488 /* Not initialized yet. */
4489 poption->poptset = server_optset;
4490 poption->common_vtable = &server_option_common_vtable;
4491 poption->type = OT_ENUM;
4492 poption->enum_vtable = &server_option_enum_vtable;
4493 }
4495 "Server setting \"%s\" (nb %d) has type %s (%d), "
4496 "expected %s (%d)",
4498 option_type_name(poption->type), poption->type,
4500
4501 if (packet->is_visible) {
4502 int i;
4503
4504 psoption->enumerator.value = packet->val;
4505 psoption->enumerator.def = packet->default_val;
4506
4507 if (NULL == psoption->enumerator.support_names) {
4508 /* First time we get this packet. */
4509 fc_assert(NULL == psoption->enumerator.pretty_names);
4510 psoption->enumerator.support_names = strvec_new();
4511 strvec_reserve(psoption->enumerator.support_names, packet->values_num);
4512 psoption->enumerator.pretty_names = strvec_new();
4513 strvec_reserve(psoption->enumerator.pretty_names, packet->values_num);
4514 for (i = 0; i < packet->values_num; i++) {
4515 strvec_set(psoption->enumerator.support_names, i,
4516 packet->support_names[i]);
4517 /* Store untranslated string from server. */
4518 strvec_set(psoption->enumerator.pretty_names, i,
4519 packet->pretty_names[i]);
4520 }
4521 } else if (strvec_size(psoption->enumerator.support_names)
4522 != packet->values_num) {
4523 fc_assert(strvec_size(psoption->enumerator.support_names)
4524 == strvec_size(psoption->enumerator.pretty_names));
4525 /* The number of values have changed, we need to reset the list
4526 * of possible values. */
4527 strvec_reserve(psoption->enumerator.support_names, packet->values_num);
4528 strvec_reserve(psoption->enumerator.pretty_names, packet->values_num);
4529 for (i = 0; i < packet->values_num; i++) {
4530 strvec_set(psoption->enumerator.support_names, i,
4531 packet->support_names[i]);
4532 /* Store untranslated string from server. */
4533 strvec_set(psoption->enumerator.pretty_names, i,
4534 packet->pretty_names[i]);
4535 }
4538 } else {
4539 /* Check if a value changed, then we need to reset the list
4540 * of possible values. */
4541 const char *str;
4542
4543 for (i = 0; i < packet->values_num; i++) {
4544 str = strvec_get(psoption->enumerator.pretty_names, i);
4545 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4546 /* Store untranslated string from server. */
4547 strvec_set(psoption->enumerator.pretty_names, i,
4548 packet->pretty_names[i]);
4551 }
4552 /* Support names are not visible, we don't need to check if it
4553 * has changed. */
4554 strvec_set(psoption->enumerator.support_names, i,
4555 packet->support_names[i]);
4556 }
4557 }
4558 }
4559
4562
4563/************************************************************************/
4567 (const struct packet_server_setting_bitwise *packet)
4568{
4571 bool need_gui_remove = FALSE;
4572 bool need_gui_add = FALSE;
4573
4575
4576 if (NULL == poption->common_vtable) {
4577 /* Not initialized yet. */
4578 poption->poptset = server_optset;
4579 poption->common_vtable = &server_option_common_vtable;
4580 poption->type = OT_BITWISE;
4581 poption->bitwise_vtable = &server_option_bitwise_vtable;
4582 }
4584 "Server setting \"%s\" (nb %d) has type %s (%d), "
4585 "expected %s (%d)",
4587 option_type_name(poption->type), poption->type,
4589
4590 if (packet->is_visible) {
4591 int i;
4592
4593 psoption->bitwise.value = packet->val;
4594 psoption->bitwise.def = packet->default_val;
4595
4596 if (NULL == psoption->bitwise.support_names) {
4597 /* First time we get this packet. */
4598 fc_assert(NULL == psoption->bitwise.pretty_names);
4599 psoption->bitwise.support_names = strvec_new();
4600 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4601 psoption->bitwise.pretty_names = strvec_new();
4602 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4603 for (i = 0; i < packet->bits_num; i++) {
4604 strvec_set(psoption->bitwise.support_names, i,
4605 packet->support_names[i]);
4606 /* Store untranslated string from server. */
4607 strvec_set(psoption->bitwise.pretty_names, i,
4608 packet->pretty_names[i]);
4609 }
4610 } else if (strvec_size(psoption->bitwise.support_names)
4611 != packet->bits_num) {
4612 fc_assert(strvec_size(psoption->bitwise.support_names)
4613 == strvec_size(psoption->bitwise.pretty_names));
4614 /* The number of values have changed, we need to reset the list
4615 * of possible values. */
4616 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4617 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4618 for (i = 0; i < packet->bits_num; i++) {
4619 strvec_set(psoption->bitwise.support_names, i,
4620 packet->support_names[i]);
4621 /* Store untranslated string from server. */
4622 strvec_set(psoption->bitwise.pretty_names, i,
4623 packet->pretty_names[i]);
4624 }
4627 } else {
4628 /* Check if a value changed, then we need to reset the list
4629 * of possible values. */
4630 const char *str;
4631
4632 for (i = 0; i < packet->bits_num; i++) {
4633 str = strvec_get(psoption->bitwise.pretty_names, i);
4634 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4635 /* Store untranslated string from server. */
4636 strvec_set(psoption->bitwise.pretty_names, i,
4637 packet->pretty_names[i]);
4640 }
4641 /* Support names are not visible, we don't need to check if it
4642 * has changed. */
4643 strvec_set(psoption->bitwise.support_names, i,
4644 packet->support_names[i]);
4645 }
4646 }
4647 }
4648
4650}
4652/************************************************************************/
4655static struct server_option *
4657{
4658 if (server_options != NULL) {
4659 const struct server_option *const max =
4661
4663 poption++;
4664 }
4665
4666 return (poption < max ? poption : NULL);
4667 }
4668
4669 return NULL;
4671
4672/************************************************************************/
4676{
4677 if (0 > id || id > server_options_num) {
4678 return NULL;
4679 }
4680 return OPTION(server_options + id);
4682
4683/************************************************************************/
4687{
4690
4691/************************************************************************/
4695{
4698
4699/************************************************************************/
4702const char *server_optset_category_name(int category)
4703{
4704 if (0 > category || category >= server_options_categories_num) {
4705 return NULL;
4706 }
4707
4708 return server_options_categories[category];
4710
4711/************************************************************************/
4714static int server_option_number(const struct option *poption)
4715{
4718
4719/************************************************************************/
4722static const char *server_option_name(const struct option *poption)
4723{
4724 return SERVER_OPTION(poption)->name;
4726
4727/************************************************************************/
4730static const char *server_option_description(const struct option *poption)
4731{
4732 return SERVER_OPTION(poption)->description;
4734
4735/************************************************************************/
4738static const char *server_option_help_text(const struct option *poption)
4739{
4740 return SERVER_OPTION(poption)->help_text;
4742
4743/************************************************************************/
4746static int server_option_category(const struct option *poption)
4747{
4748 return SERVER_OPTION(poption)->category;
4750
4751/************************************************************************/
4754static bool server_option_is_changeable(const struct option *poption)
4755{
4756 return SERVER_OPTION(poption)->is_changeable;
4758
4759/************************************************************************/
4762static struct option *server_option_next(const struct option *poption)
4763{
4766
4767/************************************************************************/
4770static bool server_option_bool_get(const struct option *poption)
4771{
4772 return SERVER_OPTION(poption)->boolean.value;
4774
4775/************************************************************************/
4778static bool server_option_bool_def(const struct option *poption)
4779{
4780 return SERVER_OPTION(poption)->boolean.def;
4781}
4783/************************************************************************/
4787static bool server_option_bool_set(struct option *poption, bool val)
4788{
4790
4791 if (psoption->boolean.value == val) {
4792 return FALSE;
4793 }
4794
4795 send_chat_printf("/set %s %s", psoption->name,
4796 val ? "enabled" : "disabled");
4797 return TRUE;
4799
4800/************************************************************************/
4803static int server_option_int_get(const struct option *poption)
4804{
4805 return SERVER_OPTION(poption)->integer.value;
4807
4808/************************************************************************/
4811static int server_option_int_def(const struct option *poption)
4812{
4813 return SERVER_OPTION(poption)->integer.def;
4815
4816/************************************************************************/
4819static int server_option_int_min(const struct option *poption)
4820{
4821 return SERVER_OPTION(poption)->integer.min;
4823
4824/************************************************************************/
4827static int server_option_int_max(const struct option *poption)
4828{
4829 return SERVER_OPTION(poption)->integer.max;
4830}
4832/************************************************************************/
4836static bool server_option_int_set(struct option *poption, int val)
4837{
4839
4841 || val > psoption->integer.max
4842 || psoption->integer.value == val) {
4843 return FALSE;
4844 }
4845
4846 send_chat_printf("/set %s %d", psoption->name, val);
4847 return TRUE;
4849
4850/************************************************************************/
4853static const char *server_option_str_get(const struct option *poption)
4854{
4855 return SERVER_OPTION(poption)->string.value;
4857
4858/************************************************************************/
4861static const char *server_option_str_def(const struct option *poption)
4862{
4863 return SERVER_OPTION(poption)->string.def;
4864}
4865
4866/************************************************************************/
4870static const struct strvec *
4872{
4873 return NULL;
4874}
4876/************************************************************************/
4880static bool server_option_str_set(struct option *poption, const char *str)
4881{
4883
4884 if (0 == strcmp(psoption->string.value, str)) {
4885 return FALSE;
4886 }
4887
4888 send_chat_printf("/set %s \"%s\"", psoption->name, str);
4889 return TRUE;
4891
4892/************************************************************************/
4895static int server_option_enum_get(const struct option *poption)
4896{
4897 return SERVER_OPTION(poption)->enumerator.value;
4899
4900/************************************************************************/
4903static int server_option_enum_def(const struct option *poption)
4904{
4905 return SERVER_OPTION(poption)->enumerator.def;
4906}
4907
4908/************************************************************************/
4912static const struct strvec *
4914{
4915 return SERVER_OPTION(poption)->enumerator.pretty_names;
4916}
4918/************************************************************************/
4922static bool server_option_enum_set(struct option *poption, int val)
4923{
4925 const char *name;
4926
4927 if (val == psoption->enumerator.value
4928 || !(name = strvec_get(psoption->enumerator.support_names, val))) {
4929 return FALSE;
4930 }
4931
4932 send_chat_printf("/set %s \"%s\"", psoption->name, name);
4933 return TRUE;
4934}
4936/************************************************************************/
4940static void server_option_enum_support_name(const struct option *poption,
4941 const char **pvalue,
4942 const char **pdefault)
4943{
4945 const struct strvec *values = psoption->enumerator.support_names;
4946
4947 if (NULL != pvalue) {
4948 *pvalue = strvec_get(values, psoption->enumerator.value);
4949 }
4950 if (NULL != pdefault) {
4951 *pdefault = strvec_get(values, psoption->enumerator.def);
4952 }
4954
4955/************************************************************************/
4958static unsigned server_option_bitwise_get(const struct option *poption)
4959{
4960 return SERVER_OPTION(poption)->bitwise.value;
4962
4963/************************************************************************/
4966static unsigned server_option_bitwise_def(const struct option *poption)
4967{
4968 return SERVER_OPTION(poption)->bitwise.def;
4969}
4970
4971/************************************************************************/
4975static const struct strvec *
4977{
4978 return SERVER_OPTION(poption)->bitwise.pretty_names;
4980
4981/************************************************************************/
4984static void server_option_bitwise_support_base(const struct strvec *values,
4985 unsigned val,
4986 char *buf, size_t buf_len)
4987{
4988 int bit;
4989
4990 buf[0] = '\0';
4991 for (bit = 0; bit < strvec_size(values); bit++) {
4992 if ((1 << bit) & val) {
4993 if ('\0' != buf[0]) {
4994 fc_strlcat(buf, "|", buf_len);
4995 }
4996 fc_strlcat(buf, strvec_get(values, bit), buf_len);
4997 }
4998 }
4999}
5001/************************************************************************/
5005static bool server_option_bitwise_set(struct option *poption, unsigned val)
5006{
5008 char name[MAX_LEN_MSG];
5009
5010 if (val == psoption->bitwise.value) {
5011 return FALSE;
5012 }
5013
5014 server_option_bitwise_support_base(psoption->bitwise.support_names, val,
5015 name, sizeof(name));
5016 send_chat_printf("/set %s \"%s\"", psoption->name, name);
5017 return TRUE;
5018}
5020/************************************************************************/
5024static void server_option_bitwise_support_name(const struct option *poption,
5025 char *val_buf, size_t val_len,
5026 char *def_buf, size_t def_len)
5027{
5029 const struct strvec *values = psoption->bitwise.support_names;
5030
5031 if (NULL != val_buf && 0 < val_len) {
5032 server_option_bitwise_support_base(values, psoption->bitwise.value,
5033 val_buf, val_len);
5034 }
5035 if (NULL != def_buf && 0 < def_len) {
5036 server_option_bitwise_support_base(values, psoption->bitwise.def,
5037 def_buf, def_len);
5038 }
5040
5041
5045
5047/************************************************************************/
5051static void message_options_init(void)
5052{
5053 int none[] = {
5059 };
5060 int out_only[] = {
5063 };
5064 int all[] = {
5066 };
5067 int i;
5068
5069 for (i = 0; i <= event_type_max(); i++) {
5070 /* Include possible undefined values. */
5072 }
5073 for (i = 0; i < ARRAY_SIZE(none); i++) {
5074 messages_where[none[i]] = 0;
5075 }
5076 for (i = 0; i < ARRAY_SIZE(out_only); i++) {
5078 }
5079 for (i = 0; i < ARRAY_SIZE(all); i++) {
5081 }
5082
5083 events_init();
5085
5086/************************************************************************/
5089static void message_options_free(void)
5090{
5091 events_free();
5092}
5094/************************************************************************/
5098static void message_options_load(struct section_file *file,
5099 const char *prefix)
5100{
5101 enum event_type event;
5102 int i, num_events;
5103 const char *p;
5104
5105 if (!secfile_lookup_int(file, &num_events, "messages.count")) {
5106 /* version < 2.2 */
5107 /* Order of the events in 2.1. */
5108 const enum event_type old_events[] = {
5137 };
5138 const size_t old_events_num = ARRAY_SIZE(old_events);
5139
5140 for (i = 0; i < old_events_num; i++) {
5143 "%s.message_where_%02d", prefix, i);
5144 }
5145 return;
5146 }
5147
5148 for (i = 0; i < num_events; i++) {
5149 p = secfile_lookup_str(file, "messages.event%d.name", i);
5150 if (NULL == p) {
5151 log_error("Corruption in file %s: %s",
5152 secfile_name(file), secfile_error());
5153 continue;
5154 }
5155 /* Compatibility: Before 3.0 E_UNIT_WIN_DEF was called E_UNIT_WIN. */
5156 if (!fc_strcasecmp("E_UNIT_WIN", p)) {
5157 log_deprecation(_("Deprecated event type E_UNIT_WIN in client options."));
5158 p = "E_UNIT_WIN_DEF";
5159 }
5160 event = event_type_by_name(p, strcmp);
5161 if (!event_type_is_valid(event)) {
5162 log_error("Event not supported: %s", p);
5163 continue;
5164 }
5165
5167 "messages.event%d.where", i)) {
5168 log_error("Corruption in file %s: %s",
5169 secfile_name(file), secfile_error());
5170 }
5171 }
5172}
5174/************************************************************************/
5178static void message_options_save(struct section_file *file,
5179 const char *prefix)
5180{
5181 enum event_type event;
5182 int i = 0;
5183
5184 for (event = event_type_begin(); event != event_type_end();
5185 event = event_type_next(event)) {
5187 "messages.event%d.name", i);
5189 "messages.event%d.where", i);
5190 i++;
5191 }
5192
5193 secfile_insert_int(file, i, "messages.count");
5195
5196/************************************************************************/
5199static void load_cma_preset(struct section_file *file, int i)
5200{
5201 struct cm_parameter parameter;
5202 const char *name =
5203 secfile_lookup_str_default(file, "preset",
5204 "cma.preset%d.name", i);
5205
5206 /* Init correct default values even for the fields that are not
5207 * loaded below. */
5208 cm_init_parameter(&parameter);
5209
5211 parameter.minimal_surplus[o] =
5212 secfile_lookup_int_default(file, 0, "cma.preset%d.minsurp%d", i, o);
5213 parameter.factor[o] =
5214 secfile_lookup_int_default(file, 0, "cma.preset%d.factor%d", i, o);
5216 parameter.require_happy =
5217 secfile_lookup_bool_default(file, FALSE, "cma.preset%d.reqhappy", i);
5218 parameter.happy_factor =
5219 secfile_lookup_int_default(file, 0, "cma.preset%d.happyfactor", i);
5220 parameter.allow_disorder = FALSE;
5221 parameter.allow_specialists = TRUE;
5222
5223 cmafec_preset_add(name, &parameter);
5225
5226/************************************************************************/
5229static void save_cma_preset(struct section_file *file, int i)
5230{
5231 const struct cm_parameter *const pparam = cmafec_preset_get_parameter(i);
5233
5234 secfile_insert_str(file, name, "cma.preset%d.name", i);
5235
5237 secfile_insert_int(file, pparam->minimal_surplus[o],
5238 "cma.preset%d.minsurp%d", i, o);
5239 secfile_insert_int(file, pparam->factor[o],
5240 "cma.preset%d.factor%d", i, o);
5242 secfile_insert_bool(file, pparam->require_happy,
5243 "cma.preset%d.reqhappy", i);
5244 secfile_insert_int(file, pparam->happy_factor,
5245 "cma.preset%d.happyfactor", i);
5247
5248/************************************************************************/
5251static void save_cma_presets(struct section_file *file)
5252{
5253 int i;
5254
5256 _("If you add a preset by hand,"
5257 " also update \"number_of_presets\""),
5258 "cma.number_of_presets");
5259 for (i = 0; i < cmafec_preset_num(); i++) {
5261 }
5264/* Old rc file name. */
5265#define OLD_OPTION_FILE_NAME ".civclientrc"
5266/* New rc file name. */
5267#define MID_OPTION_FILE_NAME ".freeciv-client-rc-%d.%d"
5268#define NEW_OPTION_FILE_NAME "freeciv-client-rc-%d.%d"
5270/* The first version the new option name appeared (2.6). */
5271#define FIRST_MAJOR_NEW_OPTION_FILE_NAME 2
5272#define FIRST_MINOR_NEW_OPTION_FILE_NAME 6
5273/* The first version the mid option name appeared (2.2). */
5274#define FIRST_MAJOR_MID_OPTION_FILE_NAME 2
5275#define FIRST_MINOR_MID_OPTION_FILE_NAME 2
5276/* The first version the new boolean values appeared (2.3). */
5277#define FIRST_MAJOR_NEW_BOOLEAN 2
5278#define FIRST_MINOR_NEW_BOOLEAN 3
5279
5280/************************************************************************/
5287static const char *get_current_option_file_name(void)
5288{
5289 static char name_buffer[256];
5290 const char *name;
5291
5292 name = getenv("FREECIV_OPT");
5293
5294 if (name) {
5296 } else {
5297#ifdef OPTION_FILE_NAME
5299#else
5301 if (!name) {
5302 log_error(_("Cannot find freeciv storage directory"));
5303 return NULL;
5304 }
5308#endif /* OPTION_FILE_NAME */
5309 }
5310 log_verbose("settings file is %s", name_buffer);
5311 return name_buffer;
5312}
5313
5314/************************************************************************/
5322static const char *get_last_option_file_name(bool *allow_digital_boolean)
5323{
5324 static char name_buffer[256];
5325 const char *name;
5326 static int last_minors[] = {
5327 0, /* There was no 0.x releases */
5328 14, /* 1.14 */
5329 6 /* 2.6 */
5330 };
5331
5332#if MINOR_VERSION >= 90
5334#else
5336#endif
5337
5338 *allow_digital_boolean = FALSE;
5339 name = getenv("FREECIV_OPT");
5340 if (name) {
5342 } else {
5343#ifdef OPTION_FILE_NAME
5345#else
5346 int major, minor;
5347 struct stat buf;
5348
5350 if (name == NULL) {
5351 log_error(_("Cannot find freeciv storage directory"));
5352
5353 return NULL;
5354 }
5355
5361 : minor >= 0); minor--) {
5364 if (0 == fc_stat(name_buffer, &buf)) {
5367 log_normal(_("Didn't find '%s' option file, "
5368 "loading from '%s' instead."),
5370 name_buffer + strlen(name) + 1);
5371 }
5372
5373 return name_buffer;
5374 }
5375 }
5376 minor = last_minors[major - 1];
5377 }
5378
5379 /* Older versions had options file in user home directory */
5380 name = user_home_dir();
5381 if (name == NULL) {
5382 log_error(_("Cannot find your home directory"));
5383
5384 return NULL;
5385 }
5386
5387 /* minor having max value of FIRST_MINOR_NEW_OPTION_FILE_NAME
5388 * works since MID versioning scheme was used within major version 2
5389 * only (2.2 - 2.6) so the last minor is bigger than any earlier minor. */
5393 minor--) {
5396 if (0 == fc_stat(name_buffer, &buf)) {
5397 log_normal(_("Didn't find '%s' option file, "
5398 "loading from '%s' instead."),
5400 name_buffer + strlen(name) + 1);
5401
5403 *allow_digital_boolean = TRUE;
5404 }
5405 return name_buffer;
5406 }
5407 }
5408
5409 /* Try with the old one. */
5412 if (0 == fc_stat(name_buffer, &buf)) {
5413 log_normal(_("Didn't find '%s' option file, "
5414 "loading from '%s' instead."),
5417 *allow_digital_boolean = TRUE;
5418 return name_buffer;
5419 } else {
5420 return NULL;
5421 }
5422#endif /* OPTION_FILE_NAME */
5423 }
5424 log_verbose("settings file is %s", name_buffer);
5425 return name_buffer;
5426}
5427#undef OLD_OPTION_FILE_NAME
5428#undef MID_OPTION_FILE_NAME
5429#undef NEW_OPTION_FILE_NAME
5430#undef FIRST_MAJOR_NEW_OPTION_FILE_NAME
5431#undef FIRST_MINOR_NEW_OPTION_FILE_NAME
5432#undef FIRST_MAJOR_MID_OPTION_FILE_NAME
5433#undef FIRST_MINOR_MID_OPTION_FILE_NAME
5434#undef FIRST_MINOR_NEW_BOOLEAN
5437/****************************************************************************
5438 Desired settable options.
5439****************************************************************************/
5440#define SPECHASH_TAG settable_options
5441#define SPECHASH_ASTR_KEY_TYPE
5442#define SPECHASH_ASTR_DATA_TYPE
5443#include "spechash.h"
5444#define settable_options_hash_iterate(hash, name, value) \
5445 TYPED_HASH_ITERATE(const char *, const char *, hash, name, value)
5446#define settable_options_hash_iterate_end HASH_ITERATE_END
5447
5449
5450/************************************************************************/
5453static void settable_options_load(struct section_file *sf)
5454{
5455 char buf[64];
5456 const struct section *psection;
5457 const struct entry_list *entries;
5458 const char *string;
5459 bool bval;
5460 int ival;
5461
5463
5465
5466 psection = secfile_section_by_name(sf, "server");
5467 if (NULL == psection) {
5468 /* Does not exist! */
5469 return;
5470 }
5471
5472 entries = section_entries(psection);
5474 string = NULL;
5475 switch (entry_type_get(pentry)) {
5476 case ENTRY_BOOL:
5477 if (entry_bool_get(pentry, &bval)) {
5478 fc_strlcpy(buf, bval ? "enabled" : "disabled", sizeof(buf));
5479 string = buf;
5480 }
5481 break;
5482
5483 case ENTRY_INT:
5484 if (entry_int_get(pentry, &ival)) {
5485 fc_snprintf(buf, sizeof(buf), "%d", ival);
5486 string = buf;
5487 }
5488 break;
5489
5490 case ENTRY_STR:
5491 (void) entry_str_get(pentry, &string);
5492 break;
5493
5494 case ENTRY_FLOAT:
5496 /* Not supported yet */
5497 break;
5498 case ENTRY_LONG_COMMENT:
5500 break;
5501 case ENTRY_ILLEGAL:
5503 break;
5504 }
5505
5506 if (NULL == string) {
5507 log_error("Entry type variant of \"%s.%s\" is not supported.",
5508 section_name(psection), entry_name(pentry));
5509 continue;
5510 }
5511
5513 string);
5516
5517/************************************************************************/
5520static void settable_options_save(struct section_file *sf)
5521{
5523
5525 if (!fc_strcasecmp(name, "gameseed") || !fc_strcasecmp(name, "mapseed")) {
5526 /* Do not save mapseed or gameseed. */
5527 continue;
5528 }
5529 if (!fc_strcasecmp(name, "topology")) {
5530 /* client_start_server() sets topology based on tileset. Don't store
5531 * its choice. The tileset is already stored. Storing topology leads
5532 * to all sort of breakage:
5533 * - it breaks ruleset default topology.
5534 * - it interacts badly with tileset ruleset change, ruleset tileset
5535 * change and topology tileset change.
5536 * - its value is probably based on what tileset was loaded when
5537 * client_start_server() decided to set topology, not on player
5538 * choice.
5539 */
5540 continue;
5541 }
5542 secfile_insert_str(sf, value, "server.%s", name);
5544}
5546/************************************************************************/
5551{
5552 char val_buf[1024], def_buf[1024];
5553 const char *value, *def_val;
5554
5556
5559
5560 if (srv->setdef != SETDEF_CHANGED) {
5561 /* Some level default - do not store */
5564 } else {
5565 value = NULL;
5566 def_val = NULL;
5567 switch (option_type(poption)) {
5568 case OT_BOOLEAN:
5569 fc_strlcpy(val_buf, option_bool_get(poption) ? "enabled" : "disabled",
5570 sizeof(val_buf));
5571 value = val_buf;
5572 fc_strlcpy(def_buf, option_bool_def(poption) ? "enabled" : "disabled",
5573 sizeof(def_buf));
5574 def_val = def_buf;
5575 break;
5576 case OT_INTEGER:
5578 value = val_buf;
5580 def_val = def_buf;
5581 break;
5582 case OT_STRING:
5585 break;
5586 case OT_ENUM:
5588 break;
5589 case OT_BITWISE:
5591 def_buf, sizeof(def_buf));
5592 value = val_buf;
5593 def_val = def_buf;
5594 break;
5595 case OT_FONT:
5596 case OT_COLOR:
5597 case OT_VIDEO_MODE:
5598 break;
5599 }
5600
5601 if (NULL == value || NULL == def_val) {
5602 log_error("Option type %s (%d) not supported for '%s'.",
5605 continue;
5606 }
5607
5610 }
5612}
5614/************************************************************************/
5619 const char *op_value,
5620 bool allow_replace)
5621{
5623
5624 if (allow_replace) {
5626 } else {
5628 }
5629}
5631/************************************************************************/
5635static bool settable_option_upgrade_value(const struct option *poption,
5636 int old_value,
5637 char *buf, size_t buf_len)
5638{
5639 const char *name = option_name(poption);
5640
5641#define SETTING_CASE(ARG_name, ...) \
5642 if (0 == strcmp(ARG_name, name)) { \
5643 static const char *values[] = { __VA_ARGS__ }; \
5644 if (0 <= old_value && old_value < ARRAY_SIZE(values) \
5645 && NULL != values[old_value]) { \
5646 fc_strlcpy(buf, values[old_value], buf_len); \
5647 return TRUE; \
5648 } else { \
5649 return FALSE; \
5650 } \
5651 }
5652
5653 SETTING_CASE("topology", "", "WRAPX", "WRAPY", "WRAPX|WRAPY", "ISO",
5654 "WRAPX|ISO", "WRAPY|ISO", "WRAPX|WRAPY|ISO", "HEX",
5655 "WRAPX|HEX", "WRAPY|HEX", "WRAPX|WRAPY|HEX", "ISO|HEX",
5656 "WRAPX|ISO|HEX", "WRAPY|ISO|HEX", "WRAPX|WRAPY|ISO|HEX");
5657 SETTING_CASE("generator", NULL, "RANDOM", "FRACTAL", "ISLAND");
5658 SETTING_CASE("startpos", "DEFAULT", "SINGLE", "2or3", "ALL", "VARIABLE");
5659 SETTING_CASE("borders", "DISABLED", "ENABLED", "SEE_INSIDE", "EXPAND");
5660 SETTING_CASE("diplomacy", "ALL", "HUMAN", "AI", "TEAM", "DISABLED");
5661 SETTING_CASE("citynames", "NO_RESTRICTIONS", "PLAYER_UNIQUE",
5662 "GLOBAL_UNIQUE", "NO_STEALING");
5663 SETTING_CASE("barbarians", "DISABLED", "HUTS_ONLY", "NORMAL", "FREQUENT",
5664 "HORDES");
5665 SETTING_CASE("phasemode", "ALL", "PLAYER", "TEAM");
5666 SETTING_CASE("compresstype", "PLAIN", "LIBZ", "BZIP2");
5667
5668#undef SETTING_CASE
5669 return FALSE;
5671
5672/************************************************************************/
5675static void desired_settable_option_send(struct option *poption)
5676{
5677 char *desired;
5678 int value;
5679
5681
5684 /* No change explicitly desired. */
5685 return;
5686 }
5687
5688 switch (option_type(poption)) {
5689 case OT_BOOLEAN:
5690 if ((0 == fc_strcasecmp("enabled", desired)
5691 || (str_to_int(desired, &value) && 1 == value))
5692 && !option_bool_get(poption)) {
5693 send_chat_printf("/set %s enabled", option_name(poption));
5694 } else if ((0 == fc_strcasecmp("disabled", desired)
5695 || (str_to_int(desired, &value) && 0 == value))
5697 send_chat_printf("/set %s disabled", option_name(poption));
5698 }
5699 return;
5700 case OT_INTEGER:
5702 send_chat_printf("/set %s %d", option_name(poption), value);
5703 }
5704 return;
5705 case OT_STRING:
5706 if (0 != strcmp(desired, option_str_get(poption))) {
5707 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5708 }
5709 return;
5710 case OT_ENUM:
5711 {
5712 char desired_buf[256];
5713 const char *value_str;
5714
5715 /* Handle old values. */
5716 if (str_to_int(desired, &value)
5718 sizeof(desired_buf))) {
5720 }
5721
5723 if (0 != strcmp(desired, value_str)) {
5724 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5725 }
5726 }
5727 return;
5728 case OT_BITWISE:
5729 {
5730 char desired_buf[256], value_buf[256];
5731
5732 /* Handle old values. */
5733 if (str_to_int(desired, &value)
5735 sizeof(desired_buf))) {
5737 }
5738
5740 sizeof(value_buf), NULL, 0);
5741 if (0 != strcmp(desired, value_buf)) {
5742 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5743 }
5744 }
5745 return;
5746 case OT_FONT:
5747 case OT_COLOR:
5748 case OT_VIDEO_MODE:
5749 break;
5750 }
5751
5752 log_error("Option type %s (%d) not supported for '%s'.",
5755}
5757/************************************************************************/
5762{
5765 (void) value; /* Silence compiler warning about unused variable */
5767
5768 if (poption != NULL) {
5770
5771 /* We only sent the option if it has been sent already in the past.
5772 * Otherwise we leave it for that "initial" sending functionality
5773 * to send it. That has the benefit that the initial send (can) check
5774 * that server is not currently using value from the savegame that
5775 * we should not override */
5776 if (psoption->desired_sent) {
5777 /* Keep this list of conditions in sync with one in
5778 * handle_server_setting_common()
5779 * For lacking initial_setting check here, see comment above about
5780 * checking psoption->desired_sent. */
5781 if (psoption->is_visible
5782 && psoption->is_changeable) {
5784 }
5785 }
5786 }
5788 }
5789}
5790
5791
5792/****************************************************************************
5793 City and player report dialog options.
5794****************************************************************************/
5795#define SPECHASH_TAG dialog_options
5796#define SPECHASH_ASTR_KEY_TYPE
5797#define SPECHASH_IDATA_TYPE bool
5798#define SPECHASH_UDATA_TO_IDATA FC_INT_TO_PTR
5799#define SPECHASH_IDATA_TO_UDATA FC_PTR_TO_INT
5800#define SPECHASH_VPTR_TO_IDATA FC_PTR_TO_INT
5801#include "spechash.h"
5802#define dialog_options_hash_iterate(hash, column, visible) \
5803 TYPED_HASH_ITERATE(const char *, intptr_t, hash, column, visible)
5804#define dialog_options_hash_iterate_end HASH_ITERATE_END
5805
5807
5808/************************************************************************/
5811static void options_dialogs_load(struct section_file *sf)
5812{
5813 const struct entry_list *entries;
5814 const char *prefixes[] = { "player_dlg_", "city_report_", NULL };
5815 const char **prefix;
5816 bool visible;
5817
5819
5821
5822 if (NULL != entries) {
5824 for (prefix = prefixes; NULL != *prefix; prefix++) {
5825 if (!fc_strncmp(*prefix, entry_name(pentry), strlen(*prefix))
5826 && secfile_lookup_bool(sf, &visible, "client.%s",
5827 entry_name(pentry))) {
5830 break;
5831 }
5832 }
5834 }
5836
5837/************************************************************************/
5840static void options_dialogs_save(struct section_file *sf)
5841{
5843
5846 secfile_insert_bool(sf, visible, "client.%s", column);
5848}
5849
5850/************************************************************************/
5855void options_dialogs_update(void)
5856{
5857 char buf[64];
5858 int i;
5859
5861
5862 /* Player report dialog options. */
5863 for (i = 1; i < num_player_dlg_columns; i++) {
5864 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5865 player_dlg_columns[i].tagname);
5868 }
5869
5870 /* City report dialog options. */
5871 for (i = 0; i < num_city_report_spec(); i++) {
5872 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5876 }
5877}
5879/************************************************************************/
5883void options_dialogs_set(void)
5884{
5885 char buf[64];
5886 bool visible;
5887 int i;
5888
5890
5891 /* Player report dialog options. */
5892 for (i = 1; i < num_player_dlg_columns; i++) {
5893 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5894 player_dlg_columns[i].tagname);
5897 }
5898 }
5899
5900 /* City report dialog options. */
5901 for (i = 0; i < num_city_report_spec(); i++) {
5902 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5906 }
5907 }
5908}
5909
5910/************************************************************************/
5916void options_load(void)
5917{
5918 struct section_file *sf;
5920 int i, num;
5921 const char *name;
5922 const char *const prefix = "client";
5923 const char *str;
5924
5926 if (!name) {
5927 log_normal(_("Didn't find the option file. Creating a new one."));
5931 return;
5932 }
5933 if (!(sf = secfile_load(name, TRUE))) {
5934 log_debug("Error loading option file '%s':\n%s", name, secfile_error());
5935 /* Try to create the rc file */
5936 sf = secfile_new(TRUE);
5937 secfile_insert_str(sf, VERSION_STRING, "client.version");
5938
5941 save_cma_presets(sf);
5942
5943 /* FIXME: need better messages */
5944 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
5945 log_error(_("Save failed, cannot write to file %s"), name);
5946 } else {
5947 log_normal(_("Saved settings to file %s"), name);
5948 }
5949 secfile_destroy(sf);
5951 return;
5952 }
5954
5955 /* A "secret" option for the lazy. TODO: make this saveable */
5957 secfile_lookup_str_default(sf, "", "%s.password", prefix));
5958
5961 "%s.save_options_on_exit", prefix);
5964 "%s.fullscreen_mode", prefix);
5965
5966 /* Settings migrations */
5969 "%s.migration_gtk3_from_gtk2", prefix);
5972 "%s.migration_gtk3_22_from_gtk3", prefix);
5975 "%s.migration_gtk4_from_gtk3_22", prefix);
5978 "%s.migration_sdl2_from_sdl", prefix);
5981 "%s.migration_sdl3_from_sdl2", prefix);
5984 "%s.migration_gtk2_from_2_5", prefix);
5987 "%s.migration_gtk3_from_2_5", prefix);
5990 "%s.migration_qt_from_2_5", prefix);
5991
5992 /* Flag values */
5995 "%s.flag_qt_default_fonts_set", prefix);
5998 "%s.flag_sdl2_default_screen_size_set", prefix);
6001 "%s.flag_sdl3_default_screen_size_set", prefix);
6002
6003 /* These are not gui-enabled yet */
6005 = secfile_lookup_bool_default(sf, FALSE, "%s.zoom_set", prefix);
6008 "%s.zoom_default_level", prefix);
6009
6012 "%s.gui_qt_show_relations_panel", prefix);
6015 "%s.gui_qt_show_techs_panel", prefix);
6018 "%s.gui_qt_show_wonders_panel", prefix);
6019
6020 /* default_tileset_name present until freeciv-3.2 */
6021 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_name");
6022 if (str == NULL) {
6024 "client.default_topology");
6025 } else {
6027 }
6028 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_overhead_name");
6029 if (str != NULL) {
6031 }
6032 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_iso_name");
6033 if (str != NULL) {
6035 }
6036
6037 /* Backwards compatibility for removed options replaced by entirely "new"
6038 * options. The equivalent "new" option will override these, if set. */
6039
6040 /* Renamed in 2.6 */
6042 "%s.popup_caravan_arrival", prefix);
6043
6044 /* Load all the regular options */
6048
6049 /* More backwards compatibility, for removed options that had been
6050 * folded into then-existing options. Here, the backwards-compatibility
6051 * behaviour overrides the "destination" option. */
6052
6053 /* Removed in 2.4 */
6055 "%s.do_combat_animation", prefix)) {
6057 }
6058
6059 message_options_load(sf, prefix);
6061
6062 /* Load cma presets. If cma.number_of_presets doesn't exist, don't load
6063 * any, the order here should be reversed to keep the order the same */
6064 if (secfile_lookup_int(sf, &num, "cma.number_of_presets")) {
6065 for (i = num - 1; i >= 0; i--) {
6066 load_cma_preset(sf, i);
6067 }
6068 } else {
6070 }
6071
6074
6075 secfile_destroy(sf);
6078
6079/************************************************************************/
6083 const char *msg, ...)
6084{
6085 va_list args;
6086
6087 va_start(args, msg);
6089 va_end(args);
6091
6092/************************************************************************/
6096{
6097 struct section_file *sf;
6098 const char *name = get_current_option_file_name();
6099 char dir_name[2048];
6100 int i;
6101
6102 if (log_cb == NULL) {
6103 /* Default callback */
6105 }
6106
6107 if (!name) {
6108 log_cb(LOG_ERROR, _("Save failed, cannot find a filename."));
6109 return;
6110 }
6111
6112 sf = secfile_new(TRUE);
6113 secfile_insert_str(sf, VERSION_STRING, "client.version");
6114
6116 "client.save_options_on_exit");
6118 "deprecated", "client.fullscreen_mode");
6119
6120 /* Migrations */
6122 "client.migration_gtk3_from_gtk2");
6124 "client.migration_gtk3_22_from_gtk3");
6126 "client.migration_gtk4_from_gtk3_22");
6128 "client.migration_sdl2_from_sdl");
6130 "client.migration_sdl3_from_sdl2");
6132 "client.migration_gtk2_from_2_5");
6134 "client.migration_gtk3_from_2_5");
6136 "client.migration_qt_from_2_5");
6137
6138 /* Flag */
6140 "client.flag_qt_default_fonts_set");
6142 "client.flag_sdl2_default_screen_size_set");
6144 "client.flag_sdl3_default_screen_size_set");
6145
6146 /* gui-enabled options */
6151 /* Once options have been migrated from a client that no longer exist to a newer client,
6152 * there's no use for those settings of dropped client any more, so no point in saving them. */
6154 }
6156
6157 /* These are not gui-enabled yet. */
6158 secfile_insert_bool(sf, gui_options.zoom_set, "client.zoom_set");
6160 "client.zoom_default_level");
6161
6163 "client.gui_qt_show_relations_panel");
6165 "client.gui_qt_show_techs_panel");
6167 "client.gui_qt_show_wonders_panel");
6168
6169 if (tileset != NULL) {
6171 "client.default_topology");
6172 } else {
6174 "client.default_topology");
6175 }
6176
6177 message_options_save(sf, "client");
6179
6180 /* Server settings */
6181 save_cma_presets(sf);
6183
6184 /* Insert global worklists */
6186
6187 /* Directory name */
6189 for (i = strlen(dir_name) - 1 ; dir_name[i] != DIR_SEPARATOR_CHAR && i >= 0; i--) {
6190 /* Nothing */
6191 }
6192
6193 if (i > 0) {
6194 dir_name[i] = '\0';
6195 if (!make_dir(dir_name)) {
6196 log_cb(LOG_ERROR, _("Saving options failed, cannot create directory %s"),
6197 dir_name);
6198 secfile_destroy(sf);
6199 return;
6200 }
6201 }
6202
6203 /* Save to disk */
6204 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
6205 log_cb(LOG_ERROR, _("Saving options failed, cannot write to file %s"), name);
6206 } else {
6207 log_cb(LOG_VERBOSE, _("Saved options to file %s"), name);
6208 }
6209 secfile_destroy(sf);
6211
6212/************************************************************************/
6215static void options_init_names(const struct copt_val_name *(*acc)(int),
6216 struct strvec **support, struct strvec **pretty)
6217{
6218 int val;
6219 const struct copt_val_name *name;
6220
6222 *support = strvec_new();
6223 *pretty = strvec_new();
6224 for (val = 0; (name = acc(val)); val++) {
6225 strvec_append(*support, name->support);
6226 strvec_append(*pretty, name->pretty);
6227 }
6229
6230/************************************************************************/
6233void options_init(void)
6234{
6238
6241
6244
6245 switch (option_type(poption)) {
6246 case OT_INTEGER:
6253
6254 log_error("option %s has default value of %d, which is "
6255 "out of its range [%d; %d], changing to %d.",
6258 new_default);
6259 *((int *) &(pcoption->integer.def)) = new_default;
6260 }
6261 break;
6262
6263 case OT_STRING:
6265 /* Hack to get a default value. */
6266 *((const char **) &(pcoption->string.def)) =
6268 }
6269
6270 if (NULL == option_str_def(poption)) {
6271 const struct strvec *values = option_str_values(poption);
6272
6273 if (NULL == values || strvec_size(values) == 0) {
6274 log_error("Invalid NULL default string for option %s.",
6276 } else {
6277 *((const char **) &(pcoption->string.def)) =
6278 strvec_get(values, 0);
6279 }
6280 }
6281 break;
6282
6283 case OT_ENUM:
6284 fc_assert(NULL == pcoption->enumerator.support_names);
6285 fc_assert(NULL == pcoption->enumerator.pretty_names);
6286 options_init_names(pcoption->enumerator.name_accessor,
6287 &pcoption->enumerator.support_names,
6288 &pcoption->enumerator.pretty_names);
6289 fc_assert(NULL != pcoption->enumerator.support_names);
6290 fc_assert(NULL != pcoption->enumerator.pretty_names);
6291 break;
6292
6293 case OT_BITWISE:
6294 fc_assert(NULL == pcoption->bitwise.support_names);
6295 fc_assert(NULL == pcoption->bitwise.pretty_names);
6296 options_init_names(pcoption->bitwise.name_accessor,
6297 &pcoption->bitwise.support_names,
6298 &pcoption->bitwise.pretty_names);
6299 fc_assert(NULL != pcoption->bitwise.support_names);
6300 fc_assert(NULL != pcoption->bitwise.pretty_names);
6301 break;
6302
6303 case OT_COLOR:
6304 {
6305 /* Duplicate the string pointers. */
6306 struct ft_color *pcolor = pcoption->color.pvalue;
6307
6308 if (NULL != pcolor->foreground) {
6309 pcolor->foreground = fc_strdup(pcolor->foreground);
6310 }
6311 if (NULL != pcolor->background) {
6312 pcolor->background = fc_strdup(pcolor->background);
6313 }
6314 }
6315 break;
6316
6317 case OT_BOOLEAN:
6318 case OT_FONT:
6319 case OT_VIDEO_MODE:
6320 break;
6321 }
6322
6323 /* Set to default. */
6327
6328/************************************************************************/
6331void options_free(void)
6332{
6335
6337
6338 switch (option_type(poption)) {
6339 case OT_ENUM:
6340 fc_assert_action(NULL != pcoption->enumerator.support_names, break);
6341 strvec_destroy(pcoption->enumerator.support_names);
6342 pcoption->enumerator.support_names = NULL;
6343 fc_assert_action(NULL != pcoption->enumerator.pretty_names, break);
6344 strvec_destroy(pcoption->enumerator.pretty_names);
6345 pcoption->enumerator.pretty_names = NULL;
6346 break;
6347
6348 case OT_BITWISE:
6349 fc_assert_action(NULL != pcoption->bitwise.support_names, break);
6350 strvec_destroy(pcoption->bitwise.support_names);
6351 pcoption->bitwise.support_names = NULL;
6352 fc_assert_action(NULL != pcoption->bitwise.pretty_names, break);
6353 strvec_destroy(pcoption->bitwise.pretty_names);
6354 pcoption->bitwise.pretty_names = NULL;
6355 break;
6356
6357 case OT_BOOLEAN:
6358 case OT_INTEGER:
6359 case OT_STRING:
6360 case OT_FONT:
6361 case OT_COLOR:
6362 case OT_VIDEO_MODE:
6363 break;
6364 }
6366
6367 if (NULL != settable_options_hash) {
6370 }
6371
6372 if (NULL != dialog_options_hash) {
6375 }
6376
6379}
6381/************************************************************************/
6385static void reqtree_show_icons_callback(struct option *poption)
6386{
6389
6390/************************************************************************/
6393static void view_option_changed_callback(struct option *poption)
6394{
6395 menus_init();
6398
6399/************************************************************************/
6402static void manual_turn_done_callback(struct option *poption)
6403{
6405
6407 struct player *pplayer = client_player();
6408
6409 if (pplayer != NULL && is_ai(pplayer)
6410 && can_end_turn()) {
6412 }
6413 }
6415
6416/****************************************************************************
6417 Callback for changing music volume
6418****************************************************************************/
6419static void sound_volume_callback(struct option *poption)
6420{
6423
6424/************************************************************************/
6427static void voteinfo_bar_callback(struct option *poption)
6428{
6431
6432/************************************************************************/
6435static void font_changed_callback(struct option *poption)
6436{
6440
6441/************************************************************************/
6444static void mapimg_changed_callback(struct option *poption)
6445{
6447#ifndef FREECIV_NDEBUG
6448 bool success;
6449#endif
6450
6451 log_normal("Error setting the value for %s (%s). Restoring the default "
6452 "value.", option_name(poption), mapimg_error());
6453
6454 /* Reset the value to the default value. */
6455#ifndef FREECIV_NDEBUG
6456 success =
6457#endif
6459
6461 "Failed to reset the option \"%s\".",
6463#ifndef FREECIV_NDEBUG
6464 success =
6465#endif
6467
6469 "Failed to restore mapimg definition for option \"%s\".",
6471 }
6473
6474/************************************************************************/
6477static void game_music_enable_callback(struct option *poption)
6478{
6479 if (client_state() == C_S_RUNNING) {
6482 } else {
6484 }
6485 }
6487
6488/************************************************************************/
6491static void menu_music_enable_callback(struct option *poption)
6492{
6493 if (client_state() != C_S_RUNNING) {
6495 start_menu_music("music_menu", NULL);
6496 } else {
6498 }
6499 }
6501
6502/************************************************************************/
6505bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
6506{
6507 return (2 < fc_snprintf(buf, buf_len, "%dx%d", mode->width, mode->height));
6509
6510/************************************************************************/
6513bool string_to_video_mode(const char *buf, struct video_mode *mode)
6514{
6515 return (2 == sscanf(buf, "%dx%d", &mode->width, &mode->height));
6517
6518/************************************************************************/
6521static const struct strvec *get_mapimg_format_list(const struct option *poption)
6522{
6523 return mapimg_get_format_list();
6525
6526/************************************************************************/
6529const char *tileset_name_for_topology(int topology_id)
6530{
6531 const char *tsn = NULL;
6532
6533 switch (topology_id & (TF_ISO | TF_HEX)) {
6534 case 0:
6535 case TF_ISO:
6537 break;
6538 case TF_HEX:
6540 break;
6541 case TF_ISO | TF_HEX:
6543 break;
6544 }
6545
6546 if (tsn == NULL) {
6548 }
6549
6550 return tsn;
6552
6553/************************************************************************/
6556void option_set_default_ts(struct tileset *t)
6557{
6558 const char *optname = "<not set>";
6559 struct option *opt;
6560
6561 switch (tileset_topo_index(t)) {
6562 case TS_TOPO_SQUARE:
6563 /* Overhead */
6564 optname = "default_tileset_square_name";
6565 break;
6566 case TS_TOPO_HEX:
6567 /* Hex */
6568 optname = "default_tileset_hex_name";
6569 break;
6570 case TS_TOPO_ISOHEX:
6571 /* Isohex */
6572 optname = "default_tileset_isohex_name";
6573 break;
6574 }
6575
6577
6578 if (opt == NULL) {
6579 log_error("Unknown option name \"%s\" in option_set_default_ts()", optname);
6580 return;
6581 }
6582
6583 /* Do not call option_str_set() since we don't want option changed callback
6584 * to reload this tileset. */
6585 opt->str_vtable->set(opt, tileset_basename(t));
6588
6589/************************************************************************/
6592static bool is_ts_option_unset(const char *optname)
6593{
6594 struct option *opt;
6595 const char *val;
6596
6598
6599 if (opt == NULL) {
6600 return TRUE;
6601 }
6602
6603 val = opt->str_vtable->get(opt);
6604
6605 if (val == NULL || val[0] == '\0') {
6606 return TRUE;
6607 }
6608
6609 return FALSE;
6611
6612/************************************************************************/
6615void fill_topo_ts_default(void)
6616{
6617 if (is_ts_option_unset("default_tileset_square_name")) {
6618 if (gui_options.default_tileset_iso_name[0] != '\0') {
6622 } else if (gui_options.default_tileset_overhead_name[0] != '\0') {
6626 } else {
6627 log_debug("Setting tileset for square topologies.");
6629 }
6630 }
6631 if (is_ts_option_unset("default_tileset_hex_name")) {
6632 log_debug("Setting tileset for hex topology.");
6634 }
6635 if (is_ts_option_unset("default_tileset_isohex_name")) {
6636 log_debug("Setting tileset for isohex topology.");
6638 }
6639}
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:324
#define output_type_iterate(output)
Definition city.h:833
#define output_type_iterate_end
Definition city.h:839
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)
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:1397
void cm_init_parameter(struct cm_parameter *dest)
Definition cm.c:2180
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:74
#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:2099
void options_extra_init(void)
Definition gui_main.c:2501
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:3364
void handle_server_setting_const(const struct packet_server_setting_const *packet)
Definition options.c:4298
void handle_server_setting_int(const struct packet_server_setting_int *packet)
Definition options.c:4391
static int server_option_int_max(const struct option *poption)
Definition options.c:4822
static bool client_option_font_set(struct option *poption, const char *font)
Definition options.c:3733
unsigned option_bitwise_mask(const struct option *poption)
Definition options.c:1095
void fill_topo_ts_default(void)
Definition options.c:6610
#define FIRST_MAJOR_MID_OPTION_FILE_NAME
Definition options.c:5269
#define client_options_iterate_all_end
Definition options.c:3326
static const struct strvec * server_option_str_values(const struct option *poption)
Definition options.c:4866
static int client_option_enum_get(const struct option *poption)
Definition options.c:3592
void resend_desired_settable_options(void)
Definition options.c:5756
const struct strvec * option_str_values(const struct option *poption)
Definition options.c:914
static void desired_settable_option_send(struct option *poption)
Definition options.c:5670
static const char * client_option_name(const struct option *poption)
Definition options.c:3418
static unsigned server_option_bitwise_def(const struct option *poption)
Definition options.c:4961
#define FIRST_MAJOR_NEW_OPTION_FILE_NAME
Definition options.c:5266
static const struct option_video_mode_vtable client_option_video_mode_vtable
Definition options.c:1405
#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd)
Definition options.c:1582
static struct dialog_options_hash * dialog_options_hash
Definition options.c:5801
void option_changed(struct option *poption)
Definition options.c:747
static void menu_music_enable_callback(struct option *poption)
Definition options.c:6486
static bool options_fully_initialized
Definition options.c:401
static const struct option_str_vtable client_option_str_vtable
Definition options.c:1339
unsigned option_bitwise_def(const struct option *poption)
Definition options.c:1084
int option_enum_str_to_int(const struct option *poption, const char *str)
Definition options.c:942
static const char * client_option_description(const struct option *poption)
Definition options.c:3426
int option_int_min(const struct option *poption)
Definition options.c:855
static void option_save_output_window_callback(enum log_level lvl, const char *msg,...)
Definition options.c:6077
static void message_options_save(struct section_file *file, const char *prefix)
Definition options.c:5173
bool option_bool_def(const struct option *poption)
Definition options.c:807
static struct option * client_option_next(const struct option *poption)
Definition options.c:3458
static const char * server_option_name(const struct option *poption)
Definition options.c:4717
const char * option_font_def(const struct option *poption)
Definition options.c:1151
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6524
static const struct copt_val_name * gui_gtk_message_chat_location_name(int value)
Definition options.c:1838
static bool server_option_str_set(struct option *poption, const char *str)
Definition options.c:4875
static const struct copt_val_name * gui_popup_tech_help_name(int value)
Definition options.c:1858
struct option * optset_option_first(const struct option_set *poptset)
Definition options.c:446
static const char * server_optset_category_name(int category)
Definition options.c:4697
const struct option_set * server_optset
Definition options.c:4019
static void view_option_changed_callback(struct option *poption)
Definition options.c:6388
static const char * client_option_font_target(const struct option *poption)
Definition options.c:3724
static void server_option_enum_support_name(const struct option *poption, const char **pvalue, const char **pdefault)
Definition options.c:4935
#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb)
Definition options.c:1544
static const char * server_option_description(const struct option *poption)
Definition options.c:4725
static unsigned server_option_bitwise_get(const struct option *poption)
Definition options.c:4953
static bool client_option_is_changeable(const struct option *poption)
Definition options.c:3450
static int server_option_int_min(const struct option *poption)
Definition options.c:4814
static const char * client_optset_category_name(int category)
Definition options.c:3380
static struct option * server_option_next(const struct option *poption)
Definition options.c:4757
static struct client_option client_options[]
Definition options.c:1885
#define SERVER_OPTION(poption)
Definition options.c:4155
#define OLD_OPTION_FILE_NAME
Definition options.c:5260
static void settable_options_save(struct section_file *sf)
Definition options.c:5515
static bool server_option_bool_get(const struct option *poption)
Definition options.c:4765
bool option_reset(struct option *poption)
Definition options.c:708
void options_free(void)
Definition options.c:6326
const char * option_description(const struct option *poption)
Definition options.c:637
const char * option_help_text(const struct option *poption)
Definition options.c:647
#define settable_options_hash_iterate_end
Definition options.c:5441
static const char * client_option_font_get(const struct option *poption)
Definition options.c:3708
static int server_option_enum_def(const struct option *poption)
Definition options.c:4898
static int server_option_int_def(const struct option *poption)
Definition options.c:4806
#define client_options_iterate_all(poption)
Definition options.c:3317
static int client_option_int_min(const struct option *poption)
Definition options.c:3514
static int server_options_categories_num
Definition options.c:4001
const char * option_enum_get_str(const struct option *poption)
Definition options.c:991
static struct ft_color client_option_color_def(const struct option *poption)
Definition options.c:3757
static const struct strvec * client_option_enum_pretty_names(const struct option *poption)
Definition options.c:3610
static bool server_option_enum_set(struct option *poption, int val)
Definition options.c:4917
static void save_cma_presets(struct section_file *file)
Definition options.c:5246
struct ft_color option_color_get(const struct option *poption)
Definition options.c:1189
static struct video_mode client_option_video_mode_def(const struct option *poption)
Definition options.c:3811
static int client_option_int_get(const struct option *poption)
Definition options.c:3498
static char ** server_options_categories
Definition options.c:3998
int option_enum_get_int(const struct option *poption)
Definition options.c:979
static void settable_options_load(struct section_file *sf)
Definition options.c:5448
int option_number(const struct option *poption)
Definition options.c:617
static struct option * server_optset_option_first(void)
Definition options.c:4681
static struct settable_options_hash * settable_options_hash
Definition options.c:5443
int option_category(const struct option *poption)
Definition options.c:667
static struct server_option * server_options
Definition options.c:3999
static const struct option_int_vtable server_option_int_vtable
Definition options.c:4059
static void options_dialogs_save(struct section_file *sf)
Definition options.c:5835
static struct option_set client_optset_static
Definition options.c:1273
static bool client_option_color_set(struct option *poption, struct ft_color color)
Definition options.c:3766
#define dialog_options_hash_iterate_end
Definition options.c:5799
static void save_cma_preset(struct section_file *file, int i)
Definition options.c:5224
static int client_optset_category_number(void)
Definition options.c:3372
static const char * client_option_str_def(const struct option *poption)
Definition options.c:3556
static bool client_option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:3820
void handle_server_setting_bitwise(const struct packet_server_setting_bitwise *packet)
Definition options.c:4562
static const struct option_font_vtable client_option_font_vtable
Definition options.c:1380
static bool client_option_enum_set(struct option *poption, int val)
Definition options.c:3619
void desired_settable_option_update(const char *op_name, const char *op_value, bool allow_replace)
Definition options.c:5613
void option_set_default_ts(struct tileset *t)
Definition options.c:6551
bool option_str_set(struct option *poption, const char *str)
Definition options.c:925
void handle_server_setting_bool(const struct packet_server_setting_bool *packet)
Definition options.c:4356
static const struct strvec * client_option_str_values(const struct option *poption)
Definition options.c:3566
const struct option_set * client_optset
Definition options.c:1279
static const struct option_bool_vtable server_option_bool_vtable
Definition options.c:4047
static const struct option_bitwise_vtable server_option_bitwise_vtable
Definition options.c:4100
const char * option_name(const struct option *poption)
Definition options.c:627
static const char * client_option_help_text(const struct option *poption)
Definition options.c:3434
static void message_options_init(void)
Definition options.c:5046
static int client_option_number(const struct option *poption)
Definition options.c:3410
void handle_server_setting_str(const struct packet_server_setting_str *packet)
Definition options.c:4428
int option_int_get(const struct option *poption)
Definition options.c:833
static void client_option_save(struct option *poption, struct section_file *sf)
Definition options.c:3938
void options_init(void)
Definition options.c:6228
static int client_option_int_def(const struct option *poption)
Definition options.c:3506
static int server_option_category(const struct option *poption)
Definition options.c:4741
#define FIRST_MINOR_MID_OPTION_FILE_NAME
Definition options.c:5270
static const struct option_enum_vtable client_option_enum_vtable
Definition options.c:1352
static const struct option_str_vtable server_option_str_vtable
Definition options.c:4073
static int server_options_num
Definition options.c:4002
#define handle_server_setting_common(psoption, packet)
Definition options.c:4319
static const struct option_color_vtable client_option_color_vtable
Definition options.c:1392
bool option_enum_set_str(struct option *poption, const char *str)
Definition options.c:1056
static const struct strvec * server_option_enum_pretty(const struct option *poption)
Definition options.c:4908
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:5019
bool option_color_set(struct option *poption, struct ft_color color)
Definition options.c:1212
#define SETTING_CASE(ARG_name,...)
static struct video_mode client_option_video_mode_get(const struct option *poption)
Definition options.c:3802
static bool is_ts_option_unset(const char *optname)
Definition options.c:6587
void option_set_changed_callback(struct option *poption, void(*callback)(struct option *))
Definition options.c:736
#define OPTION(poption)
Definition options.c:562
#define NEW_OPTION_FILE_NAME
Definition options.c:5263
static bool server_option_bool_set(struct option *poption, bool val)
Definition options.c:4782
bool option_bool_set(struct option *poption, bool val)
Definition options.c:818
bool option_is_changeable(const struct option *poption)
Definition options.c:688
#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb)
Definition options.c:1660
bool option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:1252
#define MID_OPTION_FILE_NAME
Definition options.c:5262
static int server_option_number(const struct option *poption)
Definition options.c:4709
#define dialog_options_hash_iterate(hash, column, visible)
Definition options.c:5797
#define FIRST_MINOR_NEW_BOOLEAN
Definition options.c:5273
static const char * server_option_str_get(const struct option *poption)
Definition options.c:4848
#define settable_options_hash_iterate(hash, name, value)
Definition options.c:5439
void option_set_gui_data(struct option *poption, void *data)
Definition options.c:766
#define FIRST_MINOR_NEW_OPTION_FILE_NAME
Definition options.c:5267
#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1508
const char * option_str_get(const struct option *poption)
Definition options.c:892
struct option * optset_option_by_number(const struct option_set *poptset, int id)
Definition options.c:419
static bool client_option_bool_get(const struct option *poption)
Definition options.c:3466
void * option_get_gui_data(const struct option *poption)
Definition options.c:776
static const char * server_option_str_def(const struct option *poption)
Definition options.c:4856
static const struct option_common_vtable client_option_common_vtable
Definition options.c:1299
static bool settable_option_upgrade_value(const struct option *poption, int old_value, char *buf, size_t buf_len)
Definition options.c:5630
const struct strvec * option_enum_values(const struct option *poption)
Definition options.c:1028
static const struct strvec * get_mapimg_format_list(const struct option *poption)
Definition options.c:6516
static void sound_volume_callback(struct option *poption)
Definition options.c:6414
bool option_enum_set_int(struct option *poption, int val)
Definition options.c:1039
bool option_bool_get(const struct option *poption)
Definition options.c:796
int optset_category_number(const struct option_set *poptset)
Definition options.c:456
#define color_set(color_tgt, color)
static bool client_option_bool_def(const struct option *poption)
Definition options.c:3474
static const struct strvec * server_option_bitwise_pretty(const struct option *poption)
Definition options.c:4971
void server_options_init(void)
Definition options.c:4163
enum option_type option_type(const struct option *poption)
Definition options.c:657
static int client_option_enum_def(const struct option *poption)
Definition options.c:3600
const char * option_enum_int_to_str(const struct option *poption, int val)
Definition options.c:964
void options_dialogs_update(void)
Definition options.c:5850
int option_get_cb_data(const struct option *poption)
Definition options.c:786
bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
Definition options.c:6500
static void options_dialogs_load(struct section_file *sf)
Definition options.c:5806
const struct option_set * option_optset(const struct option *poption)
Definition options.c:607
void server_options_free(void)
Definition options.c:4232
struct video_mode option_video_mode_get(const struct option *poption)
Definition options.c:1227
static int server_option_enum_get(const struct option *poption)
Definition options.c:4890
struct option * option_next(const struct option *poption)
Definition options.c:698
static struct option * client_optset_option_by_number(int id)
Definition options.c:3353
static void font_changed_callback(struct option *poption)
Definition options.c:6430
const char * option_str_def(const struct option *poption)
Definition options.c:903
const char * optset_category_name(const struct option_set *poptset, int category)
Definition options.c:466
int option_int_max(const struct option *poption)
Definition options.c:866
#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, odef_bg, ocb)
Definition options.c:1775
const char * option_enum_def_str(const struct option *poption)
Definition options.c:1015
void options_load(void)
Definition options.c:5911
static const char * client_option_str_get(const struct option *poption)
Definition options.c:3548
static const struct option_common_vtable server_option_common_vtable
Definition options.c:4033
static int server_optset_category_number(void)
Definition options.c:4689
static bool client_option_bool_set(struct option *poption, bool val)
Definition options.c:3483
static const char * server_option_help_text(const struct option *poption)
Definition options.c:4733
static const struct option_bool_vtable client_option_bool_vtable
Definition options.c:1313
static bool client_option_load(struct option *poption, struct section_file *sf)
Definition options.c:3837
bool option_font_set(struct option *poption, const char *font)
Definition options.c:1173
static bool server_option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:5000
const char * option_font_target(const struct option *poption)
Definition options.c:1162
static const char * client_option_enum_secfile_str(secfile_data_t data, int val)
Definition options.c:3638
static struct server_option * server_option_next_valid(struct server_option *poption)
Definition options.c:4651
static void server_option_bitwise_support_base(const struct strvec *values, unsigned val, char *buf, size_t buf_len)
Definition options.c:4979
static void voteinfo_bar_callback(struct option *poption)
Definition options.c:6422
static struct option * server_optset_option_by_number(int id)
Definition options.c:4670
void options_save(option_save_log_callback log_cb)
Definition options.c:6090
static void message_options_free(void)
Definition options.c:5084
static const struct option_enum_vtable server_option_enum_vtable
Definition options.c:4086
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6508
const struct strvec * option_bitwise_values(const struct option *poption)
Definition options.c:1112
static bool server_option_int_set(struct option *poption, int val)
Definition options.c:4831
int messages_where[E_COUNT]
Definition options.c:5039
static void message_options_load(struct section_file *file, const char *prefix)
Definition options.c:5093
struct client_options gui_options
Definition options.c:71
static void server_option_free(struct server_option *poption)
Definition options.c:4174
#define CLIENT_OPTION(poption)
Definition options.c:1490
#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1739
static struct option_set server_optset_static
Definition options.c:4013
void handle_server_setting_control(const struct packet_server_setting_control *packet)
Definition options.c:4264
static void mapimg_changed_callback(struct option *poption)
Definition options.c:6439
bool option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:1123
static int server_option_int_get(const struct option *poption)
Definition options.c:4798
static void manual_turn_done_callback(struct option *poption)
Definition options.c:6397
static void reqtree_show_icons_callback(struct option *poption)
Definition options.c:6380
const char * option_font_get(const struct option *poption)
Definition options.c:1140
void desired_settable_options_update(void)
Definition options.c:5545
static void load_cma_preset(struct section_file *file, int i)
Definition options.c:5194
static bool client_option_str_set(struct option *poption, const char *str)
Definition options.c:3576
void handle_server_setting_enum(const struct packet_server_setting_enum *packet)
Definition options.c:4473
struct ft_color option_color_def(const struct option *poption)
Definition options.c:1200
static int client_option_int_max(const struct option *poption)
Definition options.c:3522
#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd)
Definition options.c:1623
client_option_category
Definition options.c:1411
@ COC_MAX
Definition options.c:1419
@ COC_SOUND
Definition options.c:1414
@ COC_NETWORK
Definition options.c:1417
@ COC_INTERFACE
Definition options.c:1415
@ COC_GRAPHICS
Definition options.c:1412
@ COC_OVERVIEW
Definition options.c:1413
@ COC_FONT
Definition options.c:1418
@ COC_MAPIMG
Definition options.c:1416
unsigned option_bitwise_get(const struct option *poption)
Definition options.c:1073
static bool server_option_is_changeable(const struct option *poption)
Definition options.c:4749
static struct ft_color client_option_color_get(const struct option *poption)
Definition options.c:3749
int option_enum_def_int(const struct option *poption)
Definition options.c:1003
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:430
static const int client_options_num
Definition options.c:3314
static bool client_option_int_set(struct option *poption, int val)
Definition options.c:3531
void options_dialogs_set(void)
Definition options.c:5878
bool option_int_set(struct option *poption, int val)
Definition options.c:877
static struct client_option * client_option_next_valid(struct client_option *poption)
Definition options.c:3335
static const char * client_option_bitwise_secfile_str(secfile_data_t data, int val)
Definition options.c:3696
#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, odef_height, ocb)
Definition options.c:1810
static const struct option_int_vtable client_option_int_vtable
Definition options.c:1325
static const char * client_option_font_def(const struct option *poption)
Definition options.c:3716
static const char * get_last_option_file_name(bool *allow_digital_boolean)
Definition options.c:5317
const char * option_category_name(const struct option *poption)
Definition options.c:677
static void game_music_enable_callback(struct option *poption)
Definition options.c:6472
static const char * get_current_option_file_name(void)
Definition options.c:5282
int option_int_def(const struct option *poption)
Definition options.c:844
static void options_init_names(const struct copt_val_name *(*acc)(int), struct strvec **support, struct strvec **pretty)
Definition options.c:6210
struct video_mode option_video_mode_def(const struct option *poption)
Definition options.c:1239
static bool server_option_bool_def(const struct option *poption)
Definition options.c:4773
#define GUI_GTK3_CITYDLG_DEFAULT_XSIZE
Definition options.h:602
#define GUI_GTK3_22_GOV_RANGE_MIN_DEFAULT
Definition options.h:627
#define MW_POPUP
Definition options.h:580
#define GUI_GTK3_CITYDLG_MAX_YSIZE
Definition options.h:608
#define GUI_GTK3_22_GOV_RANGE_MIN_MIN
Definition options.h:628
#define GUI_GTK3_GOV_RANGE_MIN_DEFAULT
Definition options.h:610
#define GUI_GTK4_GOV_RANGE_MIN_MAX
Definition options.h:646
#define GUI_GTK3_22_CITYDLG_MIN_YSIZE
Definition options.h:624
#define GUI_GTK4_CITYDLG_MAX_XSIZE
Definition options.h:638
#define GUI_GTK4_GOV_RANGE_MIN_DEFAULT
Definition options.h:644
#define GUI_GTK3_GOV_RANGE_MAX_DEFAULT
Definition options.h:614
void(* option_save_log_callback)(enum log_level lvl, const char *msg,...)
Definition options.h:446
#define GUI_GTK4_CITYDLG_DEFAULT_XSIZE
Definition options.h:636
#define FC_SDL3_DEFAULT_THEME_NAME
Definition options.h:392
#define GUI_GTK2_CITYDLG_DEFAULT_YSIZE
Definition options.h:594
#define FC_GTK3_22_DEFAULT_THEME_NAME
Definition options.h:300
#define GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE
Definition options.h:619
#define FC_QT_DEFAULT_THEME_NAME
Definition options.h:405
#define GUI_GTK3_CITYDLG_MIN_YSIZE
Definition options.h:607
#define GUI_GTK3_CITYDLG_MIN_XSIZE
Definition options.h:603
#define GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE
Definition options.h:623
#define GUI_GTK4_CITYDLG_MIN_YSIZE
Definition options.h:641
#define DEFAULT_FOLLOWTAG_OPTION
Definition options.h:30
#define GUI_GTK2_CITYDLG_MIN_YSIZE
Definition options.h:595
#define options_iterate(poptset, poption)
Definition options.h:551
#define GUI_GTK2_CITYDLG_MAX_XSIZE
Definition options.h:592
#define GUI_DEFAULT_CHAT_LOGFILE
Definition options.h:587
#define GUI_GTK3_GOV_RANGE_MAX_MAX
Definition options.h:616
#define GUI_GTK4_CITYDLG_MIN_XSIZE
Definition options.h:637
#define GUI_GTK3_22_GOV_RANGE_MAX_DEFAULT
Definition options.h:631
#define DEFAULT_METASERVER_OPTION
Definition options.h:29
#define GUI_GTK3_CITYDLG_DEFAULT_YSIZE
Definition options.h:606
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:621
#define GUI_GTK3_22_GOV_RANGE_MAX_MIN
Definition options.h:632
#define GUI_GTK3_GOV_RANGE_MIN_MIN
Definition options.h:611
#define GUI_GTK3_GOV_RANGE_MIN_MAX
Definition options.h:612
#define GUI_GTK3_22_CITYDLG_MIN_XSIZE
Definition options.h:620
#define GUI_GTK4_GOV_RANGE_MAX_DEFAULT
Definition options.h:648
#define MAJOR_NEW_OPTION_FILE_NAME
Definition options.h:38
@ GUI_GTK_MSGCHAT_SEPARATE
Definition options.h:68
#define GUI_GTK3_GOV_RANGE_MAX_MIN
Definition options.h:615
#define GUI_GTK2_CITYDLG_MAX_YSIZE
Definition options.h:596
#define GUI_DEFAULT_MAPIMG_FILENAME
Definition options.h:652
#define GUI_GTK3_22_CITYDLG_MAX_YSIZE
Definition options.h:625
#define GUI_GTK4_GOV_RANGE_MIN_MIN
Definition options.h:645
#define GUI_GTK4_CITYDLG_MAX_YSIZE
Definition options.h:642
#define MW_OUTPUT
Definition options.h:578
#define GUI_GTK4_CITYDLG_DEFAULT_YSIZE
Definition options.h:640
#define options_iterate_end
Definition options.h:556
#define GUI_GTK4_GOV_RANGE_MAX_MAX
Definition options.h:650
#define MW_MESSAGES
Definition options.h:579
#define FC_GTK4_DEFAULT_THEME_NAME
Definition options.h:336
#define GUI_GTK3_22_GOV_RANGE_MIN_MAX
Definition options.h:629
#define MINOR_NEW_OPTION_FILE_NAME
Definition options.h:42
#define GUI_GTK2_CITYDLG_DEFAULT_XSIZE
Definition options.h:590
#define FC_SDL2_DEFAULT_THEME_NAME
Definition options.h:379
#define GUI_GTK3_22_GOV_RANGE_MAX_MAX
Definition options.h:633
#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:604
#define GUI_GTK4_GOV_RANGE_MAX_MIN
Definition options.h:649
#define GUI_GTK2_CITYDLG_MIN_XSIZE
Definition options.h:591
@ GUI_POPUP_TECH_HELP_RULESET
Definition options.h:77
void overview_redraw_callback(struct option *option)
#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:1779
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)
const int def
Definition options.c:1443
const unsigned def
Definition options.c:1466
struct client_option::@207::@211 string
enum gui_type specific
Definition options.c:1432
struct client_option::@207::@214 font
const char * description
Definition options.c:1429
const char *const def
Definition options.c:1449
struct ft_color *const pvalue
Definition options.c:1479
struct video_mode *const pvalue
Definition options.c:1484
const size_t size
Definition options.c:1448
char *const pvalue
Definition options.c:1447
const int max
Definition options.c:1443
const bool def
Definition options.c:1438
const char *const target
Definition options.c:1475
bool *const pvalue
Definition options.c:1437
struct option base_option
Definition options.c:1426
struct client_option::@207::@210 integer
const char * help_text
Definition options.c:1430
unsigned *const pvalue
Definition options.c:1465
enum client_option_category category
Definition options.c:1431
int *const pvalue
Definition options.c:1442
const char * name
Definition options.c:1428
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:421
char default_tileset_iso_name[512]
Definition options.h:132
bool gui_qt_show_techs_panel
Definition options.h:422
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:423
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:1282
const char * pretty
Definition options.c:1284
int(* number)(const struct option *)
Definition options.c:486
int(* category)(const struct option *)
Definition options.c:490
bool(* is_changeable)(const struct option *)
Definition options.c:491
struct option *(* option_by_number)(int)
Definition options.c:409
struct option *(* option_first)(void)
Definition options.c:410
const char *(* category_name)(int)
Definition options.c:413
int(* category_number)(void)
Definition options.c:412
const struct option::option_common_vtable * common_vtable
const struct option::@205::option_video_mode_vtable * video_mode_vtable
const struct option::@205::option_color_vtable * color_vtable
const struct option::@205::option_font_vtable * font_vtable
enum option_type type
Definition options.c:482
const struct option::@205::option_bitwise_vtable * bitwise_vtable
const struct option_set * poptset
Definition options.c:480
const struct option::@205::option_str_vtable * str_vtable
const struct option::@205::option_int_vtable * int_vtable
const struct option::@205::option_enum_vtable * enum_vtable
const struct option::@205::option_bool_vtable * bool_vtable
int callback_data
Definition options.c:556
void(* changed_callback)(struct option *option)
Definition options.c:554
void * gui_data
Definition options.c:559
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:4142
unsigned value
Definition options.c:4147
char * help_text
Definition options.c:4115
struct server_option::@217::@220 integer
char * name
Definition options.c:4113
bool is_visible
Definition options.c:4119
char * description
Definition options.c:4114
unsigned char category
Definition options.c:4116
struct strvec * pretty_names
Definition options.c:4143
enum setting_default_level setdef
Definition options.c:4120
unsigned def
Definition options.c:4148
bool is_changeable
Definition options.c:4118
char * value
Definition options.c:4135
struct option base_option
Definition options.c:4111
bool desired_sent
Definition options.c:4117
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:189
#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:154
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:7566
#define TS_TOPO_ISOHEX
Definition tilespec.h:455
#define TS_TOPO_HEX
Definition tilespec.h:454
#define TS_TOPO_SQUARE
Definition tilespec.h:453