diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c19a6883a..eb6f14a0ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -146,6 +146,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - `RealTimeLimitProgress` and `SimTimeLimitProgress` on `Timer` are now both writable properties in Lua, and not only readable. +- New `Settings.ini` property `LaunchMinimised = 0/1` to have the game window start out minimised, so that launching the game doesn't take input focus or cover other windows. Disabled by default. +
Changed diff --git a/Source/Managers/SettingsMan.cpp b/Source/Managers/SettingsMan.cpp index 7695cb9ca5..39ea1a15ae 100644 --- a/Source/Managers/SettingsMan.cpp +++ b/Source/Managers/SettingsMan.cpp @@ -114,6 +114,7 @@ int SettingsMan::ReadProperty(const std::string_view& propName, Reader& reader) MatchProperty("EnableVSync", { reader >> g_WindowMan.m_EnableVSync; }); MatchProperty("Fullscreen", { reader >> g_WindowMan.m_Fullscreen; }); MatchProperty("UseMultiDisplays", { reader >> g_WindowMan.m_UseMultiDisplays; }); + MatchProperty("LaunchMinimised", { reader >> g_WindowMan.m_LaunchMinimised; }); MatchProperty("TwoPlayerSplitscreenVertSplit", { reader >> g_FrameMan.m_TwoPlayerVSplit; }); MatchProperty("MasterVolume", { g_AudioMan.SetMasterVolume(std::stof(reader.ReadPropValue()) / 100.0F); }); MatchProperty("MuteMaster", { reader >> g_AudioMan.m_MuteMaster; }); @@ -220,6 +221,7 @@ int SettingsMan::Save(Writer& writer) const { writer.NewPropertyWithValue("Fullscreen", g_WindowMan.m_Fullscreen); writer.NewPropertyWithValue("EnableVSync", g_WindowMan.m_EnableVSync); writer.NewPropertyWithValue("UseMultiDisplays", g_WindowMan.m_UseMultiDisplays); + writer.NewPropertyWithValue("LaunchMinimised", g_WindowMan.m_LaunchMinimised); writer.NewPropertyWithValue("TwoPlayerSplitscreenVertSplit", g_FrameMan.m_TwoPlayerVSplit); writer.NewLine(false, 2); diff --git a/Source/Managers/WindowMan.cpp b/Source/Managers/WindowMan.cpp index 51c87a1616..0e09efecd6 100644 --- a/Source/Managers/WindowMan.cpp +++ b/Source/Managers/WindowMan.cpp @@ -72,6 +72,7 @@ void WindowMan::Clear() { m_Fullscreen = false; m_EnableVSync = true; m_UseMultiDisplays = false; + m_LaunchMinimised = false; } void WindowMan::ClearMultiDisplayData() { @@ -184,6 +185,7 @@ void WindowMan::CreatePrimaryWindow() { SDL_SetBooleanProperty(windowProps, SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN, true); SDL_SetBooleanProperty(windowProps, SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, true); SDL_SetBooleanProperty(windowProps, SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN, m_Fullscreen); + SDL_SetBooleanProperty(windowProps, SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN, m_LaunchMinimised); SDL_SetNumberProperty(windowProps, SDL_PROP_WINDOW_CREATE_X_NUMBER, windowPosX); SDL_SetNumberProperty(windowProps, SDL_PROP_WINDOW_CREATE_Y_NUMBER, windowPosY); SDL_SetNumberProperty(windowProps, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, m_ResX * m_ResMultiplier); @@ -207,7 +209,8 @@ void WindowMan::CreatePrimaryWindow() { SDL_GL_SwapWindow(m_PrimaryWindow.get()); SDL_SetCursor(NULL); - if (!m_Fullscreen && IsResolutionMaximized(m_ResX, m_ResY, m_ResMultiplier)) { + // Maximising a minimised window would bring it back up. + if (!m_Fullscreen && !m_LaunchMinimised && IsResolutionMaximized(m_ResX, m_ResY, m_ResMultiplier)) { SDL_MaximizeWindow(m_PrimaryWindow.get()); } diff --git a/Source/Managers/WindowMan.h b/Source/Managers/WindowMan.h index 53452dbed2..15133425b1 100644 --- a/Source/Managers/WindowMan.h +++ b/Source/Managers/WindowMan.h @@ -238,6 +238,7 @@ namespace RTE { bool m_EnableVSync; //!< Whether vertical synchronization is enabled. bool m_UseMultiDisplays; //!< Whether the multi-display arrangement should be ignored and only the display the main window is currently positioned at should be used for fullscreen. + bool m_LaunchMinimised; //!< Whether the game window starts out minimised, so that launching the game doesn't take input focus or cover other windows. bool m_DrawPostProcessBuffer; //!< Whether to draw the PostProcessBuffer while not in Activity. Resets on Frame Clear.