editor: remove shared panel services bag

This commit is contained in:
2026-04-29 13:10:03 +08:00
parent a3a80dff8f
commit a8e1a2b097
18 changed files with 202 additions and 206 deletions

View File

@@ -1,8 +1,9 @@
#include "Inspector/AddComponentPanel.h"
#include "Panels/EditorPanelServices.h"
#include "Inspector/Components/IInspectorComponentEditor.h"
#include "Inspector/Components/InspectorComponentEditorRegistry.h"
#include "Scene/EditorSceneRuntime.h"
#include "Windowing/EditorFrameServices.h"
#include <XCEditor/Fields/UIEditorFieldStyle.h>
@@ -123,7 +124,7 @@ void AddComponentPanel::RebuildEntries(
}
bool AddComponentPanel::TryActivateEntry(
EditorPanelServices& services,
EditorSceneRuntime& sceneRuntime,
std::size_t entryIndex) {
if (entryIndex >= m_entries.size()) {
return false;
@@ -134,14 +135,14 @@ bool AddComponentPanel::TryActivateEntry(
return false;
}
if (!services.sceneRuntime.AddComponentToSelectedGameObject(entry.componentTypeName)) {
if (!sceneRuntime.AddComponentToSelectedGameObject(entry.componentTypeName)) {
return false;
}
const std::optional<EditorSceneObjectSnapshot> selectedObject =
services.sceneRuntime.GetSelectedObjectSnapshot();
sceneRuntime.GetSelectedObjectSnapshot();
m_hasTarget = selectedObject.has_value();
m_targetDisplayName = services.sceneRuntime.GetSelectedDisplayName();
m_targetDisplayName = sceneRuntime.GetSelectedDisplayName();
RebuildEntries(selectedObject.has_value() ? &selectedObject.value() : nullptr);
return true;
}
@@ -157,7 +158,7 @@ std::size_t AddComponentPanel::HitTestEntry(const UIPoint& point) const {
}
void AddComponentPanel::Update(
EditorPanelServices& services,
EditorFrameServices& frameServices,
const EditorUtilityWindowHostContext& hostContext,
const std::vector<UIInputEvent>& inputEvents) {
if (!hostContext.mounted) {
@@ -165,12 +166,13 @@ void AddComponentPanel::Update(
return;
}
EditorSceneRuntime& sceneRuntime = frameServices.GetSceneRuntime();
m_visible = true;
m_bounds = hostContext.bounds;
const std::optional<EditorSceneObjectSnapshot> selectedObject =
services.sceneRuntime.GetSelectedObjectSnapshot();
sceneRuntime.GetSelectedObjectSnapshot();
m_hasTarget = selectedObject.has_value();
m_targetDisplayName = services.sceneRuntime.GetSelectedDisplayName();
m_targetDisplayName = sceneRuntime.GetSelectedDisplayName();
RebuildEntries(selectedObject.has_value() ? &selectedObject.value() : nullptr);
if (hostContext.focusLost) {
@@ -209,7 +211,7 @@ void AddComponentPanel::Update(
m_hoveredEntryIndex = HitTestEntry(event.position);
if (m_pressedEntryIndex != kInvalidEntryIndex &&
m_pressedEntryIndex == m_hoveredEntryIndex) {
TryActivateEntry(services, m_pressedEntryIndex);
TryActivateEntry(sceneRuntime, m_pressedEntryIndex);
}
m_pressedEntryIndex = kInvalidEntryIndex;
break;