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 "rom/rom.h"
18#include "core/features.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) gui::FormatCtrlShiftShortcut(ImGuiKey_##key).c_str()
24
25namespace yaze {
26namespace editor {
27
29 EditorManager* editor_manager, MenuBuilder& menu_builder,
30 RomFileManager& rom_manager, ProjectManager& project_manager,
31 EditorRegistry& editor_registry, SessionCoordinator& session_coordinator,
32 ToastManager& toast_manager, PopupManager& popup_manager)
33 : editor_manager_(editor_manager),
34 menu_builder_(menu_builder),
35 rom_manager_(rom_manager),
36 project_manager_(project_manager),
37 editor_registry_(editor_registry),
38 session_coordinator_(session_coordinator),
39 toast_manager_(toast_manager),
40 popup_manager_(popup_manager) {}
41
43 ClearMenu();
44
45 // Build all menu sections in order
49 BuildToolsMenu(); // Debug menu items merged into Tools
52
53 // Draw the constructed menu
55
56 menu_needs_refresh_ = false;
57}
58
64
66 // ROM Operations
68 .Item(
69 "Open ROM", ICON_MD_FILE_OPEN, [this]() { OnOpenRom(); }, SHORTCUT_CTRL(O))
70 .Item(
71 "Save ROM", ICON_MD_SAVE, [this]() { OnSaveRom(); }, SHORTCUT_CTRL(S),
72 [this]() { return CanSaveRom(); })
73 .Item(
74 "Save As...", ICON_MD_SAVE_AS, [this]() { OnSaveRomAs(); }, nullptr,
75 [this]() { return CanSaveRom(); })
76 .Separator();
77
78 // Project Operations
80 .Item("New Project", ICON_MD_CREATE_NEW_FOLDER,
81 [this]() { OnCreateProject(); })
82 .Item("Open Project", ICON_MD_FOLDER_OPEN, [this]() { OnOpenProject(); })
83 .Item(
84 "Save Project", ICON_MD_SAVE, [this]() { OnSaveProject(); }, nullptr,
85 [this]() { return CanSaveProject(); })
86 .Item(
87 "Save Project As...", ICON_MD_SAVE_AS,
88 [this]() { OnSaveProjectAs(); }, nullptr,
89 [this]() { return CanSaveProject(); })
90 .Item(
91 "Project Management...", ICON_MD_FOLDER_SPECIAL,
92 [this]() { OnShowProjectManagement(); }, nullptr,
93 [this]() { return CanSaveProject(); })
94 .Item(
95 "Edit Project File...", ICON_MD_DESCRIPTION,
96 [this]() { OnShowProjectFileEditor(); }, nullptr,
97 [this]() { return HasProjectFile(); })
98 .Separator();
99
100 // ROM Information and Validation
102 .Item(
103 "ROM Information", ICON_MD_INFO, [this]() { OnShowRomInfo(); },
104 nullptr, [this]() { return HasActiveRom(); })
105 .Item(
106 "Create Backup", ICON_MD_BACKUP, [this]() { OnCreateBackup(); },
107 nullptr, [this]() { return HasActiveRom(); })
108 .Item(
109 "Validate ROM", ICON_MD_CHECK_CIRCLE, [this]() { OnValidateRom(); },
110 nullptr, [this]() { return HasActiveRom(); })
111 .Separator();
112
113 // Settings and Quit
115 .Item("Settings", ICON_MD_SETTINGS, [this]() { OnShowSettings(); })
116 .Separator()
117 .Item("Quit", ICON_MD_EXIT_TO_APP, [this]() { OnQuit(); }, SHORTCUT_CTRL(Q));
118}
119
125
127 // Undo/Redo operations - delegate to current editor
129 .Item(
130 "Undo", ICON_MD_UNDO, [this]() { OnUndo(); }, SHORTCUT_CTRL(Z),
131 [this]() { return HasCurrentEditor(); })
132 .Item(
133 "Redo", ICON_MD_REDO, [this]() { OnRedo(); }, SHORTCUT_CTRL(Y),
134 [this]() { return HasCurrentEditor(); })
135 .Separator();
136
137 // Clipboard operations - delegate to current editor
139 .Item(
140 "Cut", ICON_MD_CONTENT_CUT, [this]() { OnCut(); }, SHORTCUT_CTRL(X),
141 [this]() { return HasCurrentEditor(); })
142 .Item(
143 "Copy", ICON_MD_CONTENT_COPY, [this]() { OnCopy(); }, SHORTCUT_CTRL(C),
144 [this]() { return HasCurrentEditor(); })
145 .Item(
146 "Paste", ICON_MD_CONTENT_PASTE, [this]() { OnPaste(); }, SHORTCUT_CTRL(V),
147 [this]() { return HasCurrentEditor(); })
148 .Separator();
149
150 // Search operations (Find in Files moved to Tools > Global Search)
152 "Find", ICON_MD_SEARCH, [this]() { OnFind(); }, SHORTCUT_CTRL(F),
153 [this]() { return HasCurrentEditor(); });
154}
155
161
163 // UI Layout
165 .Item("Show Sidebar", ICON_MD_VIEW_SIDEBAR,
167 nullptr, nullptr,
168 [this]() { return panel_manager_ && panel_manager_->IsSidebarVisible(); })
169 .Item("Show Status Bar", ICON_MD_HORIZONTAL_RULE,
170 [this]() {
171 if (user_settings_) {
174 if (status_bar_) {
176 }
177 }
178 },
179 nullptr, nullptr,
180 [this]() { return user_settings_ && user_settings_->prefs().show_status_bar; })
181 .Separator();
182
183 // Settings and UI
185 .Item("Display Settings", ICON_MD_DISPLAY_SETTINGS,
186 [this]() { OnShowDisplaySettings(); })
187 .Item("Welcome Screen", ICON_MD_HOME,
188 [this]() { OnShowWelcomeScreen(); })
189 .Separator();
190
191 // Panel Browser
193 .Item(
194 "Panel Browser", ICON_MD_DASHBOARD, [this]() { OnShowPanelBrowser(); },
195 SHORTCUT_CTRL_SHIFT(B), [this]() { return HasActiveRom(); })
196 .Separator();
197
198 // Editor Selection (Switch Editor)
200 .Item(
201 "Switch Editor...", ICON_MD_SWAP_HORIZ,
202 [this]() { OnShowEditorSelection(); }, SHORTCUT_CTRL(E),
203 [this]() { return HasActiveRom(); })
204 .Separator();
205
206 // Dynamically added panels
208}
209
211 if (!panel_manager_) {
212 return;
213 }
214
215 const size_t session_id = session_coordinator_.GetActiveSessionIndex();
216
217 // Get active category
218 std::string active_category = panel_manager_->GetActiveCategory();
219
220 // Get all categories from registry
221 auto all_categories = panel_manager_->GetAllCategories(session_id);
222 if (all_categories.empty()) {
223 return;
224 }
225
226 if (ImGui::BeginMenu(absl::StrFormat("%s Panels", ICON_MD_DASHBOARD).c_str())) {
227
228 // 1. Active Category (Prominent)
229 if (!active_category.empty()) {
230 auto cards = panel_manager_->GetPanelsInCategory(session_id, active_category);
231 if (!cards.empty()) {
232 ImGui::TextDisabled("%s", active_category.c_str());
233 for (const auto& card : cards) {
234 bool is_visible = panel_manager_->IsPanelVisible(session_id, card.card_id);
235 const char* shortcut = card.shortcut_hint.empty() ? nullptr : card.shortcut_hint.c_str();
236 if (ImGui::MenuItem(card.display_name.c_str(), shortcut, &is_visible)) {
237 panel_manager_->TogglePanel(session_id, card.card_id);
238 }
239 }
240 ImGui::Separator();
241 }
242 }
243
244 // 2. Other Categories
245 if (ImGui::BeginMenu("All Categories")) {
246 for (const auto& category : all_categories) {
247 // Skip active category if it was already shown above?
248 // Actually, keeping it here too is fine for completeness, or we can filter.
249 // Let's keep it simple and just list all.
250
251 if (ImGui::BeginMenu(category.c_str())) {
252 auto cards = panel_manager_->GetPanelsInCategory(session_id, category);
253 for (const auto& card : cards) {
254 bool is_visible = panel_manager_->IsPanelVisible(session_id, card.card_id);
255 const char* shortcut = card.shortcut_hint.empty() ? nullptr : card.shortcut_hint.c_str();
256 if (ImGui::MenuItem(card.display_name.c_str(), shortcut, &is_visible)) {
257 panel_manager_->TogglePanel(session_id, card.card_id);
258 }
259 }
260 ImGui::EndMenu();
261 }
262 }
263 ImGui::EndMenu();
264 }
265
266 ImGui::EndMenu();
267 }
268}
269
270
271
277
279 // Search & Navigation
281 .Item(
282 "Global Search", ICON_MD_SEARCH, [this]() { OnShowGlobalSearch(); },
284 .Item(
285 "Command Palette", ICON_MD_SEARCH,
286 [this]() { OnShowCommandPalette(); }, SHORTCUT_CTRL_SHIFT(P))
287 .Item("Resource Label Manager", ICON_MD_LABEL,
288 [this]() { OnShowResourceLabelManager(); })
289 .Item("Layout Designer", ICON_MD_DASHBOARD,
290 [this]() { OnShowLayoutDesigner(); }, SHORTCUT_CTRL(L))
291 .Separator();
292
293 // ROM Analysis (moved from Debug menu)
295 .Item(
296 "ROM Information", ICON_MD_INFO, [this]() { OnShowRomInfo(); },
297 nullptr, [this]() { return HasActiveRom(); })
298 .Item(
299 "Data Integrity Check", ICON_MD_ANALYTICS,
300 [this]() { OnRunDataIntegrityCheck(); }, nullptr,
301 [this]() { return HasActiveRom(); })
302 .Item(
303 "Test Save/Load", ICON_MD_SAVE_ALT, [this]() { OnTestSaveLoad(); },
304 nullptr, [this]() { return HasActiveRom(); })
305 .EndMenu();
306
307 // ZSCustomOverworld (moved from Debug menu)
308 menu_builder_.BeginSubMenu("ZSCustomOverworld", ICON_MD_CODE)
309 .Item(
310 "Check ROM Version", ICON_MD_INFO, [this]() { OnCheckRomVersion(); },
311 nullptr, [this]() { return HasActiveRom(); })
312 .Item(
313 "Upgrade ROM", ICON_MD_UPGRADE, [this]() { OnUpgradeRom(); }, nullptr,
314 [this]() { return HasActiveRom(); })
315 .Item("Toggle Custom Loading", ICON_MD_SETTINGS,
316 [this]() { OnToggleCustomLoading(); })
317 .EndMenu();
318
319 // Asar Integration (moved from Debug menu)
320 menu_builder_.BeginSubMenu("Asar Integration", ICON_MD_BUILD)
321 .Item("Asar Status", ICON_MD_INFO,
323 .Item(
324 "Toggle ASM Patch", ICON_MD_CODE, [this]() { OnToggleAsarPatch(); },
325 nullptr, [this]() { return HasActiveRom(); })
326 .Item("Load ASM File", ICON_MD_FOLDER_OPEN, [this]() { OnLoadAsmFile(); })
327 .EndMenu()
328 .Separator();
329
330 // Development Tools (moved from Debug menu)
332 .Item("Memory Editor", ICON_MD_MEMORY, [this]() { OnShowMemoryEditor(); })
333 .Item("Assembly Editor", ICON_MD_CODE,
334 [this]() { OnShowAssemblyEditor(); })
335 .Item("Feature Flags", ICON_MD_FLAG,
337 .Item("Performance Dashboard", ICON_MD_SPEED,
338 [this]() { OnShowPerformanceDashboard(); })
339#ifdef YAZE_WITH_GRPC
340 .Item("Agent Proposals", ICON_MD_PREVIEW,
341 [this]() { OnShowProposalDrawer(); })
342#endif
343 .EndMenu();
344
345 // Testing (moved from Debug menu)
346#ifdef YAZE_ENABLE_TESTING
348 .Item(
349 "Test Dashboard", ICON_MD_DASHBOARD,
350 [this]() { OnShowTestDashboard(); }, SHORTCUT_CTRL(T))
351 .Item("Run All Tests", ICON_MD_PLAY_ARROW, [this]() { OnRunAllTests(); })
352 .Item("Run Unit Tests", ICON_MD_CHECK_BOX, [this]() { OnRunUnitTests(); })
353 .Item("Run Integration Tests", ICON_MD_INTEGRATION_INSTRUCTIONS,
354 [this]() { OnRunIntegrationTests(); })
355 .Item("Run E2E Tests", ICON_MD_VISIBILITY, [this]() { OnRunE2ETests(); })
356 .EndMenu();
357#endif
358
359 // ImGui Debug (moved from Debug menu)
361 .Item("ImGui Demo", ICON_MD_HELP, [this]() { OnShowImGuiDemo(); })
362 .Item("ImGui Metrics", ICON_MD_ANALYTICS,
363 [this]() { OnShowImGuiMetrics(); })
364 .EndMenu()
365 .Separator();
366
367 // Collaboration (GRPC builds only)
368#ifdef YAZE_WITH_GRPC
370 .Item("Start Collaboration Session", ICON_MD_PLAY_CIRCLE,
371 [this]() { OnStartCollaboration(); })
372 .Item("Join Collaboration Session", ICON_MD_GROUP_ADD,
373 [this]() { OnJoinCollaboration(); })
374 .Item("Network Status", ICON_MD_CLOUD,
375 [this]() { OnShowNetworkStatus(); })
376 .EndMenu();
377#endif
378}
379
385
387 // Sessions Submenu
389 .Item(
390 "New Session", ICON_MD_ADD, [this]() { OnCreateNewSession(); },
392 .Item(
393 "Duplicate Session", ICON_MD_CONTENT_COPY,
394 [this]() { OnDuplicateCurrentSession(); }, nullptr,
395 [this]() { return HasActiveRom(); })
396 .Item(
397 "Close Session", ICON_MD_CLOSE, [this]() { OnCloseCurrentSession(); },
398 SHORTCUT_CTRL_SHIFT(W), [this]() { return HasMultipleSessions(); })
399 .Separator()
400 .Item(
401 "Session Switcher", ICON_MD_SWITCH_ACCOUNT,
402 [this]() { OnShowSessionSwitcher(); }, SHORTCUT_CTRL(Tab),
403 [this]() { return HasMultipleSessions(); })
404 .Item("Session Manager", ICON_MD_VIEW_LIST,
405 [this]() { OnShowSessionManager(); })
406 .EndMenu()
407 .Separator();
408
409 // Layout Management
410 const auto layout_actions_enabled = [this]() { return HasCurrentEditor(); };
411 const auto apply_preset = [this](const char* preset_name) {
412 if (editor_manager_) {
414 }
415 };
416 const auto reset_editor_layout = [this]() {
417 if (editor_manager_) {
419 }
420 };
421
423 .Item(
424 "Save Layout", ICON_MD_SAVE, [this]() { OnSaveWorkspaceLayout(); },
426 .Item(
427 "Load Layout", ICON_MD_FOLDER_OPEN,
428 [this]() { OnLoadWorkspaceLayout(); }, SHORTCUT_CTRL_SHIFT(O))
429 .Item("Reset Layout", ICON_MD_RESET_TV,
430 [this]() { OnResetWorkspaceLayout(); })
431 .BeginSubMenu("Layout Presets", ICON_MD_VIEW_QUILT)
432 .Item("Reset Active Editor Layout", ICON_MD_REFRESH,
433 [reset_editor_layout]() { reset_editor_layout(); }, nullptr,
434 layout_actions_enabled)
435 .Separator()
436 .Item("Minimal", ICON_MD_VIEW_COMPACT,
437 [apply_preset]() { apply_preset("Minimal"); }, nullptr,
438 layout_actions_enabled)
439 .Item("Developer", ICON_MD_DEVELOPER_MODE,
440 [apply_preset]() { apply_preset("Developer"); }, nullptr,
441 layout_actions_enabled)
442 .Item("Designer", ICON_MD_DESIGN_SERVICES,
443 [apply_preset]() { apply_preset("Designer"); }, nullptr,
444 layout_actions_enabled)
445 .Item("Modder", ICON_MD_BUILD,
446 [apply_preset]() { apply_preset("Modder"); }, nullptr,
447 layout_actions_enabled)
448 .Item("Overworld Expert", ICON_MD_MAP,
449 [apply_preset]() { apply_preset("Overworld Expert"); }, nullptr,
450 layout_actions_enabled)
451 .Item("Dungeon Expert", ICON_MD_CASTLE,
452 [apply_preset]() { apply_preset("Dungeon Expert"); }, nullptr,
453 layout_actions_enabled)
454 .Item("Testing", ICON_MD_SCIENCE,
455 [apply_preset]() { apply_preset("Testing"); }, nullptr,
456 layout_actions_enabled)
457 .Item("Audio", ICON_MD_MUSIC_NOTE,
458 [apply_preset]() { apply_preset("Audio"); }, nullptr,
459 layout_actions_enabled)
460 .Separator()
461 .Item("Manage Presets...", ICON_MD_TUNE,
462 [this]() { OnShowLayoutPresets(); })
463 .EndMenu()
464 .Separator();
465
466 // Window Visibility
468 .Item("Show All Windows", ICON_MD_VISIBILITY,
469 [this]() { OnShowAllWindows(); })
470 .Item("Hide All Windows", ICON_MD_VISIBILITY_OFF,
471 [this]() { OnHideAllWindows(); })
472 .Separator();
473
474 // Panel Browser (requires ROM) - Panels are accessible via the sidebar
476 .Item(
477 "Panel Browser", ICON_MD_DASHBOARD, [this]() { OnShowPanelBrowser(); },
478 SHORTCUT_CTRL_SHIFT(B), [this]() { return HasActiveRom(); })
479 .Separator();
480
481 // Note: Panel toggle buttons are on the right side of the menu bar
482}
483
489
491 // Note: Asar Integration moved to Tools menu to reduce redundancy
493 .Item("Getting Started", ICON_MD_PLAY_ARROW,
494 [this]() { OnShowGettingStarted(); })
495 .Item("Keyboard Shortcuts", ICON_MD_KEYBOARD,
496 [this]() { OnShowSettings(); })
497 .Item("Build Instructions", ICON_MD_BUILD,
498 [this]() { OnShowBuildInstructions(); })
499 .Item("CLI Usage", ICON_MD_TERMINAL, [this]() { OnShowCLIUsage(); })
500 .Separator()
501 .Item("Supported Features", ICON_MD_CHECK_CIRCLE,
502 [this]() { OnShowSupportedFeatures(); })
503 .Item("What's New", ICON_MD_NEW_RELEASES, [this]() { OnShowWhatsNew(); })
504 .Separator()
505 .Item("Troubleshooting", ICON_MD_BUILD_CIRCLE,
506 [this]() { OnShowTroubleshooting(); })
507 .Item("Contributing", ICON_MD_VOLUNTEER_ACTIVISM,
508 [this]() { OnShowContributing(); })
509 .Separator()
510 .Item("About", ICON_MD_INFO, [this]() { OnShowAbout(); }, "F1");
511}
512
513// Menu state management
517
521
522// Menu item callbacks - delegate to appropriate managers
524 // Delegate to EditorManager's LoadRom which handles session management
525 if (editor_manager_) {
526 auto status = editor_manager_->LoadRom();
527 if (!status.ok()) {
529 absl::StrFormat("Failed to load ROM: %s", status.message()),
531 }
532 }
533}
534
536 // Delegate to EditorManager's SaveRom which handles editor data saving
537 if (editor_manager_) {
538 auto status = editor_manager_->SaveRom();
539 if (!status.ok()) {
541 absl::StrFormat("Failed to save ROM: %s", status.message()),
543 } else {
544 toast_manager_.Show("ROM saved successfully", ToastType::kSuccess);
545 }
546 }
547}
548
552
554 // Delegate to EditorManager which handles the full project creation flow
555 if (editor_manager_) {
556 auto status = editor_manager_->CreateNewProject();
557 if (!status.ok()) {
559 absl::StrFormat("Failed to create project: %s", status.message()),
561 }
562 }
563}
564
566 // Delegate to EditorManager which handles ROM loading and session creation
567 if (editor_manager_) {
568 auto status = editor_manager_->OpenProject();
569 if (!status.ok()) {
571 absl::StrFormat("Failed to open project: %s", status.message()),
573 }
574 }
575}
576
578 // Delegate to EditorManager which updates project with current state
579 if (editor_manager_) {
580 auto status = editor_manager_->SaveProject();
581 if (!status.ok()) {
583 absl::StrFormat("Failed to save project: %s", status.message()),
585 } else {
586 toast_manager_.Show("Project saved successfully", ToastType::kSuccess);
587 }
588 }
589}
590
592 // Delegate to EditorManager
593 if (editor_manager_) {
594 auto status = editor_manager_->SaveProjectAs();
595 if (!status.ok()) {
597 absl::StrFormat("Failed to save project as: %s", status.message()),
599 }
600 }
601}
602
604 // Show project management panel in right sidebar
605 if (editor_manager_) {
607 }
608}
609
611 // Open the project file editor with the current project file
612 if (editor_manager_) {
614 }
615}
616
617// Edit menu actions - delegate to current editor
619 if (editor_manager_) {
620 auto* current_editor = editor_manager_->GetCurrentEditor();
621 if (current_editor) {
622 auto status = current_editor->Undo();
623 if (!status.ok()) {
625 absl::StrFormat("Undo failed: %s", status.message()),
627 }
628 }
629 }
630}
631
633 if (editor_manager_) {
634 auto* current_editor = editor_manager_->GetCurrentEditor();
635 if (current_editor) {
636 auto status = current_editor->Redo();
637 if (!status.ok()) {
639 absl::StrFormat("Redo failed: %s", status.message()),
641 }
642 }
643 }
644}
645
647 if (editor_manager_) {
648 auto* current_editor = editor_manager_->GetCurrentEditor();
649 if (current_editor) {
650 auto status = current_editor->Cut();
651 if (!status.ok()) {
652 toast_manager_.Show(absl::StrFormat("Cut failed: %s", status.message()),
654 }
655 }
656 }
657}
658
660 if (editor_manager_) {
661 auto* current_editor = editor_manager_->GetCurrentEditor();
662 if (current_editor) {
663 auto status = current_editor->Copy();
664 if (!status.ok()) {
666 absl::StrFormat("Copy failed: %s", status.message()),
668 }
669 }
670 }
671}
672
674 if (editor_manager_) {
675 auto* current_editor = editor_manager_->GetCurrentEditor();
676 if (current_editor) {
677 auto status = current_editor->Paste();
678 if (!status.ok()) {
680 absl::StrFormat("Paste failed: %s", status.message()),
682 }
683 }
684 }
685}
686
688 if (editor_manager_) {
689 auto* current_editor = editor_manager_->GetCurrentEditor();
690 if (current_editor) {
691 auto status = current_editor->Find();
692 if (!status.ok()) {
694 absl::StrFormat("Find failed: %s", status.message()),
696 }
697 }
698 }
699}
700
701// Editor-specific menu actions
703 // Delegate to EditorManager which manages editor switching
704 if (editor_manager_) {
705 editor_manager_->SwitchToEditor(editor_type);
706 }
707}
708
710 // Delegate to UICoordinator for editor selection dialog display
711 if (editor_manager_) {
712 if (auto* ui = editor_manager_->ui_coordinator()) {
713 ui->ShowEditorSelection();
714 }
715 }
716}
717
721
723 // Show hex editor card via EditorPanelManager
724 if (editor_manager_) {
726 }
727}
728
730 if (editor_manager_) {
731 if (auto* ui = editor_manager_->ui_coordinator()) {
732 ui->SetEmulatorVisible(true);
733 }
734 }
735}
736
738 if (editor_manager_) {
739 if (auto* ui = editor_manager_->ui_coordinator()) {
740 ui->SetPanelBrowserVisible(true);
741 }
742 }
743}
744
746 if (editor_manager_) {
747 if (auto* ui = editor_manager_->ui_coordinator()) {
748 ui->SetWelcomeScreenVisible(true);
749 }
750 }
751}
752
754 // Open the WYSIWYG layout designer
755 if (editor_manager_) {
757 }
758}
759
760#ifdef YAZE_BUILD_AGENT_UI
761void MenuOrchestrator::OnShowAIAgent() {
762 if (editor_manager_) {
763 if (auto* ui = editor_manager_->ui_coordinator()) {
764 ui->SetAIAgentVisible(true);
765 }
766 }
767}
768
769void MenuOrchestrator::OnShowChatHistory() {
770 if (editor_manager_) {
771 if (auto* ui = editor_manager_->ui_coordinator()) {
772 ui->SetChatHistoryVisible(true);
773 }
774 }
775}
776
777void MenuOrchestrator::OnShowProposalDrawer() {
778 if (editor_manager_) {
779 if (auto* ui = editor_manager_->ui_coordinator()) {
780 ui->SetProposalDrawerVisible(true);
781 }
782 }
783}
784#endif
785
786// Session management menu actions
790
794
798
799void MenuOrchestrator::OnSwitchToSession(size_t session_index) {
801}
802
804 // Delegate to UICoordinator for session switcher UI
805 if (editor_manager_) {
806 if (auto* ui = editor_manager_->ui_coordinator()) {
807 ui->ShowSessionSwitcher();
808 }
809 }
810}
811
815
816// Window management menu actions
818 // Delegate to EditorManager
819 if (editor_manager_) {
820 if (auto* ui = editor_manager_->ui_coordinator()) {
821 ui->ShowAllWindows();
822 }
823 }
824}
825
827 // Delegate to EditorManager
828 if (editor_manager_) {
830 }
831}
832
834 // Queue as deferred action to avoid modifying ImGui state during menu rendering
835 if (editor_manager_) {
838 toast_manager_.Show("Layout reset to default", ToastType::kInfo);
839 });
840 }
841}
842
844 // Delegate to EditorManager
845 if (editor_manager_) {
847 }
848}
849
851 // Delegate to EditorManager
852 if (editor_manager_) {
854 }
855}
856
860
866
872
878
879// Tool menu actions
881 if (editor_manager_) {
882 if (auto* ui = editor_manager_->ui_coordinator()) {
883 ui->ShowGlobalSearch();
884 }
885 }
886}
887
889 if (editor_manager_) {
890 if (auto* ui = editor_manager_->ui_coordinator()) {
891 ui->ShowCommandPalette();
892 }
893 }
894}
895
897 if (editor_manager_) {
898 if (auto* ui = editor_manager_->ui_coordinator()) {
899 ui->SetPerformanceDashboardVisible(true);
900 }
901 }
902}
903
909
915
921
923 if (editor_manager_) {
924 if (auto* ui = editor_manager_->ui_coordinator()) {
925 ui->SetResourceLabelManagerVisible(true);
926 }
927 }
928}
929
930#ifdef YAZE_ENABLE_TESTING
931void MenuOrchestrator::OnShowTestDashboard() {
932 if (editor_manager_) {
933 editor_manager_->ShowTestDashboard();
934 }
935}
936
937void MenuOrchestrator::OnRunAllTests() {
938 toast_manager_.Show("Running all tests...", ToastType::kInfo);
939 // TODO: Implement test runner integration
940}
941
942void MenuOrchestrator::OnRunUnitTests() {
943 toast_manager_.Show("Running unit tests...", ToastType::kInfo);
944 // TODO: Implement unit test runner
945}
946
947void MenuOrchestrator::OnRunIntegrationTests() {
948 toast_manager_.Show("Running integration tests...", ToastType::kInfo);
949 // TODO: Implement integration test runner
950}
951
952void MenuOrchestrator::OnRunE2ETests() {
953 toast_manager_.Show("Running E2E tests...", ToastType::kInfo);
954 // TODO: Implement E2E test runner
955}
956#endif
957
958#ifdef YAZE_WITH_GRPC
959void MenuOrchestrator::OnStartCollaboration() {
960 toast_manager_.Show("Starting collaboration session...", ToastType::kInfo);
961 // TODO: Implement collaboration session start
962}
963
964void MenuOrchestrator::OnJoinCollaboration() {
965 toast_manager_.Show("Joining collaboration session...", ToastType::kInfo);
966 // TODO: Implement collaboration session join
967}
968
969void MenuOrchestrator::OnShowNetworkStatus() {
970 toast_manager_.Show("Network Status", ToastType::kInfo);
971 // TODO: Show network status dialog
972}
973#endif
974
975// Help menu actions
979
983
987
991
995
999
1003
1007
1011
1012// Additional File menu actions
1016
1018 if (editor_manager_) {
1019 // Create backup via ROM directly (from original implementation)
1020 auto* rom = editor_manager_->GetCurrentRom();
1021 if (rom && rom->is_loaded()) {
1022 Rom::SaveSettings settings;
1023 settings.backup = true;
1024 settings.filename = rom->filename();
1025 auto status = rom->SaveToFile(settings);
1026 if (status.ok()) {
1027 toast_manager_.Show("Backup created successfully", ToastType::kSuccess);
1028 } else {
1030 absl::StrFormat("Backup failed: %s", status.message()),
1032 }
1033 }
1034 }
1035}
1036
1038 if (editor_manager_) {
1040 if (status.ok()) {
1041 toast_manager_.Show("ROM validation passed", ToastType::kSuccess);
1042 } else {
1044 absl::StrFormat("ROM validation failed: %s", status.message()),
1046 }
1047 }
1048}
1049
1051 // Activate settings editor
1052 if (editor_manager_) {
1054 }
1055}
1056
1058 if (editor_manager_) {
1060 }
1061}
1062
1063// Menu item validation helpers
1065 auto* rom = editor_manager_->GetCurrentRom();
1066 return rom ? rom_manager_.IsRomLoaded(rom) : false;
1067}
1068
1072
1074 auto* rom = editor_manager_->GetCurrentRom();
1075 return rom ? rom_manager_.IsRomLoaded(rom) : false;
1076}
1077
1081
1083 // Check if EditorManager has a project with a valid filepath
1084 // This is separate from HasActiveProject which checks ProjectManager
1085 const auto* project = editor_manager_ ? editor_manager_->GetCurrentProject() : nullptr;
1086 return project && !project->filepath.empty();
1087}
1088
1092
1096
1097// Menu item text generation
1099 auto* rom = editor_manager_->GetCurrentRom();
1100 return rom ? rom_manager_.GetRomFilename(rom) : "";
1101}
1102
1105}
1106
1108 // TODO: Get current editor name
1109 return "Unknown Editor";
1110}
1111
1112// Shortcut key management
1114 const std::string& action) const {
1115 // TODO: Implement shortcut mapping
1116 return "";
1117}
1118
1120 // TODO: Register global keyboard shortcuts
1121}
1122
1123// ============================================================================
1124// Debug Menu Actions
1125// ============================================================================
1126
1128#ifdef YAZE_ENABLE_TESTING
1129 if (!editor_manager_)
1130 return;
1131 auto* rom = editor_manager_->GetCurrentRom();
1132 if (!rom || !rom->is_loaded())
1133 return;
1134
1135 toast_manager_.Show("Running ROM integrity tests...", ToastType::kInfo);
1136 // This would integrate with the test system in master
1137 // For now, just show a placeholder
1138 toast_manager_.Show("Data integrity check completed", ToastType::kSuccess,
1139 3.0f);
1140#else
1141 toast_manager_.Show("Testing not enabled in this build", ToastType::kWarning);
1142#endif
1143}
1144
1146#ifdef YAZE_ENABLE_TESTING
1147 if (!editor_manager_)
1148 return;
1149 auto* rom = editor_manager_->GetCurrentRom();
1150 if (!rom || !rom->is_loaded())
1151 return;
1152
1153 toast_manager_.Show("Running ROM save/load tests...", ToastType::kInfo);
1154 // This would integrate with the test system in master
1155 toast_manager_.Show("Save/load test completed", ToastType::kSuccess, 3.0f);
1156#else
1157 toast_manager_.Show("Testing not enabled in this build", ToastType::kWarning);
1158#endif
1159}
1160
1162 if (!editor_manager_)
1163 return;
1164 auto* rom = editor_manager_->GetCurrentRom();
1165 if (!rom || !rom->is_loaded())
1166 return;
1167
1168 // Check ZSCustomOverworld version
1169 uint8_t version = (*rom)[zelda3::OverworldCustomASMHasBeenApplied];
1170 std::string version_str =
1171 (version == 0xFF) ? "Vanilla" : absl::StrFormat("v%d", version);
1172
1174 absl::StrFormat("ROM: %s | ZSCustomOverworld: %s", rom->title().c_str(),
1175 version_str.c_str()),
1176 ToastType::kInfo, 5.0f);
1177}
1178
1180 if (!editor_manager_)
1181 return;
1182 auto* rom = editor_manager_->GetCurrentRom();
1183 if (!rom || !rom->is_loaded())
1184 return;
1185
1186 toast_manager_.Show("Use Overworld Editor to upgrade ROM version",
1187 ToastType::kInfo, 4.0f);
1188}
1189
1191 auto& flags = core::FeatureFlags::get();
1192 flags.overworld.kLoadCustomOverworld = !flags.overworld.kLoadCustomOverworld;
1193
1195 absl::StrFormat(
1196 "Custom Overworld Loading: %s",
1197 flags.overworld.kLoadCustomOverworld ? "Enabled" : "Disabled"),
1199}
1200
1202 if (!editor_manager_)
1203 return;
1204 auto* rom = editor_manager_->GetCurrentRom();
1205 if (!rom || !rom->is_loaded())
1206 return;
1207
1208 auto& flags = core::FeatureFlags::get();
1209 flags.overworld.kApplyZSCustomOverworldASM =
1210 !flags.overworld.kApplyZSCustomOverworldASM;
1211
1213 absl::StrFormat(
1214 "ZSCustomOverworld ASM Application: %s",
1215 flags.overworld.kApplyZSCustomOverworldASM ? "Enabled" : "Disabled"),
1217}
1218
1220 toast_manager_.Show("ASM file loading not yet implemented",
1222}
1223
1229
1230} // namespace editor
1231} // 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