editor: centralize engine runtime access
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
#include "EditorContext.h"
|
||||
#include "EditorShellAssetBuilder.h"
|
||||
#include "Scene/EngineEditorSceneBackend.h"
|
||||
#include "Engine/EditorEngineServices.h"
|
||||
#include "Scene/EditorSceneRuntime.h"
|
||||
#include "Panels/EditorPanelIds.h"
|
||||
#include "Viewport/EditorViewportRuntimeServices.h"
|
||||
#include "WorkspaceEventSync.h"
|
||||
#include <XCEditor/Foundation/UIEditorRuntimeTrace.h>
|
||||
#include <sstream>
|
||||
@@ -53,7 +54,11 @@ UIEditorWorkspacePanelPresentationModel* FindMutablePresentation(
|
||||
|
||||
} // namespace
|
||||
|
||||
bool EditorContext::Initialize(const EditorRuntimePaths& runtimePaths) {
|
||||
bool EditorContext::Initialize(
|
||||
const EditorRuntimePaths& runtimePaths,
|
||||
EditorEngineServices& engineServices) {
|
||||
m_valid = false;
|
||||
m_validationMessage.clear();
|
||||
AppendUIEditorRuntimeTrace("startup", "EditorContext::Initialize begin");
|
||||
m_shellAsset = BuildEditorApplicationShellAsset(runtimePaths);
|
||||
AppendUIEditorRuntimeTrace("startup", "BuildEditorApplicationShellAsset complete");
|
||||
@@ -63,6 +68,7 @@ bool EditorContext::Initialize(const EditorRuntimePaths& runtimePaths) {
|
||||
std::string("ValidateEditorShellAsset complete valid=") +
|
||||
(m_shellValidation.IsValid() ? "1" : "0"));
|
||||
if (!m_shellValidation.IsValid()) {
|
||||
m_validationMessage = m_shellValidation.message;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -76,9 +82,13 @@ bool EditorContext::Initialize(const EditorRuntimePaths& runtimePaths) {
|
||||
m_projectRuntime.Initialize(runtimePaths.projectRoot);
|
||||
AppendUIEditorRuntimeTrace("startup", "EditorProjectRuntime::Initialize end");
|
||||
m_projectRuntime.BindSelectionService(&m_selectionService);
|
||||
m_sceneRuntime.SetBackend(CreateEngineEditorSceneBackend());
|
||||
m_sceneRuntime.SetBackend(engineServices.CreateSceneBackend());
|
||||
AppendUIEditorRuntimeTrace("startup", "EditorSceneRuntime::Initialize begin");
|
||||
m_sceneRuntime.Initialize(m_session.projectRoot);
|
||||
if (!m_sceneRuntime.Initialize(m_session.projectRoot)) {
|
||||
m_validationMessage = "Editor scene runtime failed to initialize.";
|
||||
AppendUIEditorRuntimeTrace("startup", m_validationMessage);
|
||||
return false;
|
||||
}
|
||||
AppendUIEditorRuntimeTrace("startup", "EditorSceneRuntime::Initialize end");
|
||||
m_sceneRuntime.BindSelectionService(&m_selectionService);
|
||||
ResetEditorColorPickerToolState(m_colorPickerToolState);
|
||||
@@ -95,6 +105,7 @@ bool EditorContext::Initialize(const EditorRuntimePaths& runtimePaths) {
|
||||
m_lastStatus.clear();
|
||||
m_lastMessage.clear();
|
||||
SetReadyStatus();
|
||||
m_valid = true;
|
||||
AppendUIEditorRuntimeTrace("startup", "EditorContext::Initialize end");
|
||||
return true;
|
||||
}
|
||||
@@ -131,11 +142,11 @@ void EditorContext::SyncSessionFromWorkspace(
|
||||
}
|
||||
|
||||
bool EditorContext::IsValid() const {
|
||||
return m_shellValidation.IsValid();
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
const std::string& EditorContext::GetValidationMessage() const {
|
||||
return m_shellValidation.message;
|
||||
return m_validationMessage;
|
||||
}
|
||||
|
||||
const EditorShellAsset& EditorContext::GetShellAsset() const {
|
||||
@@ -300,6 +311,12 @@ std::vector<WorkspaceTraceEntry> EditorContext::SyncWorkspacePanelFrameEvents(
|
||||
return SyncWorkspaceEvents(*this, panelEvents);
|
||||
}
|
||||
|
||||
void EditorContext::SyncSceneViewportRenderRequest(
|
||||
EditorSceneViewportRuntime& sceneViewportRuntime) {
|
||||
sceneViewportRuntime.SetRenderRequest(
|
||||
m_sceneRuntime.BuildSceneViewportRenderRequest());
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
Reference in New Issue
Block a user