From d536847790a44d167f620622734780901a7e8323 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 12 Jul 2023 04:49:55 +0300 Subject: [PATCH 33/33] sdl2: Adjust initial resolution by font size See osdn #48397 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/gui_main.c | 10 +++++++++- client/options.c | 14 ++++++++++---- client/options.h | 3 ++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/client/gui-sdl2/gui_main.c b/client/gui-sdl2/gui_main.c index 5af510a1f3..3eeea1a7db 100644 --- a/client/gui-sdl2/gui_main.c +++ b/client/gui-sdl2/gui_main.c @@ -1025,6 +1025,14 @@ int ui_main(int argc, char *argv[]) if (!gui_options.gui_sdl2_migrated_from_sdl) { migrate_options_from_sdl(); } + if (!GUI_SDL_OPTION(default_screen_size_set)) { + if (font_size_parameter > 10) { + GUI_SDL_OPTION(screen) = VIDEO_MODE(640 * font_size_parameter / 10, + 480 * font_size_parameter / 10); + } + + GUI_SDL_OPTION(default_screen_size_set) = TRUE; + } if (GUI_SDL_OPTION(fullscreen)) { flags |= SDL_WINDOW_FULLSCREEN; @@ -1099,7 +1107,7 @@ int ui_main(int argc, char *argv[]) setup_auxiliary_tech_icons(); - /* this need correct main_data.screen size */ + /* This needs correct main_data.screen size */ init_mapcanvas_and_overview(); set_client_state(C_S_DISCONNECTED); diff --git a/client/options.c b/client/options.c index 30087b3b20..e4fd94eac6 100644 --- a/client/options.c +++ b/client/options.c @@ -107,6 +107,7 @@ struct client_options gui_options = { /** Flags **/ .gui_qt_default_fonts_set = FALSE, + .gui_sdl2_default_screen_size_set = FALSE, /** Local Options: **/ @@ -6082,7 +6083,7 @@ void options_load(void) } if (!(sf = secfile_load(name, TRUE))) { log_debug("Error loading option file '%s':\n%s", name, secfile_error()); - /* try to create the rc file */ + /* Try to create the rc file */ sf = secfile_new(TRUE); secfile_insert_str(sf, VERSION_STRING, "client.version"); @@ -6137,9 +6138,12 @@ void options_load(void) "%s.migration_qt_from_2_5", prefix); /* Flag values */ - gui_options.gui_qt_default_fonts_set = - secfile_lookup_bool_default(sf, gui_options.gui_qt_default_fonts_set, - "%s.flag_qt_default_fonts_set", prefix); + gui_options.gui_qt_default_fonts_set + = secfile_lookup_bool_default(sf, gui_options.gui_qt_default_fonts_set, + "%s.flag_qt_default_fonts_set", prefix); + 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); /* These are not gui-enabled yet */ gui_options.zoom_set @@ -6273,6 +6277,8 @@ void options_save(option_save_log_callback log_cb) /* Flag */ secfile_insert_bool(sf, gui_options.gui_qt_default_fonts_set, "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"); /* gui-enabled options */ client_options_iterate_all(poption) { diff --git a/client/options.h b/client/options.h index 3615962629..bbe130b49c 100644 --- a/client/options.h +++ b/client/options.h @@ -46,7 +46,7 @@ struct video_mode { }; #define VIDEO_MODE(ARG_width, ARG_height) \ - { ARG_width, ARG_height } + (struct video_mode){ ARG_width, ARG_height } /**************************************************************************** Constructor. @@ -133,6 +133,7 @@ struct client_options bool gui_gtk3_migrated_from_2_5; bool gui_qt_migrated_from_2_5; bool gui_qt_default_fonts_set; + bool gui_sdl2_default_screen_size_set; bool migrate_fullscreen; -- 2.40.1