From: Holger Schemel Date: Sat, 5 Sep 2020 23:23:32 +0000 (+0200) Subject: split function to toggle fullscreen and change window scaling X-Git-Tag: 4.2.0.2~4 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ac94403f845928d307f2a7b60e81dfca1fd13cbb;p=rocksndiamonds.git split function to toggle fullscreen and change window scaling --- diff --git a/src/events.c b/src/events.c index 4140ab5f..0643e164 100644 --- a/src/events.c +++ b/src/events.c @@ -2177,7 +2177,7 @@ void HandleKey(Key key, int key_status) { setup.fullscreen = !setup.fullscreen; - ToggleFullscreenOrChangeWindowScalingIfNeeded(); + ToggleFullscreenIfNeeded(); if (game_status == GAME_MODE_SETUP) RedrawSetupScreenAfterFullscreenToggle(); @@ -2210,7 +2210,7 @@ void HandleKey(Key key, int key_status) else if (setup.window_scaling_percent > MAX_WINDOW_SCALING_PERCENT) setup.window_scaling_percent = MAX_WINDOW_SCALING_PERCENT; - ToggleFullscreenOrChangeWindowScalingIfNeeded(); + ChangeWindowScalingIfNeeded(); if (game_status == GAME_MODE_SETUP) RedrawSetupScreenAfterFullscreenToggle(); diff --git a/src/screens.c b/src/screens.c index a5d9d45f..1808e9bc 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1580,10 +1580,6 @@ void DrawMainMenu(void) return; } - // needed if last screen was the setup screen and fullscreen state changed - // (moved to "execSetupGraphics()" to change fullscreen state directly) - // ToggleFullscreenOrChangeWindowScalingIfNeeded(); - // leveldir_current may be invalid (level group, parent link) if (!validLevelSeries(leveldir_current)) leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid); @@ -5327,7 +5323,7 @@ static void execSetupGraphics(void) ModifyGameSpeedIfNeeded(); // window scaling may have changed at this point - ToggleFullscreenOrChangeWindowScalingIfNeeded(); + ChangeWindowScalingIfNeeded(); // window scaling quality may have changed at this point if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality)) @@ -6861,7 +6857,7 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) // fullscreen state may have changed at this point if (si->value == &setup.fullscreen) - ToggleFullscreenOrChangeWindowScalingIfNeeded(); + ToggleFullscreenIfNeeded(); // network mode may have changed at this point if (si->value == &setup.network_mode) diff --git a/src/tools.c b/src/tools.c index 4affe136..d44e2cb4 100644 --- a/src/tools.c +++ b/src/tools.c @@ -9243,7 +9243,7 @@ void PlaySoundSelecting(void) #endif } -void ToggleFullscreenOrChangeWindowScalingIfNeeded(void) +void ToggleFullscreenIfNeeded(void) { if (setup.fullscreen != video.fullscreen_enabled && video.fullscreen_available) @@ -9253,8 +9253,12 @@ void ToggleFullscreenOrChangeWindowScalingIfNeeded(void) // set setup value according to successfully changed fullscreen mode setup.fullscreen = video.fullscreen_enabled; } - else if (setup.window_scaling_percent != video.window_scaling_percent && - !video.fullscreen_enabled) +} + +void ChangeWindowScalingIfNeeded(void) +{ + if (setup.window_scaling_percent != video.window_scaling_percent && + !video.fullscreen_enabled) { SDLSetWindowScaling(setup.window_scaling_percent); diff --git a/src/tools.h b/src/tools.h index 2743d41d..a58888be 100644 --- a/src/tools.h +++ b/src/tools.h @@ -283,7 +283,8 @@ void ResetFontStatus(void); void SetLevelSetInfo(char *, int); -void ToggleFullscreenOrChangeWindowScalingIfNeeded(void); +void ToggleFullscreenIfNeeded(void); +void ChangeWindowScalingIfNeeded(void); void ChangeVsyncModeIfNeeded(void); void ChangeViewportPropertiesIfNeeded(void);