editor: centralize engine runtime access
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "SystemInteractionService.h"
|
||||
#include "EditorContext.h"
|
||||
#include "EditorShellRuntime.h"
|
||||
#include "Engine/EngineEditorServices.h"
|
||||
#include "EditorUtilityWindowRegistry.h"
|
||||
#include "EditorWorkspacePanelRegistry.h"
|
||||
#include "EditorWindowManager.h"
|
||||
@@ -21,8 +22,6 @@
|
||||
#include <XCEditor/Foundation/UIEditorRuntimeTrace.h>
|
||||
#include <XCEditor/Windowing/System/EditorWindowSystem.h>
|
||||
#include <XCEditor/Workspace/UIEditorWindowWorkspaceModel.h>
|
||||
#include <XCEngine/Core/Asset/ResourceManager.h>
|
||||
|
||||
#include <shellscalingapi.h>
|
||||
#include <utility>
|
||||
|
||||
@@ -156,6 +155,7 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
|
||||
m_hInstance = hInstance;
|
||||
m_resourceService = std::make_unique<Host::Win32EditorResourceService>(m_hInstance);
|
||||
m_runtimePaths = ResolveRuntimePaths(m_resourceService->GetExecutableDirectory());
|
||||
m_engineServices = App::CreateEngineEditorServices();
|
||||
EnableDpiAwareness();
|
||||
|
||||
const std::filesystem::path logRoot = m_resourceService->GetExecutableDirectory() / "logs";
|
||||
@@ -163,10 +163,15 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
|
||||
SetUnhandledExceptionFilter(&Application::HandleUnhandledException);
|
||||
AppendUIEditorRuntimeTrace("app", "initialize begin");
|
||||
|
||||
if (!m_editorContext->Initialize(m_runtimePaths)) {
|
||||
if (m_engineServices == nullptr) {
|
||||
AppendUIEditorRuntimeTrace("app", "engine services initialization failed");
|
||||
return false;
|
||||
}
|
||||
if (!m_editorContext->Initialize(m_runtimePaths, *m_engineServices)) {
|
||||
AppendUIEditorRuntimeTrace(
|
||||
"app",
|
||||
"shell asset validation failed: " + m_editorContext->GetValidationMessage());
|
||||
"editor context initialization failed: " +
|
||||
m_editorContext->GetValidationMessage());
|
||||
return false;
|
||||
}
|
||||
if (!RegisterWindowClass()) {
|
||||
@@ -189,14 +194,16 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
|
||||
m_runtimePaths);
|
||||
m_renderRuntimeFactory =
|
||||
std::make_unique<Host::D3D12EditorWindowRenderRuntimeFactory>();
|
||||
App::EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory = []() {
|
||||
App::EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory =
|
||||
[engineServices = m_engineServices.get()]() {
|
||||
return App::CreateEditorWorkspaceShellRuntime(
|
||||
App::CreateEditorWorkspacePanelRuntimeSet(),
|
||||
App::CreateEditorIconService(),
|
||||
App::CreateEditorViewportRuntimeServices());
|
||||
};
|
||||
App::CreateEditorViewportRuntimeServices(engineServices));
|
||||
};
|
||||
m_windowManager = std::make_unique<App::EditorWindowManager>(
|
||||
*m_editorContext,
|
||||
*m_engineServices,
|
||||
*m_windowSystem,
|
||||
*m_renderRuntimeFactory,
|
||||
*m_resourceService,
|
||||
@@ -288,7 +295,10 @@ void Application::Shutdown() {
|
||||
}
|
||||
m_systemInteractionHost.reset();
|
||||
|
||||
::XCEngine::Resources::ResourceManager::Get().Shutdown();
|
||||
if (m_engineServices != nullptr) {
|
||||
m_engineServices->Shutdown();
|
||||
m_engineServices.reset();
|
||||
}
|
||||
|
||||
if (m_windowClassAtom != 0 && m_hInstance != nullptr) {
|
||||
UnregisterClassW(kWindowClassName, m_hInstance);
|
||||
@@ -357,7 +367,9 @@ int Application::Run(HINSTANCE hInstance, int nCmdShow) {
|
||||
}
|
||||
|
||||
if (m_windowManager != nullptr) {
|
||||
::XCEngine::Resources::ResourceManager::Get().UpdateAsyncLoads();
|
||||
if (m_engineServices != nullptr) {
|
||||
m_engineServices->UpdateAsyncLoads();
|
||||
}
|
||||
m_windowManager->DestroyClosedWindows();
|
||||
if (!m_windowManager->HasWindows()) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user