Freeciv-3.1
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
86 .save_options_on_exit = TRUE,
87
88 .use_prev_server = FALSE,
89 .heartbeat_enabled = FALSE,
90
92 .first_boot = FALSE,
93 .default_tileset_name = "\0",
94 .default_tileset_overhead_name = "\0",
95 .default_tileset_iso_name = "\0",
96 .gui_gtk3_migrated_from_gtk2 = FALSE,
97 .gui_gtk3_22_migrated_from_gtk3 = FALSE,
98 .gui_gtk4_migrated_from_gtk3_22 = FALSE,
99 .gui_sdl2_migrated_from_sdl = FALSE,
100 .gui_gtk2_migrated_from_2_5 = FALSE,
101 .gui_gtk3_migrated_from_2_5 = FALSE,
102 .gui_qt_migrated_from_2_5 = FALSE,
103
104 .migrate_fullscreen = FALSE,
105
108 .gui_qt_default_fonts_set = FALSE,
109
112 .solid_color_behind_units = FALSE,
113 .sound_bell_at_new_turn = FALSE,
114 .smooth_move_unit_msec = 30,
115 .smooth_center_slide_msec = 200,
116 .smooth_combat_step_msec = 10,
117 .ai_manual_turn_done = TRUE,
118 .auto_center_on_unit = TRUE,
119 .auto_center_on_automated = TRUE,
120 .auto_center_on_combat = FALSE,
121 .auto_center_each_turn = TRUE,
122 .wakeup_focus = TRUE,
123 .goto_into_unknown = TRUE,
124 .center_when_popup_city = TRUE,
125 .show_previous_turn_messages = TRUE,
126 .concise_city_production = FALSE,
127 .auto_turn_done = FALSE,
128 .meta_accelerators = TRUE,
129 .ask_city_name = TRUE,
130 .popup_new_cities = TRUE,
131 .popup_actor_arrival = TRUE,
132 .popup_attack_actions = TRUE,
133 .popup_last_move_to_allied = TRUE,
134 .keyboardless_goto = TRUE,
135 .enable_cursor_changes = TRUE,
136 .separate_unit_selection = FALSE,
137 .unit_selection_clears_orders = TRUE,
138 .highlight_our_names = FT_COLOR("#000000", "#FFFF00"),
139
140 .voteinfo_bar_use = TRUE,
141 .voteinfo_bar_always_show = FALSE,
142 .voteinfo_bar_hide_when_not_player = FALSE,
143 .voteinfo_bar_new_at_front = FALSE,
144
145 .autoaccept_tileset_suggestion = FALSE,
146 .autoaccept_soundset_suggestion = FALSE,
147 .autoaccept_musicset_suggestion = FALSE,
148
149 .sound_enable_effects = TRUE,
150 .sound_enable_menu_music = TRUE,
151 .sound_enable_game_music = TRUE,
152 .sound_effects_volume = 100,
153
154/* This option is currently set by the client - not by the user. */
155 .update_city_text_in_refresh_tile = TRUE,
156
157 .draw_city_outlines = TRUE,
158 .draw_city_output = FALSE,
159 .draw_map_grid = FALSE,
160 .draw_city_names = TRUE,
161 .draw_city_growth = TRUE,
162 .draw_city_productions = TRUE,
163 .draw_city_buycost = FALSE,
164 .draw_city_trade_routes = FALSE,
165 .draw_terrain = TRUE,
166 .draw_coastline = FALSE,
167 .draw_roads_rails = TRUE,
168 .draw_irrigation = TRUE,
169 .draw_mines = TRUE,
170 .draw_fortress_airbase = TRUE,
171 .draw_specials = TRUE,
172 .draw_huts = TRUE,
173 .draw_pollution = TRUE,
174 .draw_cities = TRUE,
175 .draw_units = TRUE,
176 .draw_focus_unit = FALSE,
177 .draw_fog_of_war = TRUE,
178 .draw_borders = TRUE,
179 .draw_native = FALSE,
180 .draw_full_citybar = TRUE,
181 .draw_unit_shields = TRUE,
182 .draw_unit_stack_size = TRUE,
183 .player_dlg_show_dead_players = TRUE,
184 .reqtree_show_icons = TRUE,
185 .reqtree_curved_lines = FALSE,
186
187/* options for map images */
188/* .mapimg_format, */
189 .mapimg_zoom = 2,
190/* See the definition of MAPIMG_LAYER in mapimg.h. */
191 .mapimg_layer = {
192 FALSE, /* a - MAPIMG_LAYER_AREA */
193 TRUE, /* b - MAPIMG_LAYER_BORDERS */
194 TRUE, /* c - MAPIMG_LAYER_CITIES */
195 TRUE, /* f - MAPIMG_LAYER_FOGOFWAR */
196 TRUE, /* k - MAPIMG_LAYER_KNOWLEDGE */
197 TRUE, /* t - MAPIMG_LAYER_TERRAIN */
198 TRUE /* u - MAPIMG_LAYER_UNITS */
199 },
200/* .mapimg_filename, */
201
202 .zoom_set = FALSE,
203 .zoom_default_level = 1.0,
204
205/* gui-gtk-2.0 client specific options.
206 * These are still kept just so users can migrate them to gtk3-client */
207 .gui_gtk2_default_theme_name = FC_GTK2_DEFAULT_THEME_NAME,
208 .gui_gtk2_map_scrollbars = FALSE,
209 .gui_gtk2_dialogs_on_top = TRUE,
210 .gui_gtk2_show_task_icons = TRUE,
211 .gui_gtk2_enable_tabs = TRUE,
212 .gui_gtk2_better_fog = TRUE,
213 .gui_gtk2_show_chat_message_time = FALSE,
214 .gui_gtk2_new_messages_go_to_top = FALSE,
215 .gui_gtk2_show_message_window_buttons = TRUE,
216 .gui_gtk2_metaserver_tab_first = FALSE,
217 .gui_gtk2_allied_chat_only = FALSE,
218 .gui_gtk2_mouse_over_map_focus = FALSE,
219 .gui_gtk2_chatline_autocompletion = TRUE,
220 .gui_gtk2_citydlg_xsize = GUI_GTK2_CITYDLG_DEFAULT_XSIZE,
221 .gui_gtk2_citydlg_ysize = GUI_GTK2_CITYDLG_DEFAULT_YSIZE,
222 .gui_gtk2_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
223 .gui_gtk2_font_city_label = "Monospace 8",
224 .gui_gtk2_font_notify_label = "Monospace Bold 9",
225 .gui_gtk2_font_spaceship_label = "Monospace 8",
226 .gui_gtk2_font_help_label = "Sans Bold 10",
227 .gui_gtk2_font_help_link = "Sans 9",
228 .gui_gtk2_font_help_text = "Monospace 8",
229 .gui_gtk2_font_chatline = "Monospace 8",
230 .gui_gtk2_font_beta_label = "Sans Italic 10",
231 .gui_gtk2_font_small = "Sans 9",
232 .gui_gtk2_font_comment_label = "Sans Italic 9",
233 .gui_gtk2_font_city_names = "Sans Bold 10",
234 .gui_gtk2_font_city_productions = "Serif 10",
235 .gui_gtk2_font_reqtree_text = "Serif 10",
236
237/* gui-gtk-3.0 client specific options. */
238 .gui_gtk3_default_theme_name = FC_GTK3_DEFAULT_THEME_NAME,
239 .gui_gtk3_fullscreen = FALSE,
240 .gui_gtk3_map_scrollbars = FALSE,
241 .gui_gtk3_dialogs_on_top = TRUE,
242 .gui_gtk3_show_task_icons = TRUE,
243 .gui_gtk3_enable_tabs = TRUE,
244 .gui_gtk3_show_chat_message_time = FALSE,
245 .gui_gtk3_new_messages_go_to_top = FALSE,
246 .gui_gtk3_show_message_window_buttons = TRUE,
247 .gui_gtk3_metaserver_tab_first = FALSE,
248 .gui_gtk3_allied_chat_only = FALSE,
249 .gui_gtk3_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
250 .gui_gtk3_small_display_layout = FALSE,
251 .gui_gtk3_mouse_over_map_focus = FALSE,
252 .gui_gtk3_chatline_autocompletion = TRUE,
253 .gui_gtk3_citydlg_xsize = GUI_GTK3_CITYDLG_DEFAULT_XSIZE,
254 .gui_gtk3_citydlg_ysize = GUI_GTK3_CITYDLG_DEFAULT_YSIZE,
255 .gui_gtk3_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
256 .gui_gtk3_governor_range_min = -20,
257 .gui_gtk3_governor_range_max = 20,
258 .gui_gtk3_font_city_label = "Monospace 8",
259 .gui_gtk3_font_notify_label = "Monospace Bold 9",
260 .gui_gtk3_font_spaceship_label = "Monospace 8",
261 .gui_gtk3_font_help_label = "Sans Bold 10",
262 .gui_gtk3_font_help_link = "Sans 9",
263 .gui_gtk3_font_help_text = "Monospace 8",
264 .gui_gtk3_font_chatline = "Monospace 8",
265 .gui_gtk3_font_beta_label = "Sans Italic 10",
266 .gui_gtk3_font_small = "Sans 9",
267 .gui_gtk3_font_comment_label = "Sans Italic 9",
268 .gui_gtk3_font_city_names = "Sans Bold 10",
269 .gui_gtk3_font_city_productions = "Serif 10",
270 .gui_gtk3_font_reqtree_text = "Serif 10",
271
272/* gui-gtk-3.22 client specific options. */
273 .gui_gtk3_22_default_theme_name = FC_GTK3_22_DEFAULT_THEME_NAME,
274 .gui_gtk3_22_fullscreen = FALSE,
275 .gui_gtk3_22_map_scrollbars = FALSE,
276 .gui_gtk3_22_dialogs_on_top = TRUE,
277 .gui_gtk3_22_show_task_icons = TRUE,
278 .gui_gtk3_22_enable_tabs = TRUE,
279 .gui_gtk3_22_show_chat_message_time = FALSE,
280 .gui_gtk3_22_new_messages_go_to_top = FALSE,
281 .gui_gtk3_22_show_message_window_buttons = TRUE,
282 .gui_gtk3_22_metaserver_tab_first = FALSE,
283 .gui_gtk3_22_allied_chat_only = FALSE,
284 .gui_gtk3_22_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
285 .gui_gtk3_22_small_display_layout = FALSE,
286 .gui_gtk3_22_mouse_over_map_focus = FALSE,
287 .gui_gtk3_22_chatline_autocompletion = TRUE,
288 .gui_gtk3_22_citydlg_xsize = GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE,
289 .gui_gtk3_22_citydlg_ysize = GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE,
290 .gui_gtk3_22_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
291 .gui_gtk3_22_governor_range_min = -20,
292 .gui_gtk3_22_governor_range_max = 20,
293 .gui_gtk3_22_font_city_label = "Monospace 8",
294 .gui_gtk3_22_font_notify_label = "Monospace Bold 9",
295 .gui_gtk3_22_font_spaceship_label = "Monospace 8",
296 .gui_gtk3_22_font_help_label = "Sans Bold 10",
297 .gui_gtk3_22_font_help_link = "Sans 9",
298 .gui_gtk3_22_font_help_text = "Monospace 8",
299 .gui_gtk3_22_font_chatline = "Monospace 8",
300 .gui_gtk3_22_font_beta_label = "Sans Italic 10",
301 .gui_gtk3_22_font_small = "Sans 9",
302 .gui_gtk3_22_font_comment_label = "Sans Italic 9",
303 .gui_gtk3_22_font_city_names = "Sans Bold 10",
304 .gui_gtk3_22_font_city_productions = "Serif 10",
305 .gui_gtk3_22_font_reqtree_text = "Serif 10",
306
307/* gui-gtk-4.0 client specific options. */
308 .gui_gtk4_default_theme_name = FC_GTK4_DEFAULT_THEME_NAME,
309 .gui_gtk4_fullscreen = FALSE,
310 .gui_gtk4_map_scrollbars = FALSE,
311 .gui_gtk4_dialogs_on_top = TRUE,
312 .gui_gtk4_show_task_icons = TRUE,
313 .gui_gtk4_enable_tabs = TRUE,
314 .gui_gtk4_show_chat_message_time = FALSE,
315 .gui_gtk4_new_messages_go_to_top = FALSE,
316 .gui_gtk4_show_message_window_buttons = TRUE,
317 .gui_gtk4_metaserver_tab_first = FALSE,
318 .gui_gtk4_allied_chat_only = FALSE,
319 .gui_gtk4_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
320 .gui_gtk4_small_display_layout = FALSE,
321 .gui_gtk4_mouse_over_map_focus = FALSE,
322 .gui_gtk4_chatline_autocompletion = TRUE,
323 .gui_gtk4_citydlg_xsize = GUI_GTK4_CITYDLG_DEFAULT_XSIZE,
324 .gui_gtk4_citydlg_ysize = GUI_GTK4_CITYDLG_DEFAULT_YSIZE,
325 .gui_gtk4_popup_tech_help = GUI_POPUP_TECH_HELP_RULESET,
326 .gui_gtk4_governor_range_min = -20,
327 .gui_gtk4_governor_range_max = 20,
328 .gui_gtk4_font_city_label = "Monospace 8",
329 .gui_gtk4_font_notify_label = "Monospace Bold 9",
330 .gui_gtk4_font_spaceship_label = "Monospace 8",
331 .gui_gtk4_font_help_label = "Sans Bold 10",
332 .gui_gtk4_font_help_link = "Sans 9",
333 .gui_gtk4_font_help_text = "Monospace 8",
334 .gui_gtk4_font_chatline = "Monospace 8",
335 .gui_gtk4_font_beta_label = "Sans Italic 10",
336 .gui_gtk4_font_small = "Sans 9",
337 .gui_gtk4_font_comment_label = "Sans Italic 9",
338 .gui_gtk4_font_city_names = "Sans Bold 10",
339 .gui_gtk4_font_city_productions = "Serif 10",
340 .gui_gtk4_font_reqtree_text = "Serif 10",
341
342/* gui-sdl client specific options. */
343 .gui_sdl_fullscreen = FALSE,
344 .gui_sdl_screen = VIDEO_MODE(640, 480),
345 .gui_sdl_do_cursor_animation = TRUE,
346 .gui_sdl_use_color_cursors = TRUE,
347
348/* gui-sdl2 client specific options. */
349 .gui_sdl2_default_theme_name = FC_SDL2_DEFAULT_THEME_NAME,
350 .gui_sdl2_fullscreen = FALSE,
351 .gui_sdl2_screen = VIDEO_MODE(640, 480),
352 .gui_sdl2_swrenderer = FALSE,
353 .gui_sdl2_do_cursor_animation = TRUE,
354 .gui_sdl2_use_color_cursors = TRUE,
355 .gui_sdl2_font_city_names = "10",
356 .gui_sdl2_font_city_productions = "10",
357
358/* gui-qt client specific options. */
359 .gui_qt_fullscreen = FALSE,
360 .gui_qt_show_preview = TRUE,
361 .gui_qt_sidebar_left = TRUE,
362 .gui_qt_default_theme_name = FC_QT_DEFAULT_THEME_NAME,
363 .gui_qt_font_default = "Sans Serif,10,-1,5,75,0,0,0,0,0",
364 .gui_qt_font_notify_label = "Monospace,8,-1,5,75,0,0,0,0,0",
365 .gui_qt_font_help_label = "Sans Serif,9,-1,5,50,0,0,0,0,0",
366 .gui_qt_font_help_text = "Monospace,8,-1,5,50,0,0,0,0,0",
367 .gui_qt_font_chatline = "Monospace,8,-1,5,50,0,0,0,0,0",
368 .gui_qt_font_city_names = "Sans Serif,10,-1,5,75,0,0,0,0,0",
369 .gui_qt_font_city_productions = "Sans Serif,10,-1,5,50,1,0,0,0,0",
370 .gui_qt_font_reqtree_text = "Sans Serif,10,-1,5,50,1,0,0,0,0",
371 .gui_qt_show_titlebar = TRUE,
372 .gui_qt_wakeup_text = "Wake up %1"
373};
374
375/* Set to TRUE after the first call to options_init(), to avoid the usage
376 * of non-initialized datas when calling the changed callback. */
378
379static const struct strvec *get_mapimg_format_list(const struct option *poption);
380
381/****************************************************************************
382 Option set structure.
383****************************************************************************/
385 struct option * (*option_by_number) (int);
386 struct option * (*option_first) (void);
387
388 int (*category_number) (void);
389 const char * (*category_name) (int);
390};
391
392/************************************************************************/
396 int id)
397{
398 fc_assert_ret_val(NULL != poptset, NULL);
399
400 return poptset->option_by_number(id);
401}
402
403/************************************************************************/
407 const char *name)
408{
409 fc_assert_ret_val(NULL != poptset, NULL);
410
411 options_iterate(poptset, poption) {
412 if (0 == strcmp(option_name(poption), name)) {
413 return poption;
414 }
416 return NULL;
417}
418
419/************************************************************************/
423{
424 fc_assert_ret_val(NULL != poptset, NULL);
425
426 return poptset->option_first();
427}
428
429/************************************************************************/
433{
434 fc_assert_ret_val(NULL != poptset, 0);
435
436 return poptset->category_number();
437}
438
439/************************************************************************/
442const char *optset_category_name(const struct option_set *poptset,
443 int category)
444{
445 fc_assert_ret_val(NULL != poptset, NULL);
446
447 return poptset->category_name(category);
448}
449
450
451/****************************************************************************
452 The base class for options.
453****************************************************************************/
454struct option {
455 /* A link to the option set. */
456 const struct option_set *poptset;
457 /* Type of the option. */
459
460 /* Common accessors. */
461 const struct option_common_vtable {
462 int (*number) (const struct option *);
463 const char * (*name) (const struct option *);
464 const char * (*description) (const struct option *);
465 const char * (*help_text) (const struct option *);
466 int (*category) (const struct option *);
467 bool (*is_changeable) (const struct option *);
468 struct option * (*next) (const struct option *);
470 /* Specific typed accessors. */
471 union {
472 /* Specific boolean accessors (OT_BOOLEAN == type). */
473 const struct option_bool_vtable {
474 bool (*get) (const struct option *);
475 bool (*def) (const struct option *);
476 bool (*set) (struct option *, bool);
478 /* Specific integer accessors (OT_INTEGER == type). */
479 const struct option_int_vtable {
480 int (*get) (const struct option *);
481 int (*def) (const struct option *);
482 int (*minimum) (const struct option *);
483 int (*maximum) (const struct option *);
484 bool (*set) (struct option *, int);
486 /* Specific string accessors (OT_STRING == type). */
487 const struct option_str_vtable {
488 const char * (*get) (const struct option *);
489 const char * (*def) (const struct option *);
490 const struct strvec * (*values) (const struct option *);
491 bool (*set) (struct option *, const char *);
493 /* Specific enum accessors (OT_ENUM == type). */
494 const struct option_enum_vtable {
495 int (*get) (const struct option *);
496 int (*def) (const struct option *);
497 const struct strvec * (*values) (const struct option *);
498 bool (*set) (struct option *, int);
499 int (*cmp) (const char *, const char *);
501 /* Specific bitwise accessors (OT_BITWISE == type). */
502 const struct option_bitwise_vtable {
503 unsigned (*get) (const struct option *);
504 unsigned (*def) (const struct option *);
505 const struct strvec * (*values) (const struct option *);
506 bool (*set) (struct option *, unsigned);
508 /* Specific font accessors (OT_FONT == type). */
509 const struct option_font_vtable {
510 const char * (*get) (const struct option *);
511 const char * (*def) (const struct option *);
512 const char * (*target) (const struct option *);
513 bool (*set) (struct option *, const char *);
515 /* Specific color accessors (OT_COLOR == type). */
516 const struct option_color_vtable {
517 struct ft_color (*get) (const struct option *);
518 struct ft_color (*def) (const struct option *);
519 bool (*set) (struct option *, struct ft_color);
521 /* Specific video mode accessors (OT_VIDEO_MODE == type). */
522 const struct option_video_mode_vtable {
523 struct video_mode (*get) (const struct option *);
524 struct video_mode (*def) (const struct option *);
525 bool (*set) (struct option *, struct video_mode);
527 };
528
529 /* Called after the value changed. */
530 void (*changed_callback) (struct option *option);
531
533
534 /* Volatile. */
535 void *gui_data;
536};
537
538#define OPTION(poption) ((struct option *) (poption))
539
540#define OPTION_INIT(optset, spec_type, spec_table_var, common_table, \
541 spec_table, changed_cb, cb_data) { \
542 .poptset = optset, \
543 .type = spec_type, \
544 .common_vtable = &common_table, \
545 INIT_BRACE_BEGIN \
546 .spec_table_var = &spec_table \
547 INIT_BRACE_END, \
548 .changed_callback = changed_cb, \
549 .callback_data = cb_data, \
550 .gui_data = NULL \
551}
552#define OPTION_BOOL_INIT(optset, common_table, bool_table, changed_cb) \
553 OPTION_INIT(optset, OT_BOOLEAN, bool_vtable, common_table, bool_table, \
554 changed_cb, 0)
555#define OPTION_INT_INIT(optset, common_table, int_table, changed_cb) \
556 OPTION_INIT(optset, OT_INTEGER, int_vtable, common_table, int_table, \
557 changed_cb, 0)
558#define OPTION_STR_INIT(optset, common_table, str_table, changed_cb, cb_data) \
559 OPTION_INIT(optset, OT_STRING, str_vtable, common_table, str_table, \
560 changed_cb, cb_data)
561#define OPTION_ENUM_INIT(optset, common_table, enum_table, changed_cb) \
562 OPTION_INIT(optset, OT_ENUM, enum_vtable, common_table, enum_table, \
563 changed_cb, 0)
564#define OPTION_BITWISE_INIT(optset, common_table, bitwise_table, \
565 changed_cb) \
566 OPTION_INIT(optset, OT_BITWISE, bitwise_vtable, common_table, \
567 bitwise_table, changed_cb, 0)
568#define OPTION_FONT_INIT(optset, common_table, font_table, changed_cb) \
569 OPTION_INIT(optset, OT_FONT, font_vtable, common_table, font_table, \
570 changed_cb, 0)
571#define OPTION_COLOR_INIT(optset, common_table, color_table, changed_cb) \
572 OPTION_INIT(optset, OT_COLOR, color_vtable, common_table, color_table, \
573 changed_cb, 0)
574#define OPTION_VIDEO_MODE_INIT(optset, common_table, video_mode_table, \
575 changed_cb) \
576 OPTION_INIT(optset, OT_VIDEO_MODE, video_mode_vtable, common_table, \
577 video_mode_table, changed_cb, 0)
578
579
580/************************************************************************/
583const struct option_set *option_optset(const struct option *poption)
584{
585 fc_assert_ret_val(NULL != poption, NULL);
586
587 return poption->poptset;
588}
589
590/************************************************************************/
593int option_number(const struct option *poption)
594{
595 fc_assert_ret_val(NULL != poption, -1);
596
597 return poption->common_vtable->number(poption);
598}
599
600/************************************************************************/
603const char *option_name(const struct option *poption)
604{
605 fc_assert_ret_val(NULL != poption, NULL);
606
607 return poption->common_vtable->name(poption);
608}
609
610/************************************************************************/
613const char *option_description(const struct option *poption)
614{
615 fc_assert_ret_val(NULL != poption, NULL);
616
617 return poption->common_vtable->description(poption);
618}
619
620/************************************************************************/
623const char *option_help_text(const struct option *poption)
624{
625 fc_assert_ret_val(NULL != poption, NULL);
626
627 return poption->common_vtable->help_text(poption);
628}
629
630/************************************************************************/
633enum option_type option_type(const struct option *poption)
634{
635 fc_assert_ret_val(NULL != poption, -1);
636
637 return poption->type;
638}
639
640/************************************************************************/
643int option_category(const struct option *poption)
644{
645 fc_assert_ret_val(NULL != poption, -1);
646
647 return poption->common_vtable->category(poption);
648}
649
650/************************************************************************/
653const char *option_category_name(const struct option *poption)
654{
655 fc_assert_ret_val(NULL != poption, NULL);
656
657 return optset_category_name(poption->poptset,
658 poption->common_vtable->category(poption));
659}
660
661/************************************************************************/
664bool option_is_changeable(const struct option *poption)
665{
666 fc_assert_ret_val(NULL != poption, FALSE);
667
668 return poption->common_vtable->is_changeable(poption);
669}
670
671/************************************************************************/
674struct option *option_next(const struct option *poption)
675{
676 fc_assert_ret_val(NULL != poption, NULL);
677
678 return poption->common_vtable->next(poption);
679}
680
681/************************************************************************/
684bool option_reset(struct option *poption)
685{
686 fc_assert_ret_val(NULL != poption, FALSE);
687
688 switch (option_type(poption)) {
689 case OT_BOOLEAN:
690 return option_bool_set(poption, option_bool_def(poption));
691 case OT_INTEGER:
692 return option_int_set(poption, option_int_def(poption));
693 case OT_STRING:
694 return option_str_set(poption, option_str_def(poption));
695 case OT_ENUM:
696 return option_enum_set_int(poption, option_enum_def_int(poption));
697 case OT_BITWISE:
698 return option_bitwise_set(poption, option_bitwise_def(poption));
699 case OT_FONT:
700 return option_font_set(poption, option_font_def(poption));
701 case OT_COLOR:
702 return option_color_set(poption, option_color_def(poption));
703 case OT_VIDEO_MODE:
704 return option_video_mode_set(poption, option_video_mode_def(poption));
705 }
706 return FALSE;
707}
708
709/************************************************************************/
713 void (*callback) (struct option *))
714{
715 fc_assert_ret(NULL != poption);
716
717 poption->changed_callback = callback;
718}
719
720/************************************************************************/
723void option_changed(struct option *poption)
724{
725 fc_assert_ret(NULL != poption);
726
728 /* Prevent to use non-initialized datas. */
729 return;
730 }
731
732 if (poption->changed_callback) {
733 poption->changed_callback(poption);
734 }
735
736 option_gui_update(poption);
737}
738
739/************************************************************************/
742void option_set_gui_data(struct option *poption, void *data)
743{
744 fc_assert_ret(NULL != poption);
745
746 poption->gui_data = data;
747}
748
749/************************************************************************/
752void *option_get_gui_data(const struct option *poption)
753{
754 fc_assert_ret_val(NULL != poption, NULL);
755
756 return poption->gui_data;
757}
758
759/************************************************************************/
762int option_get_cb_data(const struct option *poption)
763{
764 fc_assert_ret_val(NULL != poption, 0);
765
766 return poption->callback_data;
767}
768
769/************************************************************************/
772bool option_bool_get(const struct option *poption)
773{
774 fc_assert_ret_val(NULL != poption, FALSE);
775 fc_assert_ret_val(OT_BOOLEAN == poption->type, FALSE);
776
777 return poption->bool_vtable->get(poption);
778}
779
780/************************************************************************/
783bool option_bool_def(const struct option *poption)
784{
785 fc_assert_ret_val(NULL != poption, FALSE);
786 fc_assert_ret_val(OT_BOOLEAN == poption->type, FALSE);
787
788 return poption->bool_vtable->def(poption);
789}
790
791/************************************************************************/
794bool option_bool_set(struct option *poption, bool val)
795{
796 fc_assert_ret_val(NULL != poption, FALSE);
797 fc_assert_ret_val(OT_BOOLEAN == poption->type, FALSE);
798
799 if (poption->bool_vtable->set(poption, val)) {
800 option_changed(poption);
801 return TRUE;
802 }
803 return FALSE;
804}
805
806/************************************************************************/
809int option_int_get(const struct option *poption)
810{
811 fc_assert_ret_val(NULL != poption, 0);
812 fc_assert_ret_val(OT_INTEGER == poption->type, 0);
813
814 return poption->int_vtable->get(poption);
815}
816
817/************************************************************************/
820int option_int_def(const struct option *poption)
821{
822 fc_assert_ret_val(NULL != poption, 0);
823 fc_assert_ret_val(OT_INTEGER == poption->type, 0);
824
825 return poption->int_vtable->def(poption);
826}
827
828/************************************************************************/
831int option_int_min(const struct option *poption)
832{
833 fc_assert_ret_val(NULL != poption, 0);
834 fc_assert_ret_val(OT_INTEGER == poption->type, 0);
835
836 return poption->int_vtable->minimum(poption);
837}
838
839/************************************************************************/
842int option_int_max(const struct option *poption)
843{
844 fc_assert_ret_val(NULL != poption, 0);
845 fc_assert_ret_val(OT_INTEGER == poption->type, 0);
846
847 return poption->int_vtable->maximum(poption);
848}
849
850/************************************************************************/
853bool option_int_set(struct option *poption, int val)
854{
855 fc_assert_ret_val(NULL != poption, FALSE);
856 fc_assert_ret_val(OT_INTEGER == poption->type, FALSE);
857
858 if (poption->int_vtable->set(poption, val)) {
859 option_changed(poption);
860 return TRUE;
861 }
862 return FALSE;
863}
864
865/************************************************************************/
868const char *option_str_get(const struct option *poption)
869{
870 fc_assert_ret_val(NULL != poption, NULL);
871 fc_assert_ret_val(OT_STRING == poption->type, NULL);
872
873 return poption->str_vtable->get(poption);
874}
875
876/************************************************************************/
879const char *option_str_def(const struct option *poption)
880{
881 fc_assert_ret_val(NULL != poption, NULL);
882 fc_assert_ret_val(OT_STRING == poption->type, NULL);
883
884 return poption->str_vtable->def(poption);
885}
886
887/************************************************************************/
890const struct strvec *option_str_values(const struct option *poption)
891{
892 fc_assert_ret_val(NULL != poption, NULL);
893 fc_assert_ret_val(OT_STRING == poption->type, NULL);
894
895 return poption->str_vtable->values(poption);
896}
897
898/************************************************************************/
901bool option_str_set(struct option *poption, const char *str)
902{
903 fc_assert_ret_val(NULL != poption, FALSE);
904 fc_assert_ret_val(OT_STRING == poption->type, FALSE);
905 fc_assert_ret_val(NULL != str, FALSE);
906
907 if (poption->str_vtable->set(poption, str)) {
908 option_changed(poption);
909 return TRUE;
910 }
911 return FALSE;
912}
913
914/************************************************************************/
918int option_enum_str_to_int(const struct option *poption, const char *str)
919{
920 const struct strvec *values;
921 int val;
922
923 fc_assert_ret_val(NULL != poption, -1);
924 fc_assert_ret_val(OT_ENUM == poption->type, -1);
925 values = poption->enum_vtable->values(poption);
926 fc_assert_ret_val(NULL != values, -1);
927
928 for (val = 0; val < strvec_size(values); val++) {
929 if (0 == poption->enum_vtable->cmp(strvec_get(values, val), str)) {
930 return val;
931 }
932 }
933 return -1;
934}
935
936/************************************************************************/
940const char *option_enum_int_to_str(const struct option *poption, int val)
941{
942 const struct strvec *values;
943
944 fc_assert_ret_val(NULL != poption, NULL);
945 fc_assert_ret_val(OT_ENUM == poption->type, NULL);
946 values = poption->enum_vtable->values(poption);
947 fc_assert_ret_val(NULL != values, NULL);
948
949 return strvec_get(values, val);
950}
951
952/************************************************************************/
955int option_enum_get_int(const struct option *poption)
956{
957 fc_assert_ret_val(NULL != poption, -1);
958 fc_assert_ret_val(OT_ENUM == poption->type, -1);
959
960 return poption->enum_vtable->get(poption);
961}
962
963/************************************************************************/
967const char *option_enum_get_str(const struct option *poption)
968{
969 fc_assert_ret_val(NULL != poption, NULL);
970 fc_assert_ret_val(OT_ENUM == poption->type, NULL);
971
972 return strvec_get(poption->enum_vtable->values(poption),
973 poption->enum_vtable->get(poption));
974}
975
976/************************************************************************/
979int option_enum_def_int(const struct option *poption)
980{
981 fc_assert_ret_val(NULL != poption, -1);
982 fc_assert_ret_val(OT_ENUM == poption->type, -1);
983
984 return poption->enum_vtable->def(poption);
985}
986
987/************************************************************************/
991const char *option_enum_def_str(const struct option *poption)
992{
993 fc_assert_ret_val(NULL != poption, NULL);
994 fc_assert_ret_val(OT_ENUM == poption->type, NULL);
995
996 return strvec_get(poption->enum_vtable->values(poption),
997 poption->enum_vtable->def(poption));
998}
999
1000/************************************************************************/
1004const struct strvec *option_enum_values(const struct option *poption)
1005{
1006 fc_assert_ret_val(NULL != poption, NULL);
1007 fc_assert_ret_val(OT_ENUM == poption->type, NULL);
1008
1009 return poption->enum_vtable->values(poption);
1010}
1011
1012/************************************************************************/
1015bool option_enum_set_int(struct option *poption, int val)
1016{
1017 fc_assert_ret_val(NULL != poption, FALSE);
1018 fc_assert_ret_val(OT_ENUM == poption->type, FALSE);
1019
1020 if (poption->enum_vtable->set(poption, val)) {
1021 option_changed(poption);
1022 return TRUE;
1023 }
1024 return FALSE;
1025}
1026
1027/************************************************************************/
1032bool option_enum_set_str(struct option *poption, const char *str)
1033{
1034 fc_assert_ret_val(NULL != poption, FALSE);
1035 fc_assert_ret_val(OT_ENUM == poption->type, FALSE);
1036 fc_assert_ret_val(NULL != str, FALSE);
1037
1038 if (poption->enum_vtable->set(poption,
1039 option_enum_str_to_int(poption, str))) {
1040 option_changed(poption);
1041 return TRUE;
1042 }
1043 return FALSE;
1044}
1045
1046/************************************************************************/
1049unsigned option_bitwise_get(const struct option *poption)
1050{
1051 fc_assert_ret_val(NULL != poption, 0);
1052 fc_assert_ret_val(OT_BITWISE == poption->type, 0);
1053
1054 return poption->bitwise_vtable->get(poption);
1055}
1056
1057/************************************************************************/
1060unsigned option_bitwise_def(const struct option *poption)
1061{
1062 fc_assert_ret_val(NULL != poption, 0);
1063 fc_assert_ret_val(OT_BITWISE == poption->type, 0);
1064
1065 return poption->bitwise_vtable->def(poption);
1066}
1067
1068/************************************************************************/
1071unsigned option_bitwise_mask(const struct option *poption)
1072{
1073 const struct strvec *values;
1074
1075 fc_assert_ret_val(NULL != poption, 0);
1076 fc_assert_ret_val(OT_BITWISE == poption->type, 0);
1077
1078 values = poption->bitwise_vtable->values(poption);
1079 fc_assert_ret_val(NULL != values, 0);
1080
1081 return (1 << strvec_size(values)) - 1;
1082}
1083
1084/************************************************************************/
1088const struct strvec *option_bitwise_values(const struct option *poption)
1089{
1090 fc_assert_ret_val(NULL != poption, NULL);
1091 fc_assert_ret_val(OT_BITWISE == poption->type, NULL);
1092
1093 return poption->bitwise_vtable->values(poption);
1094}
1095
1096/************************************************************************/
1099bool option_bitwise_set(struct option *poption, unsigned val)
1100{
1101 fc_assert_ret_val(NULL != poption, FALSE);
1102 fc_assert_ret_val(OT_BITWISE == poption->type, FALSE);
1103
1104 if (0 != (val & ~option_bitwise_mask(poption))
1105 || !poption->bitwise_vtable->set(poption, val)) {
1106 return FALSE;
1107 }
1108
1109 option_changed(poption);
1110 return TRUE;
1111}
1112
1113/************************************************************************/
1116const char *option_font_get(const struct option *poption)
1117{
1118 fc_assert_ret_val(NULL != poption, NULL);
1119 fc_assert_ret_val(OT_FONT == poption->type, NULL);
1120
1121 return poption->font_vtable->get(poption);
1122}
1123
1124/************************************************************************/
1127const char *option_font_def(const struct option *poption)
1128{
1129 fc_assert_ret_val(NULL != poption, NULL);
1130 fc_assert_ret_val(OT_FONT == poption->type, NULL);
1131
1132 return poption->font_vtable->def(poption);
1133}
1134
1135/************************************************************************/
1138const char *option_font_target(const struct option *poption)
1139{
1140 fc_assert_ret_val(NULL != poption, NULL);
1141 fc_assert_ret_val(OT_FONT == poption->type, NULL);
1142
1143 return poption->font_vtable->target(poption);
1144}
1145
1146/************************************************************************/
1149bool option_font_set(struct option *poption, const char *font)
1150{
1151 fc_assert_ret_val(NULL != poption, FALSE);
1152 fc_assert_ret_val(OT_FONT == poption->type, FALSE);
1153 fc_assert_ret_val(NULL != font, FALSE);
1154
1155 if (poption->font_vtable->set(poption, font)) {
1156 option_changed(poption);
1157 return TRUE;
1158 }
1159 return FALSE;
1160}
1161
1162/************************************************************************/
1165struct ft_color option_color_get(const struct option *poption)
1166{
1167 fc_assert_ret_val(NULL != poption, ft_color_construct(NULL, NULL));
1168 fc_assert_ret_val(OT_COLOR == poption->type, ft_color_construct(NULL, NULL));
1169
1170 return poption->color_vtable->get(poption);
1171}
1172
1173/************************************************************************/
1176struct ft_color option_color_def(const struct option *poption)
1177{
1178 fc_assert_ret_val(NULL != poption, ft_color_construct(NULL, NULL));
1179 fc_assert_ret_val(OT_COLOR == poption->type, ft_color_construct(NULL, NULL));
1180
1181 return poption->color_vtable->def(poption);
1182}
1183
1184/************************************************************************/
1188bool option_color_set(struct option *poption, struct ft_color color)
1189{
1190 fc_assert_ret_val(NULL != poption, FALSE);
1191 fc_assert_ret_val(OT_COLOR == poption->type, FALSE);
1192
1193 if (poption->color_vtable->set(poption, color)) {
1194 option_changed(poption);
1195 return TRUE;
1196 }
1197 return FALSE;
1198}
1199
1200/************************************************************************/
1203struct video_mode option_video_mode_get(const struct option *poption)
1204{
1205 fc_assert_ret_val(NULL != poption, video_mode_construct(-1, -1));
1206 fc_assert_ret_val(OT_VIDEO_MODE == poption->type,
1207 video_mode_construct(-1, -1));
1208
1209 return poption->video_mode_vtable->get(poption);
1210}
1211
1212/************************************************************************/
1215struct video_mode option_video_mode_def(const struct option *poption)
1216{
1217 fc_assert_ret_val(NULL != poption, video_mode_construct(-1, -1));
1218 fc_assert_ret_val(OT_VIDEO_MODE == poption->type,
1219 video_mode_construct(-1, -1));
1220
1221 return poption->video_mode_vtable->def(poption);
1222}
1223
1224/************************************************************************/
1228bool option_video_mode_set(struct option *poption, struct video_mode mode)
1229{
1230 fc_assert_ret_val(NULL != poption, FALSE);
1231 fc_assert_ret_val(OT_VIDEO_MODE == poption->type, FALSE);
1232
1233 if (poption->video_mode_vtable->set(poption, mode)) {
1234 option_changed(poption);
1235 return TRUE;
1236 }
1237 return FALSE;
1238}
1239
1240
1241/****************************************************************************
1242 Client option set.
1243****************************************************************************/
1244static struct option *client_optset_option_by_number(int id);
1245static struct option *client_optset_option_first(void);
1246static int client_optset_category_number(void);
1247static const char *client_optset_category_name(int category);
1248
1251 .option_first = client_optset_option_first,
1252 .category_number = client_optset_category_number,
1253 .category_name = client_optset_category_name
1254};
1256
1258 const char *support; /* Untranslated long support name, used
1259 * for saving. */
1260 const char *pretty; /* Translated, used to display to the
1261 * users. */
1262};
1263
1264/****************************************************************************
1265 Virtuals tables for the client options.
1266****************************************************************************/
1267static int client_option_number(const struct option *poption);
1268static const char *client_option_name(const struct option *poption);
1269static const char *client_option_description(const struct option *poption);
1270static const char *client_option_help_text(const struct option *poption);
1271static int client_option_category(const struct option *poption);
1272static bool client_option_is_changeable(const struct option *poption);
1273static struct option *client_option_next(const struct option *poption);
1274
1275static const struct option_common_vtable client_option_common_vtable = {
1276 .number = client_option_number,
1277 .name = client_option_name,
1278 .description = client_option_description,
1279 .help_text = client_option_help_text,
1280 .category = client_option_category,
1281 .is_changeable = client_option_is_changeable,
1282 .next = client_option_next
1283};
1284
1285static bool client_option_bool_get(const struct option *poption);
1286static bool client_option_bool_def(const struct option *poption);
1287static bool client_option_bool_set(struct option *poption, bool val);
1288
1289static const struct option_bool_vtable client_option_bool_vtable = {
1293};
1294
1295static int client_option_int_get(const struct option *poption);
1296static int client_option_int_def(const struct option *poption);
1297static int client_option_int_min(const struct option *poption);
1298static int client_option_int_max(const struct option *poption);
1299static bool client_option_int_set(struct option *poption, int val);
1300
1301static const struct option_int_vtable client_option_int_vtable = {
1302 .get = client_option_int_get,
1303 .def = client_option_int_def,
1304 .minimum = client_option_int_min,
1305 .maximum = client_option_int_max,
1307};
1308
1309static const char *client_option_str_get(const struct option *poption);
1310static const char *client_option_str_def(const struct option *poption);
1311static const struct strvec *
1312 client_option_str_values(const struct option *poption);
1313static bool client_option_str_set(struct option *poption, const char *str);
1314
1315static const struct option_str_vtable client_option_str_vtable = {
1316 .get = client_option_str_get,
1317 .def = client_option_str_def,
1318 .values = client_option_str_values,
1320};
1321
1322static int client_option_enum_get(const struct option *poption);
1323static int client_option_enum_def(const struct option *poption);
1324static const struct strvec *
1325 client_option_enum_pretty_names(const struct option *poption);
1326static bool client_option_enum_set(struct option *poption, int val);
1327
1328static const struct option_enum_vtable client_option_enum_vtable = {
1333 .cmp = fc_strcasecmp
1334};
1335
1336#if 0 /* There's no bitwise options currently */
1337static unsigned client_option_bitwise_get(const struct option *poption);
1338static unsigned client_option_bitwise_def(const struct option *poption);
1339static const struct strvec *
1340 client_option_bitwise_pretty_names(const struct option *poption);
1341static bool client_option_bitwise_set(struct option *poption, unsigned val);
1342
1343static const struct option_bitwise_vtable client_option_bitwise_vtable = {
1344 .get = client_option_bitwise_get,
1345 .def = client_option_bitwise_def,
1346 .values = client_option_bitwise_pretty_names,
1347 .set = client_option_bitwise_set
1348};
1349#endif /* 0 */
1350
1351static const char *client_option_font_get(const struct option *poption);
1352static const char *client_option_font_def(const struct option *poption);
1353static const char *client_option_font_target(const struct option *poption);
1354static bool client_option_font_set(struct option *poption, const char *font);
1355
1356static const struct option_font_vtable client_option_font_vtable = {
1359 .target = client_option_font_target,
1361};
1362
1363static struct ft_color client_option_color_get(const struct option *poption);
1364static struct ft_color client_option_color_def(const struct option *poption);
1365static bool client_option_color_set(struct option *poption,
1366 struct ft_color color);
1367
1368static const struct option_color_vtable client_option_color_vtable = {
1372};
1373
1374static struct video_mode
1375client_option_video_mode_get(const struct option *poption);
1376static struct video_mode
1377client_option_video_mode_def(const struct option *poption);
1378static bool client_option_video_mode_set(struct option *poption,
1379 struct video_mode mode);
1380
1381static const struct option_video_mode_vtable client_option_video_mode_vtable = {
1385};
1386
1397
1398/****************************************************************************
1399 Derived class client option, inherinting of base class option.
1400****************************************************************************/
1402 struct option base_option; /* Base structure, must be the first! */
1403
1404 const char *name; /* Short name - used as an identifier */
1405 const char *description; /* One-line description */
1406 const char *help_text; /* Paragraph-length help text */
1408 enum gui_type specific; /* GUI_STUB for common options. */
1409
1410 union {
1411 /* OT_BOOLEAN type option. */
1412 struct {
1413 bool *const pvalue;
1414 const bool def;
1415 } boolean;
1416 /* OT_INTEGER type option. */
1417 struct {
1418 int *const pvalue;
1419 const int def, min, max;
1420 } integer;
1421 /* OT_STRING type option. */
1422 struct {
1423 char *const pvalue;
1424 const size_t size;
1425 const char *const def;
1426 /*
1427 * A function to return a string vector of possible string values,
1428 * or NULL for none.
1429 */
1430 const struct strvec *(*const val_accessor) (const struct option *);
1431 } string;
1432 /* OT_ENUM type option. */
1433 struct {
1434 int *const pvalue;
1435 const int def;
1436 struct strvec *support_names, *pretty_names; /* untranslated */
1437 const struct copt_val_name * (*const name_accessor) (int value);
1438 } enumerator;
1439 /* OT_BITWISE type option. */
1440 struct {
1441 unsigned *const pvalue;
1442 const unsigned def;
1443 struct strvec *support_names, *pretty_names; /* untranslated */
1444 const struct copt_val_name * (*const name_accessor) (int value);
1445 } bitwise;
1446 /* OT_FONT type option. */
1447 struct {
1448 char *const pvalue;
1449 const size_t size;
1450 const char *const def;
1451 const char *const target;
1452 } font;
1453 /* OT_COLOR type option. */
1454 struct {
1455 struct ft_color *const pvalue;
1456 const struct ft_color def;
1458 /* OT_VIDEO_MODE type option. */
1459 struct {
1460 struct video_mode *const pvalue;
1461 const struct video_mode def;
1463 };
1464};
1465
1466#define CLIENT_OPTION(poption) ((struct client_option *) (poption))
1467
1468/*
1469 * Generate a client option of type OT_BOOLEAN.
1470 *
1471 * oname: The option data. Note it is used as name to be loaded or saved.
1472 * So, you shouldn't change the name of this variable in any case.
1473 * odesc: A short description of the client option. Should be used with the
1474 * N_() macro.
1475 * ohelp: The help text for the client option. Should be used with the N_()
1476 * macro.
1477 * ocat: The client_option_class of this client option.
1478 * ospec: A gui_type enumerator which determine for what particular client
1479 * gui this option is for. Sets to GUI_STUB for common options.
1480 * odef: The default value of this client option (FALSE or TRUE).
1481 * ocb: A callback function of type void (*)(struct option *) called when
1482 * the option changed.
1483 */
1484#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb) \
1485{ \
1486 .base_option = OPTION_BOOL_INIT(&client_optset_static, \
1487 client_option_common_vtable, \
1488 client_option_bool_vtable, ocb), \
1489 .name = #oname, \
1490 .description = odesc, \
1491 .help_text = ohelp, \
1492 .category = ocat, \
1493 .specific = ospec, \
1494 INIT_BRACE_BEGIN \
1495 .boolean = { \
1496 .pvalue = &gui_options.oname, \
1497 .def = odef, \
1498 } \
1499 INIT_BRACE_END \
1500}
1501
1502/*
1503 * Generate a client option of type OT_INTEGER.
1504 *
1505 * oname: The option data. Note it is used as name to be loaded or saved.
1506 * So, you shouldn't change the name of this variable in any case.
1507 * odesc: A short description of the client option. Should be used with the
1508 * N_() macro.
1509 * ohelp: The help text for the client option. Should be used with the N_()
1510 * macro.
1511 * ocat: The client_option_class of this client option.
1512 * ospec: A gui_type enumerator which determine for what particular client
1513 * gui this option is for. Sets to GUI_STUB for common options.
1514 * odef: The default value of this client option.
1515 * omin: The minimal value of this client option.
1516 * omax: The maximal value of this client option.
1517 * ocb: A callback function of type void (*)(struct option *) called when
1518 * the option changed.
1519 */
1520#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb) \
1521{ \
1522 .base_option = OPTION_INT_INIT(&client_optset_static, \
1523 client_option_common_vtable, \
1524 client_option_int_vtable, ocb), \
1525 .name = #oname, \
1526 .description = odesc, \
1527 .help_text = ohelp, \
1528 .category = ocat, \
1529 .specific = ospec, \
1530 INIT_BRACE_BEGIN \
1531 .integer = { \
1532 .pvalue = &gui_options.oname, \
1533 .def = odef, \
1534 .min = omin, \
1535 .max = omax \
1536 } \
1537 INIT_BRACE_END \
1538}
1539
1540/*
1541 * Generate a client option of type OT_STRING.
1542 *
1543 * oname: The option data. Note it is used as name to be loaded or saved.
1544 * So, you shouldn't change the name of this variable in any case.
1545 * Be sure to pass the array variable and not a pointer to it because
1546 * the size is calculated with sizeof().
1547 * odesc: A short description of the client option. Should be used with the
1548 * N_() macro.
1549 * ohelp: The help text for the client option. Should be used with the N_()
1550 * macro.
1551 * ocat: The client_option_class of this client option.
1552 * ospec: A gui_type enumerator which determines for what particular client
1553 * gui this option is for. Set to GUI_STUB for common options.
1554 * odef: The default string for this client option.
1555 * ocb: A callback function of type void (*)(struct option *) called when
1556 * the option changed.
1557 */
1558#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd) \
1559{ \
1560 .base_option = OPTION_STR_INIT(&client_optset_static, \
1561 client_option_common_vtable, \
1562 client_option_str_vtable, ocb, cbd), \
1563 .name = #oname, \
1564 .description = odesc, \
1565 .help_text = ohelp, \
1566 .category = ocat, \
1567 .specific = ospec, \
1568 INIT_BRACE_BEGIN \
1569 .string = { \
1570 .pvalue = gui_options.oname, \
1571 .size = sizeof(gui_options.oname), \
1572 .def = odef, \
1573 .val_accessor = NULL \
1574 } \
1575 INIT_BRACE_END \
1576}
1577
1578/*
1579 * Generate a client option of type OT_STRING with a string accessor
1580 * function.
1581 *
1582 * oname: The option data. Note it is used as name to be loaded or saved.
1583 * So, you shouldn't change the name of this variable in any case.
1584 * Be sure to pass the array variable and not a pointer to it because
1585 * the size is calculated with sizeof().
1586 * odesc: A short description of the client option. Should be used with the
1587 * N_() macro.
1588 * ohelp: The help text for the client option. Should be used with the N_()
1589 * macro.
1590 * ocat: The client_option_class of this client option.
1591 * ospec: A gui_type enumerator which determine for what particular client
1592 * gui this option is for. Sets to GUI_STUB for common options.
1593 * odef: The default string for this client option.
1594 * oacc: The string accessor where to find the allowed values of type
1595 * 'const struct strvec * (*) (void)'.
1596 * ocb: A callback function of type void (*)(struct option *) called when
1597 * the option changed.
1598 */
1599#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd) \
1600{ \
1601 .base_option = OPTION_STR_INIT(&client_optset_static, \
1602 client_option_common_vtable, \
1603 client_option_str_vtable, ocb, cbd), \
1604 .name = #oname, \
1605 .description = odesc, \
1606 .help_text = ohelp, \
1607 .category = ocat, \
1608 .specific = ospec, \
1609 INIT_BRACE_BEGIN \
1610 .string = { \
1611 .pvalue = gui_options.oname, \
1612 .size = sizeof(gui_options.oname), \
1613 .def = odef, \
1614 .val_accessor = oacc \
1615 } \
1616 INIT_BRACE_END \
1617}
1618
1619/*
1620 * Generate a client option of type OT_ENUM.
1621 *
1622 * oname: The option data. Note it is used as name to be loaded or saved.
1623 * So, you shouldn't change the name of this variable in any case.
1624 * odesc: A short description of the client option. Should be used with the
1625 * N_() macro.
1626 * ohelp: The help text for the client option. Should be used with the N_()
1627 * macro.
1628 * ocat: The client_option_class of this client option.
1629 * ospec: A gui_type enumerator which determine for what particular client
1630 * gui this option is for. Sets to GUI_STUB for common options.
1631 * odef: The default value for this client option.
1632 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1633 * ocb: A callback function of type void (*) (struct option *) called when
1634 * the option changed.
1635 */
1636#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb) \
1637{ \
1638 .base_option = OPTION_ENUM_INIT(&client_optset_static, \
1639 client_option_common_vtable, \
1640 client_option_enum_vtable, ocb), \
1641 .name = #oname, \
1642 .description = odesc, \
1643 .help_text = ohelp, \
1644 .category = ocat, \
1645 .specific = ospec, \
1646 INIT_BRACE_BEGIN \
1647 .enumerator = { \
1648 .pvalue = (int *) &gui_options.oname, \
1649 .def = odef, \
1650 .support_names = NULL, /* Set in options_init(). */ \
1651 .pretty_names = NULL, \
1652 .name_accessor = oacc \
1653 } \
1654 INIT_BRACE_END \
1655}
1656
1657/*
1658 * Generate a client option of type OT_BITWISE.
1659 *
1660 * oname: The option data. Note it is used as name to be loaded or saved.
1661 * So, you shouldn't change the name of this variable in any case.
1662 * odesc: A short description of the client option. Should be used with the
1663 * N_() macro.
1664 * ohelp: The help text for the client option. Should be used with the N_()
1665 * macro.
1666 * ocat: The client_option_class of this client option.
1667 * ospec: A gui_type enumerator which determine for what particular client
1668 * gui this option is for. Sets to GUI_STUB for common options.
1669 * odef: The default value for this client option.
1670 * oacc: The name accessor of type 'const struct copt_val_name * (*) (int)'.
1671 * ocb: A callback function of type void (*) (struct option *) called when
1672 * the option changed.
1673 */
1674#define GEN_BITWISE_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, \
1675 ocb) \
1676{ \
1677 .base_option = OPTION_BITWISE_INIT(&client_optset_static, \
1678 client_option_common_vtable, \
1679 client_option_bitwise_vtable, ocb), \
1680 .name = #oname, \
1681 .description = odesc, \
1682 .help_text = ohelp, \
1683 .category = ocat, \
1684 .specific = ospec, \
1685 INIT_BRACE_BEGIN \
1686 .bitwise = { \
1687 .pvalue = &gui_options.oname, \
1688 .def = odef, \
1689 .support_names = NULL, /* Set in options_init(). */ \
1690 .pretty_names = NULL, \
1691 .name_accessor = oacc \
1692 } \
1693 INIT_BRACE_END \
1694}
1695
1696/*
1697 * Generate a client option of type OT_FONT.
1698 *
1699 * oname: The option data. Note it is used as name to be loaded or saved.
1700 * So, you shouldn't change the name of this variable in any case.
1701 * Be sure to pass the array variable and not a pointer to it because
1702 * the size is calculated with sizeof().
1703 * otgt: The target widget style.
1704 * odesc: A short description of the client option. Should be used with the
1705 * N_() macro.
1706 * ohelp: The help text for the client option. Should be used with the N_()
1707 * macro.
1708 * ocat: The client_option_class of this client option.
1709 * ospec: A gui_type enumerator which determine for what particular client
1710 * gui this option is for. Sets to GUI_STUB for common options.
1711 * odef: The default string for this client option.
1712 * ocb: A callback function of type void (*)(struct option *) called when
1713 * the option changed.
1714 */
1715#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb) \
1716{ \
1717 .base_option = OPTION_FONT_INIT(&client_optset_static, \
1718 client_option_common_vtable, \
1719 client_option_font_vtable, ocb), \
1720 .name = #oname, \
1721 .description = odesc, \
1722 .help_text = ohelp, \
1723 .category = ocat, \
1724 .specific = ospec, \
1725 INIT_BRACE_BEGIN \
1726 .font = { \
1727 .pvalue = gui_options.oname, \
1728 .size = sizeof(gui_options.oname), \
1729 .def = odef, \
1730 .target = otgt, \
1731 } \
1732 INIT_BRACE_END \
1733}
1734
1735/*
1736 * Generate a client option of type OT_COLOR.
1737 *
1738 * oname: The option data. Note it is used as name to be loaded or saved.
1739 * So, you shouldn't change the name of this variable in any case.
1740 * odesc: A short description of the client option. Should be used with the
1741 * N_() macro.
1742 * ohelp: The help text for the client option. Should be used with the N_()
1743 * macro.
1744 * ocat: The client_option_class of this client option.
1745 * ospec: A gui_type enumerator which determine for what particular client
1746 * gui this option is for. Sets to GUI_STUB for common options.
1747 * odef_fg, odef_bg: The default values for this client option.
1748 * ocb: A callback function of type void (*)(struct option *) called when
1749 * the option changed.
1750 */
1751#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, \
1752 odef_bg, ocb) \
1753{ \
1754 .base_option = OPTION_COLOR_INIT(&client_optset_static, \
1755 client_option_common_vtable, \
1756 client_option_color_vtable, ocb), \
1757 .name = #oname, \
1758 .description = odesc, \
1759 .help_text = ohelp, \
1760 .category = ocat, \
1761 .specific = ospec, \
1762 INIT_BRACE_BEGIN \
1763 .color = { \
1764 .pvalue = &gui_options.oname, \
1765 .def = FT_COLOR(odef_fg, odef_bg) \
1766 } \
1767 INIT_BRACE_END \
1768}
1769
1770/*
1771 * Generate a client option of type OT_VIDEO_MODE.
1772 *
1773 * oname: The option data. Note it is used as name to be loaded or saved.
1774 * So, you shouldn't change the name of this variable in any case.
1775 * odesc: A short description of the client option. Should be used with the
1776 * N_() macro.
1777 * ohelp: The help text for the client option. Should be used with the N_()
1778 * macro.
1779 * ocat: The client_option_class of this client option.
1780 * ospec: A gui_type enumerator which determine for what particular client
1781 * gui this option is for. Sets to GUI_STUB for common options.
1782 * odef_width, odef_height: The default values for this client option.
1783 * ocb: A callback function of type void (*)(struct option *) called when
1784 * the option changed.
1785 */
1786#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, \
1787 odef_height, ocb) \
1788{ \
1789 .base_option = OPTION_VIDEO_MODE_INIT(&client_optset_static, \
1790 client_option_common_vtable, \
1791 client_option_video_mode_vtable, \
1792 ocb), \
1793 .name = #oname, \
1794 .description = odesc, \
1795 .help_text = ohelp, \
1796 .category = ocat, \
1797 .specific = ospec, \
1798 INIT_BRACE_BEGIN \
1799 .video_mode = { \
1800 .pvalue = &gui_options.oname, \
1801 .def = VIDEO_MODE(odef_width, odef_height) \
1802 } \
1803 INIT_BRACE_END \
1804}
1805
1806/****************************************************************************
1807 Enumerator name accessors.
1808****************************************************************************/
1809
1810/************************************************************************/
1813static const struct copt_val_name
1815{
1816 /* Order must match enum GUI_GTK_MSGCHAT_* */
1817 static const struct copt_val_name names[] = {
1818 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1819 { "SPLIT", N_("Split") },
1820 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1821 { "SEPARATE", N_("Separate") },
1822 /* TRANS: enum value for 'gui_gtk2/gtk3/gtk4_message_chat_location' */
1823 { "MERGED", N_("Merged") }
1824 };
1825
1826 return (0 <= value && value < ARRAY_SIZE(names)
1827 ? names + value : NULL);
1828}
1829
1830/************************************************************************/
1833static const struct copt_val_name
1835{
1836 /* Order must match enum GUI_POPUP_TECH_HELP_* */
1837 static const struct copt_val_name names[] = {
1838 /* TRANS: enum value for 'gui_popup_tech_help' */
1839 { "ENABLED", N_("Enabled") },
1840 /* TRANS: enum value for 'gui_popup_tech_help' */
1841 { "DISABLED", N_("Disabled") },
1842 /* TRANS: enum value for 'gui_popup_tech_help' */
1843 { "RULESET", N_("Ruleset") }
1844 };
1845
1846 return (0 <= value && value < ARRAY_SIZE(names)
1847 ? names + value : NULL);
1848}
1849
1850/* Some changed callbacks. */
1851static void reqtree_show_icons_callback(struct option *poption);
1852static void view_option_changed_callback(struct option *poption);
1853static void manual_turn_done_callback(struct option *poption);
1854static void voteinfo_bar_callback(struct option *poption);
1855static void font_changed_callback(struct option *poption);
1856static void mapimg_changed_callback(struct option *poption);
1857static void game_music_enable_callback(struct option *poption);
1858static void menu_music_enable_callback(struct option *poption);
1859static void sound_volume_callback(struct option *poption);
1860
1862 GEN_STR_OPTION(default_user_name,
1863 N_("Login name"),
1864 N_("This is the default login username that will be used "
1865 "in the connection dialogs or with the -a command-line "
1866 "parameter."),
1867 COC_NETWORK, GUI_STUB, NULL, NULL, 0),
1868 GEN_BOOL_OPTION(use_prev_server, N_("Default to previously used server"),
1869 N_("Automatically update \"Server\" and \"Server port\" "
1870 "options to match your latest connection, so by "
1871 "default you connect to the same server you used "
1872 "on the previous run. You should enable "
1873 "saving options on exit too, so that the automatic "
1874 "updates to the options get saved too."),
1875 COC_NETWORK, GUI_STUB, FALSE, NULL),
1876 GEN_STR_OPTION(default_server_host,
1877 N_("Server"),
1878 N_("This is the default server hostname that will be used "
1879 "in the connection dialogs or with the -a command-line "
1880 "parameter."),
1881 COC_NETWORK, GUI_STUB, "localhost", NULL, 0),
1882 GEN_INT_OPTION(default_server_port,
1883 N_("Server port"),
1884 N_("This is the default server port that will be used "
1885 "in the connection dialogs or with the -a command-line "
1886 "parameter."),
1887 COC_NETWORK, GUI_STUB, DEFAULT_SOCK_PORT, 0, 65535, NULL),
1888 GEN_STR_OPTION(default_metaserver,
1889 N_("Metaserver"),
1890 N_("The metaserver is a host that the client contacts to "
1891 "find out about games on the internet. Don't change "
1892 "this from its default value unless you know what "
1893 "you're doing."),
1894 COC_NETWORK, GUI_STUB, DEFAULT_METASERVER_OPTION, NULL, 0),
1895 GEN_BOOL_OPTION(heartbeat_enabled, N_("Send heartbeat messages to server"),
1896 N_("Periodically send an empty heartbeat message to the "
1897 "server to probe whether the connection is still up. "
1898 "This can help to make it obvious when the server has "
1899 "cut the connection due to a connectivity outage, if "
1900 "the client would otherwise sit idle for a long period."),
1901 COC_NETWORK, GUI_STUB, TRUE, NULL),
1902 GEN_STR_LIST_OPTION(default_sound_set_name,
1903 N_("Soundset"),
1904 N_("This is the soundset that will be used. Changing "
1905 "this is the same as using the -S command-line "
1906 "parameter. Use modpack installer utility to install "
1907 "additional soundsets."),
1908 COC_SOUND, GUI_STUB, "stdsounds", get_soundset_list, NULL, 0),
1909 GEN_STR_LIST_OPTION(default_music_set_name,
1910 N_("Musicset"),
1911 N_("This is the musicset that will be used. Changing "
1912 "this is the same as using the -m command-line "
1913 "parameter. Use modpack installer utility to install "
1914 "additional musicsets."),
1915 COC_SOUND, GUI_STUB, "stdmusic", get_musicset_list, musicspec_reread_callback, 0),
1916 GEN_STR_LIST_OPTION(default_sound_plugin_name,
1917 N_("Sound plugin"),
1918 N_("If you have a problem with sound, try changing "
1919 "the sound plugin. The new plugin won't take "
1920 "effect until you restart Freeciv. Changing this "
1921 "is the same as using the -P command-line option."),
1922 COC_SOUND, GUI_STUB, NULL, get_soundplugin_list, NULL, 0),
1923 GEN_STR_OPTION(default_chat_logfile,
1924 N_("The chat log file"),
1925 N_("The name of the chat log file."),
1926 COC_INTERFACE, GUI_STUB, GUI_DEFAULT_CHAT_LOGFILE, NULL, 0),
1927 /* gui_gtk3/4_default_theme_name and gui_sdl2_default_theme_name are
1928 * different settings to avoid client crash after loading the
1929 * style for the other gui. Keeps 5 different options! */
1930 GEN_STR_LIST_OPTION(gui_gtk3_default_theme_name, N_("Theme"),
1931 N_("By changing this option you change the "
1932 "active theme."),
1935 GEN_STR_LIST_OPTION(gui_gtk3_22_default_theme_name, N_("Theme"),
1936 N_("By changing this option you change the "
1937 "active theme."),
1940 GEN_STR_LIST_OPTION(gui_gtk4_default_theme_name, N_("Theme"),
1941 N_("By changing this option you change the "
1942 "active theme."),
1945 GEN_STR_LIST_OPTION(gui_sdl2_default_theme_name, N_("Theme"),
1946 N_("By changing this option you change the "
1947 "active theme."),
1950 GEN_STR_LIST_OPTION(gui_qt_default_theme_name, N_("Theme"),
1951 N_("By changing this option you change the "
1952 "active theme."),
1955
1956 /* It's important to give empty string instead of NULL as as default
1957 * value. For NULL value it would default to assigning first value
1958 * from the tileset list returned by get_tileset_list() as default
1959 * tileset. We don't want default tileset assigned at all here, but
1960 * leave it to tilespec code that can handle tileset priority. */
1961 GEN_STR_LIST_OPTION(default_tileset_square_name, N_("Tileset (Square)"),
1962 N_("Select the tileset used with Square based maps. "
1963 "This may change the currently active tileset, if "
1964 "you are playing on such a map, in which "
1965 "case this is the same as using the -t "
1966 "command-line parameter. "
1967 "Use modpack installer utility to install "
1968 "additional tilesets."),
1969 COC_GRAPHICS, GUI_STUB, "",
1971 GEN_STR_LIST_OPTION(default_tileset_hex_name, N_("Tileset (Hex)"),
1972 N_("Select the tileset used with Hex maps. "
1973 "This may change the currently active tileset, if "
1974 "you are playing on such a map, in which "
1975 "case this is the same as using the -t "
1976 "command-line parameter. "
1977 "Use modpack installer utility to install "
1978 "additional tilesets."),
1979 COC_GRAPHICS, GUI_STUB, "",
1981 GEN_STR_LIST_OPTION(default_tileset_isohex_name, N_("Tileset (Iso-Hex)"),
1982 N_("Select the tileset used with Iso-Hex maps. "
1983 "This may change the currently active tileset, if "
1984 "you are playing on such a map, in which "
1985 "case this is the same as using the -t "
1986 "command-line parameter."
1987 "Use modpack installer utility to install "
1988 "additional tilesets."),
1989 COC_GRAPHICS, GUI_STUB, "",
1990 get_tileset_list, tilespec_reread_callback, TF_ISO | TF_HEX),
1991
1992 GEN_BOOL_OPTION(draw_city_outlines, N_("Draw city outlines"),
1993 N_("Setting this option will draw a line at the city "
1994 "workable limit."),
1995 COC_GRAPHICS, GUI_STUB, TRUE,
1997 GEN_BOOL_OPTION(draw_city_output, N_("Draw city output"),
1998 N_("Setting this option will draw city output for every "
1999 "citizen."),
2000 COC_GRAPHICS, GUI_STUB, FALSE,
2002 GEN_BOOL_OPTION(draw_map_grid, N_("Draw the map grid"),
2003 N_("Setting this option will draw a grid over the map."),
2004 COC_GRAPHICS, GUI_STUB, FALSE,
2006 GEN_BOOL_OPTION(draw_full_citybar, N_("Draw the city bar"),
2007 N_("Setting this option will display a 'city bar' "
2008 "containing useful information beneath each city. "
2009 "Disabling this option will display only the city's "
2010 "name and, optionally, production."),
2011 COC_GRAPHICS, GUI_STUB,
2013 GEN_BOOL_OPTION(draw_city_names, N_("Draw the city names"),
2014 N_("Setting this option will draw the names of the cities "
2015 "on the map."),
2016 COC_GRAPHICS, GUI_STUB, TRUE,
2018 GEN_BOOL_OPTION(draw_city_growth, N_("Draw the city growth"),
2019 N_("Setting this option will draw in how many turns the "
2020 "cities will grow or shrink."),
2021 COC_GRAPHICS, GUI_STUB, TRUE,
2023 GEN_BOOL_OPTION(draw_city_productions, N_("Draw the city productions"),
2024 N_("Setting this option will draw what the cities are "
2025 "currently building on the map."),
2026 COC_GRAPHICS, GUI_STUB, TRUE,
2028 GEN_BOOL_OPTION(draw_city_buycost, N_("Draw the city buy costs"),
2029 N_("Setting this option will draw how much gold is "
2030 "needed to buy the production of the cities."),
2031 COC_GRAPHICS, GUI_STUB, FALSE,
2033 GEN_BOOL_OPTION(draw_city_trade_routes, N_("Draw the city trade routes"),
2034 N_("Setting this option will draw trade route lines "
2035 "between cities which have trade routes."),
2036 COC_GRAPHICS, GUI_STUB, FALSE,
2038 GEN_BOOL_OPTION(draw_terrain, N_("Draw the terrain"),
2039 N_("Setting this option will draw the terrain."),
2040 COC_GRAPHICS, GUI_STUB, TRUE,
2042 GEN_BOOL_OPTION(draw_coastline, N_("Draw the coast line"),
2043 N_("Setting this option will draw a line to separate the "
2044 "land from the ocean."),
2045 COC_GRAPHICS, GUI_STUB, FALSE,
2047 GEN_BOOL_OPTION(draw_roads_rails, N_("Draw the roads and the railroads"),
2048 N_("Setting this option will draw the roads and the "
2049 "railroads on the map."),
2050 COC_GRAPHICS, GUI_STUB, TRUE,
2052 GEN_BOOL_OPTION(draw_irrigation, N_("Draw the irrigation"),
2053 N_("Setting this option will draw the irrigation systems "
2054 "on the map."),
2055 COC_GRAPHICS, GUI_STUB, TRUE,
2057 GEN_BOOL_OPTION(draw_mines, N_("Draw the mines"),
2058 N_("Setting this option will draw the mines on the map."),
2059 COC_GRAPHICS, GUI_STUB, TRUE,
2061 GEN_BOOL_OPTION(draw_fortress_airbase, N_("Draw the bases"),
2062 N_("Setting this option will draw the bases on the map."),
2063 COC_GRAPHICS, GUI_STUB, TRUE,
2065 GEN_BOOL_OPTION(draw_specials, N_("Draw the resources"),
2066 N_("Setting this option will draw the resources on the "
2067 "map."),
2068 COC_GRAPHICS, GUI_STUB, TRUE,
2070 GEN_BOOL_OPTION(draw_huts, N_("Draw the huts"),
2071 N_("Setting this option will draw the huts on the "
2072 "map."),
2073 COC_GRAPHICS, GUI_STUB, TRUE,
2075 GEN_BOOL_OPTION(draw_pollution, N_("Draw the pollution/nuclear fallout"),
2076 N_("Setting this option will draw pollution and "
2077 "nuclear fallout on the map."),
2078 COC_GRAPHICS, GUI_STUB, TRUE,
2080 GEN_BOOL_OPTION(draw_cities, N_("Draw the cities"),
2081 N_("Setting this option will draw the cities on the map."),
2082 COC_GRAPHICS, GUI_STUB, TRUE,
2084 GEN_BOOL_OPTION(draw_units, N_("Draw the units"),
2085 N_("Setting this option will draw the units on the map."),
2086 COC_GRAPHICS, GUI_STUB, TRUE,
2088 GEN_BOOL_OPTION(solid_color_behind_units,
2089 N_("Solid unit background color"),
2090 N_("Setting this option will cause units on the map "
2091 "view to be drawn with a solid background color "
2092 "instead of the flag backdrop."),
2093 COC_GRAPHICS, GUI_STUB,
2095 GEN_BOOL_OPTION(draw_unit_shields, N_("Draw shield graphics for units"),
2096 N_("Setting this option will draw a shield icon "
2097 "as the flags on units. If unset, the full flag will "
2098 "be drawn."),
2100 GEN_BOOL_OPTION(draw_unit_stack_size, N_("Draw size of the unit stacks"),
2101 N_("Setting this option will draw a numbers indicating "
2102 "size of the unit stacks. Not all clients support "
2103 "this."),
2105 GEN_BOOL_OPTION(draw_focus_unit, N_("Draw the units in focus"),
2106 N_("Setting this option will cause the currently focused "
2107 "unit(s) to always be drawn, even if units are not "
2108 "otherwise being drawn (for instance if 'Draw the units' "
2109 "is unset)."),
2110 COC_GRAPHICS, GUI_STUB, FALSE,
2112 GEN_BOOL_OPTION(draw_fog_of_war, N_("Draw the fog of war"),
2113 N_("Setting this option will draw the fog of war."),
2114 COC_GRAPHICS, GUI_STUB, TRUE,
2116 GEN_BOOL_OPTION(draw_borders, N_("Draw the borders"),
2117 N_("Setting this option will draw the national borders."),
2118 COC_GRAPHICS, GUI_STUB, TRUE,
2120 GEN_BOOL_OPTION(draw_native, N_("Draw whether tiles are native to "
2121 "selected unit"),
2122 N_("Setting this option will highlight tiles that the "
2123 "currently selected unit cannot enter unaided due to "
2124 "non-native terrain. (If multiple units are selected, "
2125 "only tiles that all of them can enter are indicated.)"),
2126 COC_GRAPHICS, GUI_STUB, FALSE,
2128 GEN_BOOL_OPTION(player_dlg_show_dead_players,
2129 N_("Show dead players in Nations report"),
2130 N_("This option controls whether defeated nations are "
2131 "shown on the Nations report page."),
2132 COC_GRAPHICS, GUI_STUB, TRUE,
2134 GEN_BOOL_OPTION(sound_bell_at_new_turn, N_("Sound bell at new turn"),
2135 N_("Set this option to have a \"bell\" event be generated "
2136 "at the start of a new turn. You can control the "
2137 "behavior of the \"bell\" event by editing the message "
2138 "options."),
2139 COC_SOUND, GUI_STUB, FALSE, NULL),
2140 GEN_INT_OPTION(smooth_move_unit_msec,
2141 N_("Unit movement animation time (milliseconds)"),
2142 N_("This option controls how long unit \"animation\" takes "
2143 "when a unit moves on the map view. Set it to 0 to "
2144 "disable animation entirely."),
2145 COC_GRAPHICS, GUI_STUB, 30, 0, 2000, NULL),
2146 GEN_INT_OPTION(smooth_center_slide_msec,
2147 N_("Mapview recentering time (milliseconds)"),
2148 N_("When the map view is recentered, it will slide "
2149 "smoothly over the map to its new position. This "
2150 "option controls how long this slide lasts. Set it to "
2151 "0 to disable mapview sliding entirely."),
2152 COC_GRAPHICS, GUI_STUB, 200, 0, 5000, NULL),
2153 GEN_INT_OPTION(smooth_combat_step_msec,
2154 N_("Combat animation step time (milliseconds)"),
2155 N_("This option controls the speed of combat animation "
2156 "between units on the mapview. Set it to 0 to disable "
2157 "animation entirely."),
2158 COC_GRAPHICS, GUI_STUB, 10, 0, 100, NULL),
2159 GEN_BOOL_OPTION(reqtree_show_icons,
2160 N_("Show icons in the technology tree"),
2161 N_("Setting this option will display icons "
2162 "on the technology tree diagram. Turning "
2163 "this option off makes the technology tree "
2164 "more compact."),
2166 GEN_BOOL_OPTION(reqtree_curved_lines,
2167 N_("Use curved lines in the technology tree"),
2168 N_("Setting this option make the technology tree "
2169 "diagram use curved lines to show technology "
2170 "relations. Turning this option off causes "
2171 "the lines to be drawn straight."),
2172 COC_GRAPHICS, GUI_STUB, FALSE,
2174 GEN_COLOR_OPTION(highlight_our_names,
2175 N_("Color to highlight your player/user name"),
2176 N_("If set, your player and user name in the new chat "
2177 "messages will be highlighted using this color as "
2178 "background. If not set, it will just not highlight "
2179 "anything."),
2180 COC_GRAPHICS, GUI_STUB, "#000000", "#FFFF00", NULL),
2181 GEN_BOOL_OPTION(ai_manual_turn_done, N_("Manual Turn Done in AI mode"),
2182 N_("Disable this option if you do not want to "
2183 "press the Turn Done button manually when watching "
2184 "an AI player."),
2186 GEN_BOOL_OPTION(auto_center_on_unit, N_("Auto center on units"),
2187 N_("Set this option to have the active unit centered "
2188 "automatically when the unit focus changes."),
2189 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2190 GEN_BOOL_OPTION(auto_center_on_automated, N_("Show automated units"),
2191 N_("Disable this option if you do not want to see "
2192 "automated units autocentered and animated."),
2193 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2194 GEN_BOOL_OPTION(auto_center_on_combat, N_("Auto center on combat"),
2195 N_("Set this option to have any combat be centered "
2196 "automatically. Disabling this will speed up the time "
2197 "between turns but may cause you to miss combat "
2198 "entirely."),
2199 COC_INTERFACE, GUI_STUB, FALSE, NULL),
2200 GEN_BOOL_OPTION(auto_center_each_turn, N_("Auto center on new turn"),
2201 N_("Set this option to have the client automatically "
2202 "recenter the map on a suitable location at the "
2203 "start of each turn."),
2204 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2205 GEN_BOOL_OPTION(wakeup_focus, N_("Focus on awakened units"),
2206 N_("Set this option to have newly awoken units be "
2207 "focused automatically."),
2208 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2209 GEN_BOOL_OPTION(keyboardless_goto, N_("Keyboardless goto"),
2210 N_("If this option is set then a goto may be initiated "
2211 "by left-clicking and then holding down the mouse "
2212 "button while dragging the mouse onto a different "
2213 "tile."),
2214 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2215 GEN_BOOL_OPTION(goto_into_unknown, N_("Allow goto into the unknown"),
2216 N_("Setting this option will make the game consider "
2217 "moving into unknown tiles. If not, then goto routes "
2218 "will detour around or be blocked by unknown tiles."),
2219 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2220 GEN_BOOL_OPTION(center_when_popup_city, N_("Center map when popup city"),
2221 N_("Setting this option makes the mapview center on a "
2222 "city when its city dialog is popped up."),
2223 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2224 GEN_BOOL_OPTION(show_previous_turn_messages, N_("Show messages from previous turn"),
2225 N_("Message Window shows messages also from previous turn. "
2226 "This makes sure you don't miss messages received in the end of "
2227 "the turn, just before the window gets cleared."),
2228 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2229 GEN_BOOL_OPTION(concise_city_production, N_("Concise city production"),
2230 N_("Set this option to make the city production (as shown "
2231 "in the city dialog) to be more compact."),
2232 COC_INTERFACE, GUI_STUB, FALSE, NULL),
2233 GEN_BOOL_OPTION(auto_turn_done, N_("End turn when done moving"),
2234 N_("Setting this option makes your turn end automatically "
2235 "when all your units are done moving."),
2236 COC_INTERFACE, GUI_STUB, FALSE, NULL),
2237 GEN_BOOL_OPTION(ask_city_name, N_("Prompt for city names"),
2238 N_("Disabling this option will make the names of newly "
2239 "founded cities be chosen automatically by the server."),
2240 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2241 GEN_BOOL_OPTION(popup_new_cities, N_("Pop up city dialog for new cities"),
2242 N_("Setting this option will pop up a newly-founded "
2243 "city's city dialog automatically."),
2244 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2245 GEN_BOOL_OPTION(popup_actor_arrival, N_("Pop up caravan and spy actions"),
2246 N_("If this option is enabled, when a unit arrives at "
2247 "a city where it can perform an action like "
2248 "establishing a trade route, helping build a wonder, or "
2249 "establishing an embassy, a window will pop up asking "
2250 "which action should be performed. "
2251 "Disabling this option means you will have to do the "
2252 "action manually by pressing either 'r' (for a trade "
2253 "route), 'b' (for building a wonder) or 'd' (for a "
2254 "spy action) when the unit is in the city."),
2255 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2256 GEN_BOOL_OPTION(popup_attack_actions, N_("Pop up attack questions"),
2257 N_("If this option is enabled, when a unit arrives at a "
2258 "target it can attack, a window will pop up asking "
2259 "which action should be performed even if an attack "
2260 "action is legal and no other interesting action are. "
2261 "This allows you to change your mind or to select an "
2262 "uninteresting action."),
2263 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2264 GEN_BOOL_OPTION(popup_last_move_to_allied,
2265 /* TODO: Rename option ..._last_... to match _final_ in
2266 * the descriptions.
2267 * Changes options file format, needs migration
2268 * when loading old version. */
2269 N_("Pop up actions when final move to allied tile"),
2270 N_("If this option is enabled the final move in a unit's"
2271 " orders to a tile with allied units or cities it can"
2272 " perform an action to is interpreted as an attempted"
2273 " action. This makes the action selection dialog pop up"
2274 " while the unit is at the adjacent tile."
2275 " This can, in cases where the action requires that"
2276 " the actor unit has moves left, save a turn."
2277 " The down side is that the unit remains adjacent to"
2278 " rather than inside the protection of an allied city"
2279 " or unit stack."),
2280 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2281 GEN_BOOL_OPTION(enable_cursor_changes, N_("Enable cursor changing"),
2282 N_("This option controls whether the client should "
2283 "try to change the mouse cursor depending on what "
2284 "is being pointed at, as well as to indicate "
2285 "changes in the client or server state."),
2286 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2287 GEN_BOOL_OPTION(separate_unit_selection, N_("Select cities before units"),
2288 N_("If this option is enabled, when both cities and "
2289 "units are present in the selection rectangle, only "
2290 "cities will be selected. See the help on Controls."),
2291 COC_INTERFACE, GUI_STUB, FALSE, NULL),
2292 GEN_BOOL_OPTION(unit_selection_clears_orders,
2293 N_("Clear unit orders on selection"),
2294 N_("Enabling this option will cause unit orders to be "
2295 "cleared as soon as one or more units are selected. If "
2296 "this option is disabled, busy units will not stop "
2297 "their current activity when selected. Giving them "
2298 "new orders will clear their current ones; pressing "
2299 "<space> once will clear their orders and leave them "
2300 "selected, and pressing <space> a second time will "
2301 "dismiss them."),
2302 COC_INTERFACE, GUI_STUB, TRUE, NULL),
2303 GEN_BOOL_OPTION(voteinfo_bar_use, N_("Enable vote bar"),
2304 N_("If this option is turned on, the vote bar will be "
2305 "displayed to show vote information."),
2307 GEN_BOOL_OPTION(voteinfo_bar_always_show,
2308 N_("Always display the vote bar"),
2309 N_("If this option is turned on, the vote bar will never "
2310 "be hidden, even if there is no running vote."),
2312 GEN_BOOL_OPTION(voteinfo_bar_hide_when_not_player,
2313 N_("Do not show vote bar if not a player"),
2314 N_("If this option is enabled, the client won't show the "
2315 "vote bar if you are not a player."),
2317 GEN_BOOL_OPTION(voteinfo_bar_new_at_front, N_("Set new votes at front"),
2318 N_("If this option is enabled, then new votes will go "
2319 "to the front of the vote list."),
2321 GEN_BOOL_OPTION(autoaccept_tileset_suggestion,
2322 N_("Autoaccept tileset suggestions"),
2323 N_("If this option is enabled, any tileset suggested by "
2324 "the ruleset is automatically used; otherwise you "
2325 "are prompted to change tileset."),
2326 COC_GRAPHICS, GUI_STUB, FALSE, NULL),
2327
2328 GEN_BOOL_OPTION(sound_enable_effects,
2329 N_("Enable sound effects"),
2330 N_("Play sound effects, assuming there's suitable "
2331 "sound plugin and soundset with the sounds."),
2332 COC_SOUND, GUI_STUB, TRUE, NULL),
2333 GEN_BOOL_OPTION(sound_enable_game_music,
2334 N_("Enable in-game music"),
2335 N_("Play music during the game, assuming there's suitable "
2336 "sound plugin and musicset with in-game tracks."),
2338 GEN_BOOL_OPTION(sound_enable_menu_music,
2339 N_("Enable menu music"),
2340 N_("Play music while not in actual game, "
2341 "assuming there's suitable "
2342 "sound plugin and musicset with menu music tracks."),
2344 GEN_INT_OPTION(sound_effects_volume,
2345 N_("Sound volume"),
2346 N_("Volume scale from 0-100"),
2347 COC_SOUND, GUI_STUB, 100,
2348 0, 100,
2350
2351 GEN_BOOL_OPTION(autoaccept_soundset_suggestion,
2352 N_("Autoaccept soundset suggestions"),
2353 N_("If this option is enabled, any soundset suggested by "
2354 "the ruleset is automatically used."),
2355 COC_SOUND, GUI_STUB, FALSE, NULL),
2356 GEN_BOOL_OPTION(autoaccept_musicset_suggestion,
2357 N_("Autoaccept musicset suggestions"),
2358 N_("If this option is enabled, any musicset suggested by "
2359 "the ruleset is automatically used."),
2360 COC_SOUND, GUI_STUB, FALSE, NULL),
2361
2363 N_("Background layer"),
2364 N_("The background layer of the overview shows just "
2365 "ocean and land."),
2366 COC_OVERVIEW, GUI_STUB, TRUE, NULL),
2368 N_("Terrain relief map layer"),
2369 N_("The relief layer shows all terrains on the map."),
2372 N_("Borders layer"),
2373 N_("The borders layer of the overview shows which tiles "
2374 "are owned by each player."),
2377 N_("Borders layer on ocean tiles"),
2378 N_("The borders layer of the overview are drawn on "
2379 "ocean tiles as well (this may look ugly with many "
2380 "islands). This option is only of interest if you "
2381 "have set the option \"Borders layer\" already."),
2384 N_("Units layer"),
2385 N_("Enabling this will draw units on the overview."),
2388 N_("Cities layer"),
2389 N_("Enabling this will draw cities on the overview."),
2392 N_("Overview fog of war"),
2393 N_("Enabling this will show fog of war on the "
2394 "overview."),
2396
2397 /* options for map images */
2398 GEN_STR_LIST_OPTION(mapimg_format,
2399 N_("Image format"),
2400 N_("The image toolkit and file format used for "
2401 "map images."),
2402 COC_MAPIMG, GUI_STUB, NULL, get_mapimg_format_list,
2403 NULL, 0),
2404 GEN_INT_OPTION(mapimg_zoom,
2405 N_("Zoom factor for map images"),
2406 N_("The magnification used for map images."),
2407 COC_MAPIMG, GUI_STUB, 2, 1, 5, mapimg_changed_callback),
2408 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_AREA],
2409 N_("Show area within borders"),
2410 N_("If set, the territory of each nation is shown "
2411 "on the saved image."),
2413 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_BORDERS],
2414 N_("Show borders"),
2415 N_("If set, the border of each nation is shown on the "
2416 "saved image."),
2418 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_CITIES],
2419 N_("Show cities"),
2420 N_("If set, cities are shown on the saved image."),
2422 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_FOGOFWAR],
2423 N_("Show fog of war"),
2424 N_("If set, the extent of fog of war is shown on the "
2425 "saved image."),
2427 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_TERRAIN],
2428 N_("Show full terrain"),
2429 N_("If set, terrain relief is shown with different colors "
2430 "in the saved image; otherwise, only land and water are "
2431 "distinguished."),
2433 GEN_BOOL_OPTION(mapimg_layer[MAPIMG_LAYER_UNITS],
2434 N_("Show units"),
2435 N_("If set, units are shown in the saved image."),
2437 GEN_STR_OPTION(mapimg_filename,
2438 N_("Map image file name"),
2439 N_("The base part of the filename for saved map images. "
2440 "A string identifying the game turn and map options will "
2441 "be appended."),
2442 COC_MAPIMG, GUI_STUB, GUI_DEFAULT_MAPIMG_FILENAME, NULL, 0),
2443
2444 /* gui-gtk-2.0 client specific options.
2445 * These are still kept just so users can migrate them to gtk3-client */
2446 GEN_BOOL_OPTION(gui_gtk2_map_scrollbars, NULL, NULL,
2447 COC_INTERFACE, GUI_GTK2, FALSE, NULL),
2448 GEN_BOOL_OPTION(gui_gtk2_dialogs_on_top, NULL, NULL,
2449 COC_INTERFACE, GUI_GTK2, TRUE, NULL),
2450 GEN_BOOL_OPTION(gui_gtk2_show_task_icons, NULL, NULL,
2451 COC_GRAPHICS, GUI_GTK2, TRUE, NULL),
2452 GEN_BOOL_OPTION(gui_gtk2_enable_tabs, NULL, NULL,
2453 COC_INTERFACE, GUI_GTK2, TRUE, NULL),
2454 GEN_BOOL_OPTION(gui_gtk2_better_fog, NULL, NULL,
2455 COC_GRAPHICS, GUI_GTK2,
2457 GEN_BOOL_OPTION(gui_gtk2_show_chat_message_time, NULL, NULL,
2458 COC_INTERFACE, GUI_GTK2, FALSE, NULL),
2459 GEN_BOOL_OPTION(gui_gtk2_new_messages_go_to_top, NULL, NULL,
2460 COC_INTERFACE, GUI_GTK2, FALSE, NULL),
2461 GEN_BOOL_OPTION(gui_gtk2_show_message_window_buttons, NULL, NULL,
2462 COC_INTERFACE, GUI_GTK2, TRUE, NULL),
2463 GEN_BOOL_OPTION(gui_gtk2_metaserver_tab_first, NULL, NULL,
2464 COC_NETWORK, GUI_GTK2, FALSE, NULL),
2465 GEN_BOOL_OPTION(gui_gtk2_allied_chat_only, NULL, NULL,
2466 COC_INTERFACE, GUI_GTK2, FALSE, NULL),
2467 GEN_BOOL_OPTION(gui_gtk2_mouse_over_map_focus, NULL, NULL,
2468 COC_INTERFACE, GUI_GTK2, FALSE, NULL),
2469 GEN_BOOL_OPTION(gui_gtk2_chatline_autocompletion, NULL, NULL,
2470 COC_INTERFACE, GUI_GTK2, TRUE, NULL),
2471 GEN_INT_OPTION(gui_gtk2_citydlg_xsize, NULL, NULL,
2474 NULL),
2475 GEN_INT_OPTION(gui_gtk2_citydlg_ysize, NULL, NULL,
2478 NULL),
2479 GEN_ENUM_OPTION(gui_gtk2_popup_tech_help, NULL, NULL,
2480 COC_INTERFACE, GUI_GTK2,
2483 GEN_FONT_OPTION(gui_gtk2_font_city_label, "city_label",
2484 NULL, NULL,
2485 COC_FONT, GUI_GTK2,
2486 "Monospace 8", font_changed_callback),
2487 GEN_FONT_OPTION(gui_gtk2_font_notify_label, "notify_label",
2488 NULL, NULL,
2489 COC_FONT, GUI_GTK2,
2490 "Monospace Bold 9", font_changed_callback),
2491 GEN_FONT_OPTION(gui_gtk2_font_spaceship_label, "spaceship_label",
2492 NULL, NULL,
2493 COC_FONT, GUI_GTK2,
2494 "Monospace 8", font_changed_callback),
2495 GEN_FONT_OPTION(gui_gtk2_font_help_label, "help_label",
2496 NULL, NULL,
2497 COC_FONT, GUI_GTK2,
2498 "Sans Bold 10", font_changed_callback),
2499 GEN_FONT_OPTION(gui_gtk2_font_help_link, "help_link",
2500 NULL, NULL,
2501 COC_FONT, GUI_GTK2,
2502 "Sans 9", font_changed_callback),
2503 GEN_FONT_OPTION(gui_gtk2_font_help_text, "help_text",
2504 NULL, NULL,
2505 COC_FONT, GUI_GTK2,
2506 "Monospace 8", font_changed_callback),
2507 GEN_FONT_OPTION(gui_gtk2_font_chatline, "chatline",
2508 NULL, NULL,
2509 COC_FONT, GUI_GTK2,
2510 "Monospace 8", font_changed_callback),
2511 GEN_FONT_OPTION(gui_gtk2_font_beta_label, "beta_label",
2512 NULL, NULL,
2513 COC_FONT, GUI_GTK2,
2514 "Sans Italic 10", font_changed_callback),
2515 GEN_FONT_OPTION(gui_gtk2_font_small, "small_font",
2516 NULL, NULL,
2517 COC_FONT, GUI_GTK2,
2518 "Sans 9", font_changed_callback),
2519 GEN_FONT_OPTION(gui_gtk2_font_comment_label, "comment_label",
2520 NULL, NULL,
2521 COC_FONT, GUI_GTK2,
2522 "Sans Italic 9", font_changed_callback),
2523 GEN_FONT_OPTION(gui_gtk2_font_city_names, "city_names",
2524 NULL, NULL,
2525 COC_FONT, GUI_GTK2,
2526 "Sans Bold 10", NULL),
2527 GEN_FONT_OPTION(gui_gtk2_font_city_productions, "city_productions",
2528 NULL, NULL,
2529 COC_FONT, GUI_GTK2,
2530 "Serif 10", NULL),
2531 GEN_FONT_OPTION(gui_gtk2_font_reqtree_text, "reqtree_text",
2532 NULL, NULL,
2533 COC_FONT, GUI_GTK2,
2534 "Serif 10", NULL),
2535
2536 /* gui-gtk-3.0 client specific options. */
2537 GEN_BOOL_OPTION(gui_gtk3_fullscreen, N_("Fullscreen"),
2538 N_("If this option is set the client will use the "
2539 "whole screen area for drawing."),
2540 COC_INTERFACE, GUI_GTK3, FALSE, NULL),
2541 GEN_BOOL_OPTION(gui_gtk3_map_scrollbars, N_("Show map scrollbars"),
2542 N_("Disable this option to hide the scrollbars on the "
2543 "map view."),
2544 COC_INTERFACE, GUI_GTK3, FALSE, NULL),
2545 GEN_BOOL_OPTION(gui_gtk3_dialogs_on_top, N_("Keep dialogs on top"),
2546 N_("If this option is set then dialog windows will always "
2547 "remain in front of the main Freeciv window. "
2548 "Disabling this has no effect in fullscreen mode."),
2549 COC_INTERFACE, GUI_GTK3, TRUE, NULL),
2550 GEN_BOOL_OPTION(gui_gtk3_show_task_icons, N_("Show worklist task icons"),
2551 N_("Disabling this will turn off the unit and building "
2552 "icons in the worklist dialog and the production "
2553 "tab of the city dialog."),
2554 COC_GRAPHICS, GUI_GTK3, TRUE, NULL),
2555 GEN_BOOL_OPTION(gui_gtk3_enable_tabs, N_("Enable status report tabs"),
2556 N_("If this option is enabled then report dialogs will "
2557 "be shown as separate tabs rather than in popup "
2558 "dialogs."),
2559 COC_INTERFACE, GUI_GTK3, TRUE, NULL),
2560 GEN_BOOL_OPTION(gui_gtk3_show_chat_message_time,
2561 N_("Show time for each chat message"),
2562 N_("If this option is enabled then all chat messages "
2563 "will be prefixed by a time string of the form "
2564 "[hour:minute:second]."),
2565 COC_INTERFACE, GUI_GTK3, FALSE, NULL),
2566 GEN_BOOL_OPTION(gui_gtk3_new_messages_go_to_top,
2567 N_("New message events go to top of list"),
2568 N_("If this option is enabled, new events in the "
2569 "message window will appear at the top of the list, "
2570 "rather than being appended at the bottom."),
2571 COC_INTERFACE, GUI_GTK3, FALSE, NULL),
2572 GEN_BOOL_OPTION(gui_gtk3_show_message_window_buttons,
2573 N_("Show extra message window buttons"),
2574 N_("If this option is enabled, there will be two "
2575 "buttons displayed in the message window for "
2576 "inspecting a city and going to a location. If this "
2577 "option is disabled, these buttons will not appear "
2578 "(you can still double-click with the left mouse "
2579 "button or right-click on a row to inspect or goto "
2580 "respectively). This option will only take effect "
2581 "once the message window is closed and reopened."),
2582 COC_INTERFACE, GUI_GTK3, TRUE, NULL),
2583 GEN_BOOL_OPTION(gui_gtk3_metaserver_tab_first,
2584 N_("Metaserver tab first in network page"),
2585 N_("If this option is enabled, the metaserver tab will "
2586 "be the first notebook tab in the network page. This "
2587 "option requires a restart in order to take effect."),
2588 COC_NETWORK, GUI_GTK3, FALSE, NULL),
2589 GEN_BOOL_OPTION(gui_gtk3_allied_chat_only,
2590 N_("Plain chat messages are sent to allies only"),
2591 N_("If this option is enabled, then plain messages "
2592 "typed into the chat entry while the game is "
2593 "running will only be sent to your allies. "
2594 "Otherwise plain messages will be sent as "
2595 "public chat messages. To send a public chat "
2596 "message with this option enabled, prefix the "
2597 "message with a single colon ':'. This option "
2598 "can also be set using a toggle button beside "
2599 "the chat entry (only visible in multiplayer "
2600 "games)."),
2601 COC_INTERFACE, GUI_GTK3, FALSE, NULL),
2602 GEN_ENUM_OPTION(gui_gtk3_message_chat_location,
2603 N_("Messages and Chat reports location"),
2604 /* TRANS: The strings used in the UI for 'Split' etc are
2605 * tagged 'gui_gtk2/gtk3/gtk4_message_chat_location' */
2606 N_("Controls where the Messages and Chat reports "
2607 "appear relative to the main view containing the map.\n"
2608 "'Split' allows all three to be seen simultaneously, "
2609 "which is best for multiplayer, but requires a large "
2610 "window to be usable.\n"
2611 "'Separate' puts Messages and Chat in a notebook "
2612 "separate from the main view, so that one of them "
2613 "can always be seen alongside the main view.\n"
2614 "'Merged' makes the Messages and Chat reports into "
2615 "tabs alongside the map and other reports; this "
2616 "allows a larger map view on small screens.\n"
2617 "This option requires a restart in order to take "
2618 "effect."), COC_INTERFACE, GUI_GTK3,
2621 GEN_BOOL_OPTION(gui_gtk3_small_display_layout,
2622 N_("Arrange widgets for small displays"),
2623 N_("If this option is enabled, widgets in the main "
2624 "window will be arranged so that they take up the "
2625 "least amount of total screen space. Specifically, "
2626 "the left panel containing the overview, player "
2627 "status, and the unit information box will be "
2628 "extended over the entire left side of the window. "
2629 "This option requires a restart in order to take "
2630 "effect."), COC_INTERFACE, GUI_GTK3, FALSE, NULL),
2631 GEN_BOOL_OPTION(gui_gtk3_mouse_over_map_focus,
2632 N_("Mouse over the map widget selects it automatically"),
2633 N_("If this option is enabled, then the map will be "
2634 "focused when the mouse hovers over it."),
2635 COC_INTERFACE, GUI_GTK3, FALSE, NULL),
2636 GEN_BOOL_OPTION(gui_gtk3_chatline_autocompletion,
2637 N_("Player or user name autocompletion"),
2638 N_("If this option is turned on, the tabulation key "
2639 "will be used in the chatline to complete the word you "
2640 "are typing with the name of a player or a user."),
2641 COC_INTERFACE, GUI_GTK3, TRUE, NULL),
2642 GEN_INT_OPTION(gui_gtk3_citydlg_xsize,
2643 N_("Width of the city dialog"),
2644 N_("This value is only used if the width of the city "
2645 "dialog is saved."),
2648 NULL),
2649 GEN_INT_OPTION(gui_gtk3_citydlg_ysize,
2650 N_("Height of the city dialog"),
2651 N_("This value is only used if the height of the city "
2652 "dialog is saved."),
2655 NULL),
2656 GEN_ENUM_OPTION(gui_gtk3_popup_tech_help,
2657 N_("Popup tech help when gained"),
2658 N_("Controls if tech help should be opened when "
2659 "new tech has been gained.\n"
2660 "'Ruleset' means that behavior suggested by "
2661 "current ruleset is used."), COC_INTERFACE, GUI_GTK3,
2664 GEN_INT_OPTION(gui_gtk3_governor_range_min,
2665 N_("Minimum surplus for a governor"),
2666 N_("The lower limit of the range for requesting surpluses "
2667 "from the governor."),
2670 NULL),
2671 GEN_INT_OPTION(gui_gtk3_governor_range_max,
2672 N_("Maximum surplus for a governor"),
2673 N_("The higher limit of the range for requesting surpluses "
2674 "from the governor."),
2677 NULL),
2678 GEN_FONT_OPTION(gui_gtk3_font_city_label, "city_label",
2679 N_("City Label"),
2680 N_("This font is used to display the city labels on city "
2681 "dialogs."),
2682 COC_FONT, GUI_GTK3,
2683 "Monospace 8", font_changed_callback),
2684 GEN_FONT_OPTION(gui_gtk3_font_notify_label, "notify_label",
2685 N_("Notify Label"),
2686 N_("This font is used to display server reports such "
2687 "as the demographic report or historian publications."),
2688 COC_FONT, GUI_GTK3,
2689 "Monospace Bold 9", font_changed_callback),
2690 GEN_FONT_OPTION(gui_gtk3_font_spaceship_label, "spaceship_label",
2691 N_("Spaceship Label"),
2692 N_("This font is used to display the spaceship widgets."),
2693 COC_FONT, GUI_GTK3,
2694 "Monospace 8", font_changed_callback),
2695 GEN_FONT_OPTION(gui_gtk3_font_help_label, "help_label",
2696 N_("Help Label"),
2697 N_("This font is used to display the help headers in the "
2698 "help window."),
2699 COC_FONT, GUI_GTK3,
2700 "Sans Bold 10", font_changed_callback),
2701 GEN_FONT_OPTION(gui_gtk3_font_help_link, "help_link",
2702 N_("Help Link"),
2703 N_("This font is used to display the help links in the "
2704 "help window."),
2705 COC_FONT, GUI_GTK3,
2706 "Sans 9", font_changed_callback),
2707 GEN_FONT_OPTION(gui_gtk3_font_help_text, "help_text",
2708 N_("Help Text"),
2709 N_("This font is used to display the help body text in "
2710 "the help window."),
2711 COC_FONT, GUI_GTK3,
2712 "Monospace 8", font_changed_callback),
2713 GEN_FONT_OPTION(gui_gtk3_font_chatline, "chatline",
2714 N_("Chatline Area"),
2715 N_("This font is used to display the text in the "
2716 "chatline area."),
2717 COC_FONT, GUI_GTK3,
2718 "Monospace 8", font_changed_callback),
2719 GEN_FONT_OPTION(gui_gtk3_font_beta_label, "beta_label",
2720 N_("Beta Label"),
2721 N_("This font is used to display the beta label."),
2722 COC_FONT, GUI_GTK3,
2723 "Sans Italic 10", font_changed_callback),
2724 GEN_FONT_OPTION(gui_gtk3_font_small, "small_font",
2725 N_("Small Font"),
2726 N_("This font is used for any small font request. For "
2727 "example, it is used for display the building lists "
2728 "in the city dialog, the Economy report or the Units "
2729 "report."),
2730 COC_FONT, GUI_GTK3,
2731 "Sans 9", font_changed_callback),
2732 GEN_FONT_OPTION(gui_gtk3_font_comment_label, "comment_label",
2733 N_("Comment Label"),
2734 N_("This font is used to display comment labels, such as "
2735 "in the governor page of the city dialogs."),
2736 COC_FONT, GUI_GTK3,
2737 "Sans Italic 9", font_changed_callback),
2738 GEN_FONT_OPTION(gui_gtk3_font_city_names, "city_names",
2739 N_("City Names"),
2740 N_("This font is used to the display the city names "
2741 "on the map."),
2742 COC_FONT, GUI_GTK3,
2743 "Sans Bold 10", NULL),
2744 GEN_FONT_OPTION(gui_gtk3_font_city_productions, "city_productions",
2745 N_("City Productions"),
2746 N_("This font is used to display the city production "
2747 "on the map."),
2748 COC_FONT, GUI_GTK3,
2749 "Serif 10", NULL),
2750 GEN_FONT_OPTION(gui_gtk3_font_reqtree_text, "reqtree_text",
2751 N_("Requirement Tree"),
2752 N_("This font is used to the display the requirement tree "
2753 "in the Research report."),
2754 COC_FONT, GUI_GTK3,
2755 "Serif 10", NULL),
2756
2757 /* gui-gtk-3.22 client specific options. */
2758 GEN_BOOL_OPTION(gui_gtk3_22_fullscreen, N_("Fullscreen"),
2759 N_("If this option is set the client will use the "
2760 "whole screen area for drawing."),
2761 COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2762 GEN_BOOL_OPTION(gui_gtk3_22_map_scrollbars, N_("Show map scrollbars"),
2763 N_("Disable this option to hide the scrollbars on the "
2764 "map view."),
2765 COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2766 GEN_BOOL_OPTION(gui_gtk3_22_dialogs_on_top, N_("Keep dialogs on top"),
2767 N_("If this option is set then dialog windows will always "
2768 "remain in front of the main Freeciv window. "
2769 "Disabling this has no effect in fullscreen mode."),
2770 COC_INTERFACE, GUI_GTK3_22, TRUE, NULL),
2771 GEN_BOOL_OPTION(gui_gtk3_22_show_task_icons, N_("Show worklist task icons"),
2772 N_("Disabling this will turn off the unit and building "
2773 "icons in the worklist dialog and the production "
2774 "tab of the city dialog."),
2775 COC_GRAPHICS, GUI_GTK3_22, TRUE, NULL),
2776 GEN_BOOL_OPTION(gui_gtk3_22_enable_tabs, N_("Enable status report tabs"),
2777 N_("If this option is enabled then report dialogs will "
2778 "be shown as separate tabs rather than in popup "
2779 "dialogs."),
2780 COC_INTERFACE, GUI_GTK3_22, TRUE, NULL),
2781 GEN_BOOL_OPTION(gui_gtk3_22_show_chat_message_time,
2782 N_("Show time for each chat message"),
2783 N_("If this option is enabled then all chat messages "
2784 "will be prefixed by a time string of the form "
2785 "[hour:minute:second]."),
2786 COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2787 GEN_BOOL_OPTION(gui_gtk3_22_new_messages_go_to_top,
2788 N_("New message events go to top of list"),
2789 N_("If this option is enabled, new events in the "
2790 "message window will appear at the top of the list, "
2791 "rather than being appended at the bottom."),
2792 COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2793 GEN_BOOL_OPTION(gui_gtk3_22_show_message_window_buttons,
2794 N_("Show extra message window buttons"),
2795 N_("If this option is enabled, there will be two "
2796 "buttons displayed in the message window for "
2797 "inspecting a city and going to a location. If this "
2798 "option is disabled, these buttons will not appear "
2799 "(you can still double-click with the left mouse "
2800 "button or right-click on a row to inspect or goto "
2801 "respectively). This option will only take effect "
2802 "once the message window is closed and reopened."),
2803 COC_INTERFACE, GUI_GTK3_22, TRUE, NULL),
2804 GEN_BOOL_OPTION(gui_gtk3_22_metaserver_tab_first,
2805 N_("Metaserver tab first in network page"),
2806 N_("If this option is enabled, the metaserver tab will "
2807 "be the first notebook tab in the network page. This "
2808 "option requires a restart in order to take effect."),
2809 COC_NETWORK, GUI_GTK3_22, FALSE, NULL),
2810 GEN_BOOL_OPTION(gui_gtk3_22_allied_chat_only,
2811 N_("Plain chat messages are sent to allies only"),
2812 N_("If this option is enabled, then plain messages "
2813 "typed into the chat entry while the game is "
2814 "running will only be sent to your allies. "
2815 "Otherwise plain messages will be sent as "
2816 "public chat messages. To send a public chat "
2817 "message with this option enabled, prefix the "
2818 "message with a single colon ':'. This option "
2819 "can also be set using a toggle button beside "
2820 "the chat entry (only visible in multiplayer "
2821 "games)."),
2822 COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2823 GEN_ENUM_OPTION(gui_gtk3_22_message_chat_location,
2824 N_("Messages and Chat reports location"),
2825 /* TRANS: The strings used in the UI for 'Split' etc are
2826 * tagged 'gui_gtk2/gtk3/gtk4_message_chat_location' */
2827 N_("Controls where the Messages and Chat reports "
2828 "appear relative to the main view containing the map.\n"
2829 "'Split' allows all three to be seen simultaneously, "
2830 "which is best for multiplayer, but requires a large "
2831 "window to be usable.\n"
2832 "'Separate' puts Messages and Chat in a notebook "
2833 "separate from the main view, so that one of them "
2834 "can always be seen alongside the main view.\n"
2835 "'Merged' makes the Messages and Chat reports into "
2836 "tabs alongside the map and other reports; this "
2837 "allows a larger map view on small screens.\n"
2838 "This option requires a restart in order to take "
2839 "effect."), COC_INTERFACE, GUI_GTK3_22,
2842 GEN_BOOL_OPTION(gui_gtk3_22_small_display_layout,
2843 N_("Arrange widgets for small displays"),
2844 N_("If this option is enabled, widgets in the main "
2845 "window will be arranged so that they take up the "
2846 "least amount of total screen space. Specifically, "
2847 "the left panel containing the overview, player "
2848 "status, and the unit information box will be "
2849 "extended over the entire left side of the window. "
2850 "This option requires a restart in order to take "
2851 "effect."), COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2852 GEN_BOOL_OPTION(gui_gtk3_22_mouse_over_map_focus,
2853 N_("Mouse over the map widget selects it automatically"),
2854 N_("If this option is enabled, then the map will be "
2855 "focused when the mouse hovers over it."),
2856 COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
2857 GEN_BOOL_OPTION(gui_gtk3_22_chatline_autocompletion,
2858 N_("Player or user name autocompletion"),
2859 N_("If this option is turned on, the tabulation key "
2860 "will be used in the chatline to complete the word you "
2861 "are typing with the name of a player or a user."),
2862 COC_INTERFACE, GUI_GTK3_22, TRUE, NULL),
2863 GEN_INT_OPTION(gui_gtk3_22_citydlg_xsize,
2864 N_("Width of the city dialog"),
2865 N_("This value is only used if the width of the city "
2866 "dialog is saved."),
2869 NULL),
2870 GEN_INT_OPTION(gui_gtk3_22_citydlg_ysize,
2871 N_("Height of the city dialog"),
2872 N_("This value is only used if the height of the city "
2873 "dialog is saved."),
2876 NULL),
2877 GEN_ENUM_OPTION(gui_gtk3_22_popup_tech_help,
2878 N_("Popup tech help when gained"),
2879 N_("Controls if tech help should be opened when "
2880 "new tech has been gained.\n"
2881 "'Ruleset' means that behavior suggested by "
2882 "current ruleset is used."), COC_INTERFACE, GUI_GTK3_22,
2885 GEN_INT_OPTION(gui_gtk3_22_governor_range_min,
2886 N_("Minimum surplus for a governor"),
2887 N_("The lower limit of the range for requesting surpluses "
2888 "from the governor."),
2891 NULL),
2892 GEN_INT_OPTION(gui_gtk3_22_governor_range_max,
2893 N_("Maximum surplus for a governor"),
2894 N_("The higher limit of the range for requesting surpluses "
2895 "from the governor."),
2898 NULL),
2899 GEN_FONT_OPTION(gui_gtk3_22_font_city_label, "city_label",
2900 N_("City Label"),
2901 N_("This font is used to display the city labels on city "
2902 "dialogs."),
2903 COC_FONT, GUI_GTK3_22,
2904 "Monospace 8", font_changed_callback),
2905 GEN_FONT_OPTION(gui_gtk3_22_font_notify_label, "notify_label",
2906 N_("Notify Label"),
2907 N_("This font is used to display server reports such "
2908 "as the demographic report or historian publications."),
2909 COC_FONT, GUI_GTK3_22,
2910 "Monospace Bold 9", font_changed_callback),
2911 GEN_FONT_OPTION(gui_gtk3_22_font_spaceship_label, "spaceship_label",
2912 N_("Spaceship Label"),
2913 N_("This font is used to display the spaceship widgets."),
2914 COC_FONT, GUI_GTK3_22,
2915 "Monospace 8", font_changed_callback),
2916 GEN_FONT_OPTION(gui_gtk3_22_font_help_label, "help_label",
2917 N_("Help Label"),
2918 N_("This font is used to display the help headers in the "
2919 "help window."),
2920 COC_FONT, GUI_GTK3_22,
2921 "Sans Bold 10", font_changed_callback),
2922 GEN_FONT_OPTION(gui_gtk3_22_font_help_link, "help_link",
2923 N_("Help Link"),
2924 N_("This font is used to display the help links in the "
2925 "help window."),
2926 COC_FONT, GUI_GTK3_22,
2927 "Sans 9", font_changed_callback),
2928 GEN_FONT_OPTION(gui_gtk3_22_font_help_text, "help_text",
2929 N_("Help Text"),
2930 N_("This font is used to display the help body text in "
2931 "the help window."),
2932 COC_FONT, GUI_GTK3_22,
2933 "Monospace 8", font_changed_callback),
2934 GEN_FONT_OPTION(gui_gtk3_22_font_chatline, "chatline",
2935 N_("Chatline Area"),
2936 N_("This font is used to display the text in the "
2937 "chatline area."),
2938 COC_FONT, GUI_GTK3_22,
2939 "Monospace 8", font_changed_callback),
2940 GEN_FONT_OPTION(gui_gtk3_22_font_beta_label, "beta_label",
2941 N_("Beta Label"),
2942 N_("This font is used to display the beta label."),
2943 COC_FONT, GUI_GTK3_22,
2944 "Sans Italic 10", font_changed_callback),
2945 GEN_FONT_OPTION(gui_gtk3_22_font_small, "small_font",
2946 N_("Small Font"),
2947 N_("This font is used for any small font request. For "
2948 "example, it is used for display the building lists "
2949 "in the city dialog, the Economy report or the Units "
2950 "report."),
2951 COC_FONT, GUI_GTK3_22,
2952 "Sans 9", font_changed_callback),
2953 GEN_FONT_OPTION(gui_gtk3_22_font_comment_label, "comment_label",
2954 N_("Comment Label"),
2955 N_("This font is used to display comment labels, such as "
2956 "in the governor page of the city dialogs."),
2957 COC_FONT, GUI_GTK3_22,
2958 "Sans Italic 9", font_changed_callback),
2959 GEN_FONT_OPTION(gui_gtk3_22_font_city_names, "city_names",
2960 N_("City Names"),
2961 N_("This font is used to the display the city names "
2962 "on the map."),
2963 COC_FONT, GUI_GTK3_22,
2964 "Sans Bold 10", NULL),
2965 GEN_FONT_OPTION(gui_gtk3_22_font_city_productions, "city_productions",
2966 N_("City Productions"),
2967 N_("This font is used to display the city production "
2968 "on the map."),
2969 COC_FONT, GUI_GTK3_22,
2970 "Serif 10", NULL),
2971 GEN_FONT_OPTION(gui_gtk3_22_font_reqtree_text, "reqtree_text",
2972 N_("Requirement Tree"),
2973 N_("This font is used to the display the requirement tree "
2974 "in the Research report."),
2975 COC_FONT, GUI_GTK3_22,
2976 "Serif 10", NULL),
2977
2978 /* gui-gtk-4.0 client specific options. */
2979 GEN_BOOL_OPTION(gui_gtk4_fullscreen, N_("Fullscreen"),
2980 N_("If this option is set the client will use the "
2981 "whole screen area for drawing."),
2982 COC_INTERFACE, GUI_GTK4, FALSE, NULL),
2983 GEN_BOOL_OPTION(gui_gtk4_map_scrollbars, N_("Show map scrollbars"),
2984 N_("Disable this option to hide the scrollbars on the "
2985 "map view."),
2986 COC_INTERFACE, GUI_GTK4, FALSE, NULL),
2987 GEN_BOOL_OPTION(gui_gtk4_dialogs_on_top, N_("Keep dialogs on top"),
2988 N_("If this option is set then dialog windows will always "
2989 "remain in front of the main Freeciv window. "
2990 "Disabling this has no effect in fullscreen mode."),
2991 COC_INTERFACE, GUI_GTK4, TRUE, NULL),
2992 GEN_BOOL_OPTION(gui_gtk4_show_task_icons, N_("Show worklist task icons"),
2993 N_("Disabling this will turn off the unit and building "
2994 "icons in the worklist dialog and the production "
2995 "tab of the city dialog."),
2996 COC_GRAPHICS, GUI_GTK4, TRUE, NULL),
2997 GEN_BOOL_OPTION(gui_gtk4_enable_tabs, N_("Enable status report tabs"),
2998 N_("If this option is enabled then report dialogs will "
2999 "be shown as separate tabs rather than in popup "
3000 "dialogs."),
3001 COC_INTERFACE, GUI_GTK4, TRUE, NULL),
3002 GEN_BOOL_OPTION(gui_gtk4_show_chat_message_time,
3003 N_("Show time for each chat message"),
3004 N_("If this option is enabled then all chat messages "
3005 "will be prefixed by a time string of the form "
3006 "[hour:minute:second]."),
3007 COC_INTERFACE, GUI_GTK4, FALSE, NULL),
3008 GEN_BOOL_OPTION(gui_gtk4_new_messages_go_to_top,
3009 N_("New message events go to top of list"),
3010 N_("If this option is enabled, new events in the "
3011 "message window will appear at the top of the list, "
3012 "rather than being appended at the bottom."),
3013 COC_INTERFACE, GUI_GTK4, FALSE, NULL),
3014 GEN_BOOL_OPTION(gui_gtk4_show_message_window_buttons,
3015 N_("Show extra message window buttons"),
3016 N_("If this option is enabled, there will be two "
3017 "buttons displayed in the message window for "
3018 "inspecting a city and going to a location. If this "
3019 "option is disabled, these buttons will not appear "
3020 "(you can still double-click with the left mouse "
3021 "button or right-click on a row to inspect or goto "
3022 "respectively). This option will only take effect "
3023 "once the message window is closed and reopened."),
3024 COC_INTERFACE, GUI_GTK4, TRUE, NULL),
3025 GEN_BOOL_OPTION(gui_gtk4_metaserver_tab_first,
3026 N_("Metaserver tab first in network page"),
3027 N_("If this option is enabled, the metaserver tab will "
3028 "be the first notebook tab in the network page. This "
3029 "option requires a restart in order to take effect."),
3030 COC_NETWORK, GUI_GTK4, FALSE, NULL),
3031 GEN_BOOL_OPTION(gui_gtk4_allied_chat_only,
3032 N_("Plain chat messages are sent to allies only"),
3033 N_("If this option is enabled, then plain messages "
3034 "typed into the chat entry while the game is "
3035 "running will only be sent to your allies. "
3036 "Otherwise plain messages will be sent as "
3037 "public chat messages. To send a public chat "
3038 "message with this option enabled, prefix the "
3039 "message with a single colon ':'. This option "
3040 "can also be set using a toggle button beside "
3041 "the chat entry (only visible in multiplayer "
3042 "games)."),
3043 COC_INTERFACE, GUI_GTK4, FALSE, NULL),
3044 GEN_ENUM_OPTION(gui_gtk4_message_chat_location,
3045 N_("Messages and Chat reports location"),
3046 /* TRANS: The strings used in the UI for 'Split' etc are
3047 * tagged 'gui_gtk2/gtk3/gtk4_message_chat_location' */
3048 N_("Controls where the Messages and Chat reports "
3049 "appear relative to the main view containing the map.\n"
3050 "'Split' allows all three to be seen simultaneously, "
3051 "which is best for multiplayer, but requires a large "
3052 "window to be usable.\n"
3053 "'Separate' puts Messages and Chat in a notebook "
3054 "separate from the main view, so that one of them "
3055 "can always be seen alongside the main view.\n"
3056 "'Merged' makes the Messages and Chat reports into "
3057 "tabs alongside the map and other reports; this "
3058 "allows a larger map view on small screens.\n"
3059 "This option requires a restart in order to take "
3060 "effect."), COC_INTERFACE, GUI_GTK4,
3063 GEN_BOOL_OPTION(gui_gtk4_small_display_layout,
3064 N_("Arrange widgets for small displays"),
3065 N_("If this option is enabled, widgets in the main "
3066 "window will be arranged so that they take up the "
3067 "least amount of total screen space. Specifically, "
3068 "the left panel containing the overview, player "
3069 "status, and the unit information box will be "
3070 "extended over the entire left side of the window. "
3071 "This option requires a restart in order to take "
3072 "effect."), COC_INTERFACE, GUI_GTK4, FALSE, NULL),
3073 GEN_BOOL_OPTION(gui_gtk4_mouse_over_map_focus,
3074 N_("Mouse over the map widget selects it automatically"),
3075 N_("If this option is enabled, then the map will be "
3076 "focused when the mouse hovers over it."),
3077 COC_INTERFACE, GUI_GTK4, FALSE, NULL),
3078 GEN_BOOL_OPTION(gui_gtk4_chatline_autocompletion,
3079 N_("Player or user name autocompletion"),
3080 N_("If this option is turned on, the tabulation key "
3081 "will be used in the chatline to complete the word you "
3082 "are typing with the name of a player or a user."),
3083 COC_INTERFACE, GUI_GTK4, TRUE, NULL),
3084 GEN_INT_OPTION(gui_gtk4_citydlg_xsize,
3085 N_("Width of the city dialog"),
3086 N_("This value is only used if the width of the city "
3087 "dialog is saved."),
3090 NULL),
3091 GEN_INT_OPTION(gui_gtk4_citydlg_ysize,
3092 N_("Height of the city dialog"),
3093 N_("This value is only used if the height of the city "
3094 "dialog is saved."),
3097 NULL),
3098 GEN_ENUM_OPTION(gui_gtk4_popup_tech_help,
3099 N_("Popup tech help when gained"),
3100 N_("Controls if tech help should be opened when "
3101 "new tech has been gained.\n"
3102 "'Ruleset' means that behavior suggested by "
3103 "current ruleset is used."), COC_INTERFACE, GUI_GTK4,
3106 GEN_INT_OPTION(gui_gtk4_governor_range_min,
3107 N_("Minimum surplus for a governor"),
3108 N_("The lower limit of the range for requesting surpluses "
3109 "from the governor."),
3112 NULL),
3113 GEN_INT_OPTION(gui_gtk4_governor_range_max,
3114 N_("Maximum surplus for a governor"),
3115 N_("The higher limit of the range for requesting surpluses "
3116 "from the governor."),
3119 NULL),
3120 GEN_FONT_OPTION(gui_gtk4_font_city_label, "city_label",
3121 N_("City Label"),
3122 N_("This font is used to display the city labels on city "
3123 "dialogs."),
3124 COC_FONT, GUI_GTK4,
3125 "Monospace 8", font_changed_callback),
3126 GEN_FONT_OPTION(gui_gtk4_font_notify_label, "notify_label",
3127 N_("Notify Label"),
3128 N_("This font is used to display server reports such "
3129 "as the demographic report or historian publications."),
3130 COC_FONT, GUI_GTK4,
3131 "Monospace Bold 9", font_changed_callback),
3132 GEN_FONT_OPTION(gui_gtk4_font_spaceship_label, "spaceship_label",
3133 N_("Spaceship Label"),
3134 N_("This font is used to display the spaceship widgets."),
3135 COC_FONT, GUI_GTK4,
3136 "Monospace 8", font_changed_callback),
3137 GEN_FONT_OPTION(gui_gtk4_font_help_label, "help_label",
3138 N_("Help Label"),
3139 N_("This font is used to display the help headers in the "
3140 "help window."),
3141 COC_FONT, GUI_GTK4,
3142 "Sans Bold 10", font_changed_callback),
3143 GEN_FONT_OPTION(gui_gtk4_font_help_link, "help_link",
3144 N_("Help Link"),
3145 N_("This font is used to display the help links in the "
3146 "help window."),
3147 COC_FONT, GUI_GTK4,
3148 "Sans 9", font_changed_callback),
3149 GEN_FONT_OPTION(gui_gtk4_font_help_text, "help_text",
3150 N_("Help Text"),
3151 N_("This font is used to display the help body text in "
3152 "the help window."),
3153 COC_FONT, GUI_GTK4,
3154 "Monospace 8", font_changed_callback),
3155 GEN_FONT_OPTION(gui_gtk4_font_chatline, "chatline",
3156 N_("Chatline Area"),
3157 N_("This font is used to display the text in the "
3158 "chatline area."),
3159 COC_FONT, GUI_GTK4,
3160 "Monospace 8", font_changed_callback),
3161 GEN_FONT_OPTION(gui_gtk4_font_beta_label, "beta_label",
3162 N_("Beta Label"),
3163 N_("This font is used to display the beta label."),
3164 COC_FONT, GUI_GTK4,
3165 "Sans Italic 10", font_changed_callback),
3166 GEN_FONT_OPTION(gui_gtk4_font_small, "small_font",
3167 N_("Small Font"),
3168 N_("This font is used for any small font request. For "
3169 "example, it is used for display the building lists "
3170 "in the city dialog, the Economy report or the Units "
3171 "report."),
3172 COC_FONT, GUI_GTK4,
3173 "Sans 9", font_changed_callback),
3174 GEN_FONT_OPTION(gui_gtk4_font_comment_label, "comment_label",
3175 N_("Comment Label"),
3176 N_("This font is used to display comment labels, such as "
3177 "in the governor page of the city dialogs."),
3178 COC_FONT, GUI_GTK4,
3179 "Sans Italic 9", font_changed_callback),
3180 GEN_FONT_OPTION(gui_gtk4_font_city_names, "city_names",
3181 N_("City Names"),
3182 N_("This font is used to the display the city names "
3183 "on the map."),
3184 COC_FONT, GUI_GTK4,
3185 "Sans Bold 10", NULL),
3186 GEN_FONT_OPTION(gui_gtk4_font_city_productions, "city_productions",
3187 N_("City Productions"),
3188 N_("This font is used to display the city production "
3189 "on the map."),
3190 COC_FONT, GUI_GTK4,
3191 "Serif 10", NULL),
3192 GEN_FONT_OPTION(gui_gtk4_font_reqtree_text, "reqtree_text",
3193 N_("Requirement Tree"),
3194 N_("This font is used to the display the requirement tree "
3195 "in the Research report."),
3196 COC_FONT, GUI_GTK4,
3197 "Serif 10", NULL),
3198
3199 /* gui-sdl client specific options.
3200 * These are still kept just so users can migrate them to sdl2-client */
3201 GEN_BOOL_OPTION(gui_sdl_fullscreen, NULL, NULL,
3202 COC_INTERFACE, GUI_SDL, FALSE, NULL),
3203 GEN_VIDEO_OPTION(gui_sdl_screen, NULL, NULL,
3204 COC_INTERFACE, GUI_SDL, 640, 480, NULL),
3205 GEN_BOOL_OPTION(gui_sdl_do_cursor_animation, NULL, NULL,
3206 COC_INTERFACE, GUI_SDL, TRUE, NULL),
3207 GEN_BOOL_OPTION(gui_sdl_use_color_cursors, NULL, NULL,
3208 COC_INTERFACE, GUI_SDL, TRUE, NULL),
3209
3210 /* gui-sdl2 client specific options. */
3211 GEN_BOOL_OPTION(gui_sdl2_fullscreen, N_("Fullscreen"),
3212 N_("If this option is set the client will use the "
3213 "whole screen area for drawing."),
3214 COC_INTERFACE, GUI_SDL2, FALSE, NULL),
3215 GEN_VIDEO_OPTION(gui_sdl2_screen, N_("Screen resolution"),
3216 N_("This option controls the resolution of the "
3217 "selected screen."),
3218 COC_INTERFACE, GUI_SDL2, 640, 480, NULL),
3219 GEN_BOOL_OPTION(gui_sdl2_swrenderer, N_("Use software rendering"),
3220 N_("Usually hardware rendering is used when possible. "
3221 "With this option set, software rendering is always used."),
3222 COC_GRAPHICS, GUI_SDL2, FALSE, NULL),
3223 GEN_BOOL_OPTION(gui_sdl2_do_cursor_animation, N_("Do cursor animation"),
3224 N_("If this option is disabled, the cursor will "
3225 "always be displayed as static."),
3226 COC_INTERFACE, GUI_SDL2, TRUE, NULL),
3227 GEN_BOOL_OPTION(gui_sdl2_use_color_cursors, N_("Use color cursors"),
3228 N_("If this option is disabled, the cursor will "
3229 "always be displayed in black and white."),
3230 COC_INTERFACE, GUI_SDL2, TRUE, NULL),
3231 GEN_FONT_OPTION(gui_sdl2_font_city_names, "FONT_CITY_NAME",
3232 N_("City Names"),
3233 N_("The size of font used to the display the city names "
3234 "on the map."),
3235 COC_FONT, GUI_SDL2,
3236 "10", font_changed_callback),
3237 GEN_FONT_OPTION(gui_sdl2_font_city_productions, "FONT_CITY_PROD",
3238 N_("City Productions"),
3239 N_("The size of font used to the display the city "
3240 "production names on the map."),
3241 COC_FONT, GUI_SDL2,
3242 "10", font_changed_callback),
3243
3244 /* gui-qt client specific options. */
3245 GEN_BOOL_OPTION(gui_qt_fullscreen, N_("Fullscreen"),
3246 N_("If this option is set the client will use the "
3247 "whole screen area for drawing."),
3248 COC_INTERFACE, GUI_QT, FALSE, NULL),
3249 GEN_BOOL_OPTION(gui_qt_show_titlebar, N_("Show titlebar"),
3250 N_("If this option is set the client will show a titlebar. "
3251 "If disabled, then no titlebar will be shown, and "
3252 "minimize/maximize/etc buttons will be placed on the "
3253 "menu bar."),
3254 COC_INTERFACE, GUI_QT, TRUE, NULL),
3255 GEN_FONT_OPTION(gui_qt_font_default, "default_font",
3256 N_("Default font"),
3257 N_("This is default font"),
3258 COC_FONT, GUI_QT,
3259 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3260 GEN_FONT_OPTION(gui_qt_font_notify_label, "notify_label",
3261 N_("Notify Label"),
3262 N_("This font is used to display server reports such "
3263 "as the demographic report or historian publications."),
3264 COC_FONT, GUI_QT,
3265 "Monospace,9,-1,5,75,0,0,0,0,0", font_changed_callback),
3266 GEN_FONT_OPTION(gui_qt_font_help_label, "help_label",
3267 N_("Help Label"),
3268 N_("This font is used to display the help labels in the "
3269 "help window."),
3270 COC_FONT, GUI_QT,
3271 "Sans Serif,9,-1,5,50,0,0,0,0,0", font_changed_callback),
3272 GEN_FONT_OPTION(gui_qt_font_help_text, "help_text",
3273 N_("Help Text"),
3274 N_("This font is used to display the help body text in "
3275 "the help window."),
3276 COC_FONT, GUI_QT,
3277 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3278 GEN_FONT_OPTION(gui_qt_font_chatline, "chatline",
3279 N_("Chatline Area"),
3280 N_("This font is used to display the text in the "
3281 "chatline area."),
3282 COC_FONT, GUI_QT,
3283 "Monospace,8,-1,5,50,0,0,0,0,0", font_changed_callback),
3284 GEN_FONT_OPTION(gui_qt_font_city_names, "city_names",
3285 N_("City Names"),
3286 N_("This font is used to the display the city names "
3287 "on the map."),
3288 COC_FONT, GUI_QT,
3289 "Sans Serif,10,-1,5,75,0,0,0,0,0", font_changed_callback),
3290 GEN_FONT_OPTION(gui_qt_font_city_productions, "city_productions",
3291 N_("City Productions"),
3292 N_("This font is used to display the city production "
3293 "on the map."),
3294 COC_FONT, GUI_QT,
3295 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3296 GEN_FONT_OPTION(gui_qt_font_reqtree_text, "reqtree_text",
3297 N_("Requirement Tree"),
3298 N_("This font is used to the display the requirement tree "
3299 "in the Research report."),
3300 COC_FONT, GUI_QT,
3301 "Sans Serif,10,-1,5,50,1,0,0,0,0", font_changed_callback),
3302 GEN_BOOL_OPTION(gui_qt_show_preview, N_("Show savegame information"),
3303 N_("If this option is set the client will show "
3304 "information and map preview of current savegame."),
3305 COC_GRAPHICS, GUI_QT, TRUE, NULL),
3306 GEN_BOOL_OPTION(gui_qt_sidebar_left, N_("Sidebar position"),
3307 N_("If this option is set, the sidebar will be to the left "
3308 "of the map, otherwise to the right."),
3309 COC_INTERFACE, GUI_QT, TRUE, NULL),
3310 GEN_STR_OPTION(gui_qt_wakeup_text,
3311 N_("Wake up sequence"),
3312 N_("String which will trigger sound in pregame page; "
3313 "%1 stands for username."),
3314 COC_INTERFACE, GUI_QT, "Wake up %1", NULL, 0)
3315
3316};
3318
3319/* Iteration loop, including invalid options for the current gui type. */
3320#define client_options_iterate_all(poption) \
3321{ \
3322 const struct client_option *const poption##_max = \
3323 client_options + client_options_num; \
3324 struct client_option *client_##poption = client_options; \
3325 struct option *poption; \
3326 for (; client_##poption < poption##_max; client_##poption++) { \
3327 poption = OPTION(client_##poption);
3328
3329#define client_options_iterate_all_end \
3330 } \
3331}
3332
3333
3334/************************************************************************/
3337static struct client_option *
3339{
3340 const struct client_option *const max =
3342 const enum gui_type our_type = get_gui_type();
3343
3344 while (poption < max
3345 && poption->specific != GUI_STUB
3346 && poption->specific != our_type) {
3347 poption++;
3348 }
3349
3350 return (poption < max ? poption : NULL);
3351}
3352
3353/************************************************************************/
3357{
3358 if (0 > id || id > client_options_num) {
3359 return NULL;
3360 }
3361 return OPTION(client_options + id);
3362}
3363
3364/************************************************************************/
3371
3372/************************************************************************/
3376{
3377 return COC_MAX;
3378}
3379
3380/************************************************************************/
3383static const char *client_optset_category_name(int category)
3384{
3385 switch (category) {
3386 case COC_GRAPHICS:
3387 return _("Graphics");
3388 case COC_OVERVIEW:
3389 /* TRANS: Options section for overview map (mini-map) */
3390 return Q_("?map:Overview");
3391 case COC_SOUND:
3392 return _("Sound");
3393 case COC_INTERFACE:
3394 return _("Interface");
3395 case COC_MAPIMG:
3396 return _("Map Image");
3397 case COC_NETWORK:
3398 return _("Network");
3399 case COC_FONT:
3400 return _("Font");
3401 case COC_MAX:
3402 break;
3403 }
3404
3405 log_error("%s: invalid option category number %d.",
3406 __FUNCTION__, category);
3407 return NULL;
3408}
3409
3410/************************************************************************/
3413static int client_option_number(const struct option *poption)
3414{
3415 return CLIENT_OPTION(poption) - client_options;
3416}
3417
3418/************************************************************************/
3421static const char *client_option_name(const struct option *poption)
3422{
3423 return CLIENT_OPTION(poption)->name;
3424}
3425
3426/************************************************************************/
3429static const char *client_option_description(const struct option *poption)
3430{
3431 return _(CLIENT_OPTION(poption)->description);
3432}
3433
3434/************************************************************************/
3437static const char *client_option_help_text(const struct option *poption)
3438{
3439 return _(CLIENT_OPTION(poption)->help_text);
3440}
3441
3442/************************************************************************/
3445static int client_option_category(const struct option *poption)
3446{
3447 return CLIENT_OPTION(poption)->category;
3448}
3449
3450/************************************************************************/
3453static bool client_option_is_changeable(const struct option *poption)
3454{
3455 return TRUE;
3456}
3457
3458/************************************************************************/
3461static struct option *client_option_next(const struct option *poption)
3462{
3463 return OPTION(client_option_next_valid(CLIENT_OPTION(poption) + 1));
3464}
3465
3466/************************************************************************/
3469static bool client_option_bool_get(const struct option *poption)
3470{
3471 return *(CLIENT_OPTION(poption)->boolean.pvalue);
3472}
3473
3474/************************************************************************/
3477static bool client_option_bool_def(const struct option *poption)
3478{
3479 return CLIENT_OPTION(poption)->boolean.def;
3480}
3481
3482/************************************************************************/
3486static bool client_option_bool_set(struct option *poption, bool val)
3487{
3488 struct client_option *pcoption = CLIENT_OPTION(poption);
3489
3490 if (*pcoption->boolean.pvalue == val) {
3491 return FALSE;
3492 }
3493
3494 *pcoption->boolean.pvalue = val;
3495 return TRUE;
3496}
3497
3498/************************************************************************/
3501static int client_option_int_get(const struct option *poption)
3502{
3503 return *(CLIENT_OPTION(poption)->integer.pvalue);
3504}
3505
3506/************************************************************************/
3509static int client_option_int_def(const struct option *poption)
3510{
3511 return CLIENT_OPTION(poption)->integer.def;
3512}
3513
3514/************************************************************************/
3517static int client_option_int_min(const struct option *poption)
3518{
3519 return CLIENT_OPTION(poption)->integer.min;
3520}
3521
3522/************************************************************************/
3525static int client_option_int_max(const struct option *poption)
3526{
3527 return CLIENT_OPTION(poption)->integer.max;
3528}
3529
3530/************************************************************************/
3534static bool client_option_int_set(struct option *poption, int val)
3535{
3536 struct client_option *pcoption = CLIENT_OPTION(poption);
3537
3538 if (val < pcoption->integer.min
3539 || val > pcoption->integer.max
3540 || *pcoption->integer.pvalue == val) {
3541 return FALSE;
3542 }
3543
3544 *pcoption->integer.pvalue = val;
3545 return TRUE;
3546}
3547
3548/************************************************************************/
3551static const char *client_option_str_get(const struct option *poption)
3552{
3553 return CLIENT_OPTION(poption)->string.pvalue;
3554}
3555
3556/************************************************************************/
3559static const char *client_option_str_def(const struct option *poption)
3560{
3561 return CLIENT_OPTION(poption)->string.def;
3562}
3563
3564/************************************************************************/
3568static const struct strvec *
3569 client_option_str_values(const struct option *poption)
3570{
3571 return (CLIENT_OPTION(poption)->string.val_accessor
3572 ? CLIENT_OPTION(poption)->string.val_accessor(poption) : NULL);
3573}
3574
3575/************************************************************************/
3579static bool client_option_str_set(struct option *poption, const char *str)
3580{
3581 struct client_option *pcoption = CLIENT_OPTION(poption);
3582
3583 if (strlen(str) >= pcoption->string.size
3584 || 0 == strcmp(pcoption->string.pvalue, str)) {
3585 return FALSE;
3586 }
3587
3588 fc_strlcpy(pcoption->string.pvalue, str, pcoption->string.size);
3589 return TRUE;
3590}
3591
3592/************************************************************************/
3595static int client_option_enum_get(const struct option *poption)
3596{
3597 return *(CLIENT_OPTION(poption)->enumerator.pvalue);
3598}
3599
3600/************************************************************************/
3603static int client_option_enum_def(const struct option *poption)
3604{
3605 return CLIENT_OPTION(poption)->enumerator.def;
3606}
3607
3608/************************************************************************/
3612static const struct strvec *
3614{
3615 return CLIENT_OPTION(poption)->enumerator.pretty_names;
3616}
3617
3618/************************************************************************/
3622static bool client_option_enum_set(struct option *poption, int val)
3623{
3624 struct client_option *pcoption = CLIENT_OPTION(poption);
3625
3626 if (*pcoption->enumerator.pvalue == val
3627 || 0 > val
3628 || val >= strvec_size(pcoption->enumerator.support_names)) {
3629 return FALSE;
3630 }
3631
3632 *pcoption->enumerator.pvalue = val;
3633 return TRUE;
3634}
3635
3636/************************************************************************/
3642 int val)
3643{
3644 const struct strvec *names = CLIENT_OPTION(data)->enumerator.support_names;
3645
3646 return (0 <= val && val < strvec_size(names)
3647 ? strvec_get(names, val) : NULL);
3648}
3649
3650#if 0 /* There's no bitwise options currently */
3651/************************************************************************/
3654static unsigned client_option_bitwise_get(const struct option *poption)
3655{
3656 return *(CLIENT_OPTION(poption)->bitwise.pvalue);
3657}
3658
3659/************************************************************************/
3662static unsigned client_option_bitwise_def(const struct option *poption)
3663{
3664 return CLIENT_OPTION(poption)->bitwise.def;
3665}
3666
3667/************************************************************************/
3671static const struct strvec *
3672 client_option_bitwise_pretty_names(const struct option *poption)
3673{
3674 return CLIENT_OPTION(poption)->bitwise.pretty_names;
3675}
3676
3677/************************************************************************/
3681static bool client_option_bitwise_set(struct option *poption, unsigned val)
3682{
3683 struct client_option *pcoption = CLIENT_OPTION(poption);
3684
3685 if (*pcoption->bitwise.pvalue == val) {
3686 return FALSE;
3687 }
3688
3689 *pcoption->bitwise.pvalue = val;
3690 return TRUE;
3691}
3692#endif /* 0 */
3693
3694/************************************************************************/
3700 int val)
3701{
3702 const struct strvec *names = CLIENT_OPTION(data)->bitwise.support_names;
3703
3704 return (0 <= val && val < strvec_size(names)
3705 ? strvec_get(names, val) : NULL);
3706}
3707
3708/************************************************************************/
3711static const char *client_option_font_get(const struct option *poption)
3712{
3713 return CLIENT_OPTION(poption)->font.pvalue;
3714}
3715
3716/************************************************************************/
3719static const char *client_option_font_def(const struct option *poption)
3720{
3721 return CLIENT_OPTION(poption)->font.def;
3722}
3723
3724/************************************************************************/
3727static const char *client_option_font_target(const struct option *poption)
3728{
3729 return CLIENT_OPTION(poption)->font.target;
3730}
3731
3732/************************************************************************/
3736static bool client_option_font_set(struct option *poption, const char *font)
3737{
3738 struct client_option *pcoption = CLIENT_OPTION(poption);
3739
3740 if (strlen(font) >= pcoption->font.size
3741 || 0 == strcmp(pcoption->font.pvalue, font)) {
3742 return FALSE;
3743 }
3744
3745 fc_strlcpy(pcoption->font.pvalue, font, pcoption->font.size);
3746 return TRUE;
3747}
3748
3749/************************************************************************/
3752static struct ft_color client_option_color_get(const struct option *poption)
3753{
3754 return *CLIENT_OPTION(poption)->color.pvalue;
3755}
3756
3757/************************************************************************/
3760static struct ft_color client_option_color_def(const struct option *poption)
3761{
3762 return CLIENT_OPTION(poption)->color.def;
3763}
3764
3765/************************************************************************/
3769static bool client_option_color_set(struct option *poption,
3770 struct ft_color color)
3771{
3772 struct ft_color *pcolor = CLIENT_OPTION(poption)->color.pvalue;
3773 bool changed = FALSE;
3774
3775#define color_set(color_tgt, color) \
3776 if (NULL == color_tgt) { \
3777 if (NULL != color) { \
3778 color_tgt = fc_strdup(color); \
3779 changed = TRUE; \
3780 } \
3781 } else { \
3782 if (NULL == color) { \
3783 free((void *) color_tgt); \
3784 color_tgt = NULL; \
3785 changed = TRUE; \
3786 } else if (0 != strcmp(color_tgt, color)) { \
3787 free((void *) color_tgt); \
3788 color_tgt = fc_strdup(color); \
3789 changed = TRUE; \
3790 } \
3791 }
3792
3793 color_set(pcolor->foreground, color.foreground);
3794 color_set(pcolor->background, color.background);
3795
3796#undef color_set
3797
3798 return changed;
3799}
3800
3801/************************************************************************/
3804static struct video_mode
3806{
3807 return *CLIENT_OPTION(poption)->video_mode.pvalue;
3808}
3809
3810/************************************************************************/
3813static struct video_mode
3815{
3816 return CLIENT_OPTION(poption)->video_mode.def;
3817}
3818
3819/************************************************************************/
3823static bool client_option_video_mode_set(struct option *poption,
3824 struct video_mode mode)
3825{
3826 struct client_option *pcoption = CLIENT_OPTION(poption);
3827
3828 if (0 == memcmp(&mode, pcoption->video_mode.pvalue,
3829 sizeof(struct video_mode))) {
3830 return FALSE;
3831 }
3832
3833 *pcoption->video_mode.pvalue = mode;
3834 return TRUE;
3835}
3836
3837/************************************************************************/
3840static bool client_option_load(struct option *poption,
3841 struct section_file *sf)
3842{
3843 fc_assert_ret_val(NULL != poption, FALSE);
3844 fc_assert_ret_val(NULL != sf, FALSE);
3845
3846 switch (option_type(poption)) {
3847 case OT_BOOLEAN:
3848 {
3849 bool value;
3850
3851 return (secfile_lookup_bool(sf, &value, "client.%s",
3852 option_name(poption))
3853 && option_bool_set(poption, value));
3854 }
3855 case OT_INTEGER:
3856 {
3857 int value;
3858
3859 return (secfile_lookup_int(sf, &value, "client.%s",
3860 option_name(poption))
3861 && option_int_set(poption, value));
3862 }
3863 case OT_STRING:
3864 {
3865 const char *string;
3866
3867 return ((string = secfile_lookup_str(sf, "client.%s",
3868 option_name(poption)))
3869 && option_str_set(poption, string));
3870 }
3871 case OT_ENUM:
3872 {
3873 int value;
3874
3875 return (secfile_lookup_enum_data(sf, &value, FALSE,
3877 poption, "client.%s",
3878 option_name(poption))
3879 && option_enum_set_int(poption, value));
3880 }
3881 case OT_BITWISE:
3882 {
3883 int value;
3884
3885 return (secfile_lookup_enum_data(sf, &value, TRUE,
3887 poption, "client.%s",
3888 option_name(poption))
3889 && option_bitwise_set(poption, value));
3890 }
3891 case OT_FONT:
3892 {
3893 const char *string;
3894
3895 return ((string = secfile_lookup_str(sf, "client.%s",
3896 option_name(poption)))
3897 && option_font_set(poption, string));
3898 }
3899 case OT_COLOR:
3900 {
3901 struct ft_color color;
3902
3903 return ((color.foreground =
3904 secfile_lookup_str(sf, "client.%s.foreground",
3905 option_name(poption)))
3906 && (color.background =
3907 secfile_lookup_str(sf, "client.%s.background",
3908 option_name(poption)))
3909 && option_color_set(poption, color));
3910 }
3911 case OT_VIDEO_MODE:
3912 {
3913 struct video_mode mode;
3914
3915 return (secfile_lookup_int(sf, &mode.width, "client.%s.width",
3916 option_name(poption))
3917 && secfile_lookup_int(sf, &mode.height, "client.%s.height",
3918 option_name(poption))
3919 && option_video_mode_set(poption, mode));
3920 }
3921 }
3922 return FALSE;
3923}
3924
3925/************************************************************************/
3928static void client_option_save(struct option *poption,
3929 struct section_file *sf)
3930{
3931 fc_assert_ret(NULL != poption);
3932 fc_assert_ret(NULL != sf);
3933
3934 switch (option_type(poption)) {
3935 case OT_BOOLEAN:
3937 "client.%s", option_name(poption));
3938 break;
3939 case OT_INTEGER:
3941 "client.%s", option_name(poption));
3942 break;
3943 case OT_STRING:
3945 "client.%s", option_name(poption));
3946 break;
3947 case OT_ENUM:
3950 "client.%s", option_name(poption));
3951 break;
3952 case OT_BITWISE:
3955 "client.%s", option_name(poption));
3956 break;
3957 case OT_FONT:
3959 "client.%s", option_name(poption));
3960 break;
3961 case OT_COLOR:
3962 {
3963 struct ft_color color = option_color_get(poption);
3964
3965 secfile_insert_str(sf, color.foreground, "client.%s.foreground",
3966 option_name(poption));
3967 secfile_insert_str(sf, color.background, "client.%s.background",
3968 option_name(poption));
3969 }
3970 break;
3971 case OT_VIDEO_MODE:
3972 {
3973 struct video_mode mode = option_video_mode_get(poption);
3974
3975 secfile_insert_int(sf, mode.width, "client.%s.width",
3976 option_name(poption));
3977 secfile_insert_int(sf, mode.height, "client.%s.height",
3978 option_name(poption));
3979 }
3980 break;
3981 }
3982}
3983
3984
3985/****************************************************************************
3986 Server options variables.
3987****************************************************************************/
3988static char **server_options_categories = NULL;
3989static struct server_option *server_options = NULL;
3990
3992static int server_options_num = 0;
3993
3994
3995/****************************************************************************
3996 Server option set.
3997****************************************************************************/
3998static struct option *server_optset_option_by_number(int id);
3999static struct option *server_optset_option_first(void);
4000static int server_optset_category_number(void);
4001static const char *server_optset_category_name(int category);
4002
4005 .option_first = server_optset_option_first,
4006 .category_number = server_optset_category_number,
4007 .category_name = server_optset_category_name
4008};
4010
4011
4012/****************************************************************************
4013 Virtuals tables for the client options.
4014****************************************************************************/
4015static int server_option_number(const struct option *poption);
4016static const char *server_option_name(const struct option *poption);
4017static const char *server_option_description(const struct option *poption);
4018static const char *server_option_help_text(const struct option *poption);
4019static int server_option_category(const struct option *poption);
4020static bool server_option_is_changeable(const struct option *poption);
4021static struct option *server_option_next(const struct option *poption);
4022
4023static const struct option_common_vtable server_option_common_vtable = {
4024 .number = server_option_number,
4025 .name = server_option_name,
4026 .description = server_option_description,
4027 .help_text = server_option_help_text,
4028 .category = server_option_category,
4029 .is_changeable = server_option_is_changeable,
4030 .next = server_option_next
4031};
4032
4033static bool server_option_bool_get(const struct option *poption);
4034static bool server_option_bool_def(const struct option *poption);
4035static bool server_option_bool_set(struct option *poption, bool val);
4036
4037static const struct option_bool_vtable server_option_bool_vtable = {
4041};
4042
4043static int server_option_int_get(const struct option *poption);
4044static int server_option_int_def(const struct option *poption);
4045static int server_option_int_min(const struct option *poption);
4046static int server_option_int_max(const struct option *poption);
4047static bool server_option_int_set(struct option *poption, int val);
4048
4049static const struct option_int_vtable server_option_int_vtable = {
4050 .get = server_option_int_get,
4051 .def = server_option_int_def,
4052 .minimum = server_option_int_min,
4053 .maximum = server_option_int_max,
4055};
4056
4057static const char *server_option_str_get(const struct option *poption);
4058static const char *server_option_str_def(const struct option *poption);
4059static const struct strvec *
4060 server_option_str_values(const struct option *poption);
4061static bool server_option_str_set(struct option *poption, const char *str);
4062
4063static const struct option_str_vtable server_option_str_vtable = {
4064 .get = server_option_str_get,
4065 .def = server_option_str_def,
4066 .values = server_option_str_values,
4068};
4069
4070static int server_option_enum_get(const struct option *poption);
4071static int server_option_enum_def(const struct option *poption);
4072static const struct strvec *
4073 server_option_enum_pretty(const struct option *poption);
4074static bool server_option_enum_set(struct option *poption, int val);
4075
4076static const struct option_enum_vtable server_option_enum_vtable = {
4079 .values = server_option_enum_pretty,
4081 .cmp = strcmp
4082};
4083
4084static unsigned server_option_bitwise_get(const struct option *poption);
4085static unsigned server_option_bitwise_def(const struct option *poption);
4086static const struct strvec *
4087 server_option_bitwise_pretty(const struct option *poption);
4088static bool server_option_bitwise_set(struct option *poption, unsigned val);
4089
4090static const struct option_bitwise_vtable server_option_bitwise_vtable = {
4095};
4096
4097/****************************************************************************
4098 Derived class server option, inheriting from base class option.
4099****************************************************************************/
4101 struct option base_option; /* Base structure, must be the first! */
4102
4103 char *name; /* Short name - used as an identifier */
4104 char *description; /* One-line description */
4105 char *help_text; /* Paragraph-length help text */
4106 unsigned char category;
4110 enum setting_default_level setdef;
4111
4112 union {
4113 /* OT_BOOLEAN type option. */
4114 struct {
4115 bool value;
4116 bool def;
4117 } boolean;
4118 /* OT_INTEGER type option. */
4119 struct {
4121 int def, min, max;
4122 } integer;
4123 /* OT_STRING type option. */
4124 struct {
4125 char *value;
4126 char *def;
4127 } string;
4128 /* OT_ENUM type option. */
4129 struct {
4130 int value;
4131 int def;
4133 struct strvec *pretty_names; /* untranslated */
4134 } enumerator;
4135 /* OT_BITWISE type option. */
4136 struct {
4137 unsigned value;
4138 unsigned def;
4139 struct strvec *support_names;
4140 struct strvec *pretty_names; /* untranslated */
4141 } bitwise;
4142 };
4143};
4144
4145#define SERVER_OPTION(poption) ((struct server_option *) (poption))
4146
4147static void desired_settable_option_send(struct option *poption);
4148
4149
4150/************************************************************************/
4160
4161/************************************************************************/
4164static void server_option_free(struct server_option *poption)
4165{
4166 option_gui_remove(&(poption->base_option));
4167
4168 switch (poption->base_option.type) {
4169 case OT_STRING:
4170 if (NULL != poption->string.value) {
4171 FC_FREE(poption->string.value);
4172 }
4173 if (NULL != poption->string.def) {
4174 FC_FREE(poption->string.def);
4175 }
4176 break;
4177
4178 case OT_ENUM:
4179 if (NULL != poption->enumerator.support_names) {
4181 poption->enumerator.support_names = NULL;
4182 }
4183 if (NULL != poption->enumerator.pretty_names) {
4185 poption->enumerator.pretty_names = NULL;
4186 }
4187 break;
4188
4189 case OT_BITWISE:
4190 if (NULL != poption->bitwise.support_names) {
4192 poption->bitwise.support_names = NULL;
4193 }
4194 if (NULL != poption->bitwise.pretty_names) {
4196 poption->bitwise.pretty_names = NULL;
4197 }
4198 break;
4199
4200 case OT_BOOLEAN:
4201 case OT_INTEGER:
4202 case OT_FONT:
4203 case OT_COLOR:
4204 case OT_VIDEO_MODE:
4205 break;
4206 }
4207
4208 if (NULL != poption->name) {
4209 FC_FREE(poption->name);
4210 }
4211 if (NULL != poption->description) {
4212 FC_FREE(poption->description);
4213 }
4214 if (NULL != poption->help_text) {
4215 FC_FREE(poption->help_text);
4216 }
4217}
4218
4219/************************************************************************/
4223{
4224 int i;
4225
4226 /* Don't keep this dialog open. */
4228
4229 /* Free the options themselves. */
4230 if (NULL != server_options) {
4231 for (i = 0; i < server_options_num; i++) {
4233 }
4236 }
4237
4238 /* Free the categories. */
4239 if (NULL != server_options_categories) {
4240 for (i = 0; i < server_options_categories_num; i++) {
4241 if (NULL != server_options_categories[i]) {
4243 }
4244 }
4247 }
4248}
4249
4250/************************************************************************/
4254 (const struct packet_server_setting_control *packet)
4255{
4256 int i;
4257
4258 /* This packet should be received only once. */
4263
4264 /* Allocate server option categories. */
4265 if (0 < packet->categories_num) {
4269 sizeof(*server_options_categories));
4270
4271 for (i = 0; i < server_options_categories_num; i++) {
4272 /* NB: Translate now. */
4274 }
4275 }
4276
4277 /* Allocate server options. */
4278 if (0 < packet->settings_num) {
4281 }
4282}
4283
4284/************************************************************************/
4288 (const struct packet_server_setting_const *packet)
4289{
4290 struct option *poption = server_optset_option_by_number(packet->id);
4291 struct server_option *psoption = SERVER_OPTION(poption);
4292
4293 fc_assert_ret(NULL != poption);
4294
4295 fc_assert(NULL == psoption->name);
4296 psoption->name = fc_strdup(packet->name);
4297 fc_assert(NULL == psoption->description);
4298 /* NB: Translate now. */
4299 psoption->description = fc_strdup(_(packet->short_help));
4300 fc_assert(NULL == psoption->help_text);
4301 /* NB: Translate now. */
4302 psoption->help_text = fc_strdup(_(packet->extra_help));
4303 psoption->category = packet->category;
4304}
4305
4306/****************************************************************************
4307 Common part of handle_server_setting_*() functions. See below.
4308****************************************************************************/
4309#define handle_server_setting_common(psoption, packet) \
4310 psoption->is_changeable = packet->is_changeable; \
4311 psoption->setdef = packet->setdef; \
4312 if (psoption->is_visible != packet->is_visible) { \
4313 if (psoption->is_visible) { \
4314 need_gui_remove = TRUE; \
4315 } else if (packet->is_visible) { \
4316 need_gui_add = TRUE; \
4317 } \
4318 psoption->is_visible = packet->is_visible; \
4319 } \
4320 \
4321 /* Keep this list of conditions in sync with one in \
4322 resend_desired_settable_options() */ \
4323 if (!psoption->desired_sent \
4324 && psoption->is_visible \
4325 && psoption->is_changeable \
4326 && is_server_running() \
4327 && packet->initial_setting) { \
4328 /* Only send our private settings if we are running \
4329 * on a forked local server, i.e. started by the \
4330 * client with the "Start New Game" button. \
4331 * Do now override settings that are already saved to savegame \
4332 * and now loaded. */ \
4333 desired_settable_option_send(OPTION(poption)); \
4334 psoption->desired_sent = TRUE; \
4335 } \
4336 \
4337 /* Update the GUI. */ \
4338 if (need_gui_remove) { \
4339 option_gui_remove(poption); \
4340 } else if (need_gui_add) { \
4341 option_gui_add(poption); \
4342 } else { \
4343 option_gui_update(poption); \
4345
4346/************************************************************************/
4350 (const struct packet_server_setting_bool *packet)
4351{
4352 struct option *poption = server_optset_option_by_number(packet->id);
4353 struct server_option *psoption = SERVER_OPTION(poption);
4354 bool need_gui_remove = FALSE;
4355 bool need_gui_add = FALSE;
4356
4357 fc_assert_ret(NULL != poption);
4358
4359 if (NULL == poption->common_vtable) {
4360 /* Not initialized yet. */
4361 poption->poptset = server_optset;
4363 poption->type = OT_BOOLEAN;
4365 }
4366 fc_assert_ret_msg(OT_BOOLEAN == poption->type,
4367 "Server setting \"%s\" (nb %d) has type %s (%d), "
4368 "expected %s (%d)",
4369 option_name(poption), option_number(poption),
4370 option_type_name(poption->type), poption->type,
4371 option_type_name(OT_BOOLEAN), OT_BOOLEAN);
4372
4373 if (packet->is_visible) {
4374 psoption->boolean.value = packet->val;
4375 psoption->boolean.def = packet->default_val;
4376 }
4377
4378 handle_server_setting_common(psoption, packet);
4380
4381/************************************************************************/
4385 (const struct packet_server_setting_int *packet)
4386{
4387 struct option *poption = server_optset_option_by_number(packet->id);
4388 struct server_option *psoption = SERVER_OPTION(poption);
4389 bool need_gui_remove = FALSE;
4390 bool need_gui_add = FALSE;
4391
4392 fc_assert_ret(NULL != poption);
4393
4394 if (NULL == poption->common_vtable) {
4395 /* Not initialized yet. */
4396 poption->poptset = server_optset;
4398 poption->type = OT_INTEGER;
4400 }
4401 fc_assert_ret_msg(OT_INTEGER == poption->type,
4402 "Server setting \"%s\" (nb %d) has type %s (%d), "
4403 "expected %s (%d)",
4404 option_name(poption), option_number(poption),
4405 option_type_name(poption->type), poption->type,
4406 option_type_name(OT_INTEGER), OT_INTEGER);
4407
4408 if (packet->is_visible) {
4409 psoption->integer.value = packet->val;
4410 psoption->integer.def = packet->default_val;
4411 psoption->integer.min = packet->min_val;
4412 psoption->integer.max = packet->max_val;
4413 }
4414
4415 handle_server_setting_common(psoption, packet);
4417
4418/************************************************************************/
4422 (const struct packet_server_setting_str *packet)
4423{
4424 struct option *poption = server_optset_option_by_number(packet->id);
4425 struct server_option *psoption = SERVER_OPTION(poption);
4426 bool need_gui_remove = FALSE;
4427 bool need_gui_add = FALSE;
4428
4429 fc_assert_ret(NULL != poption);
4430
4431 if (NULL == poption->common_vtable) {
4432 /* Not initialized yet. */
4433 poption->poptset = server_optset;
4435 poption->type = OT_STRING;
4437 }
4438 fc_assert_ret_msg(OT_STRING == poption->type,
4439 "Server setting \"%s\" (nb %d) has type %s (%d), "
4440 "expected %s (%d)",
4441 option_name(poption), option_number(poption),
4442 option_type_name(poption->type), poption->type,
4443 option_type_name(OT_STRING), OT_STRING);
4444
4445 if (packet->is_visible) {
4446 if (NULL == psoption->string.value) {
4447 psoption->string.value = fc_strdup(packet->val);
4448 } else if (0 != strcmp(packet->val, psoption->string.value)) {
4449 free(psoption->string.value);
4450 psoption->string.value = fc_strdup(packet->val);
4451 }
4452 if (NULL == psoption->string.def) {
4453 psoption->string.def = fc_strdup(packet->default_val);
4454 } else if (0 != strcmp(packet->default_val, psoption->string.def)) {
4455 free(psoption->string.def);
4456 psoption->string.def = fc_strdup(packet->default_val);
4457 }
4458 }
4459
4460 handle_server_setting_common(psoption, packet);
4462
4463/************************************************************************/
4467 (const struct packet_server_setting_enum *packet)
4468{
4469 struct option *poption = server_optset_option_by_number(packet->id);
4470 struct server_option *psoption = SERVER_OPTION(poption);
4471 bool need_gui_remove = FALSE;
4472 bool need_gui_add = FALSE;
4473
4474 fc_assert_ret(NULL != poption);
4475
4476 if (NULL == poption->common_vtable) {
4477 /* Not initialized yet. */
4478 poption->poptset = server_optset;
4480 poption->type = OT_ENUM;
4482 }
4483 fc_assert_ret_msg(OT_ENUM == poption->type,
4484 "Server setting \"%s\" (nb %d) has type %s (%d), "
4485 "expected %s (%d)",
4486 option_name(poption), option_number(poption),
4487 option_type_name(poption->type), poption->type,
4488 option_type_name(OT_ENUM), OT_ENUM);
4489
4490 if (packet->is_visible) {
4491 int i;
4492
4493 psoption->enumerator.value = packet->val;
4494 psoption->enumerator.def = packet->default_val;
4495
4496 if (NULL == psoption->enumerator.support_names) {
4497 /* First time we get this packet. */
4498 fc_assert(NULL == psoption->enumerator.pretty_names);
4499 psoption->enumerator.support_names = strvec_new();
4501 psoption->enumerator.pretty_names = strvec_new();
4503 for (i = 0; i < packet->values_num; i++) {
4504 strvec_set(psoption->enumerator.support_names, i,
4505 packet->support_names[i]);
4506 /* Store untranslated string from server. */
4507 strvec_set(psoption->enumerator.pretty_names, i,
4508 packet->pretty_names[i]);
4509 }
4510 } else if (strvec_size(psoption->enumerator.support_names)
4511 != packet->values_num) {
4513 == strvec_size(psoption->enumerator.pretty_names));
4514 /* The number of values have changed, we need to reset the list
4515 * of possible values. */
4518 for (i = 0; i < packet->values_num; i++) {
4519 strvec_set(psoption->enumerator.support_names, i,
4520 packet->support_names[i]);
4521 /* Store untranslated string from server. */
4522 strvec_set(psoption->enumerator.pretty_names, i,
4523 packet->pretty_names[i]);
4524 }
4525 need_gui_remove = TRUE;
4526 need_gui_add = TRUE;
4527 } else {
4528 /* Check if a value changed, then we need to reset the list
4529 * of possible values. */
4530 const char *str;
4531
4532 for (i = 0; i < packet->values_num; i++) {
4533 str = strvec_get(psoption->enumerator.pretty_names, i);
4534 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4535 /* Store untranslated string from server. */
4536 strvec_set(psoption->enumerator.pretty_names, i,
4537 packet->pretty_names[i]);
4538 need_gui_remove = TRUE;
4539 need_gui_add = TRUE;
4540 }
4541 /* Support names are not visible, we don't need to check if it
4542 * has changed. */
4543 strvec_set(psoption->enumerator.support_names, i,
4544 packet->support_names[i]);
4545 }
4546 }
4547 }
4548
4549 handle_server_setting_common(psoption, packet);
4551
4552/************************************************************************/
4556 (const struct packet_server_setting_bitwise *packet)
4557{
4558 struct option *poption = server_optset_option_by_number(packet->id);
4559 struct server_option *psoption = SERVER_OPTION(poption);
4560 bool need_gui_remove = FALSE;
4561 bool need_gui_add = FALSE;
4562
4563 fc_assert_ret(NULL != poption);
4564
4565 if (NULL == poption->common_vtable) {
4566 /* Not initialized yet. */
4567 poption->poptset = server_optset;
4569 poption->type = OT_BITWISE;
4571 }
4572 fc_assert_ret_msg(OT_BITWISE == poption->type,
4573 "Server setting \"%s\" (nb %d) has type %s (%d), "
4574 "expected %s (%d)",
4575 option_name(poption), option_number(poption),
4576 option_type_name(poption->type), poption->type,
4577 option_type_name(OT_BITWISE), OT_BITWISE);
4578
4579 if (packet->is_visible) {
4580 int i;
4581
4582 psoption->bitwise.value = packet->val;
4583 psoption->bitwise.def = packet->default_val;
4584
4585 if (NULL == psoption->bitwise.support_names) {
4586 /* First time we get this packet. */
4587 fc_assert(NULL == psoption->bitwise.pretty_names);
4588 psoption->bitwise.support_names = strvec_new();
4589 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4590 psoption->bitwise.pretty_names = strvec_new();
4591 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4592 for (i = 0; i < packet->bits_num; i++) {
4593 strvec_set(psoption->bitwise.support_names, i,
4594 packet->support_names[i]);
4595 /* Store untranslated string from server. */
4596 strvec_set(psoption->bitwise.pretty_names, i,
4597 packet->pretty_names[i]);
4598 }
4599 } else if (strvec_size(psoption->bitwise.support_names)
4600 != packet->bits_num) {
4602 == strvec_size(psoption->bitwise.pretty_names));
4603 /* The number of values have changed, we need to reset the list
4604 * of possible values. */
4605 strvec_reserve(psoption->bitwise.support_names, packet->bits_num);
4606 strvec_reserve(psoption->bitwise.pretty_names, packet->bits_num);
4607 for (i = 0; i < packet->bits_num; i++) {
4608 strvec_set(psoption->bitwise.support_names, i,
4609 packet->support_names[i]);
4610 /* Store untranslated string from server. */
4611 strvec_set(psoption->bitwise.pretty_names, i,
4612 packet->pretty_names[i]);
4613 }
4614 need_gui_remove = TRUE;
4615 need_gui_add = TRUE;
4616 } else {
4617 /* Check if a value changed, then we need to reset the list
4618 * of possible values. */
4619 const char *str;
4620
4621 for (i = 0; i < packet->bits_num; i++) {
4622 str = strvec_get(psoption->bitwise.pretty_names, i);
4623 if (NULL == str || 0 != strcmp(str, packet->pretty_names[i])) {
4624 /* Store untranslated string from server. */
4625 strvec_set(psoption->bitwise.pretty_names, i,
4626 packet->pretty_names[i]);
4627 need_gui_remove = TRUE;
4628 need_gui_add = TRUE;
4629 }
4630 /* Support names are not visible, we don't need to check if it
4631 * has changed. */
4632 strvec_set(psoption->bitwise.support_names, i,
4633 packet->support_names[i]);
4634 }
4635 }
4636 }
4637
4638 handle_server_setting_common(psoption, packet);
4639}
4641/************************************************************************/
4644static struct server_option *
4646{
4647 if (server_options != NULL) {
4648 const struct server_option *const max =
4650
4651 while (NULL != poption && poption < max && !poption->is_visible) {
4652 poption++;
4653 }
4654
4655 return (poption < max ? poption : NULL);
4656 }
4657
4658 return NULL;
4660
4661/************************************************************************/
4665{
4666 if (0 > id || id > server_options_num) {
4667 return NULL;
4668 }
4669 return OPTION(server_options + id);
4671
4672/************************************************************************/
4676{
4679
4680/************************************************************************/
4684{
4687
4688/************************************************************************/
4691const char *server_optset_category_name(int category)
4692{
4693 if (0 > category || category >= server_options_categories_num) {
4694 return NULL;
4695 }
4696
4697 return server_options_categories[category];
4699
4700/************************************************************************/
4703static int server_option_number(const struct option *poption)
4704{
4705 return SERVER_OPTION(poption) - server_options;
4707
4708/************************************************************************/
4711static const char *server_option_name(const struct option *poption)
4712{
4713 return SERVER_OPTION(poption)->name;
4715
4716/************************************************************************/
4719static const char *server_option_description(const struct option *poption)
4720{
4721 return SERVER_OPTION(poption)->description;
4723
4724/************************************************************************/
4727static const char *server_option_help_text(const struct option *poption)
4728{
4729 return SERVER_OPTION(poption)->help_text;
4731
4732/************************************************************************/
4735static int server_option_category(const struct option *poption)
4736{
4737 return SERVER_OPTION(poption)->category;
4739
4740/************************************************************************/
4743static bool server_option_is_changeable(const struct option *poption)
4744{
4745 return SERVER_OPTION(poption)->is_changeable;
4747
4748/************************************************************************/
4751static struct option *server_option_next(const struct option *poption)
4752{
4753 return OPTION(server_option_next_valid(SERVER_OPTION(poption) + 1));
4755
4756/************************************************************************/
4759static bool server_option_bool_get(const struct option *poption)
4760{
4761 return SERVER_OPTION(poption)->boolean.value;
4763
4764/************************************************************************/
4767static bool server_option_bool_def(const struct option *poption)
4768{
4769 return SERVER_OPTION(poption)->boolean.def;
4770}
4772/************************************************************************/
4776static bool server_option_bool_set(struct option *poption, bool val)
4777{
4778 struct server_option *psoption = SERVER_OPTION(poption);
4779
4780 if (psoption->boolean.value == val) {
4781 return FALSE;
4782 }
4783
4784 send_chat_printf("/set %s %s", psoption->name,
4785 val ? "enabled" : "disabled");
4786 return TRUE;
4788
4789/************************************************************************/
4792static int server_option_int_get(const struct option *poption)
4793{
4794 return SERVER_OPTION(poption)->integer.value;
4796
4797/************************************************************************/
4800static int server_option_int_def(const struct option *poption)
4801{
4802 return SERVER_OPTION(poption)->integer.def;
4804
4805/************************************************************************/
4808static int server_option_int_min(const struct option *poption)
4809{
4810 return SERVER_OPTION(poption)->integer.min;
4812
4813/************************************************************************/
4816static int server_option_int_max(const struct option *poption)
4817{
4818 return SERVER_OPTION(poption)->integer.max;
4819}
4821/************************************************************************/
4825static bool server_option_int_set(struct option *poption, int val)
4826{
4827 struct server_option *psoption = SERVER_OPTION(poption);
4828
4829 if (val < psoption->integer.min
4830 || val > psoption->integer.max
4831 || psoption->integer.value == val) {
4832 return FALSE;
4833 }
4834
4835 send_chat_printf("/set %s %d", psoption->name, val);
4836 return TRUE;
4838
4839/************************************************************************/
4842static const char *server_option_str_get(const struct option *poption)
4843{
4844 return SERVER_OPTION(poption)->string.value;
4846
4847/************************************************************************/
4850static const char *server_option_str_def(const struct option *poption)
4851{
4852 return SERVER_OPTION(poption)->string.def;
4853}
4854
4855/************************************************************************/
4859static const struct strvec *
4860 server_option_str_values(const struct option *poption)
4861{
4862 return NULL;
4863}
4865/************************************************************************/
4869static bool server_option_str_set(struct option *poption, const char *str)
4870{
4871 struct server_option *psoption = SERVER_OPTION(poption);
4872
4873 if (0 == strcmp(psoption->string.value, str)) {
4874 return FALSE;
4875 }
4876
4877 send_chat_printf("/set %s \"%s\"", psoption->name, str);
4878 return TRUE;
4880
4881/************************************************************************/
4884static int server_option_enum_get(const struct option *poption)
4885{
4886 return SERVER_OPTION(poption)->enumerator.value;
4888
4889/************************************************************************/
4892static int server_option_enum_def(const struct option *poption)
4893{
4894 return SERVER_OPTION(poption)->enumerator.def;
4895}
4896
4897/************************************************************************/
4901static const struct strvec *
4902 server_option_enum_pretty(const struct option *poption)
4903{
4904 return SERVER_OPTION(poption)->enumerator.pretty_names;
4905}
4907/************************************************************************/
4911static bool server_option_enum_set(struct option *poption, int val)
4912{
4913 struct server_option *psoption = SERVER_OPTION(poption);
4914 const char *name;
4915
4916 if (val == psoption->enumerator.value
4917 || !(name = strvec_get(psoption->enumerator.support_names, val))) {
4918 return FALSE;
4919 }
4920
4921 send_chat_printf("/set %s \"%s\"", psoption->name, name);
4922 return TRUE;
4923}
4925/************************************************************************/
4929static void server_option_enum_support_name(const struct option *poption,
4930 const char **pvalue,
4931 const char **pdefault)
4932{
4933 const struct server_option *psoption = SERVER_OPTION(poption);
4934 const struct strvec *values = psoption->enumerator.support_names;
4935
4936 if (NULL != pvalue) {
4937 *pvalue = strvec_get(values, psoption->enumerator.value);
4938 }
4939 if (NULL != pdefault) {
4940 *pdefault = strvec_get(values, psoption->enumerator.def);
4941 }
4943
4944/************************************************************************/
4947static unsigned server_option_bitwise_get(const struct option *poption)
4948{
4949 return SERVER_OPTION(poption)->bitwise.value;
4951
4952/************************************************************************/
4955static unsigned server_option_bitwise_def(const struct option *poption)
4956{
4957 return SERVER_OPTION(poption)->bitwise.def;
4958}
4959
4960/************************************************************************/
4964static const struct strvec *
4965 server_option_bitwise_pretty(const struct option *poption)
4966{
4967 return SERVER_OPTION(poption)->bitwise.pretty_names;
4969
4970/************************************************************************/
4973static void server_option_bitwise_support_base(const struct strvec *values,
4974 unsigned val,
4975 char *buf, size_t buf_len)
4976{
4977 int bit;
4978
4979 buf[0] = '\0';
4980 for (bit = 0; bit < strvec_size(values); bit++) {
4981 if ((1 << bit) & val) {
4982 if ('\0' != buf[0]) {
4983 fc_strlcat(buf, "|", buf_len);
4984 }
4985 fc_strlcat(buf, strvec_get(values, bit), buf_len);
4986 }
4987 }
4988}
4990/************************************************************************/
4994static bool server_option_bitwise_set(struct option *poption, unsigned val)
4995{
4996 struct server_option *psoption = SERVER_OPTION(poption);
4997 char name[MAX_LEN_MSG];
4998
4999 if (val == psoption->bitwise.value) {
5000 return FALSE;
5001 }
5002
5004 name, sizeof(name));
5005 send_chat_printf("/set %s \"%s\"", psoption->name, name);
5006 return TRUE;
5007}
5009/************************************************************************/
5013static void server_option_bitwise_support_name(const struct option *poption,
5014 char *val_buf, size_t val_len,
5015 char *def_buf, size_t def_len)
5016{
5017 const struct server_option *psoption = SERVER_OPTION(poption);
5018 const struct strvec *values = psoption->bitwise.support_names;
5019
5020 if (NULL != val_buf && 0 < val_len) {
5022 val_buf, val_len);
5023 }
5024 if (NULL != def_buf && 0 < def_len) {
5026 def_buf, def_len);
5027 }
5029
5030
5033int messages_where[E_COUNT];
5034
5036/************************************************************************/
5040static void message_options_init(void)
5041{
5042 int none[] = {
5043 E_IMP_BUY, E_IMP_SOLD, E_UNIT_BUY,
5044 E_UNIT_LOST_ATT, E_UNIT_WIN_ATT, E_GAME_START,
5045 E_CITY_BUILD, E_NEXT_YEAR,
5046 E_CITY_PRODUCTION_CHANGED,
5047 E_CITY_MAY_SOON_GROW, E_WORKLIST, E_AI_DEBUG
5048 };
5049 int out_only[] = {
5050 E_NATION_SELECTED, E_CHAT_MSG, E_CHAT_ERROR, E_CONNECTION,
5051 E_LOG_ERROR, E_SETTING, E_VOTE_NEW, E_VOTE_RESOLVED, E_VOTE_ABORTED
5052 };
5053 int all[] = {
5054 E_LOG_FATAL, E_SCRIPT, E_DEPRECATION_WARNING, E_MESSAGE_WALL
5055 };
5056 int i;
5057
5058 for (i = 0; i <= event_type_max(); i++) {
5059 /* Include possible undefined values. */
5061 }
5062 for (i = 0; i < ARRAY_SIZE(none); i++) {
5063 messages_where[none[i]] = 0;
5064 }
5065 for (i = 0; i < ARRAY_SIZE(out_only); i++) {
5066 messages_where[out_only[i]] = MW_OUTPUT;
5067 }
5068 for (i = 0; i < ARRAY_SIZE(all); i++) {
5070 }
5071
5072 events_init();
5074
5075/************************************************************************/
5078static void message_options_free(void)
5079{
5080 events_free();
5081}
5083/************************************************************************/
5087static void message_options_load(struct section_file *file,
5088 const char *prefix)
5089{
5090 enum event_type event;
5091 int i, num_events;
5092 const char *p;
5093
5094 if (!secfile_lookup_int(file, &num_events, "messages.count")) {
5095 /* version < 2.2 */
5096 /* Order of the events in 2.1. */
5097 const enum event_type old_events[] = {
5098 E_CITY_CANTBUILD, E_CITY_LOST, E_CITY_LOVE, E_CITY_DISORDER,
5099 E_CITY_FAMINE, E_CITY_FAMINE_FEARED, E_CITY_GROWTH,
5100 E_CITY_MAY_SOON_GROW, E_CITY_AQUEDUCT, E_CITY_AQ_BUILDING,
5101 E_CITY_NORMAL, E_CITY_NUKED, E_CITY_CMA_RELEASE, E_CITY_GRAN_THROTTLE,
5102 E_CITY_TRANSFER, E_CITY_BUILD, E_CITY_PRODUCTION_CHANGED,
5103 E_WORKLIST, E_UPRISING, E_CIVIL_WAR, E_ANARCHY, E_FIRST_CONTACT,
5104 E_NEW_GOVERNMENT, E_LOW_ON_FUNDS, E_POLLUTION, E_REVOLT_DONE,
5105 E_REVOLT_START, E_SPACESHIP, E_MY_DIPLOMAT_BRIBE,
5106 E_DIPLOMATIC_INCIDENT, E_MY_DIPLOMAT_ESCAPE, E_MY_DIPLOMAT_EMBASSY,
5107 E_MY_DIPLOMAT_FAILED, E_MY_DIPLOMAT_INCITE, E_MY_DIPLOMAT_POISON,
5108 E_MY_DIPLOMAT_SABOTAGE, E_MY_DIPLOMAT_THEFT, E_ENEMY_DIPLOMAT_BRIBE,
5109 E_ENEMY_DIPLOMAT_EMBASSY, E_ENEMY_DIPLOMAT_FAILED,
5110 E_ENEMY_DIPLOMAT_INCITE, E_ENEMY_DIPLOMAT_POISON,
5111 E_ENEMY_DIPLOMAT_SABOTAGE, E_ENEMY_DIPLOMAT_THEFT,
5112 E_CARAVAN_ACTION, E_SCRIPT, E_BROADCAST_REPORT, E_GAME_END,
5113 E_GAME_START, E_NATION_SELECTED, E_DESTROYED, E_REPORT, E_TURN_BELL,
5114 E_NEXT_YEAR, E_GLOBAL_ECO, E_NUKE, E_HUT_BARB, E_HUT_CITY, E_HUT_GOLD,
5115 E_HUT_BARB_KILLED, E_HUT_MERC, E_HUT_SETTLER, E_HUT_TECH,
5116 E_HUT_BARB_CITY_NEAR, E_IMP_BUY, E_IMP_BUILD, E_IMP_AUCTIONED,
5117 E_IMP_AUTO, E_IMP_SOLD, E_TECH_GAIN, E_TECH_LEARNED, E_TREATY_ALLIANCE,
5118 E_TREATY_BROKEN, E_TREATY_CEASEFIRE, E_TREATY_PEACE,
5119 E_TREATY_SHARED_VISION, E_UNIT_LOST_ATT, E_UNIT_WIN_ATT, E_UNIT_BUY,
5120 E_UNIT_BUILT, E_UNIT_LOST_DEF, E_UNIT_WIN_DEF, E_UNIT_BECAME_VET,
5121 E_UNIT_UPGRADED, E_UNIT_RELOCATED, E_UNIT_ORDERS, E_WONDER_BUILD,
5122 E_WONDER_OBSOLETE, E_WONDER_STARTED, E_WONDER_STOPPED,
5123 E_WONDER_WILL_BE_BUILT, E_DIPLOMACY, E_TREATY_EMBASSY,
5124 E_BAD_COMMAND, E_SETTING, E_CHAT_MSG, E_MESSAGE_WALL, E_CHAT_ERROR,
5125 E_CONNECTION, E_AI_DEBUG
5126 };
5127 const size_t old_events_num = ARRAY_SIZE(old_events);
5128
5129 for (i = 0; i < old_events_num; i++) {
5130 messages_where[old_events[i]] =
5131 secfile_lookup_int_default(file, messages_where[old_events[i]],
5132 "%s.message_where_%02d", prefix, i);
5133 }
5134 return;
5135 }
5136
5137 for (i = 0; i < num_events; i++) {
5138 p = secfile_lookup_str(file, "messages.event%d.name", i);
5139 if (NULL == p) {
5140 log_error("Corruption in file %s: %s",
5141 secfile_name(file), secfile_error());
5142 continue;
5143 }
5144 /* Compatibility: Before 3.0 E_UNIT_WIN_DEF was called E_UNIT_WIN. */
5145 if (!fc_strcasecmp("E_UNIT_WIN", p)) {
5146 log_deprecation(_("Deprecated event type E_UNIT_WIN in client options."));
5147 p = "E_UNIT_WIN_DEF";
5148 }
5149 event = event_type_by_name(p, strcmp);
5150 if (!event_type_is_valid(event)) {
5151 log_error("Event not supported: %s", p);
5152 continue;
5153 }
5154
5156 "messages.event%d.where", i)) {
5157 log_error("Corruption in file %s: %s",
5158 secfile_name(file), secfile_error());
5159 }
5160 }
5161}
5163/************************************************************************/
5167static void message_options_save(struct section_file *file,
5168 const char *prefix)
5169{
5170 enum event_type event;
5171 int i = 0;
5172
5173 for (event = event_type_begin(); event != event_type_end();
5174 event = event_type_next(event)) {
5175 secfile_insert_str(file, event_type_name(event),
5176 "messages.event%d.name", i);
5178 "messages.event%d.where", i);
5179 i++;
5180 }
5181
5182 secfile_insert_int(file, i, "messages.count");
5184
5185/************************************************************************/
5188static void load_cma_preset(struct section_file *file, int i)
5189{
5190 struct cm_parameter parameter;
5191 const char *name =
5192 secfile_lookup_str_default(file, "preset",
5193 "cma.preset%d.name", i);
5194
5195 /* Init correct default values even for the fields that are not
5196 * loaded below. */
5197 cm_init_parameter(&parameter);
5198
5200 parameter.minimal_surplus[o] =
5201 secfile_lookup_int_default(file, 0, "cma.preset%d.minsurp%d", i, o);
5202 parameter.factor[o] =
5203 secfile_lookup_int_default(file, 0, "cma.preset%d.factor%d", i, o);
5205 parameter.require_happy =
5206 secfile_lookup_bool_default(file, FALSE, "cma.preset%d.reqhappy", i);
5207 parameter.happy_factor =
5208 secfile_lookup_int_default(file, 0, "cma.preset%d.happyfactor", i);
5209 parameter.allow_disorder = FALSE;
5210 parameter.allow_specialists = TRUE;
5211
5212 cmafec_preset_add(name, &parameter);
5214
5215/************************************************************************/
5218static void save_cma_preset(struct section_file *file, int i)
5219{
5220 const struct cm_parameter *const pparam = cmafec_preset_get_parameter(i);
5221 char *name = cmafec_preset_get_descr(i);
5222
5223 secfile_insert_str(file, name, "cma.preset%d.name", i);
5224
5226 secfile_insert_int(file, pparam->minimal_surplus[o],
5227 "cma.preset%d.minsurp%d", i, o);
5228 secfile_insert_int(file, pparam->factor[o],
5229 "cma.preset%d.factor%d", i, o);
5231 secfile_insert_bool(file, pparam->require_happy,
5232 "cma.preset%d.reqhappy", i);
5233 secfile_insert_int(file, pparam->happy_factor,
5234 "cma.preset%d.happyfactor", i);
5236
5237/************************************************************************/
5240static void save_cma_presets(struct section_file *file)
5241{
5242 int i;
5243
5245 _("If you add a preset by hand,"
5246 " also update \"number_of_presets\""),
5247 "cma.number_of_presets");
5248 for (i = 0; i < cmafec_preset_num(); i++) {
5250 }
5253/* Old rc file name. */
5254#define OLD_OPTION_FILE_NAME ".civclientrc"
5255/* New rc file name. */
5256#define MID_OPTION_FILE_NAME ".freeciv-client-rc-%d.%d"
5257#define NEW_OPTION_FILE_NAME "freeciv-client-rc-%d.%d"
5259/* The first version the new option name appeared (2.6). */
5260#define FIRST_MAJOR_NEW_OPTION_FILE_NAME 2
5261#define FIRST_MINOR_NEW_OPTION_FILE_NAME 6
5262/* The first version the mid option name appeared (2.2). */
5263#define FIRST_MAJOR_MID_OPTION_FILE_NAME 2
5264#define FIRST_MINOR_MID_OPTION_FILE_NAME 2
5265/* The first version the new boolean values appeared (2.3). */
5266#define FIRST_MAJOR_NEW_BOOLEAN 2
5267#define FIRST_MINOR_NEW_BOOLEAN 3
5268
5269/************************************************************************/
5276static const char *get_current_option_file_name(void)
5277{
5278 static char name_buffer[256];
5279 const char *name;
5280
5281 name = getenv("FREECIV_OPT");
5282
5283 if (name) {
5284 sz_strlcpy(name_buffer, name);
5285 } else {
5286#ifdef OPTION_FILE_NAME
5287 fc_strlcpy(name_buffer, OPTION_FILE_NAME, sizeof(name_buffer));
5288#else
5290 if (!name) {
5291 log_error(_("Cannot find freeciv storage directory"));
5292 return NULL;
5293 }
5294 fc_snprintf(name_buffer, sizeof(name_buffer),
5297#endif /* OPTION_FILE_NAME */
5298 }
5299 log_verbose("settings file is %s", name_buffer);
5300 return name_buffer;
5301}
5302
5303/************************************************************************/
5311static const char *get_last_option_file_name(bool *allow_digital_boolean)
5312{
5313 static char name_buffer[256];
5314 const char *name;
5315 static int last_minors[] = {
5316 0, /* There was no 0.x releases */
5317 14, /* 1.14 */
5318 6 /* 2.6 */
5319 };
5320
5321#if MINOR_VERSION >= 90
5322 FC_STATIC_ASSERT(MAJOR_VERSION < sizeof(last_minors) / sizeof(int), missing_last_minor);
5323#else
5324 FC_STATIC_ASSERT(MAJOR_VERSION <= sizeof(last_minors) / sizeof(int), missing_last_minor);
5325#endif
5326
5327 *allow_digital_boolean = FALSE;
5328 name = getenv("FREECIV_OPT");
5329 if (name) {
5330 sz_strlcpy(name_buffer, name);
5331 } else {
5332#ifdef OPTION_FILE_NAME
5333 fc_strlcpy(name_buffer, OPTION_FILE_NAME, sizeof(name_buffer));
5334#else
5335 int major, minor;
5336 struct stat buf;
5337
5339 if (name == NULL) {
5340 log_error(_("Cannot find freeciv storage directory"));
5341
5342 return NULL;
5343 }
5344
5345 for (major = MAJOR_NEW_OPTION_FILE_NAME,
5347 major >= FIRST_MAJOR_NEW_OPTION_FILE_NAME; major--) {
5348 for (; (major == FIRST_MAJOR_NEW_OPTION_FILE_NAME
5350 : minor >= 0); minor--) {
5351 fc_snprintf(name_buffer, sizeof(name_buffer),
5352 "%s" DIR_SEPARATOR NEW_OPTION_FILE_NAME, name, major, minor);
5353 if (0 == fc_stat(name_buffer, &buf)) {
5354 if (MAJOR_NEW_OPTION_FILE_NAME != major
5355 || MINOR_NEW_OPTION_FILE_NAME != minor) {
5356 log_normal(_("Didn't find '%s' option file, "
5357 "loading from '%s' instead."),
5358 get_current_option_file_name() + strlen(name) + 1,
5359 name_buffer + strlen(name) + 1);
5360 }
5361
5362 return name_buffer;
5363 }
5364 }
5365 minor = last_minors[major - 1];
5366 }
5367
5368 /* Older versions had options file in user home directory */
5369 name = user_home_dir();
5370 if (name == NULL) {
5371 log_error(_("Cannot find your home directory"));
5372
5373 return NULL;
5374 }
5375
5376 /* minor having max value of FIRST_MINOR_NEW_OPTION_FILE_NAME
5377 * works since MID versioning scheme was used within major version 2
5378 * only (2.2 - 2.6) so the last minor is bigger than any earlier minor. */
5382 minor--) {
5383 fc_snprintf(name_buffer, sizeof(name_buffer),
5384 "%s" DIR_SEPARATOR MID_OPTION_FILE_NAME, name, major, minor);
5385 if (0 == fc_stat(name_buffer, &buf)) {
5386 log_normal(_("Didn't find '%s' option file, "
5387 "loading from '%s' instead."),
5388 get_current_option_file_name() + strlen(name) + 1,
5389 name_buffer + strlen(name) + 1);
5390
5391 if (FIRST_MINOR_NEW_BOOLEAN > minor) {
5392 *allow_digital_boolean = TRUE;
5393 }
5394 return name_buffer;
5395 }
5396 }
5397
5398 /* Try with the old one. */
5399 fc_snprintf(name_buffer, sizeof(name_buffer),
5401 if (0 == fc_stat(name_buffer, &buf)) {
5402 log_normal(_("Didn't find '%s' option file, "
5403 "loading from '%s' instead."),
5404 get_current_option_file_name() + strlen(name) + 1,
5406 *allow_digital_boolean = TRUE;
5407 return name_buffer;
5408 } else {
5409 return NULL;
5410 }
5411#endif /* OPTION_FILE_NAME */
5412 }
5413 log_verbose("settings file is %s", name_buffer);
5414 return name_buffer;
5415}
5416#undef OLD_OPTION_FILE_NAME
5417#undef MID_OPTION_FILE_NAME
5418#undef NEW_OPTION_FILE_NAME
5419#undef FIRST_MAJOR_NEW_OPTION_FILE_NAME
5420#undef FIRST_MINOR_NEW_OPTION_FILE_NAME
5421#undef FIRST_MAJOR_MID_OPTION_FILE_NAME
5422#undef FIRST_MINOR_MID_OPTION_FILE_NAME
5423#undef FIRST_MINOR_NEW_BOOLEAN
5426/****************************************************************************
5427 Desired settable options.
5428****************************************************************************/
5429#define SPECHASH_TAG settable_options
5430#define SPECHASH_ASTR_KEY_TYPE
5431#define SPECHASH_ASTR_DATA_TYPE
5432#include "spechash.h"
5433#define settable_options_hash_iterate(hash, name, value) \
5434 TYPED_HASH_ITERATE(const char *, const char *, hash, name, value)
5435#define settable_options_hash_iterate_end HASH_ITERATE_END
5436
5438
5439/************************************************************************/
5442static void settable_options_load(struct section_file *sf)
5443{
5444 char buf[64];
5445 const struct section *psection;
5446 const struct entry_list *entries;
5447 const char *string;
5448 bool bval;
5449 int ival;
5450
5452
5453 settable_options_hash_clear(settable_options_hash);
5454
5455 psection = secfile_section_by_name(sf, "server");
5456 if (NULL == psection) {
5457 /* Does not exist! */
5458 return;
5459 }
5460
5461 entries = section_entries(psection);
5462 entry_list_iterate(entries, pentry) {
5463 string = NULL;
5464 switch (entry_type_get(pentry)) {
5465 case ENTRY_BOOL:
5466 if (entry_bool_get(pentry, &bval)) {
5467 fc_strlcpy(buf, bval ? "enabled" : "disabled", sizeof(buf));
5468 string = buf;
5469 }
5470 break;
5471
5472 case ENTRY_INT:
5473 if (entry_int_get(pentry, &ival)) {
5474 fc_snprintf(buf, sizeof(buf), "%d", ival);
5475 string = buf;
5476 }
5477 break;
5478
5479 case ENTRY_STR:
5480 (void) entry_str_get(pentry, &string);
5481 break;
5482
5483 case ENTRY_FLOAT:
5485 /* Not supported yet */
5486 break;
5487 case ENTRY_ILLEGAL:
5489 break;
5490 }
5491
5492 if (NULL == string) {
5493 log_error("Entry type variant of \"%s.%s\" is not supported.",
5494 section_name(psection), entry_name(pentry));
5495 continue;
5496 }
5497
5498 settable_options_hash_insert(settable_options_hash, entry_name(pentry),
5499 string);
5502
5503/************************************************************************/
5506static void settable_options_save(struct section_file *sf)
5507{
5509
5511 if (!fc_strcasecmp(name, "gameseed") || !fc_strcasecmp(name, "mapseed")) {
5512 /* Do not save mapseed or gameseed. */
5513 continue;
5514 }
5515 if (!fc_strcasecmp(name, "topology")) {
5516 /* client_start_server() sets topology based on tileset. Don't store
5517 * its choice. The tileset is already stored. Storing topology leads
5518 * to all sort of breakage:
5519 * - it breaks ruleset default topology.
5520 * - it interacts badly with tileset ruleset change, ruleset tileset
5521 * change and topology tileset change.
5522 * - its value is probably based on what tileset was loaded when
5523 * client_start_server() decided to set topology, not on player
5524 * choice.
5525 */
5526 continue;
5527 }
5528 secfile_insert_str(sf, value, "server.%s", name);
5530}
5532/************************************************************************/
5537{
5538 char val_buf[1024], def_buf[1024];
5539 const char *value, *def_val;
5540
5542
5543 options_iterate(server_optset, poption) {
5544 struct server_option *srv = SERVER_OPTION(poption);
5545
5546 if (srv->setdef != SETDEF_CHANGED) {
5547 /* Some level default - do not store */
5548 settable_options_hash_remove(settable_options_hash,
5549 option_name(poption));
5550 } else {
5551 value = NULL;
5552 def_val = NULL;
5553 switch (option_type(poption)) {
5554 case OT_BOOLEAN:
5555 fc_strlcpy(val_buf, option_bool_get(poption) ? "enabled" : "disabled",
5556 sizeof(val_buf));
5557 value = val_buf;
5558 fc_strlcpy(def_buf, option_bool_def(poption) ? "enabled" : "disabled",
5559 sizeof(def_buf));
5560 def_val = def_buf;
5561 break;
5562 case OT_INTEGER:
5563 fc_snprintf(val_buf, sizeof(val_buf), "%d", option_int_get(poption));
5564 value = val_buf;
5565 fc_snprintf(def_buf, sizeof(def_buf), "%d", option_int_def(poption));
5566 def_val = def_buf;
5567 break;
5568 case OT_STRING:
5569 value = option_str_get(poption);
5570 def_val = option_str_def(poption);
5571 break;
5572 case OT_ENUM:
5573 server_option_enum_support_name(poption, &value, &def_val);
5574 break;
5575 case OT_BITWISE:
5576 server_option_bitwise_support_name(poption, val_buf, sizeof(val_buf),
5577 def_buf, sizeof(def_buf));
5578 value = val_buf;
5579 def_val = def_buf;
5580 break;
5581 case OT_FONT:
5582 case OT_COLOR:
5583 case OT_VIDEO_MODE:
5584 break;
5585 }
5586
5587 if (NULL == value || NULL == def_val) {
5588 log_error("Option type %s (%d) not supported for '%s'.",
5589 option_type_name(option_type(poption)), option_type(poption),
5590 option_name(poption));
5591 continue;
5592 }
5593
5594 settable_options_hash_replace(settable_options_hash,
5595 option_name(poption), value);
5596 }
5598}
5600/************************************************************************/
5604void desired_settable_option_update(const char *op_name,
5605 const char *op_value,
5606 bool allow_replace)
5607{
5609
5610 if (allow_replace) {
5611 settable_options_hash_replace(settable_options_hash, op_name, op_value);
5612 } else {
5613 settable_options_hash_insert(settable_options_hash, op_name, op_value);
5614 }
5615}
5617/************************************************************************/
5621static bool settable_option_upgrade_value(const struct option *poption,
5622 int old_value,
5623 char *buf, size_t buf_len)
5624{
5625 const char *name = option_name(poption);
5626
5627#define SETTING_CASE(ARG_name, ...) \
5628 if (0 == strcmp(ARG_name, name)) { \
5629 static const char *values[] = { __VA_ARGS__ }; \
5630 if (0 <= old_value && old_value < ARRAY_SIZE(values) \
5631 && NULL != values[old_value]) { \
5632 fc_strlcpy(buf, values[old_value], buf_len); \
5633 return TRUE; \
5634 } else { \
5635 return FALSE; \
5636 } \
5637 }
5638
5639 SETTING_CASE("topology", "", "WRAPX", "WRAPY", "WRAPX|WRAPY", "ISO",
5640 "WRAPX|ISO", "WRAPY|ISO", "WRAPX|WRAPY|ISO", "HEX",
5641 "WRAPX|HEX", "WRAPY|HEX", "WRAPX|WRAPY|HEX", "ISO|HEX",
5642 "WRAPX|ISO|HEX", "WRAPY|ISO|HEX", "WRAPX|WRAPY|ISO|HEX");
5643 SETTING_CASE("generator", NULL, "RANDOM", "FRACTAL", "ISLAND");
5644 SETTING_CASE("startpos", "DEFAULT", "SINGLE", "2or3", "ALL", "VARIABLE");
5645 SETTING_CASE("borders", "DISABLED", "ENABLED", "SEE_INSIDE", "EXPAND");
5646 SETTING_CASE("diplomacy", "ALL", "HUMAN", "AI", "TEAM", "DISABLED");
5647 SETTING_CASE("citynames", "NO_RESTRICTIONS", "PLAYER_UNIQUE",
5648 "GLOBAL_UNIQUE", "NO_STEALING");
5649 SETTING_CASE("barbarians", "DISABLED", "HUTS_ONLY", "NORMAL", "FREQUENT",
5650 "HORDES");
5651 SETTING_CASE("phasemode", "ALL", "PLAYER", "TEAM");
5652 SETTING_CASE("compresstype", "PLAIN", "LIBZ", "BZIP2");
5653
5654#undef SETTING_CASE
5655 return FALSE;
5657
5658/************************************************************************/
5661static void desired_settable_option_send(struct option *poption)
5662{
5663 char *desired;
5664 int value;
5665
5667
5668 if (!settable_options_hash_lookup(settable_options_hash,
5669 option_name(poption), &desired)) {
5670 /* No change explicitly desired. */
5671 return;
5672 }
5673
5674 switch (option_type(poption)) {
5675 case OT_BOOLEAN:
5676 if ((0 == fc_strcasecmp("enabled", desired)
5677 || (str_to_int(desired, &value) && 1 == value))
5678 && !option_bool_get(poption)) {
5679 send_chat_printf("/set %s enabled", option_name(poption));
5680 } else if ((0 == fc_strcasecmp("disabled", desired)
5681 || (str_to_int(desired, &value) && 0 == value))
5682 && option_bool_get(poption)) {
5683 send_chat_printf("/set %s disabled", option_name(poption));
5684 }
5685 return;
5686 case OT_INTEGER:
5687 if (str_to_int(desired, &value) && value != option_int_get(poption)) {
5688 send_chat_printf("/set %s %d", option_name(poption), value);
5689 }
5690 return;
5691 case OT_STRING:
5692 if (0 != strcmp(desired, option_str_get(poption))) {
5693 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5694 }
5695 return;
5696 case OT_ENUM:
5697 {
5698 char desired_buf[256];
5699 const char *value_str;
5700
5701 /* Handle old values. */
5702 if (str_to_int(desired, &value)
5703 && settable_option_upgrade_value(poption, value, desired_buf,
5704 sizeof(desired_buf))) {
5705 desired = desired_buf;
5706 }
5707
5708 server_option_enum_support_name(poption, &value_str, NULL);
5709 if (0 != strcmp(desired, value_str)) {
5710 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5711 }
5712 }
5713 return;
5714 case OT_BITWISE:
5715 {
5716 char desired_buf[256], value_buf[256];
5717
5718 /* Handle old values. */
5719 if (str_to_int(desired, &value)
5720 && settable_option_upgrade_value(poption, value, desired_buf,
5721 sizeof(desired_buf))) {
5722 desired = desired_buf;
5723 }
5724
5725 server_option_bitwise_support_name(poption, value_buf,
5726 sizeof(value_buf), NULL, 0);
5727 if (0 != strcmp(desired, value_buf)) {
5728 send_chat_printf("/set %s \"%s\"", option_name(poption), desired);
5729 }
5730 }
5731 return;
5732 case OT_FONT:
5733 case OT_COLOR:
5734 case OT_VIDEO_MODE:
5735 break;
5736 }
5737
5738 log_error("Option type %s (%d) not supported for '%s'.",
5739 option_type_name(option_type(poption)), option_type(poption),
5740 option_name(poption));
5741}
5743/************************************************************************/
5748{
5749 if (is_server_running()) {
5751 (void) value; /* Silence compiler warning about unused variable */
5752 struct option *poption = optset_option_by_name(server_optset, name);
5753
5754 if (poption != NULL) {
5755 struct server_option *psoption = SERVER_OPTION(poption);
5756
5757 /* We only sent the option if it has been sent already in the past.
5758 * Otherwise we leave it for that "initial" sending functionality
5759 * to send it. That has the benefit that the initial send (can) check
5760 * that server is not currently using value from the savegame that
5761 * we should not override */
5762 if (psoption->desired_sent) {
5763 /* Keep this list of conditions in sync with one in
5764 * handle_server_setting_common()
5765 * For lacking initial_setting check here, see comment above about
5766 * checking psoption->desired_sent. */
5767 if (psoption->is_visible
5768 && psoption->is_changeable) {
5770 }
5771 }
5772 }
5774 }
5775}
5776
5777
5778/****************************************************************************
5779 City and player report dialog options.
5780****************************************************************************/
5781#define SPECHASH_TAG dialog_options
5782#define SPECHASH_ASTR_KEY_TYPE
5783#define SPECHASH_IDATA_TYPE bool
5784#define SPECHASH_UDATA_TO_IDATA FC_INT_TO_PTR
5785#define SPECHASH_IDATA_TO_UDATA FC_PTR_TO_INT
5786#define SPECHASH_VPTR_TO_IDATA FC_PTR_TO_INT
5787#include "spechash.h"
5788#define dialog_options_hash_iterate(hash, column, visible) \
5789 TYPED_HASH_ITERATE(const char *, intptr_t, hash, column, visible)
5790#define dialog_options_hash_iterate_end HASH_ITERATE_END
5791
5793
5794/************************************************************************/
5797static void options_dialogs_load(struct section_file *sf)
5798{
5799 const struct entry_list *entries;
5800 const char *prefixes[] = { "player_dlg_", "city_report_", NULL };
5801 const char **prefix;
5802 bool visible;
5803
5805
5807
5808 if (NULL != entries) {
5809 entry_list_iterate(entries, pentry) {
5810 for (prefix = prefixes; NULL != *prefix; prefix++) {
5811 if (0 == strncmp(*prefix, entry_name(pentry), strlen(*prefix))
5812 && secfile_lookup_bool(sf, &visible, "client.%s",
5813 entry_name(pentry))) {
5814 dialog_options_hash_replace(dialog_options_hash,
5815 entry_name(pentry), visible);
5816 break;
5817 }
5818 }
5820 }
5822
5823/************************************************************************/
5826static void options_dialogs_save(struct section_file *sf)
5827{
5829
5832 secfile_insert_bool(sf, visible, "client.%s", column);
5834}
5835
5836/************************************************************************/
5841void options_dialogs_update(void)
5842{
5843 char buf[64];
5844 int i;
5845
5847
5848 /* Player report dialog options. */
5849 for (i = 1; i < num_player_dlg_columns; i++) {
5850 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5851 player_dlg_columns[i].tagname);
5852 dialog_options_hash_replace(dialog_options_hash, buf,
5854 }
5855
5856 /* City report dialog options. */
5857 for (i = 0; i < num_city_report_spec(); i++) {
5858 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5860 dialog_options_hash_replace(dialog_options_hash, buf,
5862 }
5863}
5865/************************************************************************/
5869void options_dialogs_set(void)
5870{
5871 char buf[64];
5872 bool visible;
5873 int i;
5874
5876
5877 /* Player report dialog options. */
5878 for (i = 1; i < num_player_dlg_columns; i++) {
5879 fc_snprintf(buf, sizeof(buf), "player_dlg_%s",
5880 player_dlg_columns[i].tagname);
5881 if (dialog_options_hash_lookup(dialog_options_hash, buf, &visible)) {
5882 player_dlg_columns[i].show = visible;
5883 }
5884 }
5885
5886 /* City report dialog options. */
5887 for (i = 0; i < num_city_report_spec(); i++) {
5888 fc_snprintf(buf, sizeof(buf), "city_report_%s",
5890 if (dialog_options_hash_lookup(dialog_options_hash, buf, &visible)) {
5891 *city_report_spec_show_ptr(i) = visible;
5892 }
5893 }
5894}
5895
5896/************************************************************************/
5902void options_load(void)
5903{
5904 struct section_file *sf;
5906 int i, num;
5907 const char *name;
5908 const char *const prefix = "client";
5909 const char *str;
5910
5912 if (!name) {
5913 log_normal(_("Didn't find the option file. Creating a new one."));
5917 return;
5918 }
5919 if (!(sf = secfile_load(name, TRUE))) {
5920 log_debug("Error loading option file '%s':\n%s", name, secfile_error());
5921 /* try to create the rc file */
5922 sf = secfile_new(TRUE);
5923 secfile_insert_str(sf, VERSION_STRING, "client.version");
5924
5927 save_cma_presets(sf);
5928
5929 /* FIXME: need better messages */
5930 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
5931 log_error(_("Save failed, cannot write to file %s"), name);
5932 } else {
5933 log_normal(_("Saved settings to file %s"), name);
5934 }
5935 secfile_destroy(sf);
5937 return;
5938 }
5940
5941 /* a "secret" option for the lazy. TODO: make this saveable */
5943 secfile_lookup_str_default(sf, "", "%s.password", prefix));
5944
5947 "%s.save_options_on_exit", prefix);
5950 "%s.fullscreen_mode", prefix);
5951
5952 /* Settings migrations */
5955 "%s.migration_gtk3_from_gtk2", prefix);
5958 "%s.migration_gtk3_22_from_gtk3", prefix);
5961 "%s.migration_gtk4_from_gtk3_22", prefix);
5964 "%s.migration_sdl2_from_sdl", prefix);
5967 "%s.migration_gtk2_from_2_5", prefix);
5970 "%s.migration_gtk3_from_2_5", prefix);
5973 "%s.migration_qt_from_2_5", prefix);
5974
5975 /* Flag values */
5978 "%s.flag_qt_default_fonts_set", prefix);
5979
5980 /* These are not gui-enabled yet */
5982 secfile_lookup_bool_default(sf, FALSE, "%s.zoom_set", prefix);
5985 "%s.zoom_default_level", prefix);
5986
5987 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_name");
5988 if (str != NULL) {
5990 }
5991 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_overhead_name");
5992 if (str != NULL) {
5994 }
5995 str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_iso_name");
5996 if (str != NULL) {
5998 }
5999
6000 /* Backwards compatibility for removed options replaced by entirely "new"
6001 * options. The equivalent "new" option will override these, if set. */
6002
6003 /* Renamed in 2.6 */
6005 "%s.popup_caravan_arrival", prefix);
6006
6007 /* Load all the regular options */
6009 client_option_load(poption, sf);
6011
6012 /* More backwards compatibility, for removed options that had been
6013 * folded into then-existing options. Here, the backwards-compatibility
6014 * behaviour overrides the "destination" option. */
6015
6016 /* Removed in 2.4 */
6018 "%s.do_combat_animation", prefix)) {
6020 }
6021
6022 message_options_load(sf, prefix);
6024
6025 /* Load cma presets. If cma.number_of_presets doesn't exist, don't load
6026 * any, the order here should be reversed to keep the order the same */
6027 if (secfile_lookup_int(sf, &num, "cma.number_of_presets")) {
6028 for (i = num - 1; i >= 0; i--) {
6029 load_cma_preset(sf, i);
6030 }
6031 } else {
6033 }
6034
6037
6038 secfile_destroy(sf);
6041
6042/************************************************************************/
6046 const char *msg, ...)
6047{
6048 va_list args;
6049
6050 va_start(args, msg);
6052 va_end(args);
6054
6055/************************************************************************/
6059{
6060 struct section_file *sf;
6061 const char *name = get_current_option_file_name();
6062 char dir_name[2048];
6063 int i;
6064
6065 if (log_cb == NULL) {
6066 /* Default callback */
6068 }
6069
6070 if (!name) {
6071 log_cb(LOG_ERROR, _("Save failed, cannot find a filename."));
6072 return;
6073 }
6074
6075 sf = secfile_new(TRUE);
6076 secfile_insert_str(sf, VERSION_STRING, "client.version");
6077
6079 "client.save_options_on_exit");
6081 "deprecated", "client.fullscreen_mode");
6082
6083 /* Migrations */
6085 "client.migration_gtk3_from_gtk2");
6087 "client.migration_gtk3_22_from_gtk3");
6089 "client.migration_gtk4_from_gtk3_22");
6091 "client.migration_sdl2_from_sdl");
6093 "client.migration_gtk2_from_2_5");
6095 "client.migration_gtk3_from_2_5");
6097 "client.migration_qt_from_2_5");
6098
6099 /* Flag */
6101 "client.flag_qt_default_fonts_set");
6102
6103 /* gui-enabled options */
6105 if ((client_poption->specific != GUI_SDL || !gui_options.gui_sdl2_migrated_from_sdl)
6106 && (client_poption->specific != GUI_GTK2 || !gui_options.gui_gtk3_migrated_from_gtk2)) {
6107 /* Once sdl-client options have been migrated to sdl2-client, or gtk2-client options
6108 * to gtk3-client, there's no use for them any more, so no point in saving them. */
6109 client_option_save(poption, sf);
6110 }
6112
6113 /* These are not gui-enabled yet. */
6114 secfile_insert_bool(sf, gui_options.zoom_set, "client.zoom_set");
6116 "client.zoom_default_level");
6117
6118 if (gui_options.default_tileset_name[0] != '\0') {
6120 "client.default_tileset_name");
6121 }
6122
6123 message_options_save(sf, "client");
6125
6126 /* Server settings */
6127 save_cma_presets(sf);
6129
6130 /* Insert global worklists */
6132
6133 /* Directory name */
6134 sz_strlcpy(dir_name, name);
6135 for (i = strlen(dir_name) - 1 ; dir_name[i] != DIR_SEPARATOR_CHAR && i >= 0; i--) {
6136 /* Nothing */
6137 }
6138
6139 if (i > 0) {
6140 dir_name[i] = '\0';
6141 if (!make_dir(dir_name)) {
6142 log_cb(LOG_ERROR, _("Saving options failed, cannot create directory %s"),
6143 dir_name);
6144 secfile_destroy(sf);
6145 return;
6146 }
6147 }
6148
6149 /* Save to disk */
6150 if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
6151 log_cb(LOG_ERROR, _("Saving options failed, cannot write to file %s"), name);
6152 } else {
6153 log_cb(LOG_VERBOSE, _("Saved options to file %s"), name);
6154 }
6155 secfile_destroy(sf);
6157
6158/************************************************************************/
6161static void options_init_names(const struct copt_val_name *(*acc)(int),
6162 struct strvec **support, struct strvec **pretty)
6163{
6164 int val;
6165 const struct copt_val_name *name;
6166 fc_assert_ret(NULL != acc);
6167 *support = strvec_new();
6168 *pretty = strvec_new();
6169 for (val=0; (name = acc(val)); val++) {
6170 strvec_append(*support, name->support);
6171 strvec_append(*pretty, name->pretty);
6172 }
6174
6175/************************************************************************/
6178void options_init(void)
6179{
6183
6184 settable_options_hash = settable_options_hash_new();
6185 dialog_options_hash = dialog_options_hash_new();
6186
6188 struct client_option *pcoption = CLIENT_OPTION(poption);
6189
6190 switch (option_type(poption)) {
6191 case OT_INTEGER:
6192 if (option_int_def(poption) < option_int_min(poption)
6193 || option_int_def(poption) > option_int_max(poption)) {
6194 int int_def = option_int_def(poption);
6195 int int_max = option_int_max(poption);
6196 int int_min = option_int_min(poption);
6197 int new_default = MAX(MIN(int_def, int_max), int_min);
6198
6199 log_error("option %s has default value of %d, which is "
6200 "out of its range [%d; %d], changing to %d.",
6201 option_name(poption), option_int_def(poption),
6202 option_int_min(poption), option_int_max(poption),
6203 new_default);
6204 *((int *) &(pcoption->integer.def)) = new_default;
6205 }
6206 break;
6207
6208 case OT_STRING:
6210 /* Hack to get a default value. */
6211 *((const char **) &(pcoption->string.def)) =
6213 }
6214
6215 if (NULL == option_str_def(poption)) {
6216 const struct strvec *values = option_str_values(poption);
6217
6218 if (NULL == values || strvec_size(values) == 0) {
6219 log_error("Invalid NULL default string for option %s.",
6220 option_name(poption));
6221 } else {
6222 *((const char **) &(pcoption->string.def)) =
6223 strvec_get(values, 0);
6224 }
6225 }
6226 break;
6227
6228 case OT_ENUM:
6229 fc_assert(NULL == pcoption->enumerator.support_names);
6230 fc_assert(NULL == pcoption->enumerator.pretty_names);
6232 &pcoption->enumerator.support_names,
6233 &pcoption->enumerator.pretty_names);
6234 fc_assert(NULL != pcoption->enumerator.support_names);
6235 fc_assert(NULL != pcoption->enumerator.pretty_names);
6236 break;
6237
6238 case OT_BITWISE:
6239 fc_assert(NULL == pcoption->bitwise.support_names);
6240 fc_assert(NULL == pcoption->bitwise.pretty_names);
6242 &pcoption->bitwise.support_names,
6243 &pcoption->bitwise.pretty_names);
6244 fc_assert(NULL != pcoption->bitwise.support_names);
6245 fc_assert(NULL != pcoption->bitwise.pretty_names);
6246 break;
6247
6248 case OT_COLOR:
6249 {
6250 /* Duplicate the string pointers. */
6251 struct ft_color *pcolor = pcoption->color.pvalue;
6252
6253 if (NULL != pcolor->foreground) {
6254 pcolor->foreground = fc_strdup(pcolor->foreground);
6255 }
6256 if (NULL != pcolor->background) {
6257 pcolor->background = fc_strdup(pcolor->background);
6258 }
6259 }
6260 break;
6261
6262 case OT_BOOLEAN:
6263 case OT_FONT:
6264 case OT_VIDEO_MODE:
6265 break;
6266 }
6267
6268 /* Set to default. */
6269 option_reset(poption);
6272
6273/************************************************************************/
6276void options_free(void)
6277{
6279 struct client_option *pcoption = CLIENT_OPTION(poption);
6280
6281 option_gui_remove(poption);
6282
6283 switch (option_type(poption)) {
6284 case OT_ENUM:
6285 fc_assert_action(NULL != pcoption->enumerator.support_names, break);
6287 pcoption->enumerator.support_names = NULL;
6288 fc_assert_action(NULL != pcoption->enumerator.pretty_names, break);
6290 pcoption->enumerator.pretty_names = NULL;
6291 break;
6292
6293 case OT_BITWISE:
6294 fc_assert_action(NULL != pcoption->bitwise.support_names, break);
6296 pcoption->bitwise.support_names = NULL;
6297 fc_assert_action(NULL != pcoption->bitwise.pretty_names, break);
6299 pcoption->bitwise.pretty_names = NULL;
6300 break;
6301
6302 case OT_BOOLEAN:
6303 case OT_INTEGER:
6304 case OT_STRING:
6305 case OT_FONT:
6306 case OT_COLOR:
6307 case OT_VIDEO_MODE:
6308 break;
6309 }
6311
6312 if (NULL != settable_options_hash) {
6313 settable_options_hash_destroy(settable_options_hash);
6314 settable_options_hash = NULL;
6315 }
6316
6317 if (NULL != dialog_options_hash) {
6318 dialog_options_hash_destroy(dialog_options_hash);
6319 dialog_options_hash = NULL;
6320 }
6321
6324}
6326/************************************************************************/
6330static void reqtree_show_icons_callback(struct option *poption)
6331{
6334
6335/************************************************************************/
6338static void view_option_changed_callback(struct option *poption)
6339{
6340 menus_init();
6343
6344/************************************************************************/
6347static void manual_turn_done_callback(struct option *poption)
6348{
6350
6352 struct player *pplayer = client_player();
6353
6354 if (pplayer != NULL && is_ai(pplayer)
6355 && can_end_turn()) {
6357 }
6358 }
6360
6361/****************************************************************************
6362 Callback for changing music volume
6363****************************************************************************/
6364static void sound_volume_callback(struct option *poption)
6365{
6368
6369/************************************************************************/
6372static void voteinfo_bar_callback(struct option *poption)
6373{
6376
6377/************************************************************************/
6380static void font_changed_callback(struct option *poption)
6381{
6382 fc_assert_ret(OT_FONT == option_type(OPTION(poption)));
6385
6386/************************************************************************/
6389static void mapimg_changed_callback(struct option *poption)
6390{
6392#ifndef FREECIV_NDEBUG
6393 bool success;
6394#endif
6395
6396 log_normal("Error setting the value for %s (%s). Restoring the default "
6397 "value.", option_name(poption), mapimg_error());
6398
6399 /* Reset the value to the default value. */
6400#ifndef FREECIV_NDEBUG
6401 success =
6402#endif
6403 option_reset(poption);
6404
6405 fc_assert_msg(success,
6406 "Failed to reset the option \"%s\".",
6407 option_name(poption));
6408#ifndef FREECIV_NDEBUG
6409 success =
6410#endif
6412
6413 fc_assert_msg(success,
6414 "Failed to restore mapimg definition for option \"%s\".",
6415 option_name(poption));
6416 }
6418
6419/************************************************************************/
6422static void game_music_enable_callback(struct option *poption)
6423{
6424 if (client_state() == C_S_RUNNING) {
6427 } else {
6429 }
6430 }
6432
6433/************************************************************************/
6436static void menu_music_enable_callback(struct option *poption)
6437{
6438 if (client_state() != C_S_RUNNING) {
6440 start_menu_music("music_menu", NULL);
6441 } else {
6443 }
6444 }
6446
6447/************************************************************************/
6450bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
6451{
6452 return (2 < fc_snprintf(buf, buf_len, "%dx%d", mode->width, mode->height));
6454
6455/************************************************************************/
6458bool string_to_video_mode(const char *buf, struct video_mode *mode)
6459{
6460 return (2 == sscanf(buf, "%dx%d", &mode->width, &mode->height));
6462
6463/************************************************************************/
6466static const struct strvec *get_mapimg_format_list(const struct option *poption)
6467{
6468 return mapimg_get_format_list();
6470
6471/************************************************************************/
6474const char *tileset_name_for_topology(int topology_id)
6475{
6476 const char *tsn = NULL;
6477
6478 switch (topology_id & (TF_ISO | TF_HEX)) {
6479 case 0:
6480 case TF_ISO:
6482 break;
6483 case TF_HEX:
6485 break;
6486 case TF_ISO | TF_HEX:
6488 break;
6489 }
6490
6491 if (tsn == NULL) {
6493 }
6494
6495 return tsn;
6497
6498/************************************************************************/
6501void option_set_default_ts(struct tileset *t)
6502{
6503 const char *optname = "<not set>";
6504 struct option *opt;
6505
6506 switch (tileset_topo_index(t)) {
6507 case TS_TOPO_SQUARE:
6508 /* Overhead */
6509 optname = "default_tileset_square_name";
6510 break;
6511 case TS_TOPO_HEX:
6512 /* Hex */
6513 optname = "default_tileset_hex_name";
6514 break;
6515 case TS_TOPO_ISOHEX:
6516 /* Isohex */
6517 optname = "default_tileset_isohex_name";
6518 break;
6519 }
6520
6521 opt = optset_option_by_name(client_optset, optname);
6522
6523 if (opt == NULL) {
6524 log_error("Unknown option name \"%s\" in option_set_default_ts()", optname);
6525 return;
6526 }
6527
6528 /* Do not call option_str_set() since we don't want option changed callback
6529 * to reload this tileset. */
6530 opt->str_vtable->set(opt, tileset_basename(t));
6531 option_gui_update(opt);
6533
6534/************************************************************************/
6537static bool is_ts_option_unset(const char *optname)
6538{
6539 struct option *opt;
6540 const char *val;
6541
6542 opt = optset_option_by_name(client_optset, optname);
6543
6544 if (opt == NULL) {
6545 return TRUE;
6546 }
6547
6548 val = opt->str_vtable->get(opt);
6549
6550 if (val == NULL || val[0] == '\0') {
6551 return TRUE;
6552 }
6553
6554 return FALSE;
6556
6557/************************************************************************/
6560void fill_topo_ts_default(void)
6561{
6562 if (is_ts_option_unset("default_tileset_square_name")) {
6563 if (gui_options.default_tileset_iso_name[0] != '\0') {
6567 } else if (gui_options.default_tileset_overhead_name[0] != '\0') {
6571 } else {
6572 log_debug("Setting tileset for square topologies.");
6573 tilespec_try_read(NULL, FALSE, 0, FALSE);
6574 }
6575 }
6576 if (is_ts_option_unset("default_tileset_hex_name")) {
6577 log_debug("Setting tileset for hex topology.");
6578 tilespec_try_read(NULL, FALSE, TF_HEX, FALSE);
6579 }
6580 if (is_ts_option_unset("default_tileset_isohex_name")) {
6581 log_debug("Setting tileset for isohex topology.");
6582 tilespec_try_read(NULL, FALSE, TF_ISO | TF_HEX, FALSE);
6583 }
6584}
struct @124::my_agent entries[MAX_AGENTS]
#define str
Definition astring.c:76
void audio_set_volume(double volume)
Definition audio.c:619
const struct strvec * get_musicset_list(const struct option *poption)
Definition audio.c:125
const struct strvec * get_soundset_list(const struct option *poption)
Definition audio.c:115
const struct strvec * get_soundplugin_list(const struct option *poption)
Definition audio.c:79
struct canvas int int struct sprite bool int int fog_y struct canvas struct sprite struct color * pcolor
Definition canvas_g.h:57
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:320
#define output_type_iterate(output)
Definition city.h:821
#define output_type_iterate_end
Definition city.h:827
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:1402
void cm_init_parameter(struct cm_parameter *dest)
Definition cm.c:2181
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
bool is_server_running(void)
#define log_deprecation(message,...)
enum event_type event
Definition events.c:81
void events_init(void)
Definition events.c:330
void events_free(void)
Definition events.c:376
#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:1883
void options_extra_init(void)
Definition gui_main.c:2284
static GtkTextBuffer * help_text
Definition helpdlg.c:69
void option_gui_remove(struct option *poption)
Definition optiondlg.c:1048
void option_dialog_popdown(const struct option_set *poptset)
Definition optiondlg.c:993
void option_gui_update(struct option *poption)
Definition optiondlg.c:1020
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
void voteinfo_gui_update(void)
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:1552
const struct strvec * mapimg_get_format_list(void)
Definition mapimg.c:1152
const char * mapimg_error(void)
Definition mapimg.c:758
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:121
void start_menu_music(const char *const tag, char *const alt_tag)
Definition music.c:90
void stop_menu_music(void)
Definition music.c:100
void start_style_music(void)
Definition music.c:36
void stop_style_music(void)
Definition music.c:82
prefix(prefix, str)
static struct option * client_optset_option_first(void)
Definition options.c:3367
void handle_server_setting_const(const struct packet_server_setting_const *packet)
Definition options.c:4288
void handle_server_setting_int(const struct packet_server_setting_int *packet)
Definition options.c:4380
static int server_option_int_max(const struct option *poption)
Definition options.c:4811
static bool client_option_font_set(struct option *poption, const char *font)
Definition options.c:3736
unsigned option_bitwise_mask(const struct option *poption)
Definition options.c:1071
void fill_topo_ts_default(void)
Definition options.c:6555
#define FIRST_MAJOR_MID_OPTION_FILE_NAME
Definition options.c:5258
#define client_options_iterate_all_end
Definition options.c:3329
static const struct strvec * server_option_str_values(const struct option *poption)
Definition options.c:4855
static int client_option_enum_get(const struct option *poption)
Definition options.c:3595
void resend_desired_settable_options(void)
Definition options.c:5742
const struct strvec * option_str_values(const struct option *poption)
Definition options.c:890
static void desired_settable_option_send(struct option *poption)
Definition options.c:5656
static const char * client_option_name(const struct option *poption)
Definition options.c:3421
static unsigned server_option_bitwise_def(const struct option *poption)
Definition options.c:4950
#define FIRST_MAJOR_NEW_OPTION_FILE_NAME
Definition options.c:5255
static const struct option_video_mode_vtable client_option_video_mode_vtable
Definition options.c:1381
#define GEN_STR_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb, cbd)
Definition options.c:1558
static struct dialog_options_hash * dialog_options_hash
Definition options.c:5787
void option_changed(struct option *poption)
Definition options.c:723
static void menu_music_enable_callback(struct option *poption)
Definition options.c:6431
static bool options_fully_initialized
Definition options.c:377
static const struct option_str_vtable client_option_str_vtable
Definition options.c:1315
unsigned option_bitwise_def(const struct option *poption)
Definition options.c:1060
int option_enum_str_to_int(const struct option *poption, const char *str)
Definition options.c:918
static const char * client_option_description(const struct option *poption)
Definition options.c:3429
int option_int_min(const struct option *poption)
Definition options.c:831
static void option_save_output_window_callback(enum log_level lvl, const char *msg,...)
Definition options.c:6040
static void message_options_save(struct section_file *file, const char *prefix)
Definition options.c:5162
bool option_bool_def(const struct option *poption)
Definition options.c:783
static struct option * client_option_next(const struct option *poption)
Definition options.c:3461
static const char * server_option_name(const struct option *poption)
Definition options.c:4706
const char * option_font_def(const struct option *poption)
Definition options.c:1127
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6469
static const struct copt_val_name * gui_gtk_message_chat_location_name(int value)
Definition options.c:1814
static bool server_option_str_set(struct option *poption, const char *str)
Definition options.c:4864
static const struct copt_val_name * gui_popup_tech_help_name(int value)
Definition options.c:1834
struct option * optset_option_first(const struct option_set *poptset)
Definition options.c:422
static const char * server_optset_category_name(int category)
Definition options.c:4686
const struct option_set * server_optset
Definition options.c:4009
static void view_option_changed_callback(struct option *poption)
Definition options.c:6333
static const char * client_option_font_target(const struct option *poption)
Definition options.c:3727
static void server_option_enum_support_name(const struct option *poption, const char **pvalue, const char **pdefault)
Definition options.c:4924
#define GEN_INT_OPTION(oname, odesc, ohelp, ocat, ospec, odef, omin, omax, ocb)
Definition options.c:1520
static const char * server_option_description(const struct option *poption)
Definition options.c:4714
static unsigned server_option_bitwise_get(const struct option *poption)
Definition options.c:4942
static bool client_option_is_changeable(const struct option *poption)
Definition options.c:3453
static int server_option_int_min(const struct option *poption)
Definition options.c:4803
static const char * client_optset_category_name(int category)
Definition options.c:3383
static struct option * server_option_next(const struct option *poption)
Definition options.c:4746
static struct client_option client_options[]
Definition options.c:1861
#define SERVER_OPTION(poption)
Definition options.c:4145
#define OLD_OPTION_FILE_NAME
Definition options.c:5249
static void settable_options_save(struct section_file *sf)
Definition options.c:5501
static bool server_option_bool_get(const struct option *poption)
Definition options.c:4754
bool option_reset(struct option *poption)
Definition options.c:684
void options_free(void)
Definition options.c:6271
const char * option_description(const struct option *poption)
Definition options.c:613
const char * option_help_text(const struct option *poption)
Definition options.c:623
#define settable_options_hash_iterate_end
Definition options.c:5430
static const char * client_option_font_get(const struct option *poption)
Definition options.c:3711
static int server_option_enum_def(const struct option *poption)
Definition options.c:4887
static int server_option_int_def(const struct option *poption)
Definition options.c:4795
#define client_options_iterate_all(poption)
Definition options.c:3320
static int client_option_int_min(const struct option *poption)
Definition options.c:3517
static int server_options_categories_num
Definition options.c:3991
const char * option_enum_get_str(const struct option *poption)
Definition options.c:967
static struct ft_color client_option_color_def(const struct option *poption)
Definition options.c:3760
static const struct strvec * client_option_enum_pretty_names(const struct option *poption)
Definition options.c:3613
static bool server_option_enum_set(struct option *poption, int val)
Definition options.c:4906
static void save_cma_presets(struct section_file *file)
Definition options.c:5235
struct ft_color option_color_get(const struct option *poption)
Definition options.c:1165
static struct video_mode client_option_video_mode_def(const struct option *poption)
Definition options.c:3814
static int client_option_int_get(const struct option *poption)
Definition options.c:3501
static char ** server_options_categories
Definition options.c:3988
int option_enum_get_int(const struct option *poption)
Definition options.c:955
static void settable_options_load(struct section_file *sf)
Definition options.c:5437
int option_number(const struct option *poption)
Definition options.c:593
static struct option * server_optset_option_first(void)
Definition options.c:4670
static struct settable_options_hash * settable_options_hash
Definition options.c:5432
int option_category(const struct option *poption)
Definition options.c:643
static struct server_option * server_options
Definition options.c:3989
static const struct option_int_vtable server_option_int_vtable
Definition options.c:4049
static void options_dialogs_save(struct section_file *sf)
Definition options.c:5821
static struct option_set client_optset_static
Definition options.c:1249
static bool client_option_color_set(struct option *poption, struct ft_color color)
Definition options.c:3769
#define dialog_options_hash_iterate_end
Definition options.c:5785
static void save_cma_preset(struct section_file *file, int i)
Definition options.c:5213
static int client_optset_category_number(void)
Definition options.c:3375
static const char * client_option_str_def(const struct option *poption)
Definition options.c:3559
static bool client_option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:3823
void handle_server_setting_bitwise(const struct packet_server_setting_bitwise *packet)
Definition options.c:4551
static const struct option_font_vtable client_option_font_vtable
Definition options.c:1356
static bool client_option_enum_set(struct option *poption, int val)
Definition options.c:3622
void desired_settable_option_update(const char *op_name, const char *op_value, bool allow_replace)
Definition options.c:5599
void option_set_default_ts(struct tileset *t)
Definition options.c:6496
bool option_str_set(struct option *poption, const char *str)
Definition options.c:901
void handle_server_setting_bool(const struct packet_server_setting_bool *packet)
Definition options.c:4345
static const struct strvec * client_option_str_values(const struct option *poption)
Definition options.c:3569
const struct option_set * client_optset
Definition options.c:1255
static const struct option_bool_vtable server_option_bool_vtable
Definition options.c:4037
static const struct option_bitwise_vtable server_option_bitwise_vtable
Definition options.c:4090
const char * option_name(const struct option *poption)
Definition options.c:603
static const char * client_option_help_text(const struct option *poption)
Definition options.c:3437
static void message_options_init(void)
Definition options.c:5035
static int client_option_number(const struct option *poption)
Definition options.c:3413
void handle_server_setting_str(const struct packet_server_setting_str *packet)
Definition options.c:4417
int option_int_get(const struct option *poption)
Definition options.c:809
static void client_option_save(struct option *poption, struct section_file *sf)
Definition options.c:3928
void options_init(void)
Definition options.c:6173
static int client_option_int_def(const struct option *poption)
Definition options.c:3509
static int server_option_category(const struct option *poption)
Definition options.c:4730
#define FIRST_MINOR_MID_OPTION_FILE_NAME
Definition options.c:5259
static const struct option_enum_vtable client_option_enum_vtable
Definition options.c:1328
static const struct option_str_vtable server_option_str_vtable
Definition options.c:4063
static int server_options_num
Definition options.c:3992
#define handle_server_setting_common(psoption, packet)
Definition options.c:4309
static const struct option_color_vtable client_option_color_vtable
Definition options.c:1368
bool option_enum_set_str(struct option *poption, const char *str)
Definition options.c:1032
static const struct strvec * server_option_enum_pretty(const struct option *poption)
Definition options.c:4897
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:5008
bool option_color_set(struct option *poption, struct ft_color color)
Definition options.c:1188
#define SETTING_CASE(ARG_name,...)
static struct video_mode client_option_video_mode_get(const struct option *poption)
Definition options.c:3805
static bool is_ts_option_unset(const char *optname)
Definition options.c:6532
void option_set_changed_callback(struct option *poption, void(*callback)(struct option *))
Definition options.c:712
#define OPTION(poption)
Definition options.c:538
#define NEW_OPTION_FILE_NAME
Definition options.c:5252
static bool server_option_bool_set(struct option *poption, bool val)
Definition options.c:4771
bool option_bool_set(struct option *poption, bool val)
Definition options.c:794
bool option_is_changeable(const struct option *poption)
Definition options.c:664
#define GEN_ENUM_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb)
Definition options.c:1636
bool option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:1228
#define MID_OPTION_FILE_NAME
Definition options.c:5251
static int server_option_number(const struct option *poption)
Definition options.c:4698
#define dialog_options_hash_iterate(hash, column, visible)
Definition options.c:5783
#define FIRST_MINOR_NEW_BOOLEAN
Definition options.c:5262
static const char * server_option_str_get(const struct option *poption)
Definition options.c:4837
#define settable_options_hash_iterate(hash, name, value)
Definition options.c:5428
void option_set_gui_data(struct option *poption, void *data)
Definition options.c:742
#define FIRST_MINOR_NEW_OPTION_FILE_NAME
Definition options.c:5256
#define GEN_BOOL_OPTION(oname, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1484
const char * option_str_get(const struct option *poption)
Definition options.c:868
struct option * optset_option_by_number(const struct option_set *poptset, int id)
Definition options.c:395
static bool client_option_bool_get(const struct option *poption)
Definition options.c:3469
void * option_get_gui_data(const struct option *poption)
Definition options.c:752
static const char * server_option_str_def(const struct option *poption)
Definition options.c:4845
static const struct option_common_vtable client_option_common_vtable
Definition options.c:1275
static bool settable_option_upgrade_value(const struct option *poption, int old_value, char *buf, size_t buf_len)
Definition options.c:5616
const struct strvec * option_enum_values(const struct option *poption)
Definition options.c:1004
static const struct strvec * get_mapimg_format_list(const struct option *poption)
Definition options.c:6461
static void sound_volume_callback(struct option *poption)
Definition options.c:6359
bool option_enum_set_int(struct option *poption, int val)
Definition options.c:1015
bool option_bool_get(const struct option *poption)
Definition options.c:772
int optset_category_number(const struct option_set *poptset)
Definition options.c:432
#define color_set(color_tgt, color)
static bool client_option_bool_def(const struct option *poption)
Definition options.c:3477
static const struct strvec * server_option_bitwise_pretty(const struct option *poption)
Definition options.c:4960
void server_options_init(void)
Definition options.c:4153
enum option_type option_type(const struct option *poption)
Definition options.c:633
static int client_option_enum_def(const struct option *poption)
Definition options.c:3603
const char * option_enum_int_to_str(const struct option *poption, int val)
Definition options.c:940
void options_dialogs_update(void)
Definition options.c:5836
int option_get_cb_data(const struct option *poption)
Definition options.c:762
bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
Definition options.c:6445
static void options_dialogs_load(struct section_file *sf)
Definition options.c:5792
const struct option_set * option_optset(const struct option *poption)
Definition options.c:583
void server_options_free(void)
Definition options.c:4222
struct video_mode option_video_mode_get(const struct option *poption)
Definition options.c:1203
static int server_option_enum_get(const struct option *poption)
Definition options.c:4879
struct option * option_next(const struct option *poption)
Definition options.c:674
static struct option * client_optset_option_by_number(int id)
Definition options.c:3356
static void font_changed_callback(struct option *poption)
Definition options.c:6375
const char * option_str_def(const struct option *poption)
Definition options.c:879
const char * optset_category_name(const struct option_set *poptset, int category)
Definition options.c:442
int option_int_max(const struct option *poption)
Definition options.c:842
#define GEN_COLOR_OPTION(oname, odesc, ohelp, ocat, ospec, odef_fg, odef_bg, ocb)
Definition options.c:1751
const char * option_enum_def_str(const struct option *poption)
Definition options.c:991
void options_load(void)
Definition options.c:5897
static const char * client_option_str_get(const struct option *poption)
Definition options.c:3551
static const struct option_common_vtable server_option_common_vtable
Definition options.c:4023
static int server_optset_category_number(void)
Definition options.c:4678
static bool client_option_bool_set(struct option *poption, bool val)
Definition options.c:3486
static const char * server_option_help_text(const struct option *poption)
Definition options.c:4722
static const struct option_bool_vtable client_option_bool_vtable
Definition options.c:1289
static bool client_option_load(struct option *poption, struct section_file *sf)
Definition options.c:3840
bool option_font_set(struct option *poption, const char *font)
Definition options.c:1149
static bool server_option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:4989
const char * option_font_target(const struct option *poption)
Definition options.c:1138
static const char * client_option_enum_secfile_str(secfile_data_t data, int val)
Definition options.c:3641
static struct server_option * server_option_next_valid(struct server_option *poption)
Definition options.c:4640
static void server_option_bitwise_support_base(const struct strvec *values, unsigned val, char *buf, size_t buf_len)
Definition options.c:4968
static void voteinfo_bar_callback(struct option *poption)
Definition options.c:6367
static struct option * server_optset_option_by_number(int id)
Definition options.c:4659
void options_save(option_save_log_callback log_cb)
Definition options.c:6053
static void message_options_free(void)
Definition options.c:5073
static const struct option_enum_vtable server_option_enum_vtable
Definition options.c:4076
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6453
const struct strvec * option_bitwise_values(const struct option *poption)
Definition options.c:1088
static bool server_option_int_set(struct option *poption, int val)
Definition options.c:4820
int messages_where[E_COUNT]
Definition options.c:5028
static void message_options_load(struct section_file *file, const char *prefix)
Definition options.c:5082
struct client_options gui_options
Definition options.c:71
static void server_option_free(struct server_option *poption)
Definition options.c:4164
#define CLIENT_OPTION(poption)
Definition options.c:1466
#define GEN_FONT_OPTION(oname, otgt, odesc, ohelp, ocat, ospec, odef, ocb)
Definition options.c:1715
static struct option_set server_optset_static
Definition options.c:4003
void handle_server_setting_control(const struct packet_server_setting_control *packet)
Definition options.c:4254
static void mapimg_changed_callback(struct option *poption)
Definition options.c:6384
bool option_bitwise_set(struct option *poption, unsigned val)
Definition options.c:1099
static int server_option_int_get(const struct option *poption)
Definition options.c:4787
static void manual_turn_done_callback(struct option *poption)
Definition options.c:6342
static void reqtree_show_icons_callback(struct option *poption)
Definition options.c:6325
const char * option_font_get(const struct option *poption)
Definition options.c:1116
void desired_settable_options_update(void)
Definition options.c:5531
static void load_cma_preset(struct section_file *file, int i)
Definition options.c:5183
static bool client_option_str_set(struct option *poption, const char *str)
Definition options.c:3579
void handle_server_setting_enum(const struct packet_server_setting_enum *packet)
Definition options.c:4462
struct ft_color option_color_def(const struct option *poption)
Definition options.c:1176
static int client_option_int_max(const struct option *poption)
Definition options.c:3525
#define GEN_STR_LIST_OPTION(oname, odesc, ohelp, ocat, ospec, odef, oacc, ocb, cbd)
Definition options.c:1599
client_option_category
Definition options.c:1387
@ COC_MAX
Definition options.c:1395
@ COC_SOUND
Definition options.c:1390
@ COC_NETWORK
Definition options.c:1393
@ COC_INTERFACE
Definition options.c:1391
@ COC_GRAPHICS
Definition options.c:1388
@ COC_OVERVIEW
Definition options.c:1389
@ COC_FONT
Definition options.c:1394
@ COC_MAPIMG
Definition options.c:1392
unsigned option_bitwise_get(const struct option *poption)
Definition options.c:1049
static bool server_option_is_changeable(const struct option *poption)
Definition options.c:4738
static struct ft_color client_option_color_get(const struct option *poption)
Definition options.c:3752
int option_enum_def_int(const struct option *poption)
Definition options.c:979
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:406
static const int client_options_num
Definition options.c:3317
static bool client_option_int_set(struct option *poption, int val)
Definition options.c:3534
void options_dialogs_set(void)
Definition options.c:5864
bool option_int_set(struct option *poption, int val)
Definition options.c:853
static struct client_option * client_option_next_valid(struct client_option *poption)
Definition options.c:3338
static const char * client_option_bitwise_secfile_str(secfile_data_t data, int val)
Definition options.c:3699
#define GEN_VIDEO_OPTION(oname, odesc, ohelp, ocat, ospec, odef_width, odef_height, ocb)
Definition options.c:1786
static const struct option_int_vtable client_option_int_vtable
Definition options.c:1301
static const char * client_option_font_def(const struct option *poption)
Definition options.c:3719
static const char * get_last_option_file_name(bool *allow_digital_boolean)
Definition options.c:5306
const char * option_category_name(const struct option *poption)
Definition options.c:653
static void game_music_enable_callback(struct option *poption)
Definition options.c:6417
static const char * get_current_option_file_name(void)
Definition options.c:5271
int option_int_def(const struct option *poption)
Definition options.c:820
static void options_init_names(const struct copt_val_name *(*acc)(int), struct strvec **support, struct strvec **pretty)
Definition options.c:6156
struct video_mode option_video_mode_def(const struct option *poption)
Definition options.c:1215
static bool server_option_bool_def(const struct option *poption)
Definition options.c:4762
#define GUI_GTK3_CITYDLG_DEFAULT_XSIZE
Definition options.h:578
#define GUI_GTK3_22_GOV_RANGE_MIN_DEFAULT
Definition options.h:603
#define MW_POPUP
Definition options.h:556
#define GUI_GTK3_CITYDLG_MAX_YSIZE
Definition options.h:584
#define GUI_GTK3_22_GOV_RANGE_MIN_MIN
Definition options.h:604
#define GUI_GTK3_GOV_RANGE_MIN_DEFAULT
Definition options.h:586
#define GUI_GTK4_GOV_RANGE_MIN_MAX
Definition options.h:622
#define GUI_GTK3_22_CITYDLG_MIN_YSIZE
Definition options.h:600
#define GUI_GTK4_CITYDLG_MAX_XSIZE
Definition options.h:614
#define GUI_GTK4_GOV_RANGE_MIN_DEFAULT
Definition options.h:620
#define GUI_GTK3_GOV_RANGE_MAX_DEFAULT
Definition options.h:590
void(* option_save_log_callback)(enum log_level lvl, const char *msg,...)
Definition options.h:422
#define FC_GTK3_DEFAULT_THEME_NAME
Definition options.h:259
#define GUI_GTK4_CITYDLG_DEFAULT_XSIZE
Definition options.h:612
#define GUI_GTK2_CITYDLG_DEFAULT_YSIZE
Definition options.h:570
#define FC_GTK3_22_DEFAULT_THEME_NAME
Definition options.h:295
#define GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE
Definition options.h:595
#define FC_QT_DEFAULT_THEME_NAME
Definition options.h:385
#define GUI_GTK3_CITYDLG_MIN_YSIZE
Definition options.h:583
#define GUI_GTK3_CITYDLG_MIN_XSIZE
Definition options.h:579
#define GUI_GTK3_22_CITYDLG_DEFAULT_YSIZE
Definition options.h:599
#define GUI_GTK4_CITYDLG_MIN_YSIZE
Definition options.h:617
#define GUI_GTK2_CITYDLG_MIN_YSIZE
Definition options.h:571
#define options_iterate(poptset, poption)
Definition options.h:527
#define GUI_GTK2_CITYDLG_MAX_XSIZE
Definition options.h:568
#define GUI_DEFAULT_CHAT_LOGFILE
Definition options.h:563
#define GUI_GTK3_GOV_RANGE_MAX_MAX
Definition options.h:592
#define GUI_GTK4_CITYDLG_MIN_XSIZE
Definition options.h:613
#define GUI_GTK3_22_GOV_RANGE_MAX_DEFAULT
Definition options.h:607
#define DEFAULT_METASERVER_OPTION
Definition options.h:29
#define GUI_GTK3_CITYDLG_DEFAULT_YSIZE
Definition options.h:582
static struct video_mode video_mode_construct(int width, int height)
Definition options.h:56
#define GUI_GTK3_22_CITYDLG_MAX_XSIZE
Definition options.h:597
#define GUI_GTK3_22_GOV_RANGE_MAX_MIN
Definition options.h:608
#define GUI_GTK3_GOV_RANGE_MIN_MIN
Definition options.h:587
@ GUI_GTK_MSGCHAT_SEPARATE
Definition options.h:67
#define GUI_GTK3_GOV_RANGE_MIN_MAX
Definition options.h:588
#define GUI_GTK3_22_CITYDLG_MIN_XSIZE
Definition options.h:596
#define GUI_GTK4_GOV_RANGE_MAX_DEFAULT
Definition options.h:624
#define MAJOR_NEW_OPTION_FILE_NAME
Definition options.h:37
@ GUI_POPUP_TECH_HELP_RULESET
Definition options.h:76
#define GUI_GTK3_GOV_RANGE_MAX_MIN
Definition options.h:591
#define GUI_GTK2_CITYDLG_MAX_YSIZE
Definition options.h:572
#define GUI_DEFAULT_MAPIMG_FILENAME
Definition options.h:628
#define GUI_GTK3_22_CITYDLG_MAX_YSIZE
Definition options.h:601
#define GUI_GTK4_GOV_RANGE_MIN_MIN
Definition options.h:621
#define GUI_GTK4_CITYDLG_MAX_YSIZE
Definition options.h:618
#define MW_OUTPUT
Definition options.h:554
#define GUI_GTK4_CITYDLG_DEFAULT_YSIZE
Definition options.h:616
#define options_iterate_end
Definition options.h:532
#define GUI_GTK4_GOV_RANGE_MAX_MAX
Definition options.h:626
#define MW_MESSAGES
Definition options.h:555
#define FC_GTK4_DEFAULT_THEME_NAME
Definition options.h:331
#define GUI_GTK3_22_GOV_RANGE_MIN_MAX
Definition options.h:605
#define MINOR_NEW_OPTION_FILE_NAME
Definition options.h:41
#define GUI_GTK2_CITYDLG_DEFAULT_XSIZE
Definition options.h:566
#define FC_SDL2_DEFAULT_THEME_NAME
Definition options.h:374
#define GUI_GTK3_22_GOV_RANGE_MAX_MAX
Definition options.h:609
#define VIDEO_MODE(ARG_width, ARG_height)
Definition options.h:50
@ OLAYER_BORDERS
Definition options.h:82
@ OLAYER_BACKGROUND
Definition options.h:80
@ OLAYER_CITIES
Definition options.h:85
@ OLAYER_BORDERS_ON_OCEAN
Definition options.h:83
@ OLAYER_UNITS
Definition options.h:84
@ OLAYER_RELIEF
Definition options.h:81
#define GUI_GTK3_CITYDLG_MAX_XSIZE
Definition options.h:580
#define GUI_GTK4_GOV_RANGE_MAX_MIN
Definition options.h:625
#define FC_GTK2_DEFAULT_THEME_NAME
Definition options.h:227
#define GUI_GTK2_CITYDLG_MIN_XSIZE
Definition options.h:567
void overview_redraw_callback(struct option *option)
#define MAX_LEN_MSG
Definition packets.h:43
#define is_ai(plr)
Definition player.h:234
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_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:628
bool str_to_int(const char *str, int *pint)
Definition shared.c:512
bool make_dir(const char *pathname)
Definition shared.c:1772
char * freeciv_storage_dir(void)
Definition shared.c:672
#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:1419
const struct copt_val_name *(*const name_accessor)(int value)
Definition options.c:1437
const unsigned def
Definition options.c:1442
struct strvec * pretty_names
Definition options.c:1436
struct client_option::@224::@228 string
struct client_option::@224::@231 font
struct client_option::@224::@229 enumerator
enum gui_type specific
Definition options.c:1408
struct strvec * support_names
Definition options.c:1436
const char * description
Definition options.c:1405
const char *const def
Definition options.c:1425
struct ft_color *const pvalue
Definition options.c:1455
struct video_mode *const pvalue
Definition options.c:1460
struct client_option::@224::@233 video_mode
const size_t size
Definition options.c:1424
char *const pvalue
Definition options.c:1423
const int max
Definition options.c:1419
const bool def
Definition options.c:1414
const char *const target
Definition options.c:1451
bool *const pvalue
Definition options.c:1413
struct option base_option
Definition options.c:1402
const char * help_text
Definition options.c:1406
unsigned *const pvalue
Definition options.c:1441
struct client_option::@224::@230 bitwise
struct client_option::@224::@232 color
enum client_option_category category
Definition options.c:1407
struct client_option::@224::@226 boolean
int *const pvalue
Definition options.c:1418
struct client_option::@224::@227 integer
const char * name
Definition options.c:1404
bool gui_gtk3_22_migrated_from_gtk3
Definition options.h:130
bool gui_gtk2_migrated_from_2_5
Definition options.h:133
bool gui_sdl2_migrated_from_sdl
Definition options.h:132
bool sound_enable_menu_music
Definition options.h:181
char default_tileset_hex_name[512]
Definition options.h:114
char default_tileset_iso_name[512]
Definition options.h:128
char default_tileset_name[512]
Definition options.h:126
char default_tileset_overhead_name[512]
Definition options.h:127
bool gui_gtk3_migrated_from_2_5
Definition options.h:134
char default_tileset_square_name[512]
Definition options.h:113
bool save_options_on_exit
Definition options.h:121
int sound_effects_volume
Definition options.h:183
bool ai_manual_turn_done
Definition options.h:147
int smooth_combat_step_msec
Definition options.h:146
bool first_boot
Definition options.h:124
float zoom_default_level
Definition options.h:223
char default_tileset_isohex_name[512]
Definition options.h:115
bool gui_qt_migrated_from_2_5
Definition options.h:135
bool popup_actor_arrival
Definition options.h:161
bool sound_enable_game_music
Definition options.h:182
bool migrate_fullscreen
Definition options.h:138
bool gui_qt_default_fonts_set
Definition options.h:136
bool gui_gtk3_migrated_from_gtk2
Definition options.h:129
char default_user_name[512]
Definition options.h:107
bool gui_gtk4_migrated_from_gtk3_22
Definition options.h:131
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:20
const char * support
Definition options.c:1258
const char * pretty
Definition options.c:1260
int(* number)(const struct option *)
Definition options.c:462
const char *(* name)(const struct option *)
Definition options.c:463
int(* category)(const struct option *)
Definition options.c:466
const char *(* description)(const struct option *)
Definition options.c:464
bool(* is_changeable)(const struct option *)
Definition options.c:467
struct option *(* next)(const struct option *)
Definition options.c:468
const char *(* help_text)(const struct option *)
Definition options.c:465
struct option *(* option_by_number)(int)
Definition options.c:385
struct option *(* option_first)(void)
Definition options.c:386
const char *(* category_name)(int)
Definition options.c:389
int(* category_number)(void)
Definition options.c:388
const struct option::option_common_vtable * common_vtable
const struct option::@222::option_bool_vtable * bool_vtable
const struct option::@222::option_font_vtable * font_vtable
const struct option::@222::option_bitwise_vtable * bitwise_vtable
enum option_type type
Definition options.c:458
const struct option_set * poptset
Definition options.c:456
const struct option::@222::option_str_vtable * str_vtable
const struct option::@222::option_enum_vtable * enum_vtable
const struct option::@222::option_int_vtable * int_vtable
int callback_data
Definition options.c:532
const struct option::@222::option_color_vtable * color_vtable
void(* changed_callback)(struct option *option)
Definition options.c:530
void * gui_data
Definition options.c:535
const struct option::@222::option_video_mode_vtable * video_mode_vtable
bool fog
Definition options.h:101
bool layers[OLAYER_COUNT]
Definition options.h:102
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:4132
unsigned value
Definition options.c:4137
char * help_text
Definition options.c:4105
struct server_option::@234::@239 enumerator
char * name
Definition options.c:4103
bool is_visible
Definition options.c:4109
char * description
Definition options.c:4104
unsigned char category
Definition options.c:4106
struct strvec * pretty_names
Definition options.c:4133
enum setting_default_level setdef
Definition options.c:4110
struct server_option::@234::@240 bitwise
struct server_option::@234::@238 string
unsigned def
Definition options.c:4138
bool is_changeable
Definition options.c:4108
struct server_option::@234::@236 boolean
char * value
Definition options.c:4125
struct server_option::@234::@237 integer
struct option base_option
Definition options.c:4101
bool desired_sent
Definition options.c:4107
int height
Definition options.h:47
int width
Definition options.h:46
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:787
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:832
int fc_stat(const char *filename, struct stat *buf)
Definition support.c:575
#define sz_strlcpy(dest, src)
Definition support.h:167
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define bool
Definition support.h:61
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:1240
const struct strvec * get_tileset_list(const struct option *poption)
Definition tilespec.c:1047
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:667
void tilespec_reread_callback(struct option *poption)
Definition tilespec.c:1449
int tileset_topo_index(struct tileset *t)
Definition tilespec.c:7251
#define TS_TOPO_ISOHEX
Definition tilespec.h:450
#define TS_TOPO_HEX
Definition tilespec.h:449
#define TS_TOPO_SQUARE
Definition tilespec.h:448
#define show(id)
Definition widget.h:235