editor: bind inspector and console to live runtime state

This commit is contained in:
2026-04-29 18:07:44 +08:00
parent f74503c2a5
commit a99879065c
14 changed files with 262 additions and 71 deletions

View File

@@ -166,8 +166,8 @@ std::string DescribeHierarchyPanelEvent(const HierarchyPanel::Event& event) {
class ConsoleWorkspacePanel final : public EditorWorkspacePanel {
public:
explicit ConsoleWorkspacePanel(const EditorSession& session)
: m_session(session) {}
explicit ConsoleWorkspacePanel(const std::vector<EditorConsoleEntry>& entries)
: m_entries(entries) {}
std::string_view GetPanelId() const override {
return kConsolePanelId;
@@ -191,7 +191,7 @@ public:
void Update(const EditorWorkspacePanelUpdateContext& context) override {
m_panel.Update(
m_session,
m_entries,
ResolveHostedPanelDispatchEntry(
context.shellFrame.hostedPanelDispatchFrame,
GetPanelId()));
@@ -202,7 +202,7 @@ public:
}
private:
const EditorSession& m_session;
const std::vector<EditorConsoleEntry>& m_entries;
ConsolePanel m_panel = {};
};
@@ -286,14 +286,12 @@ private:
class InspectorWorkspacePanel final : public EditorWorkspacePanel {
public:
InspectorWorkspacePanel(
const EditorSession& session,
EditorCommandFocusService& commandFocusService,
EditorProjectRuntime& projectRuntime,
EditorSceneRuntime& sceneRuntime,
EditorColorPickerToolState& colorPickerToolState,
RequestOpenUtilityWindowCallback requestOpenUtilityWindow)
: m_session(session)
, m_commandFocusService(commandFocusService)
: m_commandFocusService(commandFocusService)
, m_projectRuntime(projectRuntime)
, m_sceneRuntime(sceneRuntime)
, m_colorPickerToolState(colorPickerToolState)
@@ -318,7 +316,6 @@ public:
void Update(const EditorWorkspacePanelUpdateContext& context) override {
m_panel.SetCommandFocusService(&m_commandFocusService);
InspectorPanelContext panelContext{
.session = m_session,
.projectRuntime = m_projectRuntime,
.sceneRuntime = m_sceneRuntime,
.colorPickerToolState = m_colorPickerToolState,
@@ -354,7 +351,6 @@ public:
}
private:
const EditorSession& m_session;
EditorCommandFocusService& m_commandFocusService;
EditorProjectRuntime& m_projectRuntime;
EditorSceneRuntime& m_sceneRuntime;
@@ -584,7 +580,7 @@ private:
std::unique_ptr<EditorWorkspacePanel> CreateWorkspacePanelRuntime(
const EditorProductPanelDescriptor& panel,
const EditorSession& session,
const std::vector<EditorConsoleEntry>& consoleEntries,
EditorCommandFocusService& commandFocusService,
EditorProjectRuntime& projectRuntime,
EditorSceneRuntime& sceneRuntime,
@@ -594,7 +590,7 @@ std::unique_ptr<EditorWorkspacePanel> CreateWorkspacePanelRuntime(
const RequestOpenSceneAssetCallback& requestOpenSceneAsset) {
switch (panel.runtimeKind) {
case EditorProductPanelRuntimeKind::Console:
return std::make_unique<ConsoleWorkspacePanel>(session);
return std::make_unique<ConsoleWorkspacePanel>(consoleEntries);
case EditorProductPanelRuntimeKind::Game:
return std::make_unique<GameWorkspacePanel>(commandFocusService);
case EditorProductPanelRuntimeKind::Hierarchy:
@@ -603,7 +599,6 @@ std::unique_ptr<EditorWorkspacePanel> CreateWorkspacePanelRuntime(
commandFocusService);
case EditorProductPanelRuntimeKind::Inspector:
return std::make_unique<InspectorWorkspacePanel>(
session,
commandFocusService,
projectRuntime,
sceneRuntime,
@@ -628,7 +623,7 @@ std::unique_ptr<EditorWorkspacePanel> CreateWorkspacePanelRuntime(
} // namespace
EditorWorkspacePanelRuntimeSet CreateEditorWorkspacePanelRuntimeSet(
const EditorSession& session,
const std::vector<EditorConsoleEntry>& consoleEntries,
EditorProjectRuntime& projectRuntime,
EditorSceneRuntime& sceneRuntime,
EditorColorPickerToolState& colorPickerToolState,
@@ -642,7 +637,7 @@ EditorWorkspacePanelRuntimeSet CreateEditorWorkspacePanelRuntimeSet(
if (std::unique_ptr<EditorWorkspacePanel> runtime =
CreateWorkspacePanelRuntime(
panel,
session,
consoleEntries,
commandFocusService,
projectRuntime,
sceneRuntime,