152 lines
6.0 KiB
C++
152 lines
6.0 KiB
C++
#include "EditorShellAssetBuilderSupport.h"
|
|
|
|
#include <XCEngine/Input/InputTypes.h>
|
|
|
|
#include <utility>
|
|
|
|
namespace XCEngine::UI::Editor::App::CompositionSupport {
|
|
|
|
namespace {
|
|
|
|
using XCEngine::Input::KeyCode;
|
|
using XCEngine::UI::UIInputEventType;
|
|
using XCEngine::UI::UIShortcutBinding;
|
|
using XCEngine::UI::UIShortcutScope;
|
|
|
|
UIEditorCommandDescriptor BuildHostCommand(
|
|
std::string commandId,
|
|
std::string displayName) {
|
|
UIEditorCommandDescriptor command = {};
|
|
command.commandId = std::move(commandId);
|
|
command.displayName = std::move(displayName);
|
|
command.kind = UIEditorCommandKind::Host;
|
|
command.workspaceCommand.panelSource = UIEditorCommandPanelSource::None;
|
|
command.workspaceCommand.panelId.clear();
|
|
return command;
|
|
}
|
|
|
|
UIEditorCommandDescriptor BuildWorkspaceCommand(
|
|
std::string commandId,
|
|
std::string displayName,
|
|
UIEditorWorkspaceCommandKind kind,
|
|
std::string panelId = {}) {
|
|
UIEditorCommandDescriptor command = {};
|
|
command.commandId = std::move(commandId);
|
|
command.displayName = std::move(displayName);
|
|
command.workspaceCommand.kind = kind;
|
|
if (kind == UIEditorWorkspaceCommandKind::ResetWorkspace) {
|
|
command.workspaceCommand.panelSource = UIEditorCommandPanelSource::None;
|
|
} else {
|
|
command.workspaceCommand.panelSource = UIEditorCommandPanelSource::FixedPanelId;
|
|
command.workspaceCommand.panelId = std::move(panelId);
|
|
}
|
|
return command;
|
|
}
|
|
|
|
UIShortcutBinding BuildBinding(
|
|
std::string commandId,
|
|
std::int32_t keyCode,
|
|
bool control = false,
|
|
bool shift = false,
|
|
bool alt = false) {
|
|
UIShortcutBinding binding = {};
|
|
binding.scope = UIShortcutScope::Global;
|
|
binding.triggerEventType = UIInputEventType::KeyDown;
|
|
binding.commandId = std::move(commandId);
|
|
binding.chord.keyCode = keyCode;
|
|
binding.chord.modifiers.control = control;
|
|
binding.chord.modifiers.shift = shift;
|
|
binding.chord.modifiers.alt = alt;
|
|
return binding;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
UIEditorCommandRegistry BuildEditorCommandRegistry() {
|
|
UIEditorCommandRegistry registry = {};
|
|
registry.commands = {
|
|
BuildHostCommand("file.new_project", "New Project..."),
|
|
BuildHostCommand("file.open_project", "Open Project..."),
|
|
BuildHostCommand("file.save_project", "Save Project"),
|
|
BuildHostCommand("file.new_scene", "New Scene"),
|
|
BuildHostCommand("file.open_scene", "Open Scene"),
|
|
BuildHostCommand("file.save_scene", "Save Scene"),
|
|
BuildHostCommand("file.save_scene_as", "Save Scene As..."),
|
|
BuildHostCommand("file.exit", "Exit"),
|
|
BuildHostCommand("edit.undo", "Undo"),
|
|
BuildHostCommand("edit.redo", "Redo"),
|
|
BuildHostCommand("edit.cut", "Cut"),
|
|
BuildHostCommand("edit.copy", "Copy"),
|
|
BuildHostCommand("edit.paste", "Paste"),
|
|
BuildHostCommand("edit.duplicate", "Duplicate"),
|
|
BuildHostCommand("edit.delete", "Delete"),
|
|
BuildHostCommand("edit.rename", "Rename"),
|
|
BuildHostCommand("assets.reimport_selected", "Reimport Selected Asset"),
|
|
BuildHostCommand("assets.reimport_all", "Reimport All Assets"),
|
|
BuildHostCommand("assets.clear_library", "Clear Library"),
|
|
BuildHostCommand("run.play", "Play"),
|
|
BuildHostCommand("run.pause", "Pause"),
|
|
BuildHostCommand("run.step", "Step"),
|
|
BuildHostCommand("scripts.rebuild", "Rebuild Script Assemblies"),
|
|
BuildHostCommand("help.about", "About"),
|
|
BuildWorkspaceCommand(
|
|
"view.reset_layout",
|
|
"Reset Layout",
|
|
UIEditorWorkspaceCommandKind::ResetWorkspace),
|
|
BuildWorkspaceCommand(
|
|
"view.activate_hierarchy",
|
|
"Hierarchy",
|
|
UIEditorWorkspaceCommandKind::ActivatePanel,
|
|
"hierarchy"),
|
|
BuildWorkspaceCommand(
|
|
"view.activate_scene",
|
|
"Scene",
|
|
UIEditorWorkspaceCommandKind::ActivatePanel,
|
|
"scene"),
|
|
BuildWorkspaceCommand(
|
|
"view.activate_game",
|
|
"Game",
|
|
UIEditorWorkspaceCommandKind::ActivatePanel,
|
|
"game"),
|
|
BuildWorkspaceCommand(
|
|
"view.activate_inspector",
|
|
"Inspector",
|
|
UIEditorWorkspaceCommandKind::ActivatePanel,
|
|
"inspector"),
|
|
BuildWorkspaceCommand(
|
|
"view.activate_console",
|
|
"Console",
|
|
UIEditorWorkspaceCommandKind::ActivatePanel,
|
|
"console"),
|
|
BuildWorkspaceCommand(
|
|
"view.activate_project",
|
|
"Project",
|
|
UIEditorWorkspaceCommandKind::ActivatePanel,
|
|
"project")
|
|
};
|
|
return registry;
|
|
}
|
|
|
|
std::vector<UIShortcutBinding> BuildEditorShortcutBindings() {
|
|
return {
|
|
BuildBinding("file.new_scene", static_cast<std::int32_t>(KeyCode::N), true),
|
|
BuildBinding("file.open_scene", static_cast<std::int32_t>(KeyCode::O), true),
|
|
BuildBinding("file.save_scene", static_cast<std::int32_t>(KeyCode::S), true),
|
|
BuildBinding("file.save_scene_as", static_cast<std::int32_t>(KeyCode::S), true, true),
|
|
BuildBinding("edit.undo", static_cast<std::int32_t>(KeyCode::Z), true),
|
|
BuildBinding("edit.redo", static_cast<std::int32_t>(KeyCode::Y), true),
|
|
BuildBinding("edit.cut", static_cast<std::int32_t>(KeyCode::X), true),
|
|
BuildBinding("edit.copy", static_cast<std::int32_t>(KeyCode::C), true),
|
|
BuildBinding("edit.paste", static_cast<std::int32_t>(KeyCode::V), true),
|
|
BuildBinding("edit.duplicate", static_cast<std::int32_t>(KeyCode::D), true),
|
|
BuildBinding("edit.delete", static_cast<std::int32_t>(KeyCode::Delete)),
|
|
BuildBinding("edit.rename", static_cast<std::int32_t>(KeyCode::F2)),
|
|
BuildBinding("run.play", static_cast<std::int32_t>(KeyCode::F5)),
|
|
BuildBinding("run.pause", static_cast<std::int32_t>(KeyCode::F6)),
|
|
BuildBinding("run.step", static_cast<std::int32_t>(KeyCode::F7)),
|
|
BuildBinding("file.exit", static_cast<std::int32_t>(KeyCode::F4), false, false, true)
|
|
};
|
|
}
|
|
|
|
} // namespace XCEngine::UI::Editor::App::CompositionSupport
|