2026-04-19 00:03:25 +08:00
|
|
|
#include "Features/Inspector/InspectorSubject.h"
|
|
|
|
|
|
|
|
|
|
#include "Scene/EditorSceneRuntime.h"
|
|
|
|
|
|
|
|
|
|
namespace XCEngine::UI::Editor::App {
|
|
|
|
|
|
|
|
|
|
InspectorSelectionSource ResolveInspectorSelectionSource(
|
|
|
|
|
const EditorSession& session,
|
|
|
|
|
const EditorSceneRuntime& sceneRuntime) {
|
2026-04-19 04:36:52 +08:00
|
|
|
switch (session.selection.kind) {
|
|
|
|
|
case EditorSelectionKind::HierarchyNode:
|
|
|
|
|
if (sceneRuntime.HasSceneSelection()) {
|
|
|
|
|
return InspectorSelectionSource::Scene;
|
|
|
|
|
}
|
|
|
|
|
return InspectorSelectionSource::None;
|
|
|
|
|
|
|
|
|
|
case EditorSelectionKind::ProjectItem:
|
|
|
|
|
if (!session.selection.itemId.empty()) {
|
|
|
|
|
return InspectorSelectionSource::Project;
|
|
|
|
|
}
|
|
|
|
|
return InspectorSelectionSource::None;
|
|
|
|
|
|
|
|
|
|
case EditorSelectionKind::None:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2026-04-19 00:03:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-19 04:36:52 +08:00
|
|
|
if (sceneRuntime.HasSceneSelection()) {
|
2026-04-19 00:03:25 +08:00
|
|
|
return InspectorSelectionSource::Scene;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return InspectorSelectionSource::None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InspectorSubject BuildInspectorSubject(
|
|
|
|
|
const EditorSession& session,
|
|
|
|
|
const EditorSceneRuntime& sceneRuntime) {
|
|
|
|
|
InspectorSubject subject = {};
|
|
|
|
|
subject.source = ResolveInspectorSelectionSource(session, sceneRuntime);
|
|
|
|
|
|
|
|
|
|
switch (subject.source) {
|
|
|
|
|
case InspectorSelectionSource::Project:
|
|
|
|
|
subject.kind = InspectorSubjectKind::ProjectAsset;
|
|
|
|
|
subject.projectAsset.selection = session.selection;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InspectorSelectionSource::Scene:
|
|
|
|
|
if (const auto* gameObject = sceneRuntime.GetSelectedGameObject();
|
|
|
|
|
gameObject != nullptr) {
|
|
|
|
|
subject.kind = InspectorSubjectKind::SceneObject;
|
|
|
|
|
subject.sceneObject.gameObject = gameObject;
|
|
|
|
|
subject.sceneObject.itemId = sceneRuntime.GetSelectedItemId();
|
|
|
|
|
subject.sceneObject.displayName =
|
|
|
|
|
sceneRuntime.GetSelectedDisplayName();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InspectorSelectionSource::None:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!subject.HasSelection()) {
|
|
|
|
|
subject.source = InspectorSelectionSource::None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return subject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace XCEngine::UI::Editor::App
|