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

@@ -1,5 +1,7 @@
#include "Scene/EditorSceneRuntime.h"
#include <XCEngine/Scene/Scene.h>
#include <cmath>
namespace XCEngine::UI::Editor::App {
@@ -294,6 +296,10 @@ std::uint64_t EditorSceneRuntime::GetInspectorRevision() const {
return m_inspectorRevision;
}
std::uint64_t EditorSceneRuntime::GetSceneContentRevision() const {
return m_sceneContentRevision;
}
bool EditorSceneRuntime::SetSelection(std::string_view itemId) {
const std::optional<EditorSceneObjectId> gameObjectId =
ParseEditorGameObjectItemId(itemId);
@@ -335,6 +341,33 @@ void EditorSceneRuntime::ClearSelection() {
SelectionService().ClearSelection();
}
bool EditorSceneRuntime::NewScene(std::string_view sceneName) {
if (m_backend == nullptr || !m_backend->NewScene(sceneName)) {
return false;
}
m_startupSceneResult.ready = true;
m_startupSceneResult.loadedFromDisk = false;
m_startupSceneResult.scenePath = std::filesystem::path();
if (::XCEngine::Components::Scene* activeScene = m_backend->GetActiveScene();
activeScene != nullptr) {
m_startupSceneResult.sceneName = activeScene->GetName();
} else {
m_startupSceneResult.sceneName = sceneName.empty()
? std::string("Untitled")
: std::string(sceneName);
}
ResetTransformEditHistory();
ResetToolInteractionState();
SelectionService().ClearSelection();
IncrementInspectorRevision();
IncrementSceneContentRevision();
RefreshScene();
EnsureSceneSelection();
return true;
}
bool EditorSceneRuntime::OpenSceneAsset(const std::filesystem::path& scenePath) {
if (m_backend == nullptr || !m_backend->OpenSceneAsset(scenePath)) {
return false;
@@ -355,6 +388,14 @@ bool EditorSceneRuntime::OpenSceneAsset(const std::filesystem::path& scenePath)
return true;
}
bool EditorSceneRuntime::SaveScene(const std::filesystem::path& scenePath) {
return m_backend != nullptr && m_backend->SaveActiveScene(scenePath);
}
::XCEngine::Components::Scene* EditorSceneRuntime::GetActiveScene() const {
return m_backend != nullptr ? m_backend->GetActiveScene() : nullptr;
}
bool EditorSceneRuntime::RenameGameObject(
std::string_view itemId,
std::string_view newName) {