47 lines
1.6 KiB
C++
47 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "Inspector/Components/IInspectorComponentEditor.h"
|
|
#include "Inspector/Components/InspectorComponentEditorRegistry.h"
|
|
#include "Inspector/InspectorPresentationModel.h"
|
|
#include "Inspector/InspectorSubject.h"
|
|
#include "Scene/EditorSceneRuntime.h"
|
|
|
|
namespace XCEngine::UI::Editor::App {
|
|
|
|
inline bool ApplyInspectorComponentBoundFieldValue(
|
|
EditorSceneRuntime& sceneRuntime,
|
|
const InspectorSceneObjectSubject& sceneObject,
|
|
const InspectorPresentationComponentBinding& binding,
|
|
const Widgets::UIEditorPropertyGridField& field,
|
|
const InspectorComponentEditorRegistry& componentEditorRegistry =
|
|
InspectorComponentEditorRegistry::Get()) {
|
|
const IInspectorComponentEditor* editor =
|
|
componentEditorRegistry.FindEditor(binding.typeName);
|
|
if (editor == nullptr) {
|
|
return false;
|
|
}
|
|
|
|
const std::vector<EditorSceneComponentDescriptor> descriptors =
|
|
sceneRuntime.GetSelectedComponents();
|
|
InspectorComponentEditorContext context = {};
|
|
context.gameObject = &sceneObject.object;
|
|
context.componentId = binding.componentId;
|
|
context.typeName = binding.typeName;
|
|
context.displayName = binding.displayName;
|
|
context.removable = binding.removable;
|
|
for (const EditorSceneComponentDescriptor& descriptor : descriptors) {
|
|
if (descriptor.componentId == binding.componentId) {
|
|
context.component = descriptor.view.get();
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (context.component == nullptr) {
|
|
return false;
|
|
}
|
|
|
|
return editor->ApplyFieldValue(sceneRuntime, context, field);
|
|
}
|
|
|
|
} // namespace XCEngine::UI::Editor::App
|