From 32e154f337f36b31349bbf8dabeaed151401f789 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 29 Sep 2023 20:38:48 +0300 Subject: [PATCH 53/53] Copy sdl2-client options as sdl3-client options See osdn #48756 Signed-off-by: Marko Lindqvist --- client/options.c | 70 +++++++++++++++++++++++++++++++++++++++++++++-- client/options.h | 14 ++++++++++ client/tilespec.c | 4 +++ common/fc_types.h | 18 ++++++------ 4 files changed, 96 insertions(+), 10 deletions(-) diff --git a/client/options.c b/client/options.c index 582ce53173..c02aec02b4 100644 --- a/client/options.c +++ b/client/options.c @@ -111,6 +111,7 @@ struct client_options gui_options = { .gui_qt_default_fonts_set = FALSE, .gui_sdl2_default_screen_size_set = FALSE, + .gui_sdl3_default_screen_size_set = FALSE, /** Local Options: **/ @@ -361,6 +362,18 @@ struct client_options gui_options = { .gui_sdl2_use_theme_font_size = TRUE, .gui_sdl2_font_size = 10, +/* gui-sdl3 client specific options. */ + .gui_sdl3_default_theme_name = FC_SDL2_DEFAULT_THEME_NAME, + .gui_sdl3_fullscreen = FALSE, + .gui_sdl3_screen = VIDEO_MODE(640, 480), + .gui_sdl3_swrenderer = FALSE, + .gui_sdl3_do_cursor_animation = TRUE, + .gui_sdl3_use_color_cursors = TRUE, + .gui_sdl3_font_city_names = "10", + .gui_sdl3_font_city_productions = "10", + .gui_sdl3_use_theme_font_size = TRUE, + .gui_sdl3_font_size = 10, + /* gui-qt client specific options. */ .gui_qt_fullscreen = FALSE, .gui_qt_show_preview = TRUE, @@ -1952,9 +1965,9 @@ static struct client_option client_options[] = { N_("The chat log file"), N_("The name of the chat log file."), COC_INTERFACE, GUI_STUB, GUI_DEFAULT_CHAT_LOGFILE, NULL, 0), - /* gui_gtk3_22/4_default_theme_name and gui_sdl2_default_theme_name are + /* gui_gtk3_22/4_default_theme_name and gui_sdl2/3_default_theme_name are * different settings to avoid client crash after loading the - * style for the other gui. Keeps 5 different options! */ + * style for the other gui. Keeps 5 different options! */ GEN_STR_LIST_OPTION(gui_gtk3_22_default_theme_name, N_("Theme"), N_("By changing this option you change the " "active theme."), @@ -1970,6 +1983,11 @@ static struct client_option client_options[] = { "active theme."), COC_GRAPHICS, GUI_SDL2, FC_SDL2_DEFAULT_THEME_NAME, get_themes_list, theme_reread_callback, 0), + GEN_STR_LIST_OPTION(gui_sdl3_default_theme_name, N_("Theme"), + N_("By changing this option you change the " + "active theme."), + COC_GRAPHICS, GUI_SDL3, FC_SDL3_DEFAULT_THEME_NAME, + get_themes_list, theme_reread_callback, 0), GEN_STR_LIST_OPTION(gui_qt_default_theme_name, N_("Theme"), N_("By changing this option you change the " "active theme."), @@ -3164,6 +3182,49 @@ static struct client_option client_options[] = { "option is disabled."), COC_FONT, GUI_SDL2, 10, 6, 50, NULL), + /* gui-sdl3 client specific options. */ + GEN_BOOL_OPTION(gui_sdl3_fullscreen, N_("Fullscreen"), + N_("If this option is set the client will use the " + "whole screen area for drawing."), + COC_INTERFACE, GUI_SDL3, FALSE, NULL), + GEN_VIDEO_OPTION(gui_sdl3_screen, N_("Screen resolution"), + N_("This option controls the resolution of the " + "selected screen."), + COC_INTERFACE, GUI_SDL3, 640, 480, NULL), + GEN_BOOL_OPTION(gui_sdl3_swrenderer, N_("Use software rendering"), + N_("Usually hardware rendering is used when possible. " + "With this option set, software rendering is always used."), + COC_GRAPHICS, GUI_SDL3, FALSE, NULL), + GEN_BOOL_OPTION(gui_sdl3_do_cursor_animation, N_("Do cursor animation"), + N_("If this option is disabled, the cursor will " + "always be displayed as static."), + COC_INTERFACE, GUI_SDL3, TRUE, NULL), + GEN_BOOL_OPTION(gui_sdl3_use_color_cursors, N_("Use color cursors"), + N_("If this option is disabled, the cursor will " + "always be displayed in black and white."), + COC_INTERFACE, GUI_SDL3, TRUE, NULL), + GEN_FONT_OPTION(gui_sdl3_font_city_names, "FONT_CITY_NAME", + N_("City Names"), + N_("The size of font used to the display the city names " + "on the map."), + COC_FONT, GUI_SDL3, + "10", font_changed_callback), + GEN_FONT_OPTION(gui_sdl3_font_city_productions, "FONT_CITY_PROD", + N_("City Productions"), + N_("The size of font used to the display the city " + "production names on the map."), + COC_FONT, GUI_SDL3, + "10", font_changed_callback), + GEN_BOOL_OPTION(gui_sdl3_use_theme_font_size, N_("Use theme defined font size"), + N_("Disable this to override base font size set by theme " + "by the setting below."), + COC_FONT, GUI_SDL3, TRUE, NULL), + GEN_INT_OPTION(gui_sdl3_font_size, N_("Base Font Size"), + N_("Base Font Size. All the fonts' sizes are defined relative " + "to this. This option has effect only if theme font sizes " + "option is disabled."), + COC_FONT, GUI_SDL3, 10, 6, 50, NULL), + /* gui-qt client specific options. */ GEN_BOOL_OPTION(gui_qt_fullscreen, N_("Fullscreen"), N_("If this option is set the client will use the " @@ -5919,6 +5980,9 @@ void options_load(void) gui_options.gui_sdl2_default_screen_size_set = secfile_lookup_bool_default(sf, gui_options.gui_sdl2_default_screen_size_set, "%s.flag_sdl2_default_screen_size_set", prefix); + gui_options.gui_sdl3_default_screen_size_set + = secfile_lookup_bool_default(sf, gui_options.gui_sdl3_default_screen_size_set, + "%s.flag_sdl3_default_screen_size_set", prefix); /* These are not gui-enabled yet */ gui_options.zoom_set @@ -6058,6 +6122,8 @@ void options_save(option_save_log_callback log_cb) "client.flag_qt_default_fonts_set"); secfile_insert_bool(sf, gui_options.gui_sdl2_default_screen_size_set, "client.flag_sdl2_default_screen_size_set"); + secfile_insert_bool(sf, gui_options.gui_sdl3_default_screen_size_set, + "client.flag_sdl3_default_screen_size_set"); /* gui-enabled options */ client_options_iterate_all(poption) { diff --git a/client/options.h b/client/options.h index f5c0a41ede..c1d4e7c452 100644 --- a/client/options.h +++ b/client/options.h @@ -139,6 +139,7 @@ struct client_options bool gui_qt_migrated_from_2_5; bool gui_qt_default_fonts_set; bool gui_sdl2_default_screen_size_set; + bool gui_sdl3_default_screen_size_set; bool migrate_fullscreen; @@ -386,6 +387,19 @@ struct client_options bool gui_sdl2_use_theme_font_size; int gui_sdl2_font_size; +/* gui-sdl3 client specific options. */ +#define FC_SDL3_DEFAULT_THEME_NAME "human" + char gui_sdl3_default_theme_name[512]; + bool gui_sdl3_fullscreen; + struct video_mode gui_sdl3_screen; + bool gui_sdl3_swrenderer; + bool gui_sdl3_do_cursor_animation; + bool gui_sdl3_use_color_cursors; + char gui_sdl3_font_city_names[64]; + char gui_sdl3_font_city_productions[64]; + bool gui_sdl3_use_theme_font_size; + int gui_sdl3_font_size; + /* gui-qt client specific options. */ #define FC_QT_DEFAULT_THEME_NAME "NightStalker" bool gui_qt_fullscreen; diff --git a/client/tilespec.c b/client/tilespec.c index 624c78e511..710750c0f6 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -7088,6 +7088,10 @@ void tileset_use_preferred_theme(const struct tileset *t) default_theme_name = gui_options.gui_sdl2_default_theme_name; default_theme_name_sz = sizeof(gui_options.gui_sdl2_default_theme_name); break; + case GUI_SDL3: + default_theme_name = gui_options.gui_sdl3_default_theme_name; + default_theme_name_sz = sizeof(gui_options.gui_sdl3_default_theme_name); + break; case GUI_STUB: case GUI_QT: case GUI_SDL: diff --git a/common/fc_types.h b/common/fc_types.h index a14e94f3c7..a523b1201f 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -884,18 +884,20 @@ BV_DEFINE(bv_startpos_nations, MAX_NUM_STARTPOS_NATIONS); #define SPECENUM_VALUE2NAME "gtk3" #define SPECENUM_VALUE3 GUI_GTK3_22 #define SPECENUM_VALUE3NAME "gtk3.22" +#define SPECENUM_VALUE4 GUI_QT +#define SPECENUM_VALUE4NAME "qt" /* GUI_SDL remains for now for keeping client options alive until * user has migrated them to sdl2-client */ -#define SPECENUM_VALUE4 GUI_SDL -#define SPECENUM_VALUE4NAME "sdl" -#define SPECENUM_VALUE5 GUI_QT -#define SPECENUM_VALUE5NAME "qt" +#define SPECENUM_VALUE5 GUI_SDL +#define SPECENUM_VALUE5NAME "sdl" #define SPECENUM_VALUE6 GUI_SDL2 #define SPECENUM_VALUE6NAME "sdl2" -#define SPECENUM_VALUE7 GUI_WEB -#define SPECENUM_VALUE7NAME "web" -#define SPECENUM_VALUE8 GUI_GTK4 -#define SPECENUM_VALUE8NAME "gtk4" +#define SPECENUM_VALUE7 GUI_SDL3 +#define SPECENUM_VALUE7NAME "sdl3" +#define SPECENUM_VALUE8 GUI_WEB +#define SPECENUM_VALUE8NAME "web" +#define SPECENUM_VALUE9 GUI_GTK4 +#define SPECENUM_VALUE9NAME "gtk4" #include "specenum_gen.h" /* Used in the network protocol. */ -- 2.40.1