Merge remote-tracking branch 'origin/master' into 1.7

This commit is contained in:
Wojtek Figat
2023-08-28 09:11:29 +02:00
29 changed files with 324 additions and 34 deletions

View File

@@ -135,6 +135,52 @@ 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);
win->SetBorderless(false, false);
break;
case GameWindowMode::Fullscreen:
SetIsFullscreen(true);
break;
case GameWindowMode::Borderless:
win->SetBorderless(true, false);
break;
case GameWindowMode::FullscreenBorderless:
win->SetBorderless(true, true);
break;
}
#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,19 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Screen);
/// </summary>
/// <param name="mode">The mode.</param>
API_PROPERTY() static void SetCursorLock(CursorLockMode mode);
/// <summary>
/// Gets the game window mode.
/// </summary>
/// <returns>The current window mode.</returns>
API_PROPERTY() static GameWindowMode GetGameWindowMode();
/// <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);
};