diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 43396150e..374522ae4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,7 +38,7 @@ jobs: dotnet msbuild Source/Tools/Flax.Build.Tests/Flax.Build.Tests.csproj /m /t:Restore,Build /p:Configuration=Debug /p:Platform=AnyCPU /nologo - name: Test run: | - ${GITHUB_WORKSPACE}/Binaries/Editor/Linux/Development/FlaxTests + ${GITHUB_WORKSPACE}/Binaries/Editor/Linux/Development/FlaxTests -headless dotnet test -f net8.0 Binaries/Tests/Flax.Build.Tests.dll cp Binaries/Editor/Linux/Development/FlaxEngine.CSharp.dll Binaries/Tests cp Binaries/Editor/Linux/Development/FlaxEngine.CSharp.runtimeconfig.json Binaries/Tests @@ -73,7 +73,7 @@ jobs: shell: pwsh run: | $ErrorActionPreference = "Stop" - .\Binaries\Editor\Win64\Development\FlaxTests.exe + .\Binaries\Editor\Win64\Development\FlaxTests.exe -headless if(!$?) { Write-Host "Tests failed with exit code $LastExitCode" -ForegroundColor Red; Exit $LastExitCode } dotnet test -f net8.0 Binaries\Tests\Flax.Build.Tests.dll xcopy /y Binaries\Editor\Win64\Development\FlaxEngine.CSharp.dll Binaries\Tests diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index c881d9dcd..0da539c38 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -407,7 +407,6 @@ namespace FlaxEditor // Close splash and show main window CloseSplashScreen(); - Assert.IsNotNull(Windows.MainWindow); if (!IsHeadlessMode) { Windows.MainWindow.Show(); diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index f8abe6ee1..bdd162fac 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -481,6 +481,8 @@ namespace FlaxEditor.Modules /// public override void OnInit() { + if (Editor.IsHeadlessMode) + return; Editor.Windows.MainWindowClosing += OnMainWindowClosing; var mainWindow = Editor.Windows.MainWindow.GUI; diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index 0d1f0e2d7..ec9665317 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -758,36 +758,39 @@ namespace FlaxEditor.Modules _windowsLayoutPath = StringUtils.CombinePaths(Globals.ProjectCacheFolder, "WindowsLayout.xml"); - // Create main window - var settings = CreateWindowSettings.Default; - settings.Title = "Flax Editor"; - settings.Size = Platform.DesktopSize * 0.75f; - settings.MinimumSize = new Float2(200, 150); - settings.StartPosition = WindowStartPosition.CenterScreen; - settings.ShowAfterFirstPaint = true; - - if (Utilities.Utils.UseCustomWindowDecorations(isMainWindow: true)) + if (!Editor.IsHeadlessMode) { - settings.HasBorder = false; -#if PLATFORM_WINDOWS && !PLATFORM_SDL - // Skip OS sizing frame and implement it using LeftButtonHit - settings.HasSizingFrame = false; -#endif - } -#if PLATFORM_LINUX && !PLATFORM_SDL - settings.HasBorder = false; -#endif - MainWindow = Platform.CreateWindow(ref settings); - if (MainWindow == null) - { - Editor.LogError("Failed to create editor main window!"); - return; - } - UpdateWindowTitle(); + // Create main window + var settings = CreateWindowSettings.Default; + settings.Title = "Flax Editor"; + settings.Size = Platform.DesktopSize * 0.75f; + settings.MinimumSize = new Float2(200, 150); + settings.StartPosition = WindowStartPosition.CenterScreen; + settings.ShowAfterFirstPaint = true; - // Link for main window events - MainWindow.Closing += MainWindow_OnClosing; - MainWindow.Closed += MainWindow_OnClosed; + if (Utilities.Utils.UseCustomWindowDecorations(isMainWindow: true)) + { + settings.HasBorder = false; +#if PLATFORM_WINDOWS && !PLATFORM_SDL + // Skip OS sizing frame and implement it using LeftButtonHit + settings.HasSizingFrame = false; +#endif + } +#if PLATFORM_LINUX && !PLATFORM_SDL + settings.HasBorder = false; +#endif + MainWindow = Platform.CreateWindow(ref settings); + if (MainWindow == null) + { + Editor.LogError("Failed to create editor main window!"); + return; + } + UpdateWindowTitle(); + + // Link for main window events + MainWindow.Closing += MainWindow_OnClosing; + MainWindow.Closed += MainWindow_OnClosed; + } // Create default editor windows ContentWin = new ContentWindow(Editor); diff --git a/Source/Engine/Platform/SDL/SDLPlatform.cpp b/Source/Engine/Platform/SDL/SDLPlatform.cpp index d31a0ff80..b8867ca10 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.cpp +++ b/Source/Engine/Platform/SDL/SDLPlatform.cpp @@ -23,10 +23,6 @@ #include #include -#if PLATFORM_LINUX -#include "Engine/Engine/CommandLine.h" -#endif - #define DefaultDPI 96 namespace SDLImpl @@ -106,10 +102,16 @@ bool SDLPlatform::Init() SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1"); // Allow screensaver in Editor when idle #endif + SDL_InitFlags initFlags = SDL_INIT_VIDEO | SDL_INIT_GAMEPAD; +#if PLATFORM_HAS_HEADLESS_MODE + if (CommandLine::Options.Headless.GetValue()) + initFlags &= ~SDL_INIT_VIDEO; +#endif + //if (InitInternal()) // return true; - if (!SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) + if (!SDL_InitSubSystem(initFlags)) Platform::Fatal(String::Format(TEXT("Failed to initialize SDL: {0}."), String(SDL_GetError()))); #if PLATFORM_LINUX || PLATFORM_WEB