diff --git a/Source/Engine/Engine/Engine.cpp b/Source/Engine/Engine/Engine.cpp
index 6b5b498d7..3e8cbe51e 100644
--- a/Source/Engine/Engine/Engine.cpp
+++ b/Source/Engine/Engine/Engine.cpp
@@ -133,7 +133,7 @@ int32 Engine::Main(const Char* cmdLine)
Platform::BeforeRun();
EngineImpl::InitMainWindow();
Application::BeforeRun();
-#if !USE_EDITOR && (PLATFORM_WINDOWS || PLATFORM_LINUX)
+#if !USE_EDITOR && (PLATFORM_WINDOWS || PLATFORM_LINUX || PLATFORM_MAC)
EngineImpl::RunInBackground = PlatformSettings::Get()->RunInBackground;
#endif
Log::Logger::WriteFloor();
diff --git a/Source/Engine/Engine/Mac/MacGame.cpp b/Source/Engine/Engine/Mac/MacGame.cpp
new file mode 100644
index 000000000..3669a9015
--- /dev/null
+++ b/Source/Engine/Engine/Mac/MacGame.cpp
@@ -0,0 +1,47 @@
+// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
+
+#if PLATFORM_MAC && !USE_EDITOR
+
+#include "MacGame.h"
+#include "Engine/Platform/Window.h"
+#include "Engine/Core/Config/PlatformSettings.h"
+#include "Engine/Engine/CommandLine.h"
+
+void MacGame::InitMainWindowSettings(CreateWindowSettings& settings)
+{
+ // TODO: restore window size and fullscreen mode from the cached local settings saved after previous session
+
+ const auto platformSettings = MacPlatformSettings::Get();
+ auto windowMode = platformSettings->WindowMode;
+
+ // Use command line switches
+ if (CommandLine::Options.Fullscreen.IsTrue())
+ windowMode = GameWindowMode::Fullscreen;
+ else if (CommandLine::Options.Windowed.IsTrue())
+ windowMode = GameWindowMode::Windowed;
+
+ settings.AllowDragAndDrop = false;
+ settings.Fullscreen = windowMode == GameWindowMode::Fullscreen;
+ settings.HasSizingFrame = platformSettings->ResizableWindow;
+
+ // Fullscreen - put window to cover the whole desktop area
+ if (windowMode == GameWindowMode::FullscreenBorderless || windowMode == GameWindowMode::Fullscreen)
+ {
+ settings.Size = Platform::GetDesktopSize();
+ settings.Position = Vector2::Zero;
+ }
+ // Not fullscreen - put window in the middle of the screen
+ else if (windowMode == GameWindowMode::Windowed || windowMode == GameWindowMode::Borderless)
+ {
+ settings.Size = Vector2((float)platformSettings->ScreenWidth, (float)platformSettings->ScreenHeight);
+ settings.Position = (Platform::GetDesktopSize() - settings.Size) / 2;
+ }
+
+ // Windowed mode
+ settings.HasBorder = windowMode == GameWindowMode::Windowed || windowMode == GameWindowMode::Fullscreen;
+ settings.AllowMaximize = true;
+ settings.AllowMinimize = platformSettings->ResizableWindow;
+
+}
+
+#endif
diff --git a/Source/Engine/Engine/Mac/MacGame.h b/Source/Engine/Engine/Mac/MacGame.h
index ff3be560e..d270f8fd1 100644
--- a/Source/Engine/Engine/Mac/MacGame.h
+++ b/Source/Engine/Engine/Mac/MacGame.h
@@ -12,6 +12,10 @@
///
class MacGame : public GameBase
{
+public:
+
+ // [GameBase]
+ static void InitMainWindowSettings(CreateWindowSettings& settings);
};
typedef MacGame Game;
diff --git a/Source/Engine/Platform/Mac/MacPlatformSettings.h b/Source/Engine/Platform/Mac/MacPlatformSettings.h
index 4b7c141ad..592a2d4e9 100644
--- a/Source/Engine/Platform/Mac/MacPlatformSettings.h
+++ b/Source/Engine/Platform/Mac/MacPlatformSettings.h
@@ -23,12 +23,42 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"General\")")
String AppIdentifier = TEXT("com.${COMPANY_NAME}.${PROJECT_NAME}");
+ ///
+ /// The default game window mode.
+ ///
+ API_FIELD(Attributes="EditorOrder(110), EditorDisplay(\"Window\")")
+ GameWindowMode WindowMode = GameWindowMode::Windowed;
+
+ ///
+ /// The default game window width (in pixels).
+ ///
+ API_FIELD(Attributes="EditorOrder(120), EditorDisplay(\"Window\")")
+ int32 ScreenWidth = 1280;
+
+ ///
+ /// The default game window height (in pixels).
+ ///
+ API_FIELD(Attributes="EditorOrder(130), EditorDisplay(\"Window\")")
+ int32 ScreenHeight = 720;
+
+ ///
+ /// Enables resizing the game window by the user.
+ ///
+ API_FIELD(Attributes="EditorOrder(140), EditorDisplay(\"Window\")")
+ bool ResizableWindow = false;
+
///
/// Custom icon texture to use for the application (overrides the default one).
///
API_FIELD(Attributes="EditorOrder(1000), EditorDisplay(\"Other\")")
SoftObjectReference OverrideIcon;
+ ///
+ /// Enables game running when application window loses focus.
+ ///
+ API_FIELD(Attributes="EditorOrder(1010), EditorDisplay(\"Other\", \"Run In Background\")")
+ bool RunInBackground = false;
+
public:
///
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
@@ -39,7 +69,12 @@ public:
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
DESERIALIZE(AppIdentifier);
+ DESERIALIZE(WindowMode);
+ DESERIALIZE(ScreenWidth);
+ DESERIALIZE(ScreenHeight);
+ DESERIALIZE(ResizableWindow);
DESERIALIZE(OverrideIcon);
+ DESERIALIZE(RunInBackground);
}
};