From 40efb2c0d67173ab235542c599dd2b26c07a2c50 Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Mon, 11 May 2015 14:33:24 -0400 Subject: [PATCH 1/2] Last windowed size is now remembered Added funciton platform_update_config_window_size() to shared.c Window size is not updated if the window is maximized --- src/platform/platform.h | 1 + src/platform/shared.c | 17 +++++++++++++++++ src/rct2.c | 3 +++ 3 files changed, 21 insertions(+) diff --git a/src/platform/platform.h b/src/platform/platform.h index 98bd6b0041..4457d3a32a 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -80,6 +80,7 @@ void platform_process_messages(); int platform_scancode_to_rct_keycode(int sdl_key); void platform_start_text_input(char* buffer, int max_length); void platform_stop_text_input(); +void platform_update_config_window_size(); // Platform specific definitions char platform_get_path_separator(); diff --git a/src/platform/shared.c b/src/platform/shared.c index 4361a35451..47129bac09 100644 --- a/src/platform/shared.c +++ b/src/platform/shared.c @@ -453,6 +453,23 @@ static void platform_close_window() platform_unload_cursors(); } +void platform_update_config_window_size() +{ + // Check if the window has been resized in windowed mode and update the config file accordingly + // This is called in rct2_update_2 and is only called after resizing a window has finished + int width, height; + uint32 flags = SDL_GetWindowFlags(gWindow); + if ((flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | + SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP)) == 0) { + SDL_GetWindowSize(gWindow, &width, &height); + if (width != gConfigGeneral.window_width || height != gConfigGeneral.window_height) { + gConfigGeneral.window_width = width; + gConfigGeneral.window_height = height; + config_save_default(); + } + } +} + void platform_init() { platform_create_window(); diff --git a/src/rct2.c b/src/rct2.c index f70848a2a7..c91f007473 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -345,6 +345,9 @@ void rct2_update_2() title_update(); else game_update(); + + // Update the windowed mode size in the config file if needed + platform_update_config_window_size(); } void rct2_endupdate() From 37ff266fc61276182c99600179414c6a30027fd1 Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Mon, 11 May 2015 14:51:13 -0400 Subject: [PATCH 2/2] Only checks window size during platform_resize() now Removed platform_update_config_window_size() --- src/platform/platform.h | 1 - src/platform/shared.c | 30 +++++++++++++----------------- src/rct2.c | 3 --- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/platform/platform.h b/src/platform/platform.h index 4457d3a32a..98bd6b0041 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -80,7 +80,6 @@ void platform_process_messages(); int platform_scancode_to_rct_keycode(int sdl_key); void platform_start_text_input(char* buffer, int max_length); void platform_stop_text_input(); -void platform_update_config_window_size(); // Platform specific definitions char platform_get_path_separator(); diff --git a/src/platform/shared.c b/src/platform/shared.c index 47129bac09..22a1977507 100644 --- a/src/platform/shared.c +++ b/src/platform/shared.c @@ -191,6 +191,7 @@ static void platform_resize(int width, int height) rct_drawpixelinfo *screenDPI; int newScreenBufferSize; void *newScreenBuffer; + uint32 flags; if (_surface != NULL) SDL_FreeSurface(_surface); @@ -247,6 +248,18 @@ static void platform_resize(int width, int height) window_relocate_windows(width, height); gfx_invalidate_screen(); + + // Check if the window has been resized in windowed mode and update the config file accordingly + // This is called in rct2_update_2 and is only called after resizing a window has finished + flags = SDL_GetWindowFlags(gWindow); + if ((flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | + SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP)) == 0) { + if (width != gConfigGeneral.window_width || height != gConfigGeneral.window_height) { + gConfigGeneral.window_width = width; + gConfigGeneral.window_height = height; + config_save_default(); + } + } } void platform_update_palette(char* colours, int start_index, int num_colours) @@ -453,23 +466,6 @@ static void platform_close_window() platform_unload_cursors(); } -void platform_update_config_window_size() -{ - // Check if the window has been resized in windowed mode and update the config file accordingly - // This is called in rct2_update_2 and is only called after resizing a window has finished - int width, height; - uint32 flags = SDL_GetWindowFlags(gWindow); - if ((flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | - SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP)) == 0) { - SDL_GetWindowSize(gWindow, &width, &height); - if (width != gConfigGeneral.window_width || height != gConfigGeneral.window_height) { - gConfigGeneral.window_width = width; - gConfigGeneral.window_height = height; - config_save_default(); - } - } -} - void platform_init() { platform_create_window(); diff --git a/src/rct2.c b/src/rct2.c index c91f007473..f70848a2a7 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -345,9 +345,6 @@ void rct2_update_2() title_update(); else game_update(); - - // Update the windowed mode size in the config file if needed - platform_update_config_window_size(); } void rct2_endupdate()