关键节点
This commit is contained in:
70
editor/app/Features/Inspector/InspectorSubject.cpp
Normal file
70
editor/app/Features/Inspector/InspectorSubject.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "Features/Inspector/InspectorSubject.h"
|
||||
|
||||
#include "Scene/EditorSceneRuntime.h"
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
InspectorSelectionSource ResolveInspectorSelectionSource(
|
||||
const EditorSession& session,
|
||||
const EditorSceneRuntime& sceneRuntime) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (sceneRuntime.HasSceneSelection()) {
|
||||
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
|
||||
Reference in New Issue
Block a user