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 "absl/strings/str_format.h"
5#include "app/gui/style.h"
6#include "app/gui/icons.h"
7#include "util/hex.h"
8#include "imgui/misc/cpp/imgui_stdlib.h"
9
10namespace yaze {
11namespace editor {
12
13using namespace ImGui;
14
16 : editor_manager_(editor_manager), status_(absl::OkStatus()) {}
17
19 // Register all popups
20 popups_["About"] = {"About", false, [this]() { DrawAboutPopup(); }};
21 popups_["ROM Information"] = {"ROM Information", false, [this]() { DrawRomInfoPopup(); }};
22 popups_["Save As.."] = {"Save As..", false, [this]() { DrawSaveAsPopup(); }};
23 popups_["New Project"] = {"New Project", false, [this]() { DrawNewProjectPopup(); }};
24 popups_["Supported Features"] = {"Supported Features", false, [this]() { DrawSupportedFeaturesPopup(); }};
25 popups_["Open a ROM"] = {"Open a ROM", false, [this]() { DrawOpenRomHelpPopup(); }};
26 popups_["Manage Project"] = {"Manage Project", false, [this]() { DrawManageProjectPopup(); }};
27
28 // v0.3 Help Documentation popups
29 popups_["Getting Started"] = {"Getting Started", false, [this]() { DrawGettingStartedPopup(); }};
30 popups_["Asar Integration"] = {"Asar Integration", false, [this]() { DrawAsarIntegrationPopup(); }};
31 popups_["Build Instructions"] = {"Build Instructions", false, [this]() { DrawBuildInstructionsPopup(); }};
32 popups_["CLI Usage"] = {"CLI Usage", false, [this]() { DrawCLIUsagePopup(); }};
33 popups_["Troubleshooting"] = {"Troubleshooting", false, [this]() { DrawTroubleshootingPopup(); }};
34 popups_["Contributing"] = {"Contributing", false, [this]() { DrawContributingPopup(); }};
35 popups_["Whats New v03"] = {"What's New in v0.3", false, [this]() { DrawWhatsNewPopup(); }};
36
37 // Workspace-related popups
38 popups_["Workspace Help"] = {"Workspace Help", false, [this]() { DrawWorkspaceHelpPopup(); }};
39 popups_["Session Limit Warning"] = {"Session Limit Warning", false, [this]() { DrawSessionLimitWarningPopup(); }};
40 popups_["Layout Reset Confirm"] = {"Reset Layout Confirmation", false, [this]() { DrawLayoutResetConfirmPopup(); }};
41
42 // Settings popups (accessible without ROM)
43 popups_["Display Settings"] = {"Display Settings", false, [this]() { DrawDisplaySettingsPopup(); }};
44}
45
47 // Draw status popup if needed
49
50 // Draw all registered popups
51 for (auto& [name, params] : popups_) {
52 if (params.is_visible) {
53 OpenPopup(name.c_str());
54
55 // Special handling for Display Settings popup to make it resizable
56 ImGuiWindowFlags popup_flags = ImGuiWindowFlags_AlwaysAutoResize;
57 if (name == "Display Settings") {
58 popup_flags = ImGuiWindowFlags_None; // Allow resizing for display settings
59 }
60
61 if (BeginPopupModal(name.c_str(), nullptr, popup_flags)) {
62 params.draw_function();
63 EndPopup();
64 }
65 }
66 }
67}
68
69void PopupManager::Show(const char* name) {
70 auto it = popups_.find(name);
71 if (it != popups_.end()) {
72 it->second.is_visible = true;
73 }
74}
75
76void PopupManager::Hide(const char* name) {
77 auto it = popups_.find(name);
78 if (it != popups_.end()) {
79 it->second.is_visible = false;
80 CloseCurrentPopup();
81 }
82}
83
84bool PopupManager::IsVisible(const char* name) const {
85 auto it = popups_.find(name);
86 if (it != popups_.end()) {
87 return it->second.is_visible;
88 }
89 return false;
90}
91
92void PopupManager::SetStatus(const absl::Status& status) {
93 if (!status.ok()) {
94 show_status_ = true;
95 prev_status_ = status;
96 status_ = status;
97 }
98}
99
100bool PopupManager::BeginCentered(const char* name) {
101 ImGuiIO const& io = GetIO();
102 ImVec2 pos(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
103 SetNextWindowPos(pos, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
104 ImGuiWindowFlags flags =
105 ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration |
106 ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings;
107 return Begin(name, nullptr, flags);
108}
109
111 if (show_status_ && BeginCentered("StatusWindow")) {
112 Text("%s", ICON_MD_ERROR);
113 Text("%s", prev_status_.ToString().c_str());
114 Spacing();
115 NextColumn();
116 Columns(1);
117 Separator();
118 NewLine();
119 SameLine(128);
120 if (Button("OK", gui::kDefaultModalSize) || IsKeyPressed(ImGuiKey_Space)) {
121 show_status_ = false;
122 status_ = absl::OkStatus();
123 }
124 SameLine();
125 if (Button(ICON_MD_CONTENT_COPY, ImVec2(50, 0))) {
126 SetClipboardText(prev_status_.ToString().c_str());
127 }
128 End();
129 }
130}
131
133 Text("Yet Another Zelda3 Editor - v%s", editor_manager_->version().c_str());
134 Text("Written by: scawful");
135 Spacing();
136 Text("Special Thanks: Zarby89, JaredBrian");
137 Separator();
138
139 if (Button("Close", gui::kDefaultModalSize)) {
140 Hide("About");
141 }
142}
143
145 auto* current_rom = editor_manager_->GetCurrentRom();
146 if (!current_rom) return;
147
148 Text("Title: %s", current_rom->title().c_str());
149 Text("ROM Size: %s", util::HexLongLong(current_rom->size()).c_str());
150
151 if (Button("Close", gui::kDefaultModalSize) || IsKeyPressed(ImGuiKey_Escape)) {
152 Hide("ROM Information");
153 }
154}
155
157 static std::string save_as_filename = "";
158 InputText("Filename", &save_as_filename);
159 if (Button("Save", gui::kDefaultModalSize)) {
160 // Call the save function from editor manager
161 // This will need to be implemented in the editor manager
162 Hide("Save As..");
163 }
164 SameLine();
165 if (Button("Cancel", gui::kDefaultModalSize)) {
166 Hide("Save As..");
167 }
168}
169
171 static std::string save_as_filename = "";
172 InputText("Project Name", &save_as_filename);
173
174 // These would need to be implemented in the editor manager
175 if (Button("Destination Filepath", gui::kDefaultModalSize)) {
176 // Call file dialog
177 }
178 SameLine();
179 Text("%s", "filepath"); // This would be from the editor manager
180
181 if (Button("ROM File", gui::kDefaultModalSize)) {
182 // Call file dialog
183 }
184 SameLine();
185 Text("%s", "rom_filename"); // This would be from the editor manager
186
187 if (Button("Labels File", gui::kDefaultModalSize)) {
188 // Call file dialog
189 }
190 SameLine();
191 Text("%s", "labels_filename"); // This would be from the editor manager
192
193 if (Button("Code Folder", gui::kDefaultModalSize)) {
194 // Call file dialog
195 }
196 SameLine();
197 Text("%s", "code_folder"); // This would be from the editor manager
198
199 Separator();
200 if (Button("Create", gui::kDefaultModalSize)) {
201 // Create project
202 Hide("New Project");
203 }
204 SameLine();
205 if (Button("Cancel", gui::kDefaultModalSize)) {
206 Hide("New Project");
207 }
208}
209
211 if (CollapsingHeader(absl::StrFormat("%s Overworld Editor", ICON_MD_LAYERS).c_str(), ImGuiTreeNodeFlags_DefaultOpen)) {
212 BulletText("LW/DW/SW Tilemap Editing");
213 BulletText("LW/DW/SW Map Properties");
214 BulletText("Create/Delete/Update Entrances");
215 BulletText("Create/Delete/Update Exits");
216 BulletText("Create/Delete/Update Sprites");
217 BulletText("Create/Delete/Update Items");
218 BulletText("Multi-session map editing support");
219 }
220
221 if (CollapsingHeader(absl::StrFormat("%s Dungeon Editor", ICON_MD_CASTLE).c_str())) {
222 BulletText("View Room Header Properties");
223 BulletText("View Entrance Properties");
224 BulletText("Enhanced room navigation");
225 }
226
227 if (CollapsingHeader(absl::StrFormat("%s Graphics & Themes", ICON_MD_PALETTE).c_str())) {
228 BulletText("View Decompressed Graphics Sheets");
229 BulletText("View/Update Graphics Groups");
230 BulletText("5+ Built-in themes (Classic, Cyberpunk, Sunset, Forest, Midnight)");
231 BulletText("Custom theme creation and editing");
232 BulletText("Theme import/export functionality");
233 BulletText("Animated background grid effects");
234 }
235
236 if (CollapsingHeader(absl::StrFormat("%s Palettes", ICON_MD_COLOR_LENS).c_str())) {
237 BulletText("View Palette Groups");
238 BulletText("Enhanced palette editing tools");
239 BulletText("Color conversion utilities");
240 }
241
242 if (CollapsingHeader(absl::StrFormat("%s Project Management", ICON_MD_FOLDER).c_str())) {
243 BulletText("Multi-session workspace support");
244 BulletText("Enhanced project creation and management");
245 BulletText("ZScream project format compatibility");
246 BulletText("Workspace settings and feature flags");
247 }
248
249 if (CollapsingHeader(absl::StrFormat("%s Development Tools", ICON_MD_BUILD).c_str())) {
250 BulletText("Asar 65816 assembler integration");
251 BulletText("Enhanced CLI tools with TUI interface");
252 BulletText("Memory editor with advanced features");
253 BulletText("Hex editor with search and navigation");
254 BulletText("Assembly validation and symbol extraction");
255 }
256
257 if (CollapsingHeader(absl::StrFormat("%s Save Capabilities", ICON_MD_SAVE).c_str())) {
258 BulletText("All Overworld editing features");
259 BulletText("Hex Editor changes");
260 BulletText("Theme configurations");
261 BulletText("Project settings and workspace layouts");
262 BulletText("Custom assembly patches");
263 }
264
265 if (Button("Close", gui::kDefaultModalSize)) {
266 Hide("Supported Features");
267 }
268}
269
271 Text("File -> Open");
272 Text("Select a ROM file to open");
273 Text("Supported ROMs (headered or unheadered):");
274 Text("The Legend of Zelda: A Link to the Past");
275 Text("US Version 1.0");
276 Text("JP Version 1.0");
277
278 if (Button("Close", gui::kDefaultModalSize)) {
279 Hide("Open a ROM");
280 }
281}
282
284 Text("Project Menu");
285 Text("Create a new project or open an existing one.");
286 Text("Save the project to save the current state of the project.");
287 TextWrapped(
288 "To save a project, you need to first open a ROM and initialize your "
289 "code path and labels file. Label resource manager can be found in "
290 "the View menu. Code path is set in the Code editor after opening a "
291 "folder.");
292
293 if (Button("Close", gui::kDefaultModalSize)) {
294 Hide("Manage Project");
295 }
296}
297
299 TextWrapped("Welcome to YAZE v0.3!");
300 TextWrapped("This software allows you to modify 'The Legend of Zelda: A Link to the Past' (US or JP) ROMs.");
301 Spacing();
302 TextWrapped("General Tips:");
303 BulletText("Experiment flags determine whether certain features are enabled");
304 BulletText("Backup files are enabled by default for safety");
305 BulletText("Use File > Options to configure settings");
306
307 if (Button("Close", gui::kDefaultModalSize)) {
308 Hide("Getting Started");
309 }
310}
311
313 TextWrapped("Asar 65816 Assembly Integration");
314 TextWrapped("YAZE v0.3 includes full Asar assembler support for ROM patching.");
315 Spacing();
316 TextWrapped("Features:");
317 BulletText("Cross-platform ROM patching with assembly code");
318 BulletText("Symbol extraction with addresses and opcodes");
319 BulletText("Assembly validation with error reporting");
320 BulletText("Memory-safe operations with automatic ROM size management");
321
322 if (Button("Close", gui::kDefaultModalSize)) {
323 Hide("Asar Integration");
324 }
325}
326
328 TextWrapped("Build Instructions");
329 TextWrapped("YAZE uses modern CMake for cross-platform builds.");
330 Spacing();
331 TextWrapped("Quick Start:");
332 BulletText("cmake -B build");
333 BulletText("cmake --build build --target yaze");
334 Spacing();
335 TextWrapped("Development:");
336 BulletText("cmake --preset dev");
337 BulletText("cmake --build --preset dev");
338
339 if (Button("Close", gui::kDefaultModalSize)) {
340 Hide("Build Instructions");
341 }
342}
343
345 TextWrapped("Command Line Interface (z3ed)");
346 TextWrapped("Enhanced CLI tool with Asar integration.");
347 Spacing();
348 TextWrapped("Commands:");
349 BulletText("z3ed asar patch.asm --rom=file.sfc");
350 BulletText("z3ed extract symbols.asm");
351 BulletText("z3ed validate assembly.asm");
352 BulletText("z3ed patch file.bps --rom=file.sfc");
353
354 if (Button("Close", gui::kDefaultModalSize)) {
355 Hide("CLI Usage");
356 }
357}
358
360 TextWrapped("Troubleshooting");
361 TextWrapped("Common issues and solutions:");
362 Spacing();
363 BulletText("ROM won't load: Check file format (SFC/SMC supported)");
364 BulletText("Graphics issues: Try disabling experimental features");
365 BulletText("Performance: Enable hardware acceleration in display settings");
366 BulletText("Crashes: Check ROM file integrity and available memory");
367
368 if (Button("Close", gui::kDefaultModalSize)) {
369 Hide("Troubleshooting");
370 }
371}
372
374 TextWrapped("Contributing to YAZE");
375 TextWrapped("YAZE is open source and welcomes contributions!");
376 Spacing();
377 TextWrapped("How to contribute:");
378 BulletText("Fork the repository on GitHub");
379 BulletText("Create feature branches for new work");
380 BulletText("Follow C++ coding standards");
381 BulletText("Include tests for new features");
382 BulletText("Submit pull requests for review");
383
384 if (Button("Close", gui::kDefaultModalSize)) {
385 Hide("Contributing");
386 }
387}
388
390 TextWrapped("What's New in YAZE v0.3");
391 Spacing();
392
393 if (CollapsingHeader(absl::StrFormat("%s User Interface & Theming", ICON_MD_PALETTE).c_str(), ImGuiTreeNodeFlags_DefaultOpen)) {
394 BulletText("Complete theme management system with 5+ built-in themes");
395 BulletText("Custom theme editor with save-to-file functionality");
396 BulletText("Animated background grid with breathing effects (optional)");
397 BulletText("Enhanced welcome screen with themed elements");
398 BulletText("Multi-session workspace support with docking");
399 BulletText("Improved editor organization and navigation");
400 }
401
402 if (CollapsingHeader(absl::StrFormat("%s Development & Build System", ICON_MD_BUILD).c_str(), ImGuiTreeNodeFlags_DefaultOpen)) {
403 BulletText("Asar 65816 assembler integration for ROM patching");
404 BulletText("Enhanced CLI tools with TUI (Terminal User Interface)");
405 BulletText("Modernized CMake build system with presets");
406 BulletText("Cross-platform CI/CD pipeline (Windows, macOS, Linux)");
407 BulletText("Comprehensive testing framework with 46+ core tests");
408 BulletText("Professional packaging for all platforms (DMG, MSI, DEB)");
409 }
410
411 if (CollapsingHeader(absl::StrFormat("%s Core Improvements", ICON_MD_SETTINGS).c_str())) {
412 BulletText("Enhanced project management with YazeProject structure");
413 BulletText("Improved ROM loading and validation");
414 BulletText("Better error handling and status reporting");
415 BulletText("Memory safety improvements with sanitizers");
416 BulletText("Enhanced file dialog integration");
417 BulletText("Improved logging and debugging capabilities");
418 }
419
420 if (CollapsingHeader(absl::StrFormat("%s Editor Features", ICON_MD_EDIT).c_str())) {
421 BulletText("Enhanced overworld editing capabilities");
422 BulletText("Improved graphics sheet viewing and editing");
423 BulletText("Better palette management and editing");
424 BulletText("Enhanced memory and hex editing tools");
425 BulletText("Improved sprite and item management");
426 BulletText("Better entrance and exit editing");
427 }
428
429 Spacing();
430 if (Button(absl::StrFormat("%s View Theme Editor", ICON_MD_PALETTE).c_str(), ImVec2(-1, 30))) {
431 // Close this popup and show theme settings
432 Hide("Whats New v03");
433 // Could trigger theme editor opening here
434 }
435
436 if (Button("Close", gui::kDefaultModalSize)) {
437 Hide("Whats New v03");
438 }
439}
440
442 TextWrapped("Workspace Management");
443 TextWrapped("YAZE supports multiple ROM sessions and flexible workspace layouts.");
444 Spacing();
445
446 TextWrapped("Session Management:");
447 BulletText("Ctrl+Shift+N: Create new session");
448 BulletText("Ctrl+Shift+W: Close current session");
449 BulletText("Ctrl+Tab: Quick session switcher");
450 BulletText("Each session maintains its own ROM and editor state");
451
452 Spacing();
453 TextWrapped("Layout Management:");
454 BulletText("Drag window tabs to dock/undock");
455 BulletText("Ctrl+Shift+S: Save current layout");
456 BulletText("Ctrl+Shift+O: Load saved layout");
457 BulletText("F11: Maximize current window");
458
459 Spacing();
460 TextWrapped("Preset Layouts:");
461 BulletText("Developer: Code, memory, testing tools");
462 BulletText("Designer: Graphics, palettes, sprites");
463 BulletText("Modder: All gameplay editing tools");
464
465 if (Button("Close", gui::kDefaultModalSize)) {
466 Hide("Workspace Help");
467 }
468}
469
471 TextColored(ImVec4(1.0f, 0.5f, 0.0f, 1.0f), "%s Warning", ICON_MD_WARNING);
472 TextWrapped("You have reached the recommended session limit.");
473 TextWrapped("Having too many sessions open may impact performance.");
474 Spacing();
475 TextWrapped("Consider closing unused sessions or saving your work.");
476
477 if (Button("Understood", gui::kDefaultModalSize)) {
478 Hide("Session Limit Warning");
479 }
480 SameLine();
481 if (Button("Open Session Manager", gui::kDefaultModalSize)) {
482 Hide("Session Limit Warning");
483 // This would trigger the session manager to open
484 }
485}
486
488 TextColored(ImVec4(1.0f, 0.5f, 0.0f, 1.0f), "%s Confirm Reset", ICON_MD_WARNING);
489 TextWrapped("This will reset your current workspace layout to default.");
490 TextWrapped("Any custom window arrangements will be lost.");
491 Spacing();
492 TextWrapped("Do you want to continue?");
493
494 if (Button("Reset Layout", gui::kDefaultModalSize)) {
495 Hide("Layout Reset Confirm");
496 // This would trigger the actual reset
497 }
498 SameLine();
499 if (Button("Cancel", gui::kDefaultModalSize)) {
500 Hide("Layout Reset Confirm");
501 }
502}
503
505 // Set a comfortable default size with natural constraints
506 SetNextWindowSize(ImVec2(900, 700), ImGuiCond_FirstUseEver);
507 SetNextWindowSizeConstraints(ImVec2(600, 400), ImVec2(FLT_MAX, FLT_MAX));
508
509 Text("%s Display & Theme Settings", ICON_MD_DISPLAY_SETTINGS);
510 TextWrapped("Customize your YAZE experience - accessible anytime!");
511 Separator();
512
513 // Create a child window for scrollable content to avoid table conflicts
514 // Use remaining space minus the close button area
515 float available_height = GetContentRegionAvail().y - 60; // Reserve space for close button
516 if (BeginChild("DisplaySettingsContent", ImVec2(0, available_height), true, ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
517 // Use the popup-safe version to avoid table conflicts
519
520 Separator();
521 gui::TextWithSeparators("Font Manager");
523
524 // Global font scale (moved from the old display settings window)
525 ImGuiIO &io = GetIO();
526 Separator();
527 Text("Global Font Scale");
528 static float font_global_scale = io.FontGlobalScale;
529 if (SliderFloat("##global_scale", &font_global_scale, 0.5f, 1.8f, "%.2f")) {
530 if (editor_manager_) {
531 editor_manager_->SetFontGlobalScale(font_global_scale);
532 } else {
533 io.FontGlobalScale = font_global_scale;
534 }
535 }
536 }
537 EndChild();
538
539 Separator();
540 if (Button("Close", gui::kDefaultModalSize)) {
541 Hide("Display Settings");
542 }
543}
544
545} // namespace editor
546} // namespace yaze
The EditorManager controls the main editor window and manages the various editor classes.
void SetFontGlobalScale(float scale)
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)
#define ICON_MD_SETTINGS
Definition icons.h:1697
#define ICON_MD_WARNING
Definition icons.h:2121
#define ICON_MD_EDIT
Definition icons.h:643
#define ICON_MD_CASTLE
Definition icons.h:378
#define ICON_MD_ERROR
Definition icons.h:684
#define ICON_MD_LAYERS
Definition icons.h:1066
#define ICON_MD_DISPLAY_SETTINGS
Definition icons.h:585
#define ICON_MD_BUILD
Definition icons.h:326
#define ICON_MD_SAVE
Definition icons.h:1642
#define ICON_MD_FOLDER
Definition icons.h:807
#define ICON_MD_PALETTE
Definition icons.h:1368
#define ICON_MD_CONTENT_COPY
Definition icons.h:463
#define ICON_MD_COLOR_LENS
Definition icons.h:438
Definition input.cc:20
void DrawFontManager()
Definition style.cc:1286
void DrawDisplaySettingsForPopup(ImGuiStyle *ref)
Definition style.cc:842
constexpr ImVec2 kDefaultModalSize
Definition input.h:21
void TextWithSeparators(const absl::string_view &text)
Definition style.cc:1280
std::string HexLongLong(uint64_t qword, HexStringParams params)
Definition hex.cc:63
Main namespace for the application.