Route editor actions by active target
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
#include "Actions/ActionRouting.h"
|
||||
#include "Actions/EditorActions.h"
|
||||
#include "Commands/EntityCommands.h"
|
||||
#include "Commands/ProjectCommands.h"
|
||||
#include "Commands/SceneCommands.h"
|
||||
#include "MenuBar.h"
|
||||
#include "Core/EditorEvents.h"
|
||||
#include "Core/EventBus.h"
|
||||
#include "Core/IEditorContext.h"
|
||||
#include "Core/IProjectManager.h"
|
||||
#include "Core/ISceneManager.h"
|
||||
#include "Core/IUndoManager.h"
|
||||
#include "Core/ISelectionManager.h"
|
||||
@@ -37,12 +40,14 @@ void MenuBar::HandleShortcuts() {
|
||||
return;
|
||||
}
|
||||
|
||||
Actions::HandleShortcut(Actions::MakeNewSceneAction(), [&]() { Commands::NewScene(*m_context); });
|
||||
Actions::HandleShortcut(Actions::MakeOpenSceneAction(), [&]() { Commands::OpenSceneWithDialog(*m_context); });
|
||||
Actions::HandleShortcut(Actions::MakeSaveSceneAction(), [&]() { Commands::SaveCurrentScene(*m_context); });
|
||||
Actions::HandleShortcut(Actions::MakeSaveSceneAsAction(), [&]() { Commands::SaveSceneAsWithDialog(*m_context); });
|
||||
Actions::HandleShortcut(Actions::MakeUndoAction(*m_context), [&]() { m_context->GetUndoManager().Undo(); });
|
||||
Actions::HandleShortcut(Actions::MakeRedoAction(*m_context), [&]() { m_context->GetUndoManager().Redo(); });
|
||||
const Actions::ShortcutContext shortcutContext = Actions::GlobalShortcutContext();
|
||||
|
||||
Actions::HandleShortcut(Actions::MakeNewSceneAction(), shortcutContext, [&]() { Commands::NewScene(*m_context); });
|
||||
Actions::HandleShortcut(Actions::MakeOpenSceneAction(), shortcutContext, [&]() { Commands::OpenSceneWithDialog(*m_context); });
|
||||
Actions::HandleShortcut(Actions::MakeSaveSceneAction(), shortcutContext, [&]() { Commands::SaveCurrentScene(*m_context); });
|
||||
Actions::HandleShortcut(Actions::MakeSaveSceneAsAction(), shortcutContext, [&]() { Commands::SaveSceneAsWithDialog(*m_context); });
|
||||
Actions::HandleShortcut(Actions::MakeUndoAction(*m_context), shortcutContext, [&]() { m_context->GetUndoManager().Undo(); });
|
||||
Actions::HandleShortcut(Actions::MakeRedoAction(*m_context), shortcutContext, [&]() { m_context->GetUndoManager().Redo(); });
|
||||
}
|
||||
|
||||
void MenuBar::ShowFileMenu() {
|
||||
@@ -60,11 +65,29 @@ void MenuBar::ShowFileMenu() {
|
||||
|
||||
void MenuBar::ShowEditMenu() {
|
||||
::XCEngine::Components::GameObject* selectedGameObject = Actions::GetSelectedGameObject(*m_context);
|
||||
const AssetItemPtr selectedAssetItem = Actions::GetSelectedAssetItem(*m_context);
|
||||
auto& projectManager = m_context->GetProjectManager();
|
||||
const EditorActionRoute actionRoute = m_context->GetActiveActionRoute();
|
||||
|
||||
UI::DrawMenuScope("Edit", [&]() {
|
||||
Actions::DrawMenuAction(Actions::MakeUndoAction(*m_context), [&]() { m_context->GetUndoManager().Undo(); });
|
||||
Actions::DrawMenuAction(Actions::MakeRedoAction(*m_context), [&]() { m_context->GetUndoManager().Redo(); });
|
||||
Actions::DrawMenuSeparator();
|
||||
|
||||
if (actionRoute == EditorActionRoute::Project) {
|
||||
Actions::DrawMenuAction(Actions::MakeOpenAssetAction(Commands::CanOpenAsset(selectedAssetItem)), [&]() {
|
||||
Commands::OpenAsset(*m_context, selectedAssetItem);
|
||||
});
|
||||
Actions::DrawMenuAction(Actions::MakeDeleteAssetAction(selectedAssetItem != nullptr), [&]() {
|
||||
Commands::DeleteAsset(projectManager, projectManager.GetSelectedIndex());
|
||||
});
|
||||
Actions::DrawMenuSeparator();
|
||||
Actions::DrawMenuAction(Actions::MakeNavigateBackAction(projectManager.CanNavigateBack()), [&]() {
|
||||
projectManager.NavigateBack();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Actions::DrawMenuAction(Actions::MakeCutAction(false), []() {});
|
||||
Actions::DrawMenuAction(Actions::MakeCopyEntityAction(selectedGameObject), [&]() {
|
||||
Commands::CopyEntity(*m_context, selectedGameObject->GetID());
|
||||
@@ -72,6 +95,15 @@ void MenuBar::ShowEditMenu() {
|
||||
Actions::DrawMenuAction(Actions::MakePasteEntityAction(*m_context), [&]() {
|
||||
Commands::PasteEntity(*m_context, selectedGameObject ? selectedGameObject->GetID() : 0);
|
||||
});
|
||||
Actions::DrawMenuAction(Actions::MakeDuplicateEntityAction(selectedGameObject), [&]() {
|
||||
Commands::DuplicateEntity(*m_context, selectedGameObject->GetID());
|
||||
});
|
||||
Actions::DrawMenuAction(Actions::MakeDeleteEntityAction(selectedGameObject), [&]() {
|
||||
Commands::DeleteEntity(*m_context, selectedGameObject->GetID());
|
||||
});
|
||||
Actions::DrawMenuAction(Actions::MakeRenameEntityAction(selectedGameObject), [&]() {
|
||||
m_context->GetEventBus().Publish(EntityRenameRequestedEvent{ selectedGameObject->GetID() });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user