Skip to content

Commit

Permalink
sdl2: Adjust initial resolution by font size
Browse files Browse the repository at this point in the history
See osdn #48397

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
  • Loading branch information
cazfi committed Jul 19, 2023
1 parent 484f278 commit 213658a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
10 changes: 9 additions & 1 deletion client/gui-sdl2/gui_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 10 additions & 4 deletions client/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: **/

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion client/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 213658a

Please sign in to comment.