From d840a32a1ff3e789b5bc5ea62112c2fa2e87dfca Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 11 Oct 2023 01:32:06 +0300 Subject: [PATCH 16/22] sdl3: Migrate options from sdl2-client See osdn #48831 Signed-off-by: Marko Lindqvist --- client/gui-sdl3/gui_main.c | 22 +++++++++++++++------- client/options.c | 6 ++++++ client/options.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/client/gui-sdl3/gui_main.c b/client/gui-sdl3/gui_main.c index 62b7f6d19f..b7a5f7a372 100644 --- a/client/gui-sdl3/gui_main.c +++ b/client/gui-sdl3/gui_main.c @@ -1001,23 +1001,31 @@ int main(int argc, char **argv) } /**********************************************************************//** - Migrate sdl2 client specific options from sdl client options. + Migrate sdl3 client specific options from sdl2 client options. **************************************************************************/ -static void migrate_options_from_sdl(void) +static void migrate_options_from_sdl2(void) { - log_normal(_("Migrating options from sdl to sdl2 client")); + log_normal(_("Migrating options from sdl2 to sdl3 client")); -#define MIGRATE_OPTION(opt) gui_options.gui_sdl2_##opt = gui_options.gui_sdl_##opt; +#define MIGRATE_OPTION(opt) gui_options.gui_sdl3_##opt = gui_options.gui_sdl2_##opt; +#define MIGRATE_STR_OPTION(opt) \ + strncpy(gui_options.gui_sdl3_##opt, gui_options.gui_sdl2_##opt, \ + sizeof(gui_options.gui_sdl3_##opt)); /* Default theme name is never migrated */ MIGRATE_OPTION(fullscreen); MIGRATE_OPTION(screen); + MIGRATE_OPTION(swrenderer); MIGRATE_OPTION(do_cursor_animation); MIGRATE_OPTION(use_color_cursors); + MIGRATE_STR_OPTION(font_city_names); + MIGRATE_STR_OPTION(font_city_productions); + MIGRATE_OPTION(use_theme_font_size); + MIGRATE_OPTION(font_size); #undef MIGRATE_OPTION - gui_options.gui_sdl2_migrated_from_sdl = TRUE; + gui_options.gui_sdl3_migrated_from_sdl2 = TRUE; } /**********************************************************************//** @@ -1029,8 +1037,8 @@ int ui_main(int argc, char *argv[]) Uint32 flags = 0; if (parse_options(argc, argv)) { - if (!gui_options.gui_sdl2_migrated_from_sdl) { - migrate_options_from_sdl(); + if (!gui_options.gui_sdl3_migrated_from_sdl2) { + migrate_options_from_sdl2(); } if (!GUI_SDL_OPTION(default_screen_size_set)) { if (font_size_parameter > 10) { diff --git a/client/options.c b/client/options.c index c02aec02b4..ec4708f319 100644 --- a/client/options.c +++ b/client/options.c @@ -101,6 +101,7 @@ struct client_options gui_options = { .gui_gtk3_22_migrated_from_gtk3 = FALSE, .gui_gtk4_migrated_from_gtk3_22 = FALSE, .gui_sdl2_migrated_from_sdl = FALSE, + .gui_sdl3_migrated_from_sdl2 = FALSE, .gui_gtk2_migrated_from_2_5 = FALSE, .gui_gtk3_migrated_from_2_5 = FALSE, .gui_qt_migrated_from_2_5 = FALSE, @@ -5963,6 +5964,9 @@ void options_load(void) gui_options.gui_sdl2_migrated_from_sdl = secfile_lookup_bool_default(sf, gui_options.gui_sdl2_migrated_from_sdl, "%s.migration_sdl2_from_sdl", prefix); + gui_options.gui_sdl3_migrated_from_sdl2 = + secfile_lookup_bool_default(sf, gui_options.gui_sdl3_migrated_from_sdl2, + "%s.migration_sdl3_from_sdl2", prefix); gui_options.gui_gtk2_migrated_from_2_5 = secfile_lookup_bool_default(sf, gui_options.gui_gtk2_migrated_from_2_5, "%s.migration_gtk2_from_2_5", prefix); @@ -6110,6 +6114,8 @@ void options_save(option_save_log_callback log_cb) "client.migration_gtk4_from_gtk3"); secfile_insert_bool(sf, gui_options.gui_sdl2_migrated_from_sdl, "client.migration_sdl2_from_sdl"); + secfile_insert_bool(sf, gui_options.gui_sdl3_migrated_from_sdl2, + "client.migration_sdl3_from_sdl2"); secfile_insert_bool(sf, gui_options.gui_gtk2_migrated_from_2_5, "client.migration_gtk2_from_2_5"); secfile_insert_bool(sf, gui_options.gui_gtk3_migrated_from_2_5, diff --git a/client/options.h b/client/options.h index c1d4e7c452..88859b715e 100644 --- a/client/options.h +++ b/client/options.h @@ -134,6 +134,7 @@ struct client_options bool gui_gtk3_22_migrated_from_gtk3; bool gui_gtk4_migrated_from_gtk3_22; bool gui_sdl2_migrated_from_sdl; + bool gui_sdl3_migrated_from_sdl2; bool gui_gtk2_migrated_from_2_5; bool gui_gtk3_migrated_from_2_5; bool gui_qt_migrated_from_2_5; -- 2.42.0