yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
popup_manager.cc
Go to the documentation of this file.
1#include "popup_manager.h"
2
3#include <functional>
4
5#include "absl/strings/str_format.h"
10#include "app/gui/core/style.h"
11#include "imgui/misc/cpp/imgui_stdlib.h"
12#include "util/hex.h"
13
14namespace yaze {
15namespace editor {
16
17using namespace ImGui;
18
20 : editor_manager_(editor_manager), status_(absl::OkStatus()) {}
21
23 // ============================================================================
24 // POPUP REGISTRATION
25 // ============================================================================
26 // All popups must be registered here BEFORE any menu callbacks can trigger
27 // them. This method is called in EditorManager constructor BEFORE
28 // MenuOrchestrator and UICoordinator are created, ensuring safe
29 // initialization order.
30 //
31 // Popup Registration Format:
32 // popups_[PopupID::kConstant] = {
33 // .name = PopupID::kConstant,
34 // .type = PopupType::kXxx,
35 // .is_visible = false,
36 // .allow_resize = false/true,
37 // .draw_function = [this]() { DrawXxxPopup(); }
38 // };
39 // ============================================================================
40
41 // File Operations
43 false, false, [this]() {
45 }};
47 PopupID::kNewProject, PopupType::kFileOperation, false, false, [this]() {
49 }};
51 PopupType::kFileOperation, false, false,
52 [this]() {
54 }};
55
56 // Information
58 [this]() {
60 }};
62 false, [this]() {
64 }};
66 PopupID::kSupportedFeatures, PopupType::kInfo, false, false, [this]() {
68 }};
70 false, false, [this]() {
72 }};
73
74 // Help Documentation
76 PopupID::kGettingStarted, PopupType::kHelp, false, false, [this]() {
78 }};
80 PopupID::kAsarIntegration, PopupType::kHelp, false, false, [this]() {
82 }};
84 PopupID::kBuildInstructions, PopupType::kHelp, false, false, [this]() {
86 }};
88 false, [this]() {
90 }};
92 PopupID::kTroubleshooting, PopupType::kHelp, false, false, [this]() {
94 }};
96 false, false, [this]() {
98 }};
100 false, [this]() {
102 }};
103
104 // Settings
107 true, // Resizable
108 [this]() {
110 }};
112 PopupID::kFeatureFlags, PopupType::kSettings, false, true, // Resizable
113 [this]() {
115 }};
116
117 // Workspace
119 false, false, [this]() {
121 }};
123 PopupType::kWarning, false, false,
124 [this]() {
126 }};
129 false, [this]() {
131 }};
132
134 PopupType::kSettings, false, false,
135 [this]() { DrawLayoutPresetsPopup(); }};
136
138 PopupType::kSettings, false, true,
139 [this]() { DrawSessionManagerPopup(); }};
140
141 // Debug/Testing
143 false, true, // Resizable
144 [this]() {
146 }};
147}
148
150 // Draw status popup if needed
152
153 // Draw all registered popups
154 for (auto& [name, params] : popups_) {
155 if (params.is_visible) {
156 OpenPopup(name.c_str());
157
158 // Use allow_resize flag from popup definition
159 ImGuiWindowFlags popup_flags = params.allow_resize
160 ? ImGuiWindowFlags_None
161 : ImGuiWindowFlags_AlwaysAutoResize;
162
163 if (BeginPopupModal(name.c_str(), nullptr, popup_flags)) {
164 params.draw_function();
165 EndPopup();
166 }
167 }
168 }
169}
170
171void PopupManager::Show(const char* name) {
172 if (!name) {
173 return; // Safety check for null pointer
174 }
175
176 std::string name_str(name);
177 auto it = popups_.find(name_str);
178 if (it != popups_.end()) {
179 it->second.is_visible = true;
180 } else {
181 // Log warning for unregistered popup
182 printf(
183 "[PopupManager] Warning: Popup '%s' not registered. Available popups: ",
184 name);
185 for (const auto& [key, _] : popups_) {
186 printf("'%s' ", key.c_str());
187 }
188 printf("\n");
189 }
190}
191
192void PopupManager::Hide(const char* name) {
193 if (!name) {
194 return; // Safety check for null pointer
195 }
196
197 std::string name_str(name);
198 auto it = popups_.find(name_str);
199 if (it != popups_.end()) {
200 it->second.is_visible = false;
201 CloseCurrentPopup();
202 }
203}
204
205bool PopupManager::IsVisible(const char* name) const {
206 if (!name) {
207 return false; // Safety check for null pointer
208 }
209
210 std::string name_str(name);
211 auto it = popups_.find(name_str);
212 if (it != popups_.end()) {
213 return it->second.is_visible;
214 }
215 return false;
216}
217
218void PopupManager::SetStatus(const absl::Status& status) {
219 if (!status.ok()) {
220 show_status_ = true;
221 prev_status_ = status;
222 status_ = status;
223 }
224}
225
226bool PopupManager::BeginCentered(const char* name) {
227 ImGuiIO const& io = GetIO();
228 ImVec2 pos(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
229 SetNextWindowPos(pos, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
230 ImGuiWindowFlags flags =
231 ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration |
232 ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings;
233 return Begin(name, nullptr, flags);
234}
235
237 if (show_status_ && BeginCentered("StatusWindow")) {
238 Text("%s", ICON_MD_ERROR);
239 Text("%s", prev_status_.ToString().c_str());
240 Spacing();
241 NextColumn();
242 Columns(1);
243 Separator();
244 NewLine();
245 SameLine(128);
246 if (Button("OK", gui::kDefaultModalSize) || IsKeyPressed(ImGuiKey_Space)) {
247 show_status_ = false;
248 status_ = absl::OkStatus();
249 }
250 SameLine();
251 if (Button(ICON_MD_CONTENT_COPY, ImVec2(50, 0))) {
252 SetClipboardText(prev_status_.ToString().c_str());
253 }
254 End();
255 }
256}
257
259 Text("Yet Another Zelda3 Editor - v%s", editor_manager_->version().c_str());
260 Text("Written by: scawful");
261 Spacing();
262 Text("Special Thanks: Zarby89, JaredBrian");
263 Separator();
264
265 if (Button("Close", gui::kDefaultModalSize)) {
266 Hide("About");
267 }
268}
269
271 auto* current_rom = editor_manager_->GetCurrentRom();
272 if (!current_rom)
273 return;
274
275 Text("Title: %s", current_rom->title().c_str());
276 Text("ROM Size: %s", util::HexLongLong(current_rom->size()).c_str());
277
278 if (Button("Close", gui::kDefaultModalSize) ||
279 IsKeyPressed(ImGuiKey_Escape)) {
280 Hide("ROM Information");
281 }
282}
283
285 using namespace ImGui;
286
287 Text("%s Save ROM to new location", ICON_MD_SAVE_AS);
288 Separator();
289
290 static std::string save_as_filename = "";
291 if (editor_manager_->GetCurrentRom() && save_as_filename.empty()) {
292 save_as_filename = editor_manager_->GetCurrentRom()->title();
293 }
294
295 InputText("Filename", &save_as_filename);
296 Separator();
297
298 if (Button(absl::StrFormat("%s Browse...", ICON_MD_FOLDER_OPEN).c_str(),
300 auto file_path =
301 util::FileDialogWrapper::ShowSaveFileDialog(save_as_filename, "sfc");
302 if (!file_path.empty()) {
303 save_as_filename = file_path;
304 }
305 }
306
307 SameLine();
308 if (Button(absl::StrFormat("%s Save", ICON_MD_SAVE).c_str(),
310 if (!save_as_filename.empty()) {
311 // Ensure proper file extension
312 std::string final_filename = save_as_filename;
313 if (final_filename.find(".sfc") == std::string::npos &&
314 final_filename.find(".smc") == std::string::npos) {
315 final_filename += ".sfc";
316 }
317
318 auto status = editor_manager_->SaveRomAs(final_filename);
319 if (status.ok()) {
320 save_as_filename = "";
322 }
323 }
324 }
325
326 SameLine();
327 if (Button(absl::StrFormat("%s Cancel", ICON_MD_CANCEL).c_str(),
329 save_as_filename = "";
331 }
332}
333
335 using namespace ImGui;
336
337 static std::string project_name = "";
338 static std::string project_filepath = "";
339 static std::string rom_filename = "";
340 static std::string labels_filename = "";
341 static std::string code_folder = "";
342
343 InputText("Project Name", &project_name);
344
345 if (Button(absl::StrFormat("%s Destination Folder", ICON_MD_FOLDER).c_str(),
348 }
349 SameLine();
350 Text("%s", project_filepath.empty() ? "(Not set)" : project_filepath.c_str());
351
352 if (Button(absl::StrFormat("%s ROM File", ICON_MD_VIDEOGAME_ASSET).c_str(),
355 }
356 SameLine();
357 Text("%s", rom_filename.empty() ? "(Not set)" : rom_filename.c_str());
358
359 if (Button(absl::StrFormat("%s Labels File", ICON_MD_LABEL).c_str(),
362 }
363 SameLine();
364 Text("%s", labels_filename.empty() ? "(Not set)" : labels_filename.c_str());
365
366 if (Button(absl::StrFormat("%s Code Folder", ICON_MD_CODE).c_str(),
369 }
370 SameLine();
371 Text("%s", code_folder.empty() ? "(Not set)" : code_folder.c_str());
372
373 Separator();
374
375 if (Button(absl::StrFormat("%s Choose Project File Location", ICON_MD_SAVE)
376 .c_str(),
378 auto project_file_path =
380 if (!project_file_path.empty()) {
381 if (project_file_path.find(".yaze") == std::string::npos) {
382 project_file_path += ".yaze";
383 }
384 project_filepath = project_file_path;
385 }
386 }
387
388 if (Button(absl::StrFormat("%s Create Project", ICON_MD_ADD).c_str(),
390 if (!project_filepath.empty() && !project_name.empty()) {
391 auto status = editor_manager_->CreateNewProject();
392 if (status.ok()) {
393 // Clear fields
394 project_name = "";
395 project_filepath = "";
396 rom_filename = "";
397 labels_filename = "";
398 code_folder = "";
400 }
401 }
402 }
403 SameLine();
404 if (Button(absl::StrFormat("%s Cancel", ICON_MD_CANCEL).c_str(),
406 // Clear fields
407 project_name = "";
408 project_filepath = "";
409 rom_filename = "";
410 labels_filename = "";
411 code_folder = "";
413 }
414}
415
417 if (CollapsingHeader(
418 absl::StrFormat("%s Overworld Editor", ICON_MD_LAYERS).c_str(),
419 ImGuiTreeNodeFlags_DefaultOpen)) {
420 BulletText("LW/DW/SW Tilemap Editing");
421 BulletText("LW/DW/SW Map Properties");
422 BulletText("Create/Delete/Update Entrances");
423 BulletText("Create/Delete/Update Exits");
424 BulletText("Create/Delete/Update Sprites");
425 BulletText("Create/Delete/Update Items");
426 BulletText("Multi-session map editing support");
427 }
428
429 if (CollapsingHeader(
430 absl::StrFormat("%s Dungeon Editor", ICON_MD_CASTLE).c_str())) {
431 BulletText("View Room Header Properties");
432 BulletText("View Entrance Properties");
433 BulletText("Enhanced room navigation");
434 }
435
436 if (CollapsingHeader(
437 absl::StrFormat("%s Graphics & Themes", ICON_MD_PALETTE).c_str())) {
438 BulletText("View Decompressed Graphics Sheets");
439 BulletText("View/Update Graphics Groups");
440 BulletText(
441 "5+ Built-in themes (Classic, Cyberpunk, Sunset, Forest, Midnight)");
442 BulletText("Custom theme creation and editing");
443 BulletText("Theme import/export functionality");
444 BulletText("Animated background grid effects");
445 }
446
447 if (CollapsingHeader(
448 absl::StrFormat("%s Palettes", ICON_MD_COLOR_LENS).c_str())) {
449 BulletText("View Palette Groups");
450 BulletText("Enhanced palette editing tools");
451 BulletText("Color conversion utilities");
452 }
453
454 if (CollapsingHeader(
455 absl::StrFormat("%s Project Management", ICON_MD_FOLDER).c_str())) {
456 BulletText("Multi-session workspace support");
457 BulletText("Enhanced project creation and management");
458 BulletText("ZScream project format compatibility");
459 BulletText("Workspace settings and feature flags");
460 }
461
462 if (CollapsingHeader(
463 absl::StrFormat("%s Development Tools", ICON_MD_BUILD).c_str())) {
464 BulletText("Asar 65816 assembler integration");
465 BulletText("Enhanced CLI tools with TUI interface");
466 BulletText("Memory editor with advanced features");
467 BulletText("Hex editor with search and navigation");
468 BulletText("Assembly validation and symbol extraction");
469 }
470
471 if (CollapsingHeader(
472 absl::StrFormat("%s Save Capabilities", ICON_MD_SAVE).c_str())) {
473 BulletText("All Overworld editing features");
474 BulletText("Hex Editor changes");
475 BulletText("Theme configurations");
476 BulletText("Project settings and workspace layouts");
477 BulletText("Custom assembly patches");
478 }
479
480 if (Button("Close", gui::kDefaultModalSize)) {
481 Hide("Supported Features");
482 }
483}
484
486 Text("File -> Open");
487 Text("Select a ROM file to open");
488 Text("Supported ROMs (headered or unheadered):");
489 Text("The Legend of Zelda: A Link to the Past");
490 Text("US Version 1.0");
491 Text("JP Version 1.0");
492
493 if (Button("Close", gui::kDefaultModalSize)) {
494 Hide("Open a ROM");
495 }
496}
497
499 Text("Project Menu");
500 Text("Create a new project or open an existing one.");
501 Text("Save the project to save the current state of the project.");
502 TextWrapped(
503 "To save a project, you need to first open a ROM and initialize your "
504 "code path and labels file. Label resource manager can be found in "
505 "the View menu. Code path is set in the Code editor after opening a "
506 "folder.");
507
508 if (Button("Close", gui::kDefaultModalSize)) {
509 Hide("Manage Project");
510 }
511}
512
514 TextWrapped("Welcome to YAZE v0.3!");
515 TextWrapped(
516 "This software allows you to modify 'The Legend of Zelda: A Link to the "
517 "Past' (US or JP) ROMs.");
518 Spacing();
519 TextWrapped("General Tips:");
520 BulletText("Experiment flags determine whether certain features are enabled");
521 BulletText("Backup files are enabled by default for safety");
522 BulletText("Use File > Options to configure settings");
523
524 if (Button("Close", gui::kDefaultModalSize)) {
525 Hide("Getting Started");
526 }
527}
528
530 TextWrapped("Asar 65816 Assembly Integration");
531 TextWrapped(
532 "YAZE v0.3 includes full Asar assembler support for ROM patching.");
533 Spacing();
534 TextWrapped("Features:");
535 BulletText("Cross-platform ROM patching with assembly code");
536 BulletText("Symbol extraction with addresses and opcodes");
537 BulletText("Assembly validation with error reporting");
538 BulletText("Memory-safe operations with automatic ROM size management");
539
540 if (Button("Close", gui::kDefaultModalSize)) {
541 Hide("Asar Integration");
542 }
543}
544
546 TextWrapped("Build Instructions");
547 TextWrapped("YAZE uses modern CMake for cross-platform builds.");
548 Spacing();
549 TextWrapped("Quick Start:");
550 BulletText("cmake -B build");
551 BulletText("cmake --build build --target yaze");
552 Spacing();
553 TextWrapped("Development:");
554 BulletText("cmake --preset dev");
555 BulletText("cmake --build --preset dev");
556
557 if (Button("Close", gui::kDefaultModalSize)) {
558 Hide("Build Instructions");
559 }
560}
561
563 TextWrapped("Command Line Interface (z3ed)");
564 TextWrapped("Enhanced CLI tool with Asar integration.");
565 Spacing();
566 TextWrapped("Commands:");
567 BulletText("z3ed asar patch.asm --rom=file.sfc");
568 BulletText("z3ed extract symbols.asm");
569 BulletText("z3ed validate assembly.asm");
570 BulletText("z3ed patch file.bps --rom=file.sfc");
571
572 if (Button("Close", gui::kDefaultModalSize)) {
573 Hide("CLI Usage");
574 }
575}
576
578 TextWrapped("Troubleshooting");
579 TextWrapped("Common issues and solutions:");
580 Spacing();
581 BulletText("ROM won't load: Check file format (SFC/SMC supported)");
582 BulletText("Graphics issues: Try disabling experimental features");
583 BulletText("Performance: Enable hardware acceleration in display settings");
584 BulletText("Crashes: Check ROM file integrity and available memory");
585
586 if (Button("Close", gui::kDefaultModalSize)) {
587 Hide("Troubleshooting");
588 }
589}
590
592 TextWrapped("Contributing to YAZE");
593 TextWrapped("YAZE is open source and welcomes contributions!");
594 Spacing();
595 TextWrapped("How to contribute:");
596 BulletText("Fork the repository on GitHub");
597 BulletText("Create feature branches for new work");
598 BulletText("Follow C++ coding standards");
599 BulletText("Include tests for new features");
600 BulletText("Submit pull requests for review");
601
602 if (Button("Close", gui::kDefaultModalSize)) {
603 Hide("Contributing");
604 }
605}
606
608 TextWrapped("What's New in YAZE v0.3");
609 Spacing();
610
611 if (CollapsingHeader(
612 absl::StrFormat("%s User Interface & Theming", ICON_MD_PALETTE)
613 .c_str(),
614 ImGuiTreeNodeFlags_DefaultOpen)) {
615 BulletText("Complete theme management system with 5+ built-in themes");
616 BulletText("Custom theme editor with save-to-file functionality");
617 BulletText("Animated background grid with breathing effects (optional)");
618 BulletText("Enhanced welcome screen with themed elements");
619 BulletText("Multi-session workspace support with docking");
620 BulletText("Improved editor organization and navigation");
621 }
622
623 if (CollapsingHeader(
624 absl::StrFormat("%s Development & Build System", ICON_MD_BUILD)
625 .c_str(),
626 ImGuiTreeNodeFlags_DefaultOpen)) {
627 BulletText("Asar 65816 assembler integration for ROM patching");
628 BulletText("Enhanced CLI tools with TUI (Terminal User Interface)");
629 BulletText("Modernized CMake build system with presets");
630 BulletText("Cross-platform CI/CD pipeline (Windows, macOS, Linux)");
631 BulletText("Comprehensive testing framework with 46+ core tests");
632 BulletText("Professional packaging for all platforms (DMG, MSI, DEB)");
633 }
634
635 if (CollapsingHeader(
636 absl::StrFormat("%s Core Improvements", ICON_MD_SETTINGS).c_str())) {
637 BulletText("Enhanced project management with YazeProject structure");
638 BulletText("Improved ROM loading and validation");
639 BulletText("Better error handling and status reporting");
640 BulletText("Memory safety improvements with sanitizers");
641 BulletText("Enhanced file dialog integration");
642 BulletText("Improved logging and debugging capabilities");
643 }
644
645 if (CollapsingHeader(
646 absl::StrFormat("%s Editor Features", ICON_MD_EDIT).c_str())) {
647 BulletText("Enhanced overworld editing capabilities");
648 BulletText("Improved graphics sheet viewing and editing");
649 BulletText("Better palette management and editing");
650 BulletText("Enhanced memory and hex editing tools");
651 BulletText("Improved sprite and item management");
652 BulletText("Better entrance and exit editing");
653 }
654
655 Spacing();
656 if (Button(absl::StrFormat("%s View Theme Editor", ICON_MD_PALETTE).c_str(),
657 ImVec2(-1, 30))) {
658 // Close this popup and show theme settings
659 Hide("Whats New v03");
660 // Could trigger theme editor opening here
661 }
662
663 if (Button("Close", gui::kDefaultModalSize)) {
664 Hide("Whats New v03");
665 }
666}
667
669 TextWrapped("Workspace Management");
670 TextWrapped(
671 "YAZE supports multiple ROM sessions and flexible workspace layouts.");
672 Spacing();
673
674 TextWrapped("Session Management:");
675 BulletText("Ctrl+Shift+N: Create new session");
676 BulletText("Ctrl+Shift+W: Close current session");
677 BulletText("Ctrl+Tab: Quick session switcher");
678 BulletText("Each session maintains its own ROM and editor state");
679
680 Spacing();
681 TextWrapped("Layout Management:");
682 BulletText("Drag window tabs to dock/undock");
683 BulletText("Ctrl+Shift+S: Save current layout");
684 BulletText("Ctrl+Shift+O: Load saved layout");
685 BulletText("F11: Maximize current window");
686
687 Spacing();
688 TextWrapped("Preset Layouts:");
689 BulletText("Developer: Code, memory, testing tools");
690 BulletText("Designer: Graphics, palettes, sprites");
691 BulletText("Modder: All gameplay editing tools");
692
693 if (Button("Close", gui::kDefaultModalSize)) {
694 Hide("Workspace Help");
695 }
696}
697
699 TextColored(ImVec4(1.0f, 0.5f, 0.0f, 1.0f), "%s Warning", ICON_MD_WARNING);
700 TextWrapped("You have reached the recommended session limit.");
701 TextWrapped("Having too many sessions open may impact performance.");
702 Spacing();
703 TextWrapped("Consider closing unused sessions or saving your work.");
704
705 if (Button("Understood", gui::kDefaultModalSize)) {
706 Hide("Session Limit Warning");
707 }
708 SameLine();
709 if (Button("Open Session Manager", gui::kDefaultModalSize)) {
710 Hide("Session Limit Warning");
711 // This would trigger the session manager to open
712 }
713}
714
716 TextColored(ImVec4(1.0f, 0.5f, 0.0f, 1.0f), "%s Confirm Reset",
718 TextWrapped("This will reset your current workspace layout to default.");
719 TextWrapped("Any custom window arrangements will be lost.");
720 Spacing();
721 TextWrapped("Do you want to continue?");
722
723 if (Button("Reset Layout", gui::kDefaultModalSize)) {
724 Hide("Layout Reset Confirm");
725 // This would trigger the actual reset
726 }
727 SameLine();
728 if (Button("Cancel", gui::kDefaultModalSize)) {
729 Hide("Layout Reset Confirm");
730 }
731}
732
734 TextColored(ImVec4(0.4f, 0.8f, 1.0f, 1.0f), "%s Layout Presets",
736 Separator();
737 Spacing();
738
739 TextWrapped("Choose a workspace preset to quickly configure your layout:");
740 Spacing();
741
742 // Get named presets from LayoutPresets
743 struct PresetInfo {
744 const char* name;
745 const char* icon;
746 const char* description;
747 std::function<PanelLayoutPreset()> getter;
748 };
749
750 PresetInfo presets[] = {
751 {"Minimal", ICON_MD_CROP_FREE,
752 "Essential cards only - maximum editing space",
753 []() { return LayoutPresets::GetMinimalPreset(); }},
754 {"Developer", ICON_MD_BUG_REPORT,
755 "Debug and development focused - CPU/Memory/Breakpoints",
756 []() { return LayoutPresets::GetDeveloperPreset(); }},
757 {"Designer", ICON_MD_PALETTE,
758 "Visual and artistic focused - Graphics/Palettes/Sprites",
759 []() { return LayoutPresets::GetDesignerPreset(); }},
760 {"Modder", ICON_MD_BUILD,
761 "Full-featured - All tools available for comprehensive editing",
762 []() { return LayoutPresets::GetModderPreset(); }},
763 {"Overworld Expert", ICON_MD_MAP,
764 "Complete overworld editing toolkit with all map tools",
765 []() { return LayoutPresets::GetOverworldExpertPreset(); }},
766 {"Dungeon Expert", ICON_MD_DOOR_SLIDING,
767 "Complete dungeon editing toolkit with room tools",
768 []() { return LayoutPresets::GetDungeonExpertPreset(); }},
769 {"Testing", ICON_MD_SCIENCE,
770 "Quality assurance and ROM testing layout",
771 []() { return LayoutPresets::GetTestingPreset(); }},
772 {"Audio", ICON_MD_MUSIC_NOTE,
773 "Music and sound editing layout",
774 []() { return LayoutPresets::GetAudioPreset(); }},
775 };
776
777 constexpr int kPresetCount = 8;
778
779 // Draw preset buttons in a grid
780 float button_width = 200.0f;
781 float button_height = 50.0f;
782
783 for (int i = 0; i < kPresetCount; i++) {
784 if (i % 2 != 0) SameLine();
785
786 PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f));
787 if (Button(absl::StrFormat("%s %s", presets[i].icon, presets[i].name).c_str(),
788 ImVec2(button_width, button_height))) {
789 // Apply the preset
790 auto preset = presets[i].getter();
791 auto& panel_manager = editor_manager_->panel_manager();
792 // Hide all panels first
793 panel_manager.HideAll();
794 // Show preset panels
795 for (const auto& panel_id : preset.default_visible_panels) {
796 panel_manager.ShowPanel(panel_id);
797 }
799 }
800 PopStyleVar();
801
802 if (IsItemHovered()) {
803 BeginTooltip();
804 TextUnformatted(presets[i].description);
805 EndTooltip();
806 }
807 }
808
809 Spacing();
810 Separator();
811 Spacing();
812
813 // Reset current editor to defaults
814 if (Button(absl::StrFormat("%s Reset Current Editor", ICON_MD_REFRESH).c_str(),
815 ImVec2(-1, 0))) {
816 auto& panel_manager = editor_manager_->card_registry();
817 auto* current_editor = editor_manager_->GetCurrentEditor();
818 if (current_editor) {
819 auto current_type = current_editor->type();
820 panel_manager.ResetToDefaults(0, current_type);
821 }
823 }
824
825 Spacing();
826 if (Button("Close", ImVec2(-1, 0))) {
828 }
829}
830
832 TextColored(ImVec4(0.4f, 0.8f, 1.0f, 1.0f), "%s Session Manager",
834 Separator();
835 Spacing();
836
837 size_t session_count = editor_manager_->GetActiveSessionCount();
838 size_t active_session = editor_manager_->GetCurrentSessionId();
839
840 Text("Active Sessions: %zu", session_count);
841 Spacing();
842
843 // Session table
844 if (BeginTable("SessionTable", 4,
845 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
846 TableSetupColumn("#", ImGuiTableColumnFlags_WidthFixed, 30.0f);
847 TableSetupColumn("ROM", ImGuiTableColumnFlags_WidthStretch);
848 TableSetupColumn("Status", ImGuiTableColumnFlags_WidthFixed, 80.0f);
849 TableSetupColumn("Actions", ImGuiTableColumnFlags_WidthFixed, 120.0f);
850 TableHeadersRow();
851
852 for (size_t i = 0; i < session_count; i++) {
853 TableNextRow();
854
855 // Session number
856 TableSetColumnIndex(0);
857 Text("%zu", i + 1);
858
859 // ROM name (simplified - show current ROM for active session)
860 TableSetColumnIndex(1);
861 if (i == active_session) {
862 auto* rom = editor_manager_->GetCurrentRom();
863 if (rom && rom->is_loaded()) {
864 TextUnformatted(rom->filename().c_str());
865 } else {
866 TextDisabled("(No ROM loaded)");
867 }
868 } else {
869 TextDisabled("Session %zu", i + 1);
870 }
871
872 // Status indicator
873 TableSetColumnIndex(2);
874 if (i == active_session) {
875 TextColored(ImVec4(0.2f, 0.8f, 0.2f, 1.0f), "%s Active",
877 } else {
878 TextDisabled("Inactive");
879 }
880
881 // Actions
882 TableSetColumnIndex(3);
883 PushID(static_cast<int>(i));
884
885 if (i != active_session) {
886 if (SmallButton("Switch")) {
888 }
889 SameLine();
890 }
891
892 BeginDisabled(session_count <= 1);
893 if (SmallButton("Close")) {
895 }
896 EndDisabled();
897
898 PopID();
899 }
900
901 EndTable();
902 }
903
904 Spacing();
905 Separator();
906 Spacing();
907
908 // New session button
909 if (Button(absl::StrFormat("%s New Session", ICON_MD_ADD).c_str(),
910 ImVec2(-1, 0))) {
912 }
913
914 Spacing();
915 if (Button("Close", ImVec2(-1, 0))) {
917 }
918}
919
921 // Set a comfortable default size with natural constraints
922 SetNextWindowSize(ImVec2(900, 700), ImGuiCond_FirstUseEver);
923 SetNextWindowSizeConstraints(ImVec2(600, 400), ImVec2(FLT_MAX, FLT_MAX));
924
925 Text("%s Display & Theme Settings", ICON_MD_DISPLAY_SETTINGS);
926 TextWrapped("Customize your YAZE experience - accessible anytime!");
927 Separator();
928
929 // Create a child window for scrollable content to avoid table conflicts
930 // Use remaining space minus the close button area
931 float available_height =
932 GetContentRegionAvail().y - 60; // Reserve space for close button
933 if (BeginChild("DisplaySettingsContent", ImVec2(0, available_height), true,
934 ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
935 // Use the popup-safe version to avoid table conflicts
937
938 Separator();
939 gui::TextWithSeparators("Font Manager");
941
942 // Global font scale (moved from the old display settings window)
943 ImGuiIO& io = GetIO();
944 Separator();
945 Text("Global Font Scale");
946 static float font_global_scale = io.FontGlobalScale;
947 if (SliderFloat("##global_scale", &font_global_scale, 0.5f, 1.8f, "%.2f")) {
948 if (editor_manager_) {
949 editor_manager_->SetFontGlobalScale(font_global_scale);
950 } else {
951 io.FontGlobalScale = font_global_scale;
952 }
953 }
954 }
955 EndChild();
956
957 Separator();
958 if (Button("Close", gui::kDefaultModalSize)) {
959 Hide("Display Settings");
960 }
961}
962
964 using namespace ImGui;
965
966 // Display feature flags editor using the existing FlagsMenu system
967 Text("Feature Flags Configuration");
968 Separator();
969
970 BeginChild("##FlagsContent", ImVec2(0, -30), true);
971
972 // Use the feature flags menu system
973 static gui::FlagsMenu flags_menu;
974
975 if (BeginTabBar("FlagCategories")) {
976 if (BeginTabItem("Overworld")) {
977 flags_menu.DrawOverworldFlags();
978 EndTabItem();
979 }
980 if (BeginTabItem("Dungeon")) {
981 flags_menu.DrawDungeonFlags();
982 EndTabItem();
983 }
984 if (BeginTabItem("Resources")) {
985 flags_menu.DrawResourceFlags();
986 EndTabItem();
987 }
988 if (BeginTabItem("System")) {
989 flags_menu.DrawSystemFlags();
990 EndTabItem();
991 }
992 EndTabBar();
993 }
994
995 EndChild();
996
997 Separator();
998 if (Button("Close", gui::kDefaultModalSize)) {
1000 }
1001}
1002
1004 using namespace ImGui;
1005
1006 Text("Data Integrity Check Results");
1007 Separator();
1008
1009 BeginChild("##IntegrityContent", ImVec2(0, -30), true);
1010
1011 // Placeholder for data integrity results
1012 // In a full implementation, this would show test results
1013 Text("ROM Data Integrity:");
1014 Separator();
1015 TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "✓ ROM header valid");
1016 TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "✓ Checksum valid");
1017 TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "✓ Graphics data intact");
1018 TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "✓ Map data intact");
1019
1020 Spacing();
1021 Text("No issues detected.");
1022
1023 EndChild();
1024
1025 Separator();
1026 if (Button("Close", gui::kDefaultModalSize)) {
1028 }
1029}
1030
1031} // namespace editor
1032} // namespace yaze
The EditorManager controls the main editor window and manages the various editor classes.
absl::Status SaveRomAs(const std::string &filename)
void SwitchToSession(size_t index)
absl::Status CreateNewProject(const std::string &template_name="Basic ROM Hack")
void SetFontGlobalScale(float scale)
auto GetCurrentEditor() const -> Editor *
auto GetCurrentRom() const -> Rom *
void RemoveSession(size_t index)
static PanelLayoutPreset GetDungeonExpertPreset()
Get the "dungeon expert" workspace preset.
static PanelLayoutPreset GetTestingPreset()
Get the "testing" workspace preset (QA focused)
static PanelLayoutPreset GetDesignerPreset()
Get the "designer" workspace preset (visual-focused)
static PanelLayoutPreset GetAudioPreset()
Get the "audio" workspace preset (music focused)
static PanelLayoutPreset GetModderPreset()
Get the "modder" workspace preset (full-featured)
static PanelLayoutPreset GetOverworldExpertPreset()
Get the "overworld expert" workspace preset.
static PanelLayoutPreset GetMinimalPreset()
Get the "minimal" workspace preset (minimal cards)
static PanelLayoutPreset GetDeveloperPreset()
Get the "developer" workspace preset (debug-focused)
void HideAll(size_t session_id)
void SetStatus(const absl::Status &status)
bool IsVisible(const char *name) const
void Show(const char *name)
void Hide(const char *name)
PopupManager(EditorManager *editor_manager)
std::unordered_map< std::string, PopupParams > popups_
EditorManager * editor_manager_
bool BeginCentered(const char *name)
static std::string ShowSaveFileDialog(const std::string &default_name="", const std::string &default_extension="")
ShowSaveFileDialog opens a save file dialog and returns the selected filepath. Uses global feature fl...
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
static std::string ShowOpenFolderDialog()
ShowOpenFolderDialog opens a file dialog and returns the selected folder path. Uses global feature fl...
#define ICON_MD_FOLDER_OPEN
Definition icons.h:813
#define ICON_MD_SETTINGS
Definition icons.h:1699
#define ICON_MD_CANCEL
Definition icons.h:364
#define ICON_MD_WARNING
Definition icons.h:2123
#define ICON_MD_DOOR_SLIDING
Definition icons.h:614
#define ICON_MD_SAVE_AS
Definition icons.h:1646
#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_VIDEOGAME_ASSET
Definition icons.h:2076
#define ICON_MD_BUG_REPORT
Definition icons.h:327
#define ICON_MD_EDIT
Definition icons.h:645
#define ICON_MD_CASTLE
Definition icons.h:380
#define ICON_MD_ERROR
Definition icons.h:686
#define ICON_MD_MUSIC_NOTE
Definition icons.h:1264
#define ICON_MD_LAYERS
Definition icons.h:1068
#define ICON_MD_DISPLAY_SETTINGS
Definition icons.h:587
#define ICON_MD_ADD
Definition icons.h:86
#define ICON_MD_SCIENCE
Definition icons.h:1656
#define ICON_MD_CHECK_CIRCLE
Definition icons.h:400
#define ICON_MD_BUILD
Definition icons.h:328
#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_FOLDER
Definition icons.h:809
#define ICON_MD_PALETTE
Definition icons.h:1370
#define ICON_MD_CONTENT_COPY
Definition icons.h:465
#define ICON_MD_COLOR_LENS
Definition icons.h:440
#define ICON_MD_CROP_FREE
Definition icons.h:495
Definition input.cc:22
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 * kDataIntegrity
constexpr const char * kManageProject
constexpr const char * kNewProject
constexpr const char * kSaveAs
constexpr const char * kDisplaySettings
constexpr const char * kSessionLimitWarning
constexpr const char * kCLIUsage
constexpr const char * kLayoutResetConfirm
constexpr const char * kAsarIntegration
constexpr const char * kOpenRomHelp
constexpr const char * kFeatureFlags
constexpr const char * kGettingStarted
constexpr const char * kContributing
constexpr const char * kBuildInstructions
constexpr const char * kWorkspaceHelp
void DrawFontManager()
Definition style.cc:1323
void DrawDisplaySettingsForPopup(ImGuiStyle *ref)
Definition style.cc:868
constexpr ImVec2 kDefaultModalSize
Definition input.h:21
void TextWithSeparators(const absl::string_view &text)
Definition style.cc:1317
std::string HexLongLong(uint64_t qword, HexStringParams params)
Definition hex.cc:63
Defines default panel visibility for an editor type.