Merge branch 'set-window-mode' of https://github.com/Tryibion/FlaxEngine into Tryibion-set-window-mode

This commit is contained in:
Wojtek Figat
2023-08-21 22:42:13 +02:00
5 changed files with 120 additions and 0 deletions

View File

@@ -135,6 +135,36 @@ void Screen::SetCursorLock(CursorLockMode mode)
CursorLock = mode;
}
void Screen::SetGameWindowMode(GameWindowMode windowMode)
{
#if !USE_EDITOR
switch (windowMode)
{
case GameWindowMode::Windowed:
if (GetIsFullscreen())
SetIsFullscreen(false);
#if (PLATFORM_WINDOWS)
Engine::MainWindow->SetBorderless(false, false);
#endif
break;
case GameWindowMode::Fullscreen:
SetIsFullscreen(true);
break;
case GameWindowMode::Borderless:
#if (PLATFORM_WINDOWS)
Engine::MainWindow->SetBorderless(true, false);
#endif
break;
case GameWindowMode::FullscreenBorderless:
#if (PLATFORM_WINDOWS)
Engine::MainWindow->SetBorderless(true, true);
#endif
break;
default: ;
}
#endif
}
void ScreenService::Update()
{
#if USE_EDITOR

View File

@@ -2,6 +2,7 @@
#pragma once
#include "Engine/Core/Config/PlatformSettingsBase.h"
#include "Engine/Scripting/ScriptingType.h"
#include "Engine/Input/Enums.h"
#include "Engine/Core/Math/Vector2.h"
@@ -80,4 +81,13 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Screen);
/// </summary>
/// <param name="mode">The mode.</param>
API_PROPERTY() static void SetCursorLock(CursorLockMode mode);
/// <summary>
/// Sets the game window mode.
/// </summary>
/// <remarks>
/// A fullscreen mode switch may not happen immediately. It will be performed before next frame rendering. Will not work in editor.
/// </remarks>
/// <param name="windowMode">The window mode.</param>
API_PROPERTY() static void SetGameWindowMode(GameWindowMode windowMode);
};