233 if (!shortcut_manager) {
242 if (editor_manager) {
244 [editor_manager]() -> std::optional<EditorType> {
245 auto* current_editor = editor_manager->GetCurrentEditor();
246 if (!current_editor) {
249 return current_editor->
type();
255 shortcut_manager,
"view.toggle_activity_bar", {ImGuiMod_Ctrl, ImGuiKey_B},
257 if (window_manager) {
258 window_manager->ToggleSidebarVisibility();
265 shortcut_manager,
"view.toggle_side_panel",
266 {ImGuiMod_Ctrl, ImGuiMod_Alt, ImGuiKey_E},
268 if (window_manager) {
269 window_manager->ToggleSidebarExpanded();
276 shortcut_manager,
"ui.font_scale_increase",
277 {ImGuiMod_Ctrl, ImGuiKey_Equal},
279 AdjustUiFontScaleBy(editor_manager, kUiFontScaleStep);
284 shortcut_manager,
"ui.font_scale_increase_keypad",
285 {ImGuiMod_Ctrl, ImGuiKey_KeypadAdd},
287 AdjustUiFontScaleBy(editor_manager, kUiFontScaleStep);
292 shortcut_manager,
"ui.font_scale_decrease",
293 {ImGuiMod_Ctrl, ImGuiKey_Minus},
295 AdjustUiFontScaleBy(editor_manager, -kUiFontScaleStep);
300 shortcut_manager,
"ui.font_scale_decrease_keypad",
301 {ImGuiMod_Ctrl, ImGuiKey_KeypadSubtract},
303 AdjustUiFontScaleBy(editor_manager, -kUiFontScaleStep);
308 shortcut_manager,
"ui.font_scale_reset", {ImGuiMod_Ctrl, ImGuiKey_0},
310 if (!editor_manager || ImGui::GetIO().WantTextInput) {
313 editor_manager->SetFontGlobalScale(1.0f);
318 shortcut_manager,
"Open", {ImGuiMod_Ctrl, ImGuiKey_O},
320 if (editor_manager) {
321 editor_manager->LoadRom();
326 RegisterIfValid(shortcut_manager,
"Save", {ImGuiMod_Ctrl, ImGuiKey_S},
328 if (editor_manager) {
329 editor_manager->SaveRom();
334 shortcut_manager,
"Save As", {ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_S},
336 if (editor_manager && editor_manager->popup_manager()) {
343 shortcut_manager,
"Close ROM", {ImGuiMod_Ctrl, ImGuiKey_W},
347 if (editor_manager) {
348 editor_manager->CloseRom();
354 shortcut_manager,
"Quit", {ImGuiMod_Ctrl, ImGuiKey_Q},
356 if (editor_manager) {
357 editor_manager->Quit();
363 shortcut_manager,
"Undo", {ImGuiMod_Ctrl, ImGuiKey_Z},
365 if (editor_manager && editor_manager->GetCurrentEditor()) {
366 editor_manager->GetCurrentEditor()->Undo();
372 shortcut_manager,
"Redo", {ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_Z},
374 if (editor_manager && editor_manager->GetCurrentEditor()) {
375 editor_manager->GetCurrentEditor()->Redo();
382 shortcut_manager,
"Redo (Alt)", {ImGuiMod_Ctrl, ImGuiKey_Y},
384 if (editor_manager && editor_manager->GetCurrentEditor()) {
385 editor_manager->GetCurrentEditor()->Redo();
391 shortcut_manager,
"Cut", {ImGuiMod_Ctrl, ImGuiKey_X},
393 if (editor_manager && editor_manager->GetCurrentEditor()) {
394 editor_manager->GetCurrentEditor()->Cut();
400 shortcut_manager,
"Copy", {ImGuiMod_Ctrl, ImGuiKey_C},
402 if (editor_manager && editor_manager->GetCurrentEditor()) {
403 editor_manager->GetCurrentEditor()->Copy();
409 shortcut_manager,
"Paste", {ImGuiMod_Ctrl, ImGuiKey_V},
411 if (editor_manager && editor_manager->GetCurrentEditor()) {
412 editor_manager->GetCurrentEditor()->Paste();
418 shortcut_manager,
"Find", {ImGuiMod_Ctrl, ImGuiKey_F},
420 if (editor_manager && editor_manager->GetCurrentEditor()) {
421 editor_manager->GetCurrentEditor()->Find();
427 shortcut_manager,
"Command Palette",
428 {ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_P},
430 if (ui_coordinator) {
431 ui_coordinator->ShowCommandPalette();
437 shortcut_manager,
"Window Finder", {ImGuiMod_Ctrl, ImGuiKey_P},
439 if (ui_coordinator) {
440 ui_coordinator->ShowPanelFinder();
446 shortcut_manager,
"Keyboard Shortcuts",
447 {ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_Slash},
449 if (ui_coordinator) {
450 ui_coordinator->ShowShortcutsBrowser();
456 shortcut_manager,
"Global Search",
457 {ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_K},
459 if (ui_coordinator) {
460 ui_coordinator->ShowGlobalSearch();
466 shortcut_manager,
"Load Last ROM", {ImGuiMod_Ctrl, ImGuiKey_R},
469 if (!recent.GetRecentFiles().empty() && editor_manager) {
470 editor_manager->OpenRomOrProject(recent.GetRecentFiles().front());
476 shortcut_manager,
"Show About", ImGuiKey_F1,
479 popup_manager->Show(
"About");
484 auto register_editor_shortcut = [&](
EditorType type, ImGuiKey key) {
485 RegisterIfValid(shortcut_manager,
486 absl::StrFormat(
"switch.%d",
static_cast<int>(type)),
487 {ImGuiMod_Ctrl, key}, [editor_manager, type]() {
488 if (editor_manager) {
489 editor_manager->SwitchToEditor(type);
510 auto register_editor_command = [&](
EditorType type,
const std::string& name) {
512 absl::StrFormat(
"Switch to %s Editor", name), [editor_manager, type]() {
513 if (editor_manager) {
514 editor_manager->SwitchToEditor(type);
532 if (editor_manager) {
533 for (
const auto& def : kMusicEditorShortcuts) {
534 RegisterEditorIfValid(
535 shortcut_manager, def.id, def.keys,
536 [editor_manager,
id = def.id]() {
539 auto* editor_set = editor_manager->GetCurrentEditorSet();
541 editor_set ? editor_set->GetMusicEditor() : nullptr;
545 if (id ==
"music.play_pause") {
546 music_editor->TogglePlayPause();
547 }
else if (
id ==
"music.stop") {
548 music_editor->StopPlayback();
549 }
else if (
id ==
"music.speed_up" ||
550 id ==
"music.speed_up_keypad") {
551 music_editor->SpeedUp();
552 }
else if (
id ==
"music.speed_down" ||
553 id ==
"music.speed_down_keypad") {
554 music_editor->SlowDown();
562 if (editor_manager) {
563 for (
const auto& def : kDungeonEditorShortcuts) {
564 RegisterEditorIfValid(
565 shortcut_manager, def.id, def.keys,
566 [editor_manager,
id = def.id]() {
569 auto* editor_set = editor_manager->GetCurrentEditorSet();
570 auto* dungeon_editor =
571 editor_set ? editor_set->GetDungeonEditor() : nullptr;
575 if (id ==
"dungeon.room.navigate_up") {
576 dungeon_editor->NavigateToAdjacentRoom(
577 DungeonRoomNavigationDirection::kUp);
578 }
else if (
id ==
"dungeon.room.navigate_down") {
579 dungeon_editor->NavigateToAdjacentRoom(
581 }
else if (
id ==
"dungeon.room.navigate_left") {
582 dungeon_editor->NavigateToAdjacentRoom(
584 }
else if (
id ==
"dungeon.room.navigate_right") {
585 dungeon_editor->NavigateToAdjacentRoom(
587 }
else if (
id ==
"dungeon.room.previous") {
588 dungeon_editor->CycleRoomSelection(-1);
589 }
else if (
id ==
"dungeon.room.next") {
590 dungeon_editor->CycleRoomSelection(1);
591 }
else if (
id ==
"dungeon.open_room_list") {
593 }
else if (
id ==
"dungeon.open_entrances") {
594 dungeon_editor->OpenWindow(
"dungeon.entrance_properties");
595 }
else if (
id ==
"dungeon.open_matrix") {
597 }
else if (
id ==
"dungeon.open_room_graphics") {
599 }
else if (
id ==
"dungeon.open_palette") {
601 }
else if (
id ==
"dungeon.object.select_tool") {
603 if (
auto* selector = dungeon_editor->object_editor_panel())
604 selector->CancelPlacement();
605 }
else if (
id ==
"dungeon.object.next_object") {
606 (void)dungeon_editor->CycleObjectSelection(1);
607 }
else if (
id ==
"dungeon.object.prev_object") {
608 (void)dungeon_editor->CycleObjectSelection(-1);
609 }
else if (
id ==
"dungeon.object.delete_tool" ||
610 id ==
"dungeon.object.delete") {
611 dungeon_editor->QueueRoomCanvasDeleteShortcut();
615 if (def.id.starts_with(
"dungeon.room.")) {
617 if (!editor_manager) {
620 auto* editor_set = editor_manager->GetCurrentEditorSet();
621 auto* dungeon_editor =
622 editor_set ? editor_set->GetDungeonEditor() :
nullptr;
623 return dungeon_editor !=
nullptr &&
624 dungeon_editor->CanHandleDungeonNavigationShortcut();
631 if (editor_manager) {
634 shortcut_manager, def.id, def.keys,
635 [editor_manager,
id = def.id]() {
638 auto* editor_set = editor_manager->GetCurrentEditorSet();
639 auto* overworld_editor =
640 editor_set ? editor_set->GetOverworldEditor() : nullptr;
641 if (!overworld_editor)
644 if (id ==
"overworld.brush_toggle") {
645 overworld_editor->ToggleBrushTool();
646 }
else if (
id ==
"overworld.fill") {
647 overworld_editor->ActivateFillTool();
648 }
else if (
id ==
"overworld.next_tile") {
649 overworld_editor->CycleTileSelection(1);
650 }
else if (
id ==
"overworld.prev_tile") {
651 overworld_editor->CycleTileSelection(-1);
652 }
else if (
id ==
"overworld.toggle_fullscreen") {
653 overworld_editor->ToggleCanvasFullscreen();
654 }
else if (
id ==
"overworld.toggle_lock") {
655 overworld_editor->ToggleMapLock();
656 }
else if (
id ==
"overworld.toggle_tile16_editor") {
657 overworld_editor->ToggleTile16EditorWindow();
658 }
else if (
id ==
"overworld.toggle_item_list") {
659 overworld_editor->ToggleItemListWindow();
660 }
else if (
id ==
"overworld.world_light") {
661 overworld_editor->SwitchToWorld(0);
662 }
else if (
id ==
"overworld.world_dark") {
663 overworld_editor->SwitchToWorld(1);
664 }
else if (
id ==
"overworld.world_special") {
665 overworld_editor->SwitchToWorld(2);
666 }
else if (
id ==
"overworld.map_left") {
667 overworld_editor->SelectAdjacentMap(-1, 0);
668 }
else if (
id ==
"overworld.map_right") {
669 overworld_editor->SelectAdjacentMap(1, 0);
670 }
else if (
id ==
"overworld.map_up") {
671 overworld_editor->SelectAdjacentMap(0, -1);
672 }
else if (
id ==
"overworld.map_down") {
673 overworld_editor->SelectAdjacentMap(0, 1);
674 }
else if (
id ==
"overworld.zoom_in" ||
675 id ==
"overworld.zoom_in_keypad") {
676 overworld_editor->ZoomIn();
677 }
else if (
id ==
"overworld.zoom_out" ||
678 id ==
"overworld.zoom_out_keypad") {
679 overworld_editor->ZoomOut();
680 }
else if (
id ==
"overworld.zoom_fit") {
681 overworld_editor->ZoomToFit();
682 }
else if (
id ==
"overworld.center_map") {
683 overworld_editor->CenterOverworldView();
684 }
else if (
id ==
"overworld.toggle_entities") {
685 overworld_editor->ToggleEntityVisibility();
686 }
else if (
id ==
"overworld.toggle_grid") {
687 overworld_editor->ToggleGrid();
690 EditorType::kOverworld);
695 if (editor_manager) {
698 shortcut_manager, def.id, def.keys,
699 [editor_manager,
id = def.id]() {
702 auto* editor_set = editor_manager->GetCurrentEditorSet();
703 auto* graphics_editor =
704 editor_set ? editor_set->GetGraphicsEditor() : nullptr;
705 if (!graphics_editor)
708 static const std::map<std::string, PixelTool> kTools = {
709 {
"graphics.tool.select", PixelTool::kSelect},
710 {
"graphics.tool.hand", PixelTool::kHand},
711 {
"graphics.tool.pencil", PixelTool::kPencil},
712 {
"graphics.tool.brush", PixelTool::kBrush},
713 {
"graphics.tool.eraser", PixelTool::kEraser},
714 {
"graphics.tool.fill", PixelTool::kFill},
715 {
"graphics.tool.line", PixelTool::kLine},
716 {
"graphics.tool.rectangle", PixelTool::kRectangle},
717 {
"graphics.tool.eyedropper", PixelTool::kEyedropper},
719 if (
id ==
"graphics.next_sheet") {
720 graphics_editor->NextSheet();
721 }
else if (
id ==
"graphics.prev_sheet") {
722 graphics_editor->PrevSheet();
723 }
else if (
auto tool = kTools.find(
id); tool != kTools.end()) {
724 graphics_editor->SetPixelTool(tool->second);
725 }
else if (
id ==
"graphics.zoom_in" ||
726 id ==
"graphics.zoom_in_keypad") {
727 graphics_editor->ZoomIn();
728 }
else if (
id ==
"graphics.zoom_out" ||
729 id ==
"graphics.zoom_out_keypad") {
730 graphics_editor->ZoomOut();
731 }
else if (
id ==
"graphics.toggle_grid") {
732 graphics_editor->ToggleGrid();
735 EditorType::kGraphics);
740 shortcut_manager,
"Editor Selection", {ImGuiMod_Ctrl, ImGuiKey_E},
742 if (ui_coordinator) {
743 ui_coordinator->ShowEditorSelection();
746 Shortcut::Scope::kGlobal);
749 shortcut_manager,
"Window Browser",
750 {ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_B},
752 if (ui_coordinator) {
753 ui_coordinator->ShowWindowBrowser();
756 Shortcut::Scope::kGlobal);
758 shortcut_manager,
"Window Browser (Alt)",
759 {ImGuiMod_Ctrl, ImGuiMod_Alt, ImGuiKey_P},
761 if (ui_coordinator) {
762 ui_coordinator->ShowWindowBrowser();
765 Shortcut::Scope::kGlobal);
766 RegisterAlias(shortcut_manager,
"Panel Browser",
"Window Browser");
768 "Window Browser (Alt)");
771 shortcut_manager,
"View: Previous Right Drawer",
772 {ImGuiMod_Ctrl, ImGuiMod_Alt, ImGuiKey_LeftBracket},
774 if (!editor_manager) {
777 if (
auto* right_drawer = editor_manager->right_drawer_manager()) {
778 right_drawer->CycleToPreviousDrawer();
781 Shortcut::Scope::kGlobal);
784 shortcut_manager,
"View: Next Right Drawer",
785 {ImGuiMod_Ctrl, ImGuiMod_Alt, ImGuiKey_RightBracket},
787 if (!editor_manager) {
790 if (
auto* right_drawer = editor_manager->right_drawer_manager()) {
791 right_drawer->CycleToNextDrawer();
794 Shortcut::Scope::kGlobal);
795 RegisterAlias(shortcut_manager,
"View: Previous Right Panel",
796 "View: Previous Right Drawer");
798 "View: Next Right Drawer");
800 if (window_manager) {
804 shortcut_manager,
"Show Dungeon Windows",
805 {ImGuiMod_Ctrl, ImGuiMod_Alt, ImGuiKey_D},
807 window_manager->ShowAllWindowsInCategory(
808 window_manager->GetActiveSessionId(),
"Dungeon");
810 Shortcut::Scope::kEditor);
812 "Show Dungeon Windows");
814 shortcut_manager,
"Show Graphics Windows",
815 {ImGuiMod_Ctrl, ImGuiMod_Alt, ImGuiKey_G},
817 window_manager->ShowAllWindowsInCategory(
818 window_manager->GetActiveSessionId(),
"Graphics");
820 Shortcut::Scope::kEditor);
822 "Show Graphics Windows");
824 shortcut_manager,
"Show Screen Windows",
825 {ImGuiMod_Ctrl, ImGuiMod_Alt, ImGuiKey_S},
827 window_manager->ShowAllWindowsInCategory(
828 window_manager->GetActiveSessionId(),
"Screen");
830 Shortcut::Scope::kEditor);
832 "Show Screen Windows");
835#ifdef YAZE_BUILD_AGENT_UI
837 {ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiKey_A},
839 if (editor_manager) {
840 editor_manager->ShowAIAgent();
845 {ImGuiMod_Ctrl, ImGuiKey_H}, [editor_manager]() {
846 if (editor_manager) {
847 editor_manager->ShowChatHistory();
852 {ImGuiMod_Ctrl, ImGuiMod_Shift,
855 if (editor_manager) {
856 editor_manager->ShowProposalDrawer();
864 shortcut_manager->
RegisterCommand(
"Layout Profile: Code", [editor_manager]() {
865 if (editor_manager) {
866 editor_manager->ApplyLayoutProfile(
"code");
870 "Layout Profile: Debug", [editor_manager]() {
871 if (editor_manager) {
872 editor_manager->ApplyLayoutProfile(
"debug");
876 "Layout Profile: Mapping", [editor_manager]() {
877 if (editor_manager) {
878 editor_manager->ApplyLayoutProfile(
"mapping");
881 shortcut_manager->
RegisterCommand(
"Layout Profile: Chat", [editor_manager]() {
882 if (editor_manager) {
883 editor_manager->ApplyLayoutProfile(
"chat");
887 "Layout Snapshot: Capture", [editor_manager]() {
888 if (editor_manager) {
889 editor_manager->CaptureTemporaryLayoutSnapshot();
893 "Layout Snapshot: Restore", [editor_manager]() {
894 if (editor_manager) {
895 editor_manager->RestoreTemporaryLayoutSnapshot();
899 "Layout Snapshot: Clear", [editor_manager]() {
900 if (editor_manager) {
901 editor_manager->ClearTemporaryLayoutSnapshot();
906 "Layout: Apply Minimal Preset", [editor_manager]() {
907 if (editor_manager) {
908 editor_manager->ApplyLayoutPreset(
"Minimal");
912 "Layout: Apply Developer Preset", [editor_manager]() {
913 if (editor_manager) {
914 editor_manager->ApplyLayoutPreset(
"Developer");
918 "Layout: Apply Designer Preset", [editor_manager]() {
919 if (editor_manager) {
920 editor_manager->ApplyLayoutPreset(
"Designer");
924 "Layout: Apply Modder Preset", [editor_manager]() {
925 if (editor_manager) {
926 editor_manager->ApplyLayoutPreset(
"Modder");
930 "Layout: Apply Overworld Expert Preset", [editor_manager]() {
931 if (editor_manager) {
932 editor_manager->ApplyLayoutPreset(
"Overworld Expert");
936 "Layout: Apply Dungeon Expert Preset", [editor_manager]() {
937 if (editor_manager) {
938 editor_manager->ApplyLayoutPreset(
"Dungeon Expert");
942 "Layout: Apply Testing Preset", [editor_manager]() {
943 if (editor_manager) {
944 editor_manager->ApplyLayoutPreset(
"Testing");
948 "Layout: Apply Audio Preset", [editor_manager]() {
949 if (editor_manager) {
950 editor_manager->ApplyLayoutPreset(
"Audio");
954 "Layout: Reset Current Editor", [editor_manager]() {
955 if (editor_manager) {
956 editor_manager->ResetCurrentEditorLayout();
963 if (editor_manager) {
964 using DrawerType = RightDrawerManager::DrawerType;
965 auto* right_drawer_manager = editor_manager->right_drawer_manager();
966 if (right_drawer_manager) {
971 DrawerCmd drawer_cmds[] = {
972 {
"View: Toggle AI Agent Panel", DrawerType::kAgentChat},
973 {
"View: Toggle AI Agent Drawer", DrawerType::kAgentChat},
974 {
"View: Toggle Proposals Panel", DrawerType::kProposals},
975 {
"View: Toggle Proposals Drawer", DrawerType::kProposals},
976 {
"View: Toggle Settings Panel", DrawerType::kSettings},
977 {
"View: Toggle Settings Drawer", DrawerType::kSettings},
978 {
"View: Toggle Help Panel", DrawerType::kHelp},
979 {
"View: Toggle Help Drawer", DrawerType::kHelp},
980 {
"View: Toggle Notifications", DrawerType::kNotifications},
981 {
"View: Toggle Notifications Drawer", DrawerType::kNotifications},
982 {
"View: Toggle Properties Panel", DrawerType::kProperties},
983 {
"View: Toggle Properties Drawer", DrawerType::kProperties},
984 {
"View: Toggle Project Panel", DrawerType::kProject},
985 {
"View: Toggle Project Drawer", DrawerType::kProject},
987 for (
const auto& cmd : drawer_cmds) {
989 cmd.label, [right_drawer_manager, drawer_type = cmd.type]() {
990 right_drawer_manager->ToggleDrawer(drawer_type);
1002 if (window_manager) {
1003 auto categories = window_manager->GetAllCategories();
1004 const size_t registration_session_id = window_manager->GetActiveSessionId();
1007 "View: Show Panel Browser",
1008 [window_manager]() { window_manager->TriggerShowWindowBrowser(); });
1010 "View: Show Window Browser",
1011 [window_manager]() { window_manager->TriggerShowWindowBrowser(); });
1013 for (
const auto& category : categories) {
1014 auto windows = window_manager->GetWindowsInCategory(
1015 registration_session_id, category);
1016 for (
const auto& window : windows) {
1017 const std::string window_id = window.card_id;
1018 const std::string display_name = window.display_name;
1021 absl::StrFormat(
"View: Show %s", display_name),
1022 [window_manager, window_id]() {
1023 if (window_manager) {
1024 window_manager->OpenWindow(window_manager->GetActiveSessionId(),
1029 absl::StrFormat(
"View: Hide %s", display_name),
1030 [window_manager, window_id]() {
1031 if (window_manager) {
1032 window_manager->CloseWindow(
1033 window_manager->GetActiveSessionId(), window_id);
1037 absl::StrFormat(
"View: Toggle %s", display_name),
1038 [window_manager, window_id]() {
1039 if (window_manager) {
1040 window_manager->ToggleWindow(
1041 window_manager->GetActiveSessionId(), window_id);
1046 absl::StrFormat(
"View: Open %s Window", display_name),
1047 [window_manager, window_id]() {
1048 if (window_manager) {
1049 window_manager->OpenWindow(window_manager->GetActiveSessionId(),
1054 absl::StrFormat(
"View: Close %s Window", display_name),
1055 [window_manager, window_id]() {
1056 if (window_manager) {
1057 window_manager->CloseWindow(
1058 window_manager->GetActiveSessionId(), window_id);
1062 absl::StrFormat(
"View: Toggle %s Window", display_name),
1063 [window_manager, window_id]() {
1064 if (window_manager) {
1065 window_manager->ToggleWindow(
1066 window_manager->GetActiveSessionId(), window_id);
1072 absl::StrFormat(
"View: Show All %s Panels", category),
1074 if (window_manager) {
1075 window_manager->ShowAllWindowsInCategory(
1076 window_manager->GetActiveSessionId(),
category);
1080 absl::StrFormat(
"View: Hide All %s Panels", category),
1082 if (window_manager) {
1083 window_manager->HideAllWindowsInCategory(
1084 window_manager->GetActiveSessionId(),
category);
1088 absl::StrFormat(
"View: Show All %s Windows", category),
1090 if (window_manager) {
1091 window_manager->ShowAllWindowsInCategory(
1092 window_manager->GetActiveSessionId(),
category);
1096 absl::StrFormat(
"View: Hide All %s Windows", category),
1098 if (window_manager) {
1099 window_manager->HideAllWindowsInCategory(
1100 window_manager->GetActiveSessionId(),
category);