yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
menu_orchestrator.cc
Go to the documentation of this file.
1#include "menu_orchestrator.h"
2
3#include "absl/strings/str_format.h"
4#include "app/editor/editor.h"
15#include "app/gui/core/icons.h"
17#include "core/features.h"
18#include "rom/rom.h"
20
21// Platform-aware shortcut macros for menu display
22#define SHORTCUT_CTRL(key) gui::FormatCtrlShortcut(ImGuiKey_##key).c_str()
23#define SHORTCUT_CTRL_SHIFT(key) \
24 gui::FormatCtrlShiftShortcut(ImGuiKey_##key).c_str()
25
26namespace yaze {
27namespace editor {
28
30 EditorManager* editor_manager, MenuBuilder& menu_builder,
31 RomFileManager& rom_manager, ProjectManager& project_manager,
32 EditorRegistry& editor_registry, SessionCoordinator& session_coordinator,
33 ToastManager& toast_manager, PopupManager& popup_manager)
34 : editor_manager_(editor_manager),
35 menu_builder_(menu_builder),
36 rom_manager_(rom_manager),
37 project_manager_(project_manager),
38 editor_registry_(editor_registry),
39 session_coordinator_(session_coordinator),
40 toast_manager_(toast_manager),
41 popup_manager_(popup_manager) {}
42
44 ClearMenu();
45
46 // Build all menu sections in order
50 BuildToolsMenu(); // Debug menu items merged into Tools
53
54 // Draw the constructed menu
56
57 menu_needs_refresh_ = false;
58}
59
65
67 // ROM Operations
69 .Item(
70 "Open ROM", ICON_MD_FILE_OPEN, [this]() { OnOpenRom(); },
72 .Item(
73 "Save ROM", ICON_MD_SAVE, [this]() { OnSaveRom(); }, SHORTCUT_CTRL(S),
74 [this]() { return CanSaveRom(); })
75 .Item(
76 "Save As...", ICON_MD_SAVE_AS, [this]() { OnSaveRomAs(); }, nullptr,
77 [this]() { return CanSaveRom(); })
78 .Separator();
79
80 // Project Operations
82 .Item("New Project", ICON_MD_CREATE_NEW_FOLDER,
83 [this]() { OnCreateProject(); })
84 .Item("Open Project", ICON_MD_FOLDER_OPEN, [this]() { OnOpenProject(); })
85 .Item(
86 "Save Project", ICON_MD_SAVE, [this]() { OnSaveProject(); }, nullptr,
87 [this]() { return CanSaveProject(); })
88 .Item(
89 "Save Project As...", ICON_MD_SAVE_AS,
90 [this]() { OnSaveProjectAs(); }, nullptr,
91 [this]() { return CanSaveProject(); })
92 .Item(
93 "Project Management...", ICON_MD_FOLDER_SPECIAL,
94 [this]() { OnShowProjectManagement(); }, nullptr,
95 [this]() { return CanSaveProject(); })
96 .Item(
97 "Edit Project File...", ICON_MD_DESCRIPTION,
98 [this]() { OnShowProjectFileEditor(); }, nullptr,
99 [this]() { return HasProjectFile(); })
100 .Separator();
101
102 // ROM Information and Validation
104 .Item(
105 "ROM Information", ICON_MD_INFO, [this]() { OnShowRomInfo(); },
106 nullptr, [this]() { return HasActiveRom(); })
107 .Item(
108 "Create Backup", ICON_MD_BACKUP, [this]() { OnCreateBackup(); },
109 nullptr, [this]() { return HasActiveRom(); })
110 .Item(
111 "Validate ROM", ICON_MD_CHECK_CIRCLE, [this]() { OnValidateRom(); },
112 nullptr, [this]() { return HasActiveRom(); })
113 .Separator();
114
115 // Settings and Quit
117 .Item("Settings", ICON_MD_SETTINGS, [this]() { OnShowSettings(); })
118 .Separator()
119 .Item(
120 "Quit", ICON_MD_EXIT_TO_APP, [this]() { OnQuit(); },
121 SHORTCUT_CTRL(Q));
122}
123
129
131 // Undo/Redo operations - delegate to current editor
133 .Item(
134 "Undo", ICON_MD_UNDO, [this]() { OnUndo(); }, SHORTCUT_CTRL(Z),
135 [this]() { return HasCurrentEditor(); })
136 .Item(
137 "Redo", ICON_MD_REDO, [this]() { OnRedo(); }, SHORTCUT_CTRL(Y),
138 [this]() { return HasCurrentEditor(); })
139 .Separator();
140
141 // Clipboard operations - delegate to current editor
143 .Item(
144 "Cut", ICON_MD_CONTENT_CUT, [this]() { OnCut(); }, SHORTCUT_CTRL(X),
145 [this]() { return HasCurrentEditor(); })
146 .Item(
147 "Copy", ICON_MD_CONTENT_COPY, [this]() { OnCopy(); },
148 SHORTCUT_CTRL(C), [this]() { return HasCurrentEditor(); })
149 .Item(
150 "Paste", ICON_MD_CONTENT_PASTE, [this]() { OnPaste(); },
151 SHORTCUT_CTRL(V), [this]() { return HasCurrentEditor(); })
152 .Separator();
153
154 // Search operations (Find in Files moved to Tools > Global Search)
156 "Find", ICON_MD_SEARCH, [this]() { OnFind(); }, SHORTCUT_CTRL(F),
157 [this]() { return HasCurrentEditor(); });
158}
159
165
167 // UI Layout
169 .Item(
170 "Show Sidebar", ICON_MD_VIEW_SIDEBAR,
171 [this]() {
172 if (panel_manager_)
174 },
175 nullptr, nullptr,
176 [this]() {
178 })
179 .Item(
180 "Show Status Bar", ICON_MD_HORIZONTAL_RULE,
181 [this]() {
182 if (user_settings_) {
186 if (status_bar_) {
189 }
190 }
191 },
192 nullptr, nullptr,
193 [this]() {
195 })
196 .Separator();
197
198 // Settings and UI
200 .Item("Display Settings", ICON_MD_DISPLAY_SETTINGS,
201 [this]() { OnShowDisplaySettings(); })
202 .Item("Welcome Screen", ICON_MD_HOME, [this]() { OnShowWelcomeScreen(); })
203 .Separator();
204
205 // Panel Browser
207 .Item(
208 "Panel Browser", ICON_MD_DASHBOARD,
209 [this]() { OnShowPanelBrowser(); }, SHORTCUT_CTRL_SHIFT(B),
210 [this]() { return HasActiveRom(); })
211 .Separator();
212
213 // Editor Selection (Switch Editor)
215 .Item(
216 "Switch Editor...", ICON_MD_SWAP_HORIZ,
217 [this]() { OnShowEditorSelection(); }, SHORTCUT_CTRL(E),
218 [this]() { return HasActiveRom(); })
219 .Separator();
220
221 // Dynamically added panels
223}
224
226 if (!panel_manager_) {
227 return;
228 }
229
230 const size_t session_id = session_coordinator_.GetActiveSessionIndex();
231
232 // Get active category
233 std::string active_category = panel_manager_->GetActiveCategory();
234
235 // Get all categories from registry
236 auto all_categories = panel_manager_->GetAllCategories(session_id);
237 if (all_categories.empty()) {
238 return;
239 }
240
241 if (ImGui::BeginMenu(
242 absl::StrFormat("%s Panels", ICON_MD_DASHBOARD).c_str())) {
243
244 // 1. Active Category (Prominent)
245 if (!active_category.empty()) {
246 auto cards =
247 panel_manager_->GetPanelsInCategory(session_id, active_category);
248 if (!cards.empty()) {
249 ImGui::TextDisabled("%s", active_category.c_str());
250 for (const auto& card : cards) {
251 bool is_visible =
252 panel_manager_->IsPanelVisible(session_id, card.card_id);
253 const char* shortcut =
254 card.shortcut_hint.empty() ? nullptr : card.shortcut_hint.c_str();
255 if (ImGui::MenuItem(card.display_name.c_str(), shortcut,
256 &is_visible)) {
257 panel_manager_->TogglePanel(session_id, card.card_id);
258 }
259 }
260 ImGui::Separator();
261 }
262 }
263
264 // 2. Other Categories
265 if (ImGui::BeginMenu("All Categories")) {
266 for (const auto& category : all_categories) {
267 // Skip active category if it was already shown above?
268 // Actually, keeping it here too is fine for completeness, or we can filter.
269 // Let's keep it simple and just list all.
270
271 if (ImGui::BeginMenu(category.c_str())) {
272 auto cards =
273 panel_manager_->GetPanelsInCategory(session_id, category);
274 for (const auto& card : cards) {
275 bool is_visible =
276 panel_manager_->IsPanelVisible(session_id, card.card_id);
277 const char* shortcut = card.shortcut_hint.empty()
278 ? nullptr
279 : card.shortcut_hint.c_str();
280 if (ImGui::MenuItem(card.display_name.c_str(), shortcut,
281 &is_visible)) {
282 panel_manager_->TogglePanel(session_id, card.card_id);
283 }
284 }
285 ImGui::EndMenu();
286 }
287 }
288 ImGui::EndMenu();
289 }
290
291 ImGui::EndMenu();
292 }
293}
294
300
302 // Search & Navigation
304 .Item(
305 "Global Search", ICON_MD_SEARCH, [this]() { OnShowGlobalSearch(); },
307 .Item(
308 "Command Palette", ICON_MD_SEARCH,
309 [this]() { OnShowCommandPalette(); }, SHORTCUT_CTRL_SHIFT(P))
310 .Item("Resource Label Manager", ICON_MD_LABEL,
311 [this]() { OnShowResourceLabelManager(); })
312 .Separator();
313
314 // ROM Analysis (moved from Debug menu)
316 .Item(
317 "ROM Information", ICON_MD_INFO, [this]() { OnShowRomInfo(); },
318 nullptr, [this]() { return HasActiveRom(); })
319 .Item(
320 "Data Integrity Check", ICON_MD_ANALYTICS,
321 [this]() { OnRunDataIntegrityCheck(); }, nullptr,
322 [this]() { return HasActiveRom(); })
323 .Item(
324 "Test Save/Load", ICON_MD_SAVE_ALT, [this]() { OnTestSaveLoad(); },
325 nullptr, [this]() { return HasActiveRom(); })
326 .EndMenu();
327
328 // ZSCustomOverworld (moved from Debug menu)
329 menu_builder_.BeginSubMenu("ZSCustomOverworld", ICON_MD_CODE)
330 .Item(
331 "Check ROM Version", ICON_MD_INFO, [this]() { OnCheckRomVersion(); },
332 nullptr, [this]() { return HasActiveRom(); })
333 .Item(
334 "Upgrade ROM", ICON_MD_UPGRADE, [this]() { OnUpgradeRom(); }, nullptr,
335 [this]() { return HasActiveRom(); })
336 .Item("Toggle Custom Loading", ICON_MD_SETTINGS,
337 [this]() { OnToggleCustomLoading(); })
338 .EndMenu();
339
340 // Asar Integration (moved from Debug menu)
341 menu_builder_.BeginSubMenu("Asar Integration", ICON_MD_BUILD)
342 .Item("Asar Status", ICON_MD_INFO,
344 .Item(
345 "Toggle ASM Patch", ICON_MD_CODE, [this]() { OnToggleAsarPatch(); },
346 nullptr, [this]() { return HasActiveRom(); })
347 .Item("Load ASM File", ICON_MD_FOLDER_OPEN, [this]() { OnLoadAsmFile(); })
348 .EndMenu()
349 .Separator();
350
351 // Development Tools (moved from Debug menu)
353 .Item("Memory Editor", ICON_MD_MEMORY, [this]() { OnShowMemoryEditor(); })
354 .Item("Assembly Editor", ICON_MD_CODE,
355 [this]() { OnShowAssemblyEditor(); })
356 .Item("Feature Flags", ICON_MD_FLAG,
358 .Item("Performance Dashboard", ICON_MD_SPEED,
359 [this]() { OnShowPerformanceDashboard(); })
360#ifdef YAZE_WITH_GRPC
361 .Item("Agent Proposals", ICON_MD_PREVIEW,
362 [this]() { OnShowProposalDrawer(); })
363#endif
364 .EndMenu();
365
366 // Testing (moved from Debug menu)
367#ifdef YAZE_ENABLE_TESTING
369 .Item(
370 "Test Dashboard", ICON_MD_DASHBOARD,
371 [this]() { OnShowTestDashboard(); }, SHORTCUT_CTRL(T))
372 .Item("Run All Tests", ICON_MD_PLAY_ARROW, [this]() { OnRunAllTests(); })
373 .Item("Run Unit Tests", ICON_MD_CHECK_BOX, [this]() { OnRunUnitTests(); })
374 .Item("Run Integration Tests", ICON_MD_INTEGRATION_INSTRUCTIONS,
375 [this]() { OnRunIntegrationTests(); })
376 .Item("Run E2E Tests", ICON_MD_VISIBILITY, [this]() { OnRunE2ETests(); })
377 .EndMenu();
378#endif
379
380 // ImGui Debug (moved from Debug menu)
382 .Item("ImGui Demo", ICON_MD_HELP, [this]() { OnShowImGuiDemo(); })
383 .Item("ImGui Metrics", ICON_MD_ANALYTICS,
384 [this]() { OnShowImGuiMetrics(); })
385 .EndMenu()
386 .Separator();
387
388 // Collaboration (GRPC builds only)
389#ifdef YAZE_WITH_GRPC
391 .Item("Start Collaboration Session", ICON_MD_PLAY_CIRCLE,
392 [this]() { OnStartCollaboration(); })
393 .Item("Join Collaboration Session", ICON_MD_GROUP_ADD,
394 [this]() { OnJoinCollaboration(); })
395 .Item("Network Status", ICON_MD_CLOUD,
396 [this]() { OnShowNetworkStatus(); })
397 .EndMenu();
398#endif
399}
400
406
408 // Sessions Submenu
410 .Item(
411 "New Session", ICON_MD_ADD, [this]() { OnCreateNewSession(); },
413 .Item(
414 "Duplicate Session", ICON_MD_CONTENT_COPY,
415 [this]() { OnDuplicateCurrentSession(); }, nullptr,
416 [this]() { return HasActiveRom(); })
417 .Item(
418 "Close Session", ICON_MD_CLOSE, [this]() { OnCloseCurrentSession(); },
419 SHORTCUT_CTRL_SHIFT(W), [this]() { return HasMultipleSessions(); })
420 .Separator()
421 .Item(
422 "Session Switcher", ICON_MD_SWITCH_ACCOUNT,
423 [this]() { OnShowSessionSwitcher(); }, SHORTCUT_CTRL(Tab),
424 [this]() { return HasMultipleSessions(); })
425 .Item("Session Manager", ICON_MD_VIEW_LIST,
426 [this]() { OnShowSessionManager(); })
427 .EndMenu()
428 .Separator();
429
430 // Layout Management
431 const auto layout_actions_enabled = [this]() {
432 return HasCurrentEditor();
433 };
434 const auto apply_preset = [this](const char* preset_name) {
435 if (editor_manager_) {
437 }
438 };
439 const auto reset_editor_layout = [this]() {
440 if (editor_manager_) {
442 }
443 };
444
446 .Item(
447 "Save Layout", ICON_MD_SAVE, [this]() { OnSaveWorkspaceLayout(); },
449 .Item(
450 "Load Layout", ICON_MD_FOLDER_OPEN,
451 [this]() { OnLoadWorkspaceLayout(); }, SHORTCUT_CTRL_SHIFT(O))
452 .Item("Reset Layout", ICON_MD_RESET_TV,
453 [this]() { OnResetWorkspaceLayout(); })
454 .BeginSubMenu("Layout Presets", ICON_MD_VIEW_QUILT)
455 .Item(
456 "Reset Active Editor Layout", ICON_MD_REFRESH,
457 [reset_editor_layout]() { reset_editor_layout(); }, nullptr,
458 layout_actions_enabled)
459 .Separator()
460 .Item(
461 "Minimal", ICON_MD_VIEW_COMPACT,
462 [apply_preset]() { apply_preset("Minimal"); }, nullptr,
463 layout_actions_enabled)
464 .Item(
465 "Developer", ICON_MD_DEVELOPER_MODE,
466 [apply_preset]() { apply_preset("Developer"); }, nullptr,
467 layout_actions_enabled)
468 .Item(
469 "Designer", ICON_MD_DESIGN_SERVICES,
470 [apply_preset]() { apply_preset("Designer"); }, nullptr,
471 layout_actions_enabled)
472 .Item(
473 "Modder", ICON_MD_BUILD, [apply_preset]() { apply_preset("Modder"); },
474 nullptr, layout_actions_enabled)
475 .Item(
476 "Overworld Expert", ICON_MD_MAP,
477 [apply_preset]() { apply_preset("Overworld Expert"); }, nullptr,
478 layout_actions_enabled)
479 .Item(
480 "Dungeon Expert", ICON_MD_CASTLE,
481 [apply_preset]() { apply_preset("Dungeon Expert"); }, nullptr,
482 layout_actions_enabled)
483 .Item(
484 "Testing", ICON_MD_SCIENCE,
485 [apply_preset]() { apply_preset("Testing"); }, nullptr,
486 layout_actions_enabled)
487 .Item(
488 "Audio", ICON_MD_MUSIC_NOTE,
489 [apply_preset]() { apply_preset("Audio"); }, nullptr,
490 layout_actions_enabled)
491 .Separator()
492 .Item("Manage Presets...", ICON_MD_TUNE,
493 [this]() { OnShowLayoutPresets(); })
494 .EndMenu()
495 .Separator();
496
497 // Window Visibility
499 .Item("Show All Windows", ICON_MD_VISIBILITY,
500 [this]() { OnShowAllWindows(); })
501 .Item("Hide All Windows", ICON_MD_VISIBILITY_OFF,
502 [this]() { OnHideAllWindows(); })
503 .Separator();
504
505 // Panel Browser (requires ROM) - Panels are accessible via the sidebar
507 .Item(
508 "Panel Browser", ICON_MD_DASHBOARD,
509 [this]() { OnShowPanelBrowser(); }, SHORTCUT_CTRL_SHIFT(B),
510 [this]() { return HasActiveRom(); })
511 .Separator();
512
513 // Note: Panel toggle buttons are on the right side of the menu bar
514}
515
521
523 // Note: Asar Integration moved to Tools menu to reduce redundancy
525 .Item("Getting Started", ICON_MD_PLAY_ARROW,
526 [this]() { OnShowGettingStarted(); })
527 .Item("Keyboard Shortcuts", ICON_MD_KEYBOARD,
528 [this]() { OnShowSettings(); })
529 .Item("Build Instructions", ICON_MD_BUILD,
530 [this]() { OnShowBuildInstructions(); })
531 .Item("CLI Usage", ICON_MD_TERMINAL, [this]() { OnShowCLIUsage(); })
532 .Separator()
533 .Item("Supported Features", ICON_MD_CHECK_CIRCLE,
534 [this]() { OnShowSupportedFeatures(); })
535 .Item("What's New", ICON_MD_NEW_RELEASES, [this]() { OnShowWhatsNew(); })
536 .Separator()
537 .Item("Troubleshooting", ICON_MD_BUILD_CIRCLE,
538 [this]() { OnShowTroubleshooting(); })
539 .Item("Contributing", ICON_MD_VOLUNTEER_ACTIVISM,
540 [this]() { OnShowContributing(); })
541 .Separator()
542 .Item(
543 "About", ICON_MD_INFO, [this]() { OnShowAbout(); }, "F1");
544}
545
546// Menu state management
550
554
555// Menu item callbacks - delegate to appropriate managers
557 // Delegate to EditorManager's LoadRom which handles session management
558 if (editor_manager_) {
559 auto status = editor_manager_->LoadRom();
560 if (!status.ok()) {
562 absl::StrFormat("Failed to load ROM: %s", status.message()),
564 }
565 }
566}
567
569 // Delegate to EditorManager's SaveRom which handles editor data saving
570 if (editor_manager_) {
571 auto status = editor_manager_->SaveRom();
572 if (!status.ok()) {
574 absl::StrFormat("Failed to save ROM: %s", status.message()),
576 } else {
577 toast_manager_.Show("ROM saved successfully", ToastType::kSuccess);
578 }
579 }
580}
581
585
587 // Delegate to EditorManager which handles the full project creation flow
588 if (editor_manager_) {
589 auto status = editor_manager_->CreateNewProject();
590 if (!status.ok()) {
592 absl::StrFormat("Failed to create project: %s", status.message()),
594 }
595 }
596}
597
599 // Delegate to EditorManager which handles ROM loading and session creation
600 if (editor_manager_) {
601 auto status = editor_manager_->OpenProject();
602 if (!status.ok()) {
604 absl::StrFormat("Failed to open project: %s", status.message()),
606 }
607 }
608}
609
611 // Delegate to EditorManager which updates project with current state
612 if (editor_manager_) {
613 auto status = editor_manager_->SaveProject();
614 if (!status.ok()) {
616 absl::StrFormat("Failed to save project: %s", status.message()),
618 } else {
619 toast_manager_.Show("Project saved successfully", ToastType::kSuccess);
620 }
621 }
622}
623
625 // Delegate to EditorManager
626 if (editor_manager_) {
627 auto status = editor_manager_->SaveProjectAs();
628 if (!status.ok()) {
630 absl::StrFormat("Failed to save project as: %s", status.message()),
632 }
633 }
634}
635
637 // Show project management panel in right sidebar
638 if (editor_manager_) {
640 }
641}
642
644 // Open the project file editor with the current project file
645 if (editor_manager_) {
647 }
648}
649
650// Edit menu actions - delegate to current editor
652 if (editor_manager_) {
653 auto* current_editor = editor_manager_->GetCurrentEditor();
654 if (current_editor) {
655 auto status = current_editor->Undo();
656 if (!status.ok()) {
658 absl::StrFormat("Undo failed: %s", status.message()),
660 }
661 }
662 }
663}
664
666 if (editor_manager_) {
667 auto* current_editor = editor_manager_->GetCurrentEditor();
668 if (current_editor) {
669 auto status = current_editor->Redo();
670 if (!status.ok()) {
672 absl::StrFormat("Redo failed: %s", status.message()),
674 }
675 }
676 }
677}
678
680 if (editor_manager_) {
681 auto* current_editor = editor_manager_->GetCurrentEditor();
682 if (current_editor) {
683 auto status = current_editor->Cut();
684 if (!status.ok()) {
685 toast_manager_.Show(absl::StrFormat("Cut failed: %s", status.message()),
687 }
688 }
689 }
690}
691
693 if (editor_manager_) {
694 auto* current_editor = editor_manager_->GetCurrentEditor();
695 if (current_editor) {
696 auto status = current_editor->Copy();
697 if (!status.ok()) {
699 absl::StrFormat("Copy failed: %s", status.message()),
701 }
702 }
703 }
704}
705
707 if (editor_manager_) {
708 auto* current_editor = editor_manager_->GetCurrentEditor();
709 if (current_editor) {
710 auto status = current_editor->Paste();
711 if (!status.ok()) {
713 absl::StrFormat("Paste failed: %s", status.message()),
715 }
716 }
717 }
718}
719
721 if (editor_manager_) {
722 auto* current_editor = editor_manager_->GetCurrentEditor();
723 if (current_editor) {
724 auto status = current_editor->Find();
725 if (!status.ok()) {
727 absl::StrFormat("Find failed: %s", status.message()),
729 }
730 }
731 }
732}
733
734// Editor-specific menu actions
736 // Delegate to EditorManager which manages editor switching
737 if (editor_manager_) {
738 editor_manager_->SwitchToEditor(editor_type);
739 }
740}
741
743 // Delegate to UICoordinator for editor selection dialog display
744 if (editor_manager_) {
745 if (auto* ui = editor_manager_->ui_coordinator()) {
746 ui->ShowEditorSelection();
747 }
748 }
749}
750
754
756 // Show hex editor card via EditorPanelManager
757 if (editor_manager_) {
759 editor_manager_->GetCurrentSessionId(), "Hex Editor");
760 }
761}
762
764 if (editor_manager_) {
765 if (auto* ui = editor_manager_->ui_coordinator()) {
766 ui->SetEmulatorVisible(true);
767 }
768 }
769}
770
772 if (editor_manager_) {
773 if (auto* ui = editor_manager_->ui_coordinator()) {
774 ui->SetPanelBrowserVisible(true);
775 }
776 }
777}
778
780 if (editor_manager_) {
781 if (auto* ui = editor_manager_->ui_coordinator()) {
782 ui->SetWelcomeScreenVisible(true);
783 }
784 }
785}
786
787#ifdef YAZE_BUILD_AGENT_UI
788void MenuOrchestrator::OnShowAIAgent() {
789 if (editor_manager_) {
790 if (auto* ui = editor_manager_->ui_coordinator()) {
791 ui->SetAIAgentVisible(true);
792 }
793 }
794}
795
796void MenuOrchestrator::OnShowChatHistory() {
797 if (editor_manager_) {
798 if (auto* ui = editor_manager_->ui_coordinator()) {
799 ui->SetChatHistoryVisible(true);
800 }
801 }
802}
803
804void MenuOrchestrator::OnShowProposalDrawer() {
805 if (editor_manager_) {
806 if (auto* ui = editor_manager_->ui_coordinator()) {
807 ui->SetProposalDrawerVisible(true);
808 }
809 }
810}
811#endif
812
813// Session management menu actions
817
821
825
826void MenuOrchestrator::OnSwitchToSession(size_t session_index) {
828}
829
831 // Delegate to UICoordinator for session switcher UI
832 if (editor_manager_) {
833 if (auto* ui = editor_manager_->ui_coordinator()) {
834 ui->ShowSessionSwitcher();
835 }
836 }
837}
838
842
843// Window management menu actions
845 // Delegate to EditorManager
846 if (editor_manager_) {
847 if (auto* ui = editor_manager_->ui_coordinator()) {
848 ui->ShowAllWindows();
849 }
850 }
851}
852
854 // Delegate to EditorManager
855 if (editor_manager_) {
857 }
858}
859
861 // Queue as deferred action to avoid modifying ImGui state during menu rendering
862 if (editor_manager_) {
865 toast_manager_.Show("Layout reset to default", ToastType::kInfo);
866 });
867 }
868}
869
871 // Delegate to EditorManager
872 if (editor_manager_) {
874 }
875}
876
878 // Delegate to EditorManager
879 if (editor_manager_) {
881 }
882}
883
887
893
899
905
906// Tool menu actions
908 if (editor_manager_) {
909 if (auto* ui = editor_manager_->ui_coordinator()) {
910 ui->ShowGlobalSearch();
911 }
912 }
913}
914
916 if (editor_manager_) {
917 if (auto* ui = editor_manager_->ui_coordinator()) {
918 ui->ShowCommandPalette();
919 }
920 }
921}
922
924 if (editor_manager_) {
925 if (auto* ui = editor_manager_->ui_coordinator()) {
926 ui->SetPerformanceDashboardVisible(true);
927 }
928 }
929}
930
936
942
949
951 if (editor_manager_) {
952 if (auto* ui = editor_manager_->ui_coordinator()) {
953 ui->SetResourceLabelManagerVisible(true);
954 }
955 }
956}
957
958#ifdef YAZE_ENABLE_TESTING
959void MenuOrchestrator::OnShowTestDashboard() {
960 if (editor_manager_) {
961 editor_manager_->ShowTestDashboard();
962 }
963}
964
965void MenuOrchestrator::OnRunAllTests() {
966 toast_manager_.Show("Running all tests...", ToastType::kInfo);
967 // TODO: Implement test runner integration
968}
969
970void MenuOrchestrator::OnRunUnitTests() {
971 toast_manager_.Show("Running unit tests...", ToastType::kInfo);
972 // TODO: Implement unit test runner
973}
974
975void MenuOrchestrator::OnRunIntegrationTests() {
976 toast_manager_.Show("Running integration tests...", ToastType::kInfo);
977 // TODO: Implement integration test runner
978}
979
980void MenuOrchestrator::OnRunE2ETests() {
981 toast_manager_.Show("Running E2E tests...", ToastType::kInfo);
982 // TODO: Implement E2E test runner
983}
984#endif
985
986#ifdef YAZE_WITH_GRPC
987void MenuOrchestrator::OnStartCollaboration() {
988 toast_manager_.Show("Starting collaboration session...", ToastType::kInfo);
989 // TODO: Implement collaboration session start
990}
991
992void MenuOrchestrator::OnJoinCollaboration() {
993 toast_manager_.Show("Joining collaboration session...", ToastType::kInfo);
994 // TODO: Implement collaboration session join
995}
996
997void MenuOrchestrator::OnShowNetworkStatus() {
998 toast_manager_.Show("Network Status", ToastType::kInfo);
999 // TODO: Show network status dialog
1000}
1001#endif
1002
1003// Help menu actions
1007
1011
1015
1019
1023
1027
1031
1035
1039
1040// Additional File menu actions
1044
1046 if (editor_manager_) {
1047 // Create backup via ROM directly (from original implementation)
1048 auto* rom = editor_manager_->GetCurrentRom();
1049 if (rom && rom->is_loaded()) {
1050 Rom::SaveSettings settings;
1051 settings.backup = true;
1052 settings.filename = rom->filename();
1053 auto status = rom->SaveToFile(settings);
1054 if (status.ok()) {
1055 toast_manager_.Show("Backup created successfully", ToastType::kSuccess);
1056 } else {
1058 absl::StrFormat("Backup failed: %s", status.message()),
1060 }
1061 }
1062 }
1063}
1064
1066 if (editor_manager_) {
1068 if (status.ok()) {
1069 toast_manager_.Show("ROM validation passed", ToastType::kSuccess);
1070 } else {
1072 absl::StrFormat("ROM validation failed: %s", status.message()),
1074 }
1075 }
1076}
1077
1079 // Activate settings editor
1080 if (editor_manager_) {
1082 }
1083}
1084
1086 if (editor_manager_) {
1088 }
1089}
1090
1091// Menu item validation helpers
1093 auto* rom = editor_manager_->GetCurrentRom();
1094 return rom ? rom_manager_.IsRomLoaded(rom) : false;
1095}
1096
1100
1102 auto* rom = editor_manager_->GetCurrentRom();
1103 return rom ? rom_manager_.IsRomLoaded(rom) : false;
1104}
1105
1109
1111 // Check if EditorManager has a project with a valid filepath
1112 // This is separate from HasActiveProject which checks ProjectManager
1113 const auto* project =
1115 return project && !project->filepath.empty();
1116}
1117
1121
1125
1126// Menu item text generation
1128 auto* rom = editor_manager_->GetCurrentRom();
1129 return rom ? rom_manager_.GetRomFilename(rom) : "";
1130}
1131
1134}
1135
1137 // TODO: Get current editor name
1138 return "Unknown Editor";
1139}
1140
1141// Shortcut key management
1143 const std::string& action) const {
1144 // TODO: Implement shortcut mapping
1145 return "";
1146}
1147
1149 // TODO: Register global keyboard shortcuts
1150}
1151
1152// ============================================================================
1153// Debug Menu Actions
1154// ============================================================================
1155
1157#ifdef YAZE_ENABLE_TESTING
1158 if (!editor_manager_)
1159 return;
1160 auto* rom = editor_manager_->GetCurrentRom();
1161 if (!rom || !rom->is_loaded())
1162 return;
1163
1164 toast_manager_.Show("Running ROM integrity tests...", ToastType::kInfo);
1165 // This would integrate with the test system in master
1166 // For now, just show a placeholder
1167 toast_manager_.Show("Data integrity check completed", ToastType::kSuccess,
1168 3.0f);
1169#else
1170 toast_manager_.Show("Testing not enabled in this build", ToastType::kWarning);
1171#endif
1172}
1173
1175#ifdef YAZE_ENABLE_TESTING
1176 if (!editor_manager_)
1177 return;
1178 auto* rom = editor_manager_->GetCurrentRom();
1179 if (!rom || !rom->is_loaded())
1180 return;
1181
1182 toast_manager_.Show("Running ROM save/load tests...", ToastType::kInfo);
1183 // This would integrate with the test system in master
1184 toast_manager_.Show("Save/load test completed", ToastType::kSuccess, 3.0f);
1185#else
1186 toast_manager_.Show("Testing not enabled in this build", ToastType::kWarning);
1187#endif
1188}
1189
1191 if (!editor_manager_)
1192 return;
1193 auto* rom = editor_manager_->GetCurrentRom();
1194 if (!rom || !rom->is_loaded())
1195 return;
1196
1197 // Check ZSCustomOverworld version
1198 uint8_t version = (*rom)[zelda3::OverworldCustomASMHasBeenApplied];
1199 std::string version_str =
1200 (version == 0xFF) ? "Vanilla" : absl::StrFormat("v%d", version);
1201
1203 absl::StrFormat("ROM: %s | ZSCustomOverworld: %s", rom->title().c_str(),
1204 version_str.c_str()),
1205 ToastType::kInfo, 5.0f);
1206}
1207
1209 if (!editor_manager_)
1210 return;
1211 auto* rom = editor_manager_->GetCurrentRom();
1212 if (!rom || !rom->is_loaded())
1213 return;
1214
1215 toast_manager_.Show("Use Overworld Editor to upgrade ROM version",
1216 ToastType::kInfo, 4.0f);
1217}
1218
1220 auto& flags = core::FeatureFlags::get();
1221 flags.overworld.kLoadCustomOverworld = !flags.overworld.kLoadCustomOverworld;
1222
1224 absl::StrFormat(
1225 "Custom Overworld Loading: %s",
1226 flags.overworld.kLoadCustomOverworld ? "Enabled" : "Disabled"),
1228}
1229
1231 if (!editor_manager_)
1232 return;
1233 auto* rom = editor_manager_->GetCurrentRom();
1234 if (!rom || !rom->is_loaded())
1235 return;
1236
1237 auto& flags = core::FeatureFlags::get();
1238 flags.overworld.kApplyZSCustomOverworldASM =
1239 !flags.overworld.kApplyZSCustomOverworldASM;
1240
1242 absl::StrFormat(
1243 "ZSCustomOverworld ASM Application: %s",
1244 flags.overworld.kApplyZSCustomOverworldASM ? "Enabled" : "Disabled"),
1246}
1247
1249 toast_manager_.Show("ASM file loading not yet implemented",
1251}
1252
1258
1259} // namespace editor
1260} // namespace yaze
static Flags & get()
Definition features.h:92
The EditorManager controls the main editor window and manages the various editor classes.
UICoordinator * ui_coordinator()
void ShowProjectManagement()
Injects dependencies into all editors within an EditorSet.
absl::Status CreateNewProject(const std::string &template_name="Basic ROM Hack")
void ApplyLayoutPreset(const std::string &preset_name)
auto GetCurrentEditor() const -> Editor *
absl::Status LoadRom()
Load a ROM file into a new or existing session.
project::YazeProject * GetCurrentProject()
void QueueDeferredAction(std::function< void()> action)
void SwitchToEditor(EditorType editor_type, bool force_visible=false, bool from_dialog=false)
auto GetCurrentRom() const -> Rom *
absl::Status SaveRom()
Save the current ROM file.
Manages editor types, categories, and lifecycle.
Fluent interface for building ImGui menus with icons.
MenuBuilder & Item(const char *label, const char *icon, Callback callback, const char *shortcut=nullptr, EnabledCheck enabled=nullptr, EnabledCheck checked=nullptr)
Add a menu item.
void Draw()
Draw the menu bar (call in main menu bar)
void Clear()
Clear all menus.
MenuBuilder & BeginMenu(const char *label, const char *icon=nullptr)
Begin a top-level menu.
MenuBuilder & Separator()
Add a separator.
MenuBuilder & EndMenu()
End the current menu/submenu.
MenuBuilder & BeginSubMenu(const char *label, const char *icon=nullptr, EnabledCheck enabled=nullptr)
Begin a submenu.
void OnSwitchToSession(size_t session_index)
void OnSwitchToEditor(EditorType editor_type)
SessionCoordinator & session_coordinator_
MenuOrchestrator(EditorManager *editor_manager, MenuBuilder &menu_builder, RomFileManager &rom_manager, ProjectManager &project_manager, EditorRegistry &editor_registry, SessionCoordinator &session_coordinator, ToastManager &toast_manager, PopupManager &popup_manager)
std::string GetShortcutForAction(const std::string &action) const
std::vector< std::string > GetAllCategories(size_t session_id) const
bool TogglePanel(size_t session_id, const std::string &base_card_id)
std::vector< PanelDescriptor > GetPanelsInCategory(size_t session_id, const std::string &category) const
bool ShowPanel(size_t session_id, const std::string &base_card_id)
std::string GetActiveCategory() const
bool IsPanelVisible(size_t session_id, const std::string &base_card_id) const
void Show(const char *name)
Handles all project file operations with ROM-first workflow.
std::string GetProjectName() const
Handles all ROM file I/O operations.
absl::Status ValidateRom(Rom *rom)
std::string GetRomFilename(Rom *rom) const
bool IsRomLoaded(Rom *rom) const
High-level orchestrator for multi-session UI.
void SetEnabled(bool enabled)
Enable or disable the status bar.
Definition status_bar.h:52
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f)
#define ICON_MD_DEVELOPER_MODE
Definition icons.h:549
#define ICON_MD_FOLDER_OPEN
Definition icons.h:813
#define ICON_MD_CONTENT_CUT
Definition icons.h:466
#define ICON_MD_SAVE_ALT
Definition icons.h:1645
#define ICON_MD_VOLUNTEER_ACTIVISM
Definition icons.h:2112
#define ICON_MD_SETTINGS
Definition icons.h:1699
#define ICON_MD_FILE_OPEN
Definition icons.h:747
#define ICON_MD_CHECK_BOX
Definition icons.h:398
#define ICON_MD_EXIT_TO_APP
Definition icons.h:699
#define ICON_MD_VIEW_QUILT
Definition icons.h:2094
#define ICON_MD_INFO
Definition icons.h:993
#define ICON_MD_MEMORY
Definition icons.h:1195
#define ICON_MD_STORAGE
Definition icons.h:1865
#define ICON_MD_UPGRADE
Definition icons.h:2047
#define ICON_MD_FOLDER_SPECIAL
Definition icons.h:815
#define ICON_MD_VIEW_LIST
Definition icons.h:2092
#define ICON_MD_SEARCH
Definition icons.h:1673
#define ICON_MD_NEW_RELEASES
Definition icons.h:1291
#define ICON_MD_PLAY_ARROW
Definition icons.h:1479
#define ICON_MD_SWAP_HORIZ
Definition icons.h:1896
#define ICON_MD_SAVE_AS
Definition icons.h:1646
#define ICON_MD_DESIGN_SERVICES
Definition icons.h:541
#define ICON_MD_INTEGRATION_INSTRUCTIONS
Definition icons.h:1008
#define ICON_MD_RESET_TV
Definition icons.h:1601
#define ICON_MD_TUNE
Definition icons.h:2022
#define ICON_MD_REFRESH
Definition icons.h:1572
#define ICON_MD_MAP
Definition icons.h:1173
#define ICON_MD_CODE
Definition icons.h:434
#define ICON_MD_LABEL
Definition icons.h:1053
#define ICON_MD_REDO
Definition icons.h:1570
#define ICON_MD_SWITCH_ACCOUNT
Definition icons.h:1913
#define ICON_MD_VISIBILITY
Definition icons.h:2101
#define ICON_MD_BUG_REPORT
Definition icons.h:327
#define ICON_MD_SPEED
Definition icons.h:1817
#define ICON_MD_CASTLE
Definition icons.h:380
#define ICON_MD_BUILD_CIRCLE
Definition icons.h:329
#define ICON_MD_MUSIC_NOTE
Definition icons.h:1264
#define ICON_MD_CONTENT_PASTE
Definition icons.h:467
#define ICON_MD_HOME
Definition icons.h:953
#define ICON_MD_VISIBILITY_OFF
Definition icons.h:2102
#define ICON_MD_DISPLAY_SETTINGS
Definition icons.h:587
#define ICON_MD_VIEW_COMPACT
Definition icons.h:2085
#define ICON_MD_ADD
Definition icons.h:86
#define ICON_MD_KEYBOARD
Definition icons.h:1028
#define ICON_MD_SCIENCE
Definition icons.h:1656
#define ICON_MD_PLAY_CIRCLE
Definition icons.h:1480
#define ICON_MD_CHECK_CIRCLE
Definition icons.h:400
#define ICON_MD_TERMINAL
Definition icons.h:1951
#define ICON_MD_PREVIEW
Definition icons.h:1512
#define ICON_MD_FLAG
Definition icons.h:784
#define ICON_MD_DESCRIPTION
Definition icons.h:539
#define ICON_MD_BUILD
Definition icons.h:328
#define ICON_MD_HORIZONTAL_RULE
Definition icons.h:960
#define ICON_MD_CREATE_NEW_FOLDER
Definition icons.h:483
#define ICON_MD_DASHBOARD
Definition icons.h:517
#define ICON_MD_SAVE
Definition icons.h:1644
#define ICON_MD_TAB
Definition icons.h:1930
#define ICON_MD_PEOPLE
Definition icons.h:1401
#define ICON_MD_BACKUP
Definition icons.h:231
#define ICON_MD_CONTENT_COPY
Definition icons.h:465
#define ICON_MD_CLOUD
Definition icons.h:423
#define ICON_MD_CLOSE
Definition icons.h:418
#define ICON_MD_ANALYTICS
Definition icons.h:154
#define ICON_MD_HELP
Definition icons.h:933
#define ICON_MD_VIEW_SIDEBAR
Definition icons.h:2095
#define ICON_MD_UNDO
Definition icons.h:2039
#define ICON_MD_GROUP_ADD
Definition icons.h:899
#define SHORTCUT_CTRL_SHIFT(key)
#define SHORTCUT_CTRL(key)
constexpr const char * kRomInfo
constexpr const char * kLayoutPresets
constexpr const char * kAbout
constexpr const char * kSessionManager
constexpr const char * kTroubleshooting
constexpr const char * kWhatsNew
constexpr const char * kSupportedFeatures
constexpr const char * kSaveAs
constexpr const char * kDisplaySettings
constexpr const char * kCLIUsage
constexpr const char * kAsarIntegration
constexpr const char * kFeatureFlags
constexpr const char * kGettingStarted
constexpr const char * kContributing
constexpr const char * kBuildInstructions
constexpr int OverworldCustomASMHasBeenApplied
Definition common.h:89
std::string filename
Definition rom.h:29