Add Requesting engine exit event. Expose Fatal erro and requesting exit to c#

This commit is contained in:
Chandler Cox
2024-08-07 12:16:07 -05:00
parent 0b03a5da0d
commit 03de914dbc
5 changed files with 22 additions and 1 deletions

View File

@@ -199,6 +199,7 @@ void GameBaseImpl::OnMainWindowClosed()
// Request engine exit
Globals::IsRequestingExit = true;
Engine::RequestingExit();
}
void GameBaseImpl::OnPostRender(GPUContext* context, RenderContext& renderContext)

View File

@@ -70,6 +70,7 @@ Action Engine::LateFixedUpdate;
Action Engine::Draw;
Action Engine::Pause;
Action Engine::Unpause;
Action Engine::RequestingExit;
Window* Engine::MainWindow = nullptr;
int32 Engine::Main(const Char* cmdLine)
@@ -259,10 +260,12 @@ void Engine::RequestExit(int32 exitCode)
{
Globals::IsRequestingExit = true;
Globals::ExitCode = exitCode;
RequestingExit();
}
#else
Globals::IsRequestingExit = true;
Globals::ExitCode = exitCode;
RequestingExit();
#endif
}

View File

@@ -79,6 +79,11 @@ public:
/// </summary>
static Action Unpause;
/// <summary>
/// Event called when the engine is requesting exit.
/// </summary>
API_EVENT() static Action RequestingExit;
public:
/// <summary>

View File

@@ -2,6 +2,7 @@
#pragma once
#include "Engine/Core/Delegate.h"
#include "Engine/Scripting/ScriptingType.h"
#include "Engine/Input/Enums.h"
@@ -59,9 +60,19 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Globals);
// True if fatal error occurred (engine is exiting)
static bool FatalErrorOccurred;
// True if engine need to be closed
// True if engine needs to be closed
static bool IsRequestingExit;
/// <summary>
/// True if engine needs to be closed
/// </summary>
API_PROPERTY() FORCE_INLINE static bool GetIsRequestingExit() { return IsRequestingExit; }
/// <summary>
/// True if fatal error occurred (engine is exiting)
/// </summary>
API_PROPERTY() FORCE_INLINE static bool GetFatalErrorOccurred() { return FatalErrorOccurred; }
// Exit code
static int32 ExitCode;

View File

@@ -271,6 +271,7 @@ void PlatformBase::Fatal(const Char* msg, void* context)
Globals::FatalErrorOccurred = true;
Globals::IsRequestingExit = true;
Globals::ExitCode = -1;
Engine::RequestingExit();
// Collect crash info (platform-dependant implementation that might collect stack trace and/or create memory dump)
{