Extract editor edit action router

This commit is contained in:
2026-03-26 22:31:22 +08:00
parent 8bdb1f34c7
commit f87bc53875
15 changed files with 227 additions and 125 deletions

View File

@@ -63,9 +63,6 @@ void HierarchyPanel::Render() {
Actions::ObserveFocusedActionRoute(*m_context, EditorActionRoute::Hierarchy);
RenderSearchBar();
HandleKeyboardShortcuts();
std::string filter = m_searchBuffer;
UI::PanelContentScope content("EntityList");
@@ -315,29 +312,6 @@ void HierarchyPanel::HandleDragDrop(::XCEngine::Components::GameObject* gameObje
}
}
void HierarchyPanel::HandleKeyboardShortcuts() {
auto& sceneManager = m_context->GetSceneManager();
auto& selectionManager = m_context->GetSelectionManager();
::XCEngine::Components::GameObject* selectedGameObject = sceneManager.GetEntity(selectionManager.GetSelectedEntity());
const Actions::ShortcutContext shortcutContext = Actions::FocusedWindowShortcutContext();
Actions::HandleShortcut(Actions::MakeDeleteEntityAction(selectedGameObject), shortcutContext, [&]() {
Commands::DeleteEntity(*m_context, selectedGameObject->GetID());
});
Actions::HandleShortcut(Actions::MakeRenameEntityAction(selectedGameObject), shortcutContext, [&]() {
BeginRename(selectedGameObject);
});
Actions::HandleShortcut(Actions::MakeCopyEntityAction(selectedGameObject), shortcutContext, [&]() {
Commands::CopyEntity(*m_context, selectedGameObject->GetID());
});
Actions::HandleShortcut(Actions::MakePasteEntityAction(*m_context), shortcutContext, [&]() {
Commands::PasteEntity(*m_context, selectedGameObject ? selectedGameObject->GetID() : 0);
});
Actions::HandleShortcut(Actions::MakeDuplicateEntityAction(selectedGameObject), shortcutContext, [&]() {
Commands::DuplicateEntity(*m_context, selectedGameObject->GetID());
});
}
bool HierarchyPanel::PassesFilter(::XCEngine::Components::GameObject* gameObject, const std::string& filter) {
if (!gameObject) return false;