checkpoint: commit current workspace state
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "Features/Inspector/AddComponentPanel.h"
|
||||
|
||||
#include "Composition/EditorContext.h"
|
||||
#include "Windowing/Utility/EditorUtilityWindowFeatureCommands.h"
|
||||
#include "Features/Inspector/Components/IInspectorComponentEditor.h"
|
||||
#include "Features/Inspector/Components/InspectorComponentEditorRegistry.h"
|
||||
|
||||
@@ -122,8 +122,15 @@ void AddComponentPanel::RebuildEntries(
|
||||
}
|
||||
|
||||
bool AddComponentPanel::TryActivateEntry(
|
||||
EditorContext& context,
|
||||
std::size_t entryIndex) {
|
||||
const EditorUtilityWindowSession& session,
|
||||
std::size_t entryIndex,
|
||||
EditorUtilityWindowPanelResult& outResult) const {
|
||||
outResult = {};
|
||||
const EditorUtilityWindowAddComponentPayload* payload = TryGetAddComponentPayload(session);
|
||||
if (payload == nullptr || !payload->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entryIndex >= m_entries.size()) {
|
||||
return false;
|
||||
}
|
||||
@@ -133,13 +140,9 @@ bool AddComponentPanel::TryActivateEntry(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context.GetSceneRuntime().AddComponentToSelectedGameObject(entry.componentTypeName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_hasTarget = context.GetSceneRuntime().GetSelectedGameObject() != nullptr;
|
||||
m_targetDisplayName = context.GetSceneRuntime().GetSelectedDisplayName();
|
||||
RebuildEntries(context.GetSceneRuntime().GetSelectedGameObject());
|
||||
outResult.type = EditorUtilityWindowPanelResult::Type::AddComponent;
|
||||
outResult.targetItemId = payload->targetItemId;
|
||||
outResult.componentTypeName = entry.componentTypeName;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -153,20 +156,33 @@ std::size_t AddComponentPanel::HitTestEntry(const UIPoint& point) const {
|
||||
return kInvalidEntryIndex;
|
||||
}
|
||||
|
||||
void AddComponentPanel::Update(
|
||||
EditorContext& context,
|
||||
EditorUtilityWindowPanelOutput AddComponentPanel::Update(
|
||||
EditorUtilityWindowPanelServices services,
|
||||
const EditorUtilityWindowHostContext& hostContext,
|
||||
const EditorUtilityWindowSession& session,
|
||||
const std::vector<UIInputEvent>& inputEvents) {
|
||||
if (!hostContext.mounted) {
|
||||
ResetPanelState();
|
||||
return;
|
||||
return {};
|
||||
}
|
||||
|
||||
m_visible = true;
|
||||
const EditorUtilityWindowAddComponentPayload* payload = TryGetAddComponentPayload(session);
|
||||
m_hasTarget = payload != nullptr && payload->IsValid();
|
||||
if (!m_hasTarget) {
|
||||
m_targetDisplayName.clear();
|
||||
m_entries.clear();
|
||||
ResetInteractionState();
|
||||
return {};
|
||||
}
|
||||
m_bounds = hostContext.bounds;
|
||||
m_hasTarget = context.GetSceneRuntime().GetSelectedGameObject() != nullptr;
|
||||
m_targetDisplayName = context.GetSceneRuntime().GetSelectedDisplayName();
|
||||
RebuildEntries(context.GetSceneRuntime().GetSelectedGameObject());
|
||||
const ::XCEngine::Components::GameObject* gameObject =
|
||||
services.addComponentQueries != nullptr
|
||||
? services.addComponentQueries->FindTargetGameObject(payload->targetItemId)
|
||||
: nullptr;
|
||||
m_hasTarget = gameObject != nullptr;
|
||||
m_targetDisplayName = payload->targetDisplayName;
|
||||
RebuildEntries(gameObject);
|
||||
|
||||
if (hostContext.focusLost) {
|
||||
ResetInteractionState();
|
||||
@@ -204,7 +220,13 @@ void AddComponentPanel::Update(
|
||||
m_hoveredEntryIndex = HitTestEntry(event.position);
|
||||
if (m_pressedEntryIndex != kInvalidEntryIndex &&
|
||||
m_pressedEntryIndex == m_hoveredEntryIndex) {
|
||||
TryActivateEntry(context, m_pressedEntryIndex);
|
||||
EditorUtilityWindowPanelResult result = {};
|
||||
if (TryActivateEntry(session, m_pressedEntryIndex, result)) {
|
||||
return EditorUtilityWindowPanelOutput{
|
||||
.closeRequested = true,
|
||||
.result = std::move(result),
|
||||
};
|
||||
}
|
||||
}
|
||||
m_pressedEntryIndex = kInvalidEntryIndex;
|
||||
break;
|
||||
@@ -213,6 +235,8 @@ void AddComponentPanel::Update(
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void AddComponentPanel::Append(UIDrawList& drawList) const {
|
||||
@@ -302,3 +326,11 @@ void AddComponentPanel::Append(UIDrawList& drawList) const {
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user