Align editor runtime scene handoff

This commit is contained in:
2026-04-29 04:05:54 +08:00
parent 2fde2f16c2
commit 595d39c4c3
32 changed files with 996 additions and 52 deletions

View File

@@ -26,6 +26,13 @@ void RequestEditorContextUtilityWindow(
}
}
bool RequestEditorContextOpenSceneAsset(
void* requester,
const std::filesystem::path& scenePath) {
auto* context = static_cast<EditorContext*>(requester);
return context != nullptr && context->RequestOpenSceneAsset(scenePath);
}
std::string ComposeStatusText(
std::string_view status,
std::string_view message) {
@@ -91,11 +98,17 @@ bool EditorContext::Initialize(
}
AppendUIEditorRuntimeTrace("startup", "EditorSceneRuntime::Initialize end");
m_sceneRuntime.BindSelectionService(&m_selectionService);
m_runtimeCoordinator.Initialize(
m_session,
m_sceneRuntime,
m_projectRuntime,
runtimePaths);
ResetEditorColorPickerToolState(m_colorPickerToolState);
ResetEditorUtilityWindowRequestState(m_utilityWindowRequestState);
SyncSessionFromSelectionService();
m_hostCommandBridge.BindSession(m_session);
m_hostCommandBridge.BindCommandFocusService(m_commandFocusService);
m_hostCommandBridge.BindRuntimeCommandOwner(&m_runtimeCoordinator);
SyncSessionFromCommandFocusService();
m_shortcutManager = BuildEditorShellShortcutManager(m_shellAsset);
m_shortcutManager.SetHostCommandHandler(&m_hostCommandBridge);
@@ -141,6 +154,10 @@ void EditorContext::SyncSessionFromWorkspace(
SyncSessionFromCommandFocusService();
}
void EditorContext::TickEditorRuntime() {
m_runtimeCoordinator.TickFrame();
}
bool EditorContext::IsValid() const {
return m_valid;
}
@@ -181,6 +198,14 @@ const EditorSceneRuntime& EditorContext::GetSceneRuntime() const {
return m_sceneRuntime;
}
EditorRuntimeCoordinator& EditorContext::GetRuntimeCoordinator() {
return m_runtimeCoordinator;
}
const EditorRuntimeCoordinator& EditorContext::GetRuntimeCoordinator() const {
return m_runtimeCoordinator;
}
EditorColorPickerToolState& EditorContext::GetColorPickerToolState() {
return m_colorPickerToolState;
}
@@ -246,9 +271,24 @@ EditorPanelServices EditorContext::BuildPanelServices() {
.textMeasurer = m_shellServices.textMeasurer,
.utilityWindowRequester = this,
.requestUtilityWindow = RequestEditorContextUtilityWindow,
.sceneAssetOpenRequester = this,
.requestOpenSceneAsset = RequestEditorContextOpenSceneAsset,
};
}
bool EditorContext::RequestOpenSceneAsset(const std::filesystem::path& scenePath) {
const bool opened = m_runtimeCoordinator.RequestOpenSceneAsset(scenePath);
SetStatus(
"Scene",
opened
? m_runtimeCoordinator.GetLastMessage()
: m_runtimeCoordinator.GetLastMessage().empty()
? std::string("Failed to open scene asset.")
: m_runtimeCoordinator.GetLastMessage());
SyncSessionFromSelectionService();
return opened;
}
UIEditorShellInteractionDefinition EditorContext::BuildShellDefinition(
const UIEditorWorkspaceController& workspaceController,
std::string_view captureText,