diff --git a/Flax.sln.DotSettings b/Flax.sln.DotSettings
index fe1d1463e..e8af1461c 100644
--- a/Flax.sln.DotSettings
+++ b/Flax.sln.DotSettings
@@ -248,6 +248,7 @@
True
True
True
+ True
True
True
True
diff --git a/Source/Engine/Engine/Screen.cpp b/Source/Engine/Engine/Screen.cpp
index cb2994129..2bc6e1f58 100644
--- a/Source/Engine/Engine/Screen.cpp
+++ b/Source/Engine/Engine/Screen.cpp
@@ -135,32 +135,48 @@ void Screen::SetCursorLock(CursorLockMode mode)
CursorLock = mode;
}
+GameWindowMode Screen::GetGameWindowMode()
+{
+ GameWindowMode result = GameWindowMode::Windowed;
+#if !USE_EDITOR
+ auto win = Engine::MainWindow;
+ if (win)
+ {
+ if (GetIsFullscreen() || win->IsFullscreen())
+ result = GameWindowMode::Fullscreen;
+ else if (win->GetSettings().HasBorder)
+ result = GameWindowMode::Windowed;
+ else if (win->GetClientPosition().IsZero() && win->GetSize() == Platform::GetDesktopSize())
+ result = GameWindowMode::FullscreenBorderless;
+ else
+ result = GameWindowMode::Borderless;
+ }
+#endif
+ return result;
+}
+
void Screen::SetGameWindowMode(GameWindowMode windowMode)
{
#if !USE_EDITOR
+ auto win = Engine::MainWindow;
+ if (!win)
+ return;
switch (windowMode)
{
case GameWindowMode::Windowed:
if (GetIsFullscreen())
SetIsFullscreen(false);
-#if (PLATFORM_WINDOWS)
- Engine::MainWindow->SetBorderless(false, false);
-#endif
+ win->SetBorderless(false, false);
break;
case GameWindowMode::Fullscreen:
SetIsFullscreen(true);
break;
case GameWindowMode::Borderless:
-#if (PLATFORM_WINDOWS)
- Engine::MainWindow->SetBorderless(true, false);
-#endif
+ win->SetBorderless(true, false);
break;
case GameWindowMode::FullscreenBorderless:
-#if (PLATFORM_WINDOWS)
- Engine::MainWindow->SetBorderless(true, true);
-#endif
+ win->SetBorderless(true, true);
break;
- default: ;
}
#endif
}
diff --git a/Source/Engine/Engine/Screen.h b/Source/Engine/Engine/Screen.h
index 8f7d21766..42be20a38 100644
--- a/Source/Engine/Engine/Screen.h
+++ b/Source/Engine/Engine/Screen.h
@@ -82,6 +82,12 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Screen);
/// The mode.
API_PROPERTY() static void SetCursorLock(CursorLockMode mode);
+ ///
+ /// Gets the game window mode.
+ ///
+ /// The current window mode.
+ API_PROPERTY() static GameWindowMode GetGameWindowMode();
+
///
/// Sets the game window mode.
///
diff --git a/Source/Engine/Platform/Base/WindowBase.h b/Source/Engine/Platform/Base/WindowBase.h
index 10b99d1cf..e4e7d2080 100644
--- a/Source/Engine/Platform/Base/WindowBase.h
+++ b/Source/Engine/Platform/Base/WindowBase.h
@@ -449,8 +449,8 @@ public:
/// Sets the window to be borderless or not and to be fullscreen.
///
/// Whether or not to have borders on window.
- /// Whether or not to make the borderless window fullscreen.
- API_FUNCTION() virtual void SetBorderless(bool isBorderless, bool fullscreen)
+ /// Whether or not to make the borderless window fullscreen (maximize to cover whole screen).
+ API_FUNCTION() virtual void SetBorderless(bool isBorderless, bool maximized = false)
{
}
diff --git a/Source/Engine/Platform/Windows/WindowsWindow.cpp b/Source/Engine/Platform/Windows/WindowsWindow.cpp
index ec5850b13..d712102fa 100644
--- a/Source/Engine/Platform/Windows/WindowsWindow.cpp
+++ b/Source/Engine/Platform/Windows/WindowsWindow.cpp
@@ -260,7 +260,7 @@ void WindowsWindow::Maximize()
_isDuringMaximize = false;
}
-void WindowsWindow::SetBorderless(bool isBorderless, bool fullscreen)
+void WindowsWindow::SetBorderless(bool isBorderless, bool maximized)
{
ASSERT(HasHWND());
@@ -292,8 +292,7 @@ void WindowsWindow::SetBorderless(bool isBorderless, bool fullscreen)
SetWindowLong(_handle, GWL_STYLE, lStyle);
SetWindowPos(_handle, HWND_TOP, 0, 0,0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
-
- if (fullscreen)
+ if (maximized)
{
ShowWindow(_handle, SW_SHOWMAXIMIZED);
}
@@ -312,13 +311,12 @@ void WindowsWindow::SetBorderless(bool isBorderless, bool fullscreen)
lStyle |= WS_MINIMIZEBOX;
if (_settings.HasSizingFrame)
lStyle |= WS_THICKFRAME;
- // Create window style flags
lStyle |= WS_OVERLAPPED | WS_SYSMENU | WS_BORDER | WS_CAPTION;
SetWindowLong(_handle, GWL_STYLE, lStyle);
SetWindowPos(_handle, nullptr, 0, 0, (int)_settings.Size.X, (int)_settings.Size.Y, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
- if (fullscreen)
+ if (maximized)
{
Maximize();
}
@@ -327,6 +325,7 @@ void WindowsWindow::SetBorderless(bool isBorderless, bool fullscreen)
ShowWindow(_handle, SW_SHOW);
}
}
+
CheckForWindowResize();
}
diff --git a/Source/Engine/Platform/Windows/WindowsWindow.h b/Source/Engine/Platform/Windows/WindowsWindow.h
index cbbd8342d..e15f86a45 100644
--- a/Source/Engine/Platform/Windows/WindowsWindow.h
+++ b/Source/Engine/Platform/Windows/WindowsWindow.h
@@ -100,7 +100,7 @@ public:
void Hide() override;
void Minimize() override;
void Maximize() override;
- void SetBorderless(bool isBorderless, bool fullscreen) override;
+ void SetBorderless(bool isBorderless, bool maximized = false) override;
void Restore() override;
bool IsClosed() const override;
bool IsForegroundWindow() const override;