From 501e029e247ad8f33032e0fe2891540c39ca4bf3 Mon Sep 17 00:00:00 2001 From: Nikita Krapivin Date: Sat, 12 Mar 2022 17:15:35 +0500 Subject: [PATCH] Fix macOS fullscreen and included files --- SonicTimeTwisted.gmx/Configs/MacOS.config.gmx | 14 ++++---- .../SonicTimeTwisted.project.gmx | 18 +++++------ .../objects/objScreen.object.gmx | 32 +++++++++++++++++++ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/SonicTimeTwisted.gmx/Configs/MacOS.config.gmx b/SonicTimeTwisted.gmx/Configs/MacOS.config.gmx index fd483814d..b2db5419c 100644 --- a/SonicTimeTwisted.gmx/Configs/MacOS.config.gmx +++ b/SonicTimeTwisted.gmx/Configs/MacOS.config.gmx @@ -405,13 +405,13 @@ false Action Games : public.app-category.action-games com.overboundstudio.sonictimetwisted - 0 - 0 + -1 + -1 2 - (c)2022 Overbound Game Studio + (c) 2022 Overbound and contributors 0 Sonic Time Twisted - -1 + 0 0 0 Configs\MacOS\mac\icon512.png @@ -419,12 +419,12 @@ 1 0 1 - ~/GameMaker-Studio/SonicTimeTwisted + ~/GameMaker-Studio/STT -1 - 0 + -1 0 Apple Development: quesonlibert@gmail.com (GKJ63CR7Y5) - 0 + -1 Configs\MacOS\mac\splash.png 0 1 diff --git a/SonicTimeTwisted.gmx/SonicTimeTwisted.project.gmx b/SonicTimeTwisted.gmx/SonicTimeTwisted.project.gmx index 3b6194f5a..4ce64da7c 100644 --- a/SonicTimeTwisted.gmx/SonicTimeTwisted.project.gmx +++ b/SonicTimeTwisted.gmx/SonicTimeTwisted.project.gmx @@ -1859,19 +1859,19 @@ 2097160 - 9223372036854775807 + 2097160 - 9223372036854775807 + 2097160 - 9223372036854775807 + 2097160 2097160 - 9223372036854775807 + 2097160 2097160 @@ -1894,19 +1894,19 @@ 2097160 - 9223372036854775807 + 2097160 - 9223372036854775807 + 2097160 - 9223372036854775807 + 2097160 2097160 - 9223372036854775807 + 2097160 2097160 @@ -5837,7 +5837,7 @@ - "v1.1.2" + "v1.1.2.1" 7 6 5 diff --git a/SonicTimeTwisted.gmx/objects/objScreen.object.gmx b/SonicTimeTwisted.gmx/objects/objScreen.object.gmx index c620d26f4..3a7085754 100644 --- a/SonicTimeTwisted.gmx/objects/objScreen.object.gmx +++ b/SonicTimeTwisted.gmx/objects/objScreen.object.gmx @@ -289,6 +289,38 @@ show_debug_message("video_mode = " + string(video_mode)); 1 ///Detect alt-enter or enter-alt presses. + +// macOS special begin, this does nothing on any target that's not macOS! +if (DEVICE_INFO & DEVICE_OS_MACOS) { + var _iswindowfs = window_get_fullscreen(); + var _isgamefs = video_mode == 0; + // check if the window state does not match game's expected state. + if (_iswindowfs && !_isgamefs) { + // window is now fullscreen, update video_mode accordingly + prev_video_mode = video_mode; + video_mode = 0; // fs + window_scale = 0; // fs + show_debug_message("osx: wnd -> fs: prevscale=" + string(prev_video_mode)); + save_options(); + } + else if (!_iswindowfs && _isgamefs) { + // fetch max_scale from display: + event_user(3); + // fun: + var _scalebyX = clamp(window_get_width() div width, 1, max_scale); + var _scalebyY = clamp(window_get_height() div height, 1, max_scale); + // pick the minimum scale (so it fits) + var _scaleguess = min(_scalebyX, _scalebyY); + video_mode = _scaleguess; + window_scale = _scaleguess; + show_debug_message("osx: fs -> wnd: scale=" + string(video_mode)); + save_options(); + } + // do not execute the code below please, we can't do that. + exit; +} +// macOS special end + // Since we can never trust GameMaker, let's handle Alt-Enter manually. // oh and Alt-Enter can be pressed in various ways, Alt-Enter, Enter-Alt, weird! // PS: This user event can technically be called from any object.