yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
welcome_screen.cc
Go to the documentation of this file.
2#include "util/i18n/tr.h"
3
4#include <algorithm>
5#include <cmath>
6#include <cstdint>
7#include <string>
8
9#include "absl/strings/str_format.h"
10#include "absl/time/clock.h"
11#include "absl/time/time.h"
13#include "app/gui/core/icons.h"
18#include "app/platform/timing.h"
19#include "imgui/imgui.h"
20#include "imgui/imgui_internal.h"
21#include "util/file_util.h"
22#include "util/log.h"
23
24#ifndef M_PI
25#define M_PI 3.14159265358979323846
26#endif
27
28namespace yaze {
29namespace editor {
30
31namespace {
32
33// Zelda-inspired color palette (fallbacks)
34const ImVec4 kTriforceGoldFallback = ImVec4(1.0f, 0.843f, 0.0f, 1.0f);
35const ImVec4 kHyruleGreenFallback = ImVec4(0.133f, 0.545f, 0.133f, 1.0f);
36const ImVec4 kMasterSwordBlueFallback = ImVec4(0.196f, 0.6f, 0.8f, 1.0f);
37const ImVec4 kGanonPurpleFallback = ImVec4(0.502f, 0.0f, 0.502f, 1.0f);
38const ImVec4 kHeartRedFallback = ImVec4(0.863f, 0.078f, 0.235f, 1.0f);
39const ImVec4 kSpiritOrangeFallback = ImVec4(1.0f, 0.647f, 0.0f, 1.0f);
40const ImVec4 kShadowPurpleFallback = ImVec4(0.416f, 0.353f, 0.804f, 1.0f);
41
42constexpr float kRecentCardBaseWidth = 240.0f;
43constexpr float kRecentCardBaseHeight = 128.0f;
44constexpr float kRecentCardWidthMaxFactor = 1.30f;
45constexpr float kRecentCardHeightMaxFactor = 1.30f;
46
47// Active colors (updated each frame from theme)
55
57 auto& theme_mgr = gui::ThemeManager::Get();
58 // Skip the palette recompute when the active theme hasn't changed. The
59 // welcome screen ran this every frame previously, doing 7 ImLerps + 6
60 // Color-to-ImVec4 conversions; cheap individually but pure waste while the
61 // theme is static (almost always).
62 static std::string s_cached_theme_name;
63 static bool s_cached_once = false;
64 const std::string& current_name = theme_mgr.GetCurrentThemeName();
65 if (s_cached_once && current_name == s_cached_theme_name) {
66 return;
67 }
68 s_cached_theme_name = current_name;
69 s_cached_once = true;
70
71 const auto& theme = theme_mgr.GetCurrentTheme();
72
73 const ImVec4 secondary = gui::ConvertColorToImVec4(theme.secondary);
74 const ImVec4 accent = gui::ConvertColorToImVec4(theme.accent);
75 const ImVec4 warning = gui::ConvertColorToImVec4(theme.warning);
76 const ImVec4 success = gui::ConvertColorToImVec4(theme.success);
77 const ImVec4 info = gui::ConvertColorToImVec4(theme.info);
78 const ImVec4 error = gui::ConvertColorToImVec4(theme.error);
79 const ImVec4 surface = gui::GetSurfaceVec4();
80
81 // Welcome accent palette: themed, but with distinct flavor per role.
82 kTriforceGold = ImLerp(accent, warning, 0.55f);
83 kHyruleGreen = success;
84 kMasterSwordBlue = info;
85 kGanonPurple = secondary;
86 kHeartRed = error;
87 kSpiritOrange = ImLerp(warning, accent, 0.35f);
88 kShadowPurple = ImLerp(secondary, surface, 0.45f);
89}
90
91// Truncate `text` to fit within `max_width` pixels, appending "..." if clipped.
92// Uses binary search over byte positions; CalcTextSize is invoked at most
93// log2(N) times per call instead of the previous O(N) pop_back loop that
94// re-measured the string after every character removal.
95std::string EllipsizeText(const std::string& text, float max_width) {
96 if (text.empty())
97 return std::string();
98 if (ImGui::CalcTextSize(text.c_str()).x <= max_width)
99 return text;
100
101 static constexpr const char* kEllipsis = "...";
102 const float ellipsis_w = ImGui::CalcTextSize(kEllipsis).x;
103 if (ellipsis_w > max_width)
104 return std::string(kEllipsis);
105
106 const float budget = max_width - ellipsis_w;
107
108 // Binary search the longest byte-prefix whose width is <= budget.
109 // Note: this splits by bytes, not code points; for ASCII-only titles (the
110 // common case here) that is exact. For UTF-8 multi-byte sequences we nudge
111 // the split point back to a code-point boundary after the search.
112 size_t lo = 0;
113 size_t hi = text.size();
114 std::string buffer;
115 buffer.reserve(text.size());
116 while (lo < hi) {
117 size_t mid = lo + (hi - lo + 1) / 2;
118 buffer.assign(text, 0, mid);
119 if (ImGui::CalcTextSize(buffer.c_str()).x <= budget) {
120 lo = mid;
121 } else {
122 hi = mid - 1;
123 }
124 }
125
126 // Pull back off any UTF-8 continuation bytes so we don't split a codepoint.
127 while (lo > 0 && (static_cast<unsigned char>(text[lo]) & 0xC0) == 0x80) {
128 --lo;
129 }
130
131 if (lo == 0)
132 return std::string(kEllipsis);
133 buffer.assign(text, 0, lo);
134 buffer.append(kEllipsis);
135 return buffer;
136}
137
138// Draw a pixelated triforce in the background (ALTTP style)
139void DrawTriforceBackground(ImDrawList* draw_list, ImVec2 pos, float size,
140 float alpha, float glow) {
141 // Make it pixelated - round size to nearest 4 pixels
142 size = std::round(size / 4.0f) * 4.0f;
143
144 // Calculate triangle points with pixel-perfect positioning
145 auto triangle = [&](ImVec2 center, float s, ImU32 color) {
146 // Round to pixel boundaries for crisp edges
147 float half_s = s / 2.0f;
148 float tri_h = s * 0.866f; // Height of equilateral triangle
149
150 // Fixed: Proper equilateral triangle with apex at top
151 ImVec2 p1(std::round(center.x),
152 std::round(center.y - tri_h / 2.0f)); // Top apex
153 ImVec2 p2(std::round(center.x - half_s),
154 std::round(center.y + tri_h / 2.0f)); // Bottom left
155 ImVec2 p3(std::round(center.x + half_s),
156 std::round(center.y + tri_h / 2.0f)); // Bottom right
157
158 draw_list->AddTriangleFilled(p1, p2, p3, color);
159 };
160
161 ImVec4 gold_color = kTriforceGold;
162 gold_color.w = alpha;
163 ImU32 gold = ImGui::GetColorU32(gold_color);
164
165 // Proper triforce layout with three triangles
166 float small_size = size / 2.0f;
167 float small_height = small_size * 0.866f;
168
169 // Top triangle (centered above)
170 triangle(ImVec2(pos.x, pos.y), small_size, gold);
171
172 // Bottom left triangle
173 triangle(ImVec2(pos.x - small_size / 2.0f, pos.y + small_height), small_size,
174 gold);
175
176 // Bottom right triangle
177 triangle(ImVec2(pos.x + small_size / 2.0f, pos.y + small_height), small_size,
178 gold);
179}
180
182 int columns = 1;
183 float item_width = 0.0f;
184 float item_height = 0.0f;
185 float spacing = 0.0f;
186 float row_start_x = 0.0f;
187};
188
189GridLayout ComputeGridLayout(float avail_width, float min_width,
190 float max_width, float min_height,
191 float max_height, float preferred_width,
192 float aspect_ratio, float spacing) {
193 GridLayout layout;
194 layout.spacing = spacing;
195 const auto width_for_columns = [avail_width, spacing](int columns) {
196 return (avail_width - spacing * static_cast<float>(columns - 1)) /
197 static_cast<float>(columns);
198 };
199
200 layout.columns = std::max(1, static_cast<int>((avail_width + spacing) /
201 (preferred_width + spacing)));
202
203 layout.item_width = width_for_columns(layout.columns);
204 while (layout.columns > 1 && layout.item_width < min_width) {
205 layout.columns -= 1;
206 layout.item_width = width_for_columns(layout.columns);
207 }
208
209 layout.item_width = std::min(layout.item_width, max_width);
210 layout.item_width = std::min(layout.item_width, avail_width);
211 layout.item_height =
212 std::clamp(layout.item_width * aspect_ratio, min_height, max_height);
213
214 const float row_width =
215 layout.item_width * static_cast<float>(layout.columns) +
216 spacing * static_cast<float>(layout.columns - 1);
217 layout.row_start_x = ImGui::GetCursorPosX();
218 if (row_width < avail_width) {
219 layout.row_start_x += (avail_width - row_width) * 0.5f;
220 }
221
222 return layout;
223}
224
225void DrawThemeQuickSwitcher(const char* popup_id, const ImVec2& button_size) {
226 auto& theme_mgr = gui::ThemeManager::Get();
227 const std::string button_label = absl::StrFormat(
228 "%s Theme: %s", ICON_MD_PALETTE, theme_mgr.GetCurrentThemeName());
229
230 if (gui::ThemedButton(button_label.c_str(), button_size, "welcome_screen",
231 "theme_quick_switch")) {
232 ImGui::OpenPopup(popup_id);
233 }
234
235 if (ImGui::BeginPopup(popup_id)) {
236 auto themes = theme_mgr.GetAvailableThemes();
237 std::sort(themes.begin(), themes.end());
238
239 for (const auto& name : themes) {
240 if (ImGui::Selectable(name.c_str(),
241 theme_mgr.GetCurrentThemeName() == name)) {
242 if (theme_mgr.IsPreviewActive()) {
243 theme_mgr.EndPreview();
244 }
245 theme_mgr.ApplyTheme(name);
246 }
247 if (ImGui::IsItemHovered() && (!theme_mgr.IsPreviewActive() ||
248 theme_mgr.GetCurrentThemeName() != name)) {
249 theme_mgr.StartPreview(name);
250 }
251 }
252
253 ImGui::EndPopup();
254 } else if (theme_mgr.IsPreviewActive()) {
255 theme_mgr.EndPreview();
256 }
257}
258
259} // namespace
260
264
266 user_settings_ = settings;
267 if (!user_settings_)
268 return;
269 const auto& prefs = user_settings_->prefs();
271 triforce_speed_multiplier_ = prefs.welcome_triforce_speed;
272 triforce_size_multiplier_ = prefs.welcome_triforce_size;
273 particles_enabled_ = prefs.welcome_particles_enabled;
274 triforce_mouse_repel_enabled_ = prefs.welcome_mouse_repel_enabled;
275}
276
278 if (!user_settings_)
279 return;
280 auto& prefs = user_settings_->prefs();
282 prefs.welcome_triforce_speed = triforce_speed_multiplier_;
283 prefs.welcome_triforce_size = triforce_size_multiplier_;
284 prefs.welcome_particles_enabled = particles_enabled_;
285 prefs.welcome_mouse_repel_enabled = triforce_mouse_repel_enabled_;
286 auto status = user_settings_->Save();
287 if (!status.ok()) {
288 LOG_WARN("WelcomeScreen", "Failed to persist animation settings: %s",
289 status.ToString().c_str());
290 }
291}
292
293// Helper function to calculate staggered animation progress
294float GetStaggeredEntryProgress(float entry_time, int section_index,
295 float duration, float stagger_delay) {
296 float section_start = section_index * stagger_delay;
297 float section_time = entry_time - section_start;
298 if (section_time < 0.0f) {
299 return 0.0f;
300 }
301 float progress = std::min(section_time / duration, 1.0f);
302 // Use EaseOutCubic for smooth deceleration
303 float inv = 1.0f - progress;
304 return 1.0f - (inv * inv * inv);
305}
306
307bool WelcomeScreen::Show(bool* p_open) {
308 // Update theme colors each frame
309 UpdateWelcomeAccentPalette();
310
311 // Update entry animation time
313 entry_time_ = 0.0f;
315 }
316 entry_time_ += ImGui::GetIO().DeltaTime;
317
319
320 // Get mouse position for interactive triforce movement
321 ImVec2 mouse_pos = ImGui::GetMousePos();
322
323 bool action_taken = false;
324
325 // Center the window within the dockspace region (accounting for sidebars)
326 ImGuiViewport* viewport = ImGui::GetMainViewport();
327 ImVec2 viewport_size = viewport->WorkSize;
328
329 // Calculate the dockspace region (excluding sidebars)
330 float dockspace_x = viewport->WorkPos.x + left_offset_;
331 float dockspace_width = viewport_size.x - left_offset_ - right_offset_;
332 if (dockspace_width < 200.0f) {
333 dockspace_x = viewport->WorkPos.x;
334 dockspace_width = viewport_size.x;
335 }
336 float dockspace_center_x = dockspace_x + dockspace_width / 2.0f;
337 float dockspace_center_y = viewport->WorkPos.y + viewport_size.y / 2.0f;
338 ImVec2 center(dockspace_center_x, dockspace_center_y);
339
340 // Size based on dockspace region, not full viewport. Clamps scale with the
341 // current font size so high-DPI users and font-scaled layouts get a
342 // proportionally sized window instead of a cramped 480px minimum.
343 const float font_scale = ImGui::GetFontSize() / 16.0f;
344 float width = std::clamp(dockspace_width * 0.85f, 480.0f * font_scale,
345 1400.0f * font_scale);
346 float height = std::clamp(viewport_size.y * 0.85f, 360.0f * font_scale,
347 1050.0f * font_scale);
348
349 ImGui::SetNextWindowPos(center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
350 ImGui::SetNextWindowSize(ImVec2(width, height), ImGuiCond_Always);
351
352 // Window flags: allow menu bar to be clickable by not bringing to front
353 ImGuiWindowFlags window_flags =
354 ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize |
355 ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus |
356 ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
357
358 gui::StyleVarGuard window_padding_guard(ImGuiStyleVar_WindowPadding,
359 ImVec2(20, 20));
360
361 if (ImGui::Begin("##WelcomeScreen", p_open, window_flags)) {
362 // Esc dismisses the welcome screen when it (or one of its children) has
363 // focus. Avoids stealing Esc globally, which would conflict with other
364 // editors that use it for their own "cancel current interaction" flow.
365 if (p_open != nullptr &&
366 ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
367 ImGui::IsKeyPressed(ImGuiKey_Escape, /*repeat=*/false)) {
368 *p_open = false;
369 }
370
371 ImDrawList* bg_draw_list = ImGui::GetWindowDrawList();
372 ImVec2 window_pos = ImGui::GetWindowPos();
373 ImVec2 window_size = ImGui::GetWindowSize();
374
375 // Interactive scattered triforces (react to mouse position)
376 struct TriforceConfig {
377 float x_pct, y_pct; // Base position (percentage of window)
378 float size;
379 float alpha;
380 float repel_distance; // How far they move away from mouse
381 };
382
383 TriforceConfig triforce_configs[] = {
384 {0.08f, 0.12f, 36.0f, 0.025f, 50.0f}, // Top left corner
385 {0.92f, 0.15f, 34.0f, 0.022f, 50.0f}, // Top right corner
386 {0.06f, 0.88f, 32.0f, 0.020f, 45.0f}, // Bottom left
387 {0.94f, 0.85f, 34.0f, 0.023f, 50.0f}, // Bottom right
388 {0.50f, 0.08f, 38.0f, 0.028f, 55.0f}, // Top center
389 {0.50f, 0.92f, 32.0f, 0.020f, 45.0f}, // Bottom center
390 };
391
392 // Initialize base positions on first frame
394 for (int i = 0; i < kNumTriforces; ++i) {
395 float x = window_pos.x + window_size.x * triforce_configs[i].x_pct;
396 float y = window_pos.y + window_size.y * triforce_configs[i].y_pct;
397 triforce_base_positions_[i] = ImVec2(x, y);
399 }
401 }
402
403 // Skip the triforce background entirely when the user has faded it out.
404 // The alpha_multiplier slider at 0 should mean "no work at all", not
405 // "compute positions and draw transparent triangles".
406 const bool triforces_visible = triforce_alpha_multiplier_ > 0.001f;
407
408 // Update triforce positions based on mouse interaction + floating animation
409 for (int i = 0; triforces_visible && i < kNumTriforces; ++i) {
410 // Update base position in case window moved/resized
411 float base_x = window_pos.x + window_size.x * triforce_configs[i].x_pct;
412 float base_y = window_pos.y + window_size.y * triforce_configs[i].y_pct;
413 triforce_base_positions_[i] = ImVec2(base_x, base_y);
414
415 // Slow, subtle floating animation
416 float time_offset = i * 1.2f; // Offset each triforce's animation
417 float float_speed_x =
418 (0.15f + (i % 2) * 0.1f) * triforce_speed_multiplier_; // Very slow
419 float float_speed_y =
420 (0.12f + ((i + 1) % 2) * 0.08f) * triforce_speed_multiplier_;
421 float float_amount_x = (20.0f + (i % 2) * 10.0f) *
422 triforce_size_multiplier_; // Smaller amplitude
423 float float_amount_y =
424 (25.0f + ((i + 1) % 2) * 15.0f) * triforce_size_multiplier_;
425
426 // Create gentle orbital motion
427 float float_x = std::sin(animation_time_ * float_speed_x + time_offset) *
428 float_amount_x;
429 float float_y =
430 std::cos(animation_time_ * float_speed_y + time_offset * 1.2f) *
431 float_amount_y;
432
433 // Calculate distance from mouse
434 float dx = triforce_base_positions_[i].x - mouse_pos.x;
435 float dy = triforce_base_positions_[i].y - mouse_pos.y;
436 float dist = std::sqrt(dx * dx + dy * dy);
437
438 // Calculate repulsion offset with stronger effect
439 ImVec2 target_pos = triforce_base_positions_[i];
440 float repel_radius =
441 200.0f; // Larger radius for more visible interaction
442
443 // Add floating motion to base position
444 target_pos.x += float_x;
445 target_pos.y += float_y;
446
447 // Apply mouse repulsion if enabled
448 if (triforce_mouse_repel_enabled_ && dist < repel_radius && dist > 0.1f) {
449 // Normalize direction away from mouse
450 float dir_x = dx / dist;
451 float dir_y = dy / dist;
452
453 // Much stronger repulsion when closer with exponential falloff
454 float normalized_dist = dist / repel_radius;
455 float repel_strength = (1.0f - normalized_dist * normalized_dist) *
456 triforce_configs[i].repel_distance;
457
458 target_pos.x += dir_x * repel_strength;
459 target_pos.y += dir_y * repel_strength;
460 }
461
462 // Smooth interpolation to target position (faster response)
463 // Use TimingManager for accurate delta time
464 float lerp_speed = 8.0f * yaze::TimingManager::Get().GetDeltaTime();
465 triforce_positions_[i].x +=
466 (target_pos.x - triforce_positions_[i].x) * lerp_speed;
467 triforce_positions_[i].y +=
468 (target_pos.y - triforce_positions_[i].y) * lerp_speed;
469
470 // Draw at current position with alpha multiplier. Skip issuing draw
471 // commands for alphas that would quantize to 0 in an 8-bit color.
472 float adjusted_alpha =
473 triforce_configs[i].alpha * triforce_alpha_multiplier_;
474 if (adjusted_alpha < (1.0f / 255.0f)) {
475 continue;
476 }
477 float adjusted_size =
478 triforce_configs[i].size * triforce_size_multiplier_;
479 DrawTriforceBackground(bg_draw_list, triforce_positions_[i],
480 adjusted_size, adjusted_alpha, 0.0f);
481 }
482
483 // Update and draw particle system. Also skipped when the triforce alpha
484 // multiplier is 0, because particles inherit that alpha — drawing them
485 // invisibly is pure overhead.
486 if (particles_enabled_ && triforces_visible) {
487 // Spawn new particles
489 ImGui::GetIO().DeltaTime * particle_spawn_rate_;
490 while (particle_spawn_accumulator_ >= 1.0f &&
492 // Find inactive particle slot
493 for (int i = 0; i < kMaxParticles; ++i) {
494 if (particles_[i].lifetime <= 0.0f) {
495 // Spawn from random triforce
496 int source_triforce = rand() % kNumTriforces;
497 particles_[i].position = triforce_positions_[source_triforce];
498
499 // Random direction and speed
500 float angle = (rand() % 360) * (M_PI / 180.0f);
501 float speed = 20.0f + (rand() % 40);
503 ImVec2(std::cos(angle) * speed, std::sin(angle) * speed);
504
505 particles_[i].size = 2.0f + (rand() % 4);
506 particles_[i].alpha = 0.4f + (rand() % 40) / 100.0f;
507 particles_[i].max_lifetime = 2.0f + (rand() % 30) / 10.0f;
510 break;
511 }
512 }
514 }
515
516 // Update and draw particles
517 float dt = ImGui::GetIO().DeltaTime;
518 for (int i = 0; i < kMaxParticles; ++i) {
519 if (particles_[i].lifetime > 0.0f) {
520 // Update lifetime
521 particles_[i].lifetime -= dt;
522 if (particles_[i].lifetime <= 0.0f) {
524 continue;
525 }
526
527 // Update position
528 particles_[i].position.x += particles_[i].velocity.x * dt;
529 particles_[i].position.y += particles_[i].velocity.y * dt;
530
531 // Fade out near end of life
532 float life_ratio =
534 float alpha =
536
537 // Draw particle as small golden circle
538 ImU32 particle_color = ImGui::GetColorU32(
539 ImVec4(kTriforceGold.x, kTriforceGold.y, kTriforceGold.z, alpha));
540 bg_draw_list->AddCircleFilled(particles_[i].position,
541 particles_[i].size, particle_color, 8);
542 }
543 }
544 }
545
546 DrawHeader();
547
548 ImGui::Spacing();
549 ImGui::Spacing();
550
551 // Main content area with subtle gradient separator
552 ImDrawList* draw_list = ImGui::GetWindowDrawList();
553 ImVec2 separator_start = ImGui::GetCursorScreenPos();
554 ImVec2 separator_end(separator_start.x + ImGui::GetContentRegionAvail().x,
555 separator_start.y + 1);
556 ImVec4 gold_faded = kTriforceGold;
557 gold_faded.w = 0.18f;
558 ImVec4 blue_faded = kMasterSwordBlue;
559 blue_faded.w = 0.18f;
560 draw_list->AddRectFilledMultiColor(
561 separator_start, separator_end, ImGui::GetColorU32(gold_faded),
562 ImGui::GetColorU32(blue_faded), ImGui::GetColorU32(blue_faded),
563 ImGui::GetColorU32(gold_faded));
564
565 ImGui::Dummy(ImVec2(0, 14));
566
567 ImGui::BeginChild("WelcomeContent", ImVec2(0, -40), false);
568 const float content_width = ImGui::GetContentRegionAvail().x;
569 const float content_height = ImGui::GetContentRegionAvail().y;
570 const bool narrow_layout = content_width < 900.0f;
571 const float layout_scale = ImGui::GetFontSize() / 16.0f;
572
573 if (narrow_layout) {
574 const float quick_actions_h = std::clamp(
575 content_height * 0.35f, 160.0f * layout_scale, 300.0f * layout_scale);
576 const float release_h = std::clamp(
577 content_height * 0.32f, 160.0f * layout_scale, 320.0f * layout_scale);
578
579 ImGui::BeginChild("QuickActionsNarrow", ImVec2(0, quick_actions_h), true,
580 ImGuiWindowFlags_NoScrollbar);
583 ImGui::EndChild();
584
585 ImGui::Spacing();
586
587 ImGui::BeginChild("ReleaseHistoryNarrow", ImVec2(0, release_h), true);
588 DrawWhatsNew();
589 ImGui::EndChild();
590
591 ImGui::Spacing();
592
593 ImGui::BeginChild("RecentPanelNarrow", ImVec2(0, 0), true);
595 ImGui::EndChild();
596 } else {
597 float left_width =
598 std::clamp(ImGui::GetContentRegionAvail().x * 0.38f,
599 320.0f * layout_scale, 520.0f * layout_scale);
600 ImGui::BeginChild("LeftPanel", ImVec2(left_width, 0), true,
601 ImGuiWindowFlags_NoScrollbar);
602 const float left_height = ImGui::GetContentRegionAvail().y;
603 const float quick_actions_h = std::clamp(
604 left_height * 0.35f, 180.0f * layout_scale, 300.0f * layout_scale);
605
606 ImGui::BeginChild("QuickActionsWide", ImVec2(0, quick_actions_h), false,
607 ImGuiWindowFlags_NoScrollbar);
610 ImGui::EndChild();
611
612 ImGui::Spacing();
613 ImVec2 sep_start = ImGui::GetCursorScreenPos();
614 draw_list->AddLine(
615 sep_start,
616 ImVec2(sep_start.x + ImGui::GetContentRegionAvail().x, sep_start.y),
617 ImGui::GetColorU32(ImVec4(kMasterSwordBlue.x, kMasterSwordBlue.y,
618 kMasterSwordBlue.z, 0.2f)),
619 1.0f);
620 ImGui::Dummy(ImVec2(0, 5));
621
622 ImGui::BeginChild("ReleaseHistoryWide", ImVec2(0, 0), true);
623 DrawWhatsNew();
624 ImGui::EndChild();
625 ImGui::EndChild();
626
627 ImGui::SameLine();
628
629 ImGui::BeginChild("RightPanel", ImVec2(0, 0), true);
631 ImGui::EndChild();
632 }
633
634 ImGui::EndChild();
635
636 // Footer with subtle gradient
637 ImVec2 footer_start = ImGui::GetCursorScreenPos();
638 ImVec2 footer_end(footer_start.x + ImGui::GetContentRegionAvail().x,
639 footer_start.y + 1);
640 ImVec4 red_faded = kHeartRed;
641 red_faded.w = 0.3f;
642 ImVec4 green_faded = kHyruleGreen;
643 green_faded.w = 0.3f;
644 draw_list->AddRectFilledMultiColor(
645 footer_start, footer_end, ImGui::GetColorU32(red_faded),
646 ImGui::GetColorU32(green_faded), ImGui::GetColorU32(green_faded),
647 ImGui::GetColorU32(red_faded));
648
649 ImGui::Dummy(ImVec2(0, 5));
651 }
652 ImGui::End();
653
654 return action_taken;
655}
656
658 animation_time_ += ImGui::GetIO().DeltaTime;
659
660 // Update hover scale for cards (smooth interpolation)
661 for (int i = 0; i < 6; ++i) {
662 float target = (hovered_card_ == i) ? 1.03f : 1.0f;
664 (target - card_hover_scale_[i]) * ImGui::GetIO().DeltaTime * 10.0f;
665 }
666
667 // Note: Triforce positions and particles are updated in Show() based on mouse
668 // position
669}
670
674
676 ImDrawList* draw_list = ImGui::GetWindowDrawList();
677
678 // Entry animation for header (section 0)
679 float header_progress = GetStaggeredEntryProgress(
681 float header_alpha = header_progress;
682 float header_offset_y = (1.0f - header_progress) * 20.0f;
683
684 if (header_progress < 0.001f) {
685 ImGui::Dummy(ImVec2(0, 80)); // Reserve space
686 return;
687 }
688
689 ImFont* header_font = nullptr;
690 const auto& font_list = ImGui::GetIO().Fonts->Fonts;
691 if (font_list.Size > 2) {
692 header_font = font_list[2];
693 } else if (font_list.Size > 0) {
694 header_font = font_list[0];
695 }
696 if (header_font) {
697 ImGui::PushFont(header_font); // Large font (fallback to default)
698 }
699
700 // Simple centered title
701 const char* title = ICON_MD_CASTLE " yaze";
702 const float window_width = ImGui::GetWindowSize().x;
703 const float title_width = ImGui::CalcTextSize(title).x;
704 const float xPos = (window_width - title_width) * 0.5f;
705
706 // Apply entry offset
707 ImVec2 cursor_pos = ImGui::GetCursorPos();
708 ImGui::SetCursorPos(ImVec2(xPos, cursor_pos.y - header_offset_y));
709 ImVec2 text_pos = ImGui::GetCursorScreenPos();
710
711 // Subtle static glow behind text (faded by entry alpha)
712 float glow_size = 30.0f;
713 ImU32 glow_color = ImGui::GetColorU32(ImVec4(
714 kTriforceGold.x, kTriforceGold.y, kTriforceGold.z, 0.15f * header_alpha));
715 draw_list->AddCircleFilled(
716 ImVec2(text_pos.x + title_width / 2, text_pos.y + 15), glow_size,
717 glow_color, 32);
718
719 // Simple gold color for title with entry alpha
720 ImVec4 title_color = kTriforceGold;
721 title_color.w *= header_alpha;
722 ImGui::TextColored(title_color, "%s", title);
723 if (header_font) {
724 ImGui::PopFont();
725 }
726
727 // Static subtitle (entry animation section 1)
728 float subtitle_progress = GetStaggeredEntryProgress(
730 float subtitle_alpha = subtitle_progress;
731 const ImVec4 text_secondary = gui::GetTextSecondaryVec4();
732 const ImVec4 text_disabled = gui::GetTextDisabledVec4();
733
734 const char* subtitle = "Yet Another Zelda3 Editor";
735 const float subtitle_width = ImGui::CalcTextSize(subtitle).x;
736 ImGui::SetCursorPosX((window_width - subtitle_width) * 0.5f);
737
738 ImGui::TextColored(
739 ImVec4(text_secondary.x, text_secondary.y, text_secondary.z,
740 text_secondary.w * subtitle_alpha),
741 "%s", subtitle);
742
743 const std::string version_line =
744 absl::StrFormat("Version %s", YAZE_VERSION_STRING);
745 const float version_width = ImGui::CalcTextSize(version_line.c_str()).x;
746 ImGui::SetCursorPosX((window_width - version_width) * 0.5f);
747 ImGui::TextColored(ImVec4(text_disabled.x, text_disabled.y, text_disabled.z,
748 text_disabled.w * subtitle_alpha),
749 "%s", version_line.c_str());
750
751 // Small decorative triforces flanking the title (static, transparent)
752 // Positioned well away from text to avoid crowding
753 float tri_alpha = 0.12f * header_alpha;
754 ImVec2 left_tri_pos(xPos - 80, text_pos.y + 20);
755 ImVec2 right_tri_pos(xPos + title_width + 50, text_pos.y + 20);
756 DrawTriforceBackground(draw_list, left_tri_pos, 20, tri_alpha, 0.0f);
757 DrawTriforceBackground(draw_list, right_tri_pos, 20, tri_alpha, 0.0f);
758
759 ImGui::Spacing();
760}
761
763 // Shown above Quick Actions when the user has no recents and no ROM loaded.
764 // Zelda hacking has steep terminology; the cards below otherwise drop a
765 // first-time visitor into "Vanilla ROM Hack vs ZSO3" before they know
766 // what's a ROM file. Three numbered steps lower the activation energy.
767 if (!recent_projects_model_.entries().empty() || has_rom_)
768 return;
769
770 // Entry animation piggybacks on the quick actions section.
773 if (progress < 0.001f)
774 return;
775 gui::StyleVarGuard alpha_guard(ImGuiStyleVar_Alpha, progress);
776
777 const ImVec4 text_secondary = gui::GetTextSecondaryVec4();
778 ImGui::TextColored(kTriforceGold,
779 ICON_MD_AUTO_AWESOME " New to Zelda hacking?");
780 {
781 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
782 ImGui::TextWrapped(
783 tr("Three quick steps get you from zero to poking at the game:"));
784 }
785 ImGui::Spacing();
786
787 auto numbered_step = [&](int n, const char* icon, const char* title,
788 const char* body) {
789 ImGui::TextColored(kTriforceGold, "%d.", n);
790 ImGui::SameLine();
791 ImGui::TextColored(kMasterSwordBlue, "%s %s", icon, title);
792 {
793 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
794 ImGui::Indent();
795 ImGui::TextWrapped("%s", body);
796 ImGui::Unindent();
797 }
798 ImGui::Spacing();
799 };
800
801 numbered_step(
802 1, ICON_MD_MEMORY, "Load a ROM",
803 "Click \"Open ROM\" below and pick a vanilla A Link to the Past "
804 "(.sfc or .smc) file. We read it locally — it's never uploaded.");
805 numbered_step(
806 2, ICON_MD_LAYERS, "Pick a project template",
807 "Templates decide what kinds of changes your ROM will support. "
808 "Start with \"Vanilla ROM Hack\" if you just want to edit rooms, "
809 "sprites, or graphics — you can upgrade to ZSO v3 later.");
810 numbered_step(
811 3, ICON_MD_EDIT, "Open an editor",
812 "Use the left sidebar to jump into the overworld, a dungeon, or "
813 "the graphics editor. Quick Actions below can open \"Prototype "
814 "Research\" "
815 "or the assembly editor without a ROM (CGX/SCR imports or asm files). "
816 "Changes live in the editor until you save — nothing touches the ROM "
817 "until you click Save.");
818
819 ImGui::Separator();
820 ImGui::Spacing();
821}
822
824 // Entry animation for quick actions (section 2)
825 float actions_progress = GetStaggeredEntryProgress(
827 float actions_alpha = actions_progress;
828 float actions_offset_x =
829 (1.0f - actions_progress) * -30.0f; // Slide from left
830
831 if (actions_progress < 0.001f) {
832 return; // Don't draw yet
833 }
834
835 gui::StyleVarGuard alpha_guard(ImGuiStyleVar_Alpha, actions_alpha);
836
837 // Apply horizontal offset for slide effect
838 float indent = std::max(0.0f, -actions_offset_x);
839 if (indent > 0.0f) {
840 ImGui::Indent(indent);
841 }
842
843 ImGui::TextColored(kSpiritOrange, ICON_MD_BOLT " Quick Actions");
844 const ImVec4 text_secondary = gui::GetTextSecondaryVec4();
845 {
846 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
847 ImGui::TextWrapped(
848 tr("Open a ROM or project when you are ready to hack a cartridge — or "
849 "jump "
850 "into Prototype Research or the assembly editor first without any "
851 "ROM."));
852 }
853 const auto& entries = recent_projects_model_.entries();
854 size_t rom_count = 0;
855 size_t project_count = 0;
856 size_t unavailable_count = 0;
857 for (const auto& recent : entries) {
858 if (recent.unavailable) {
859 ++unavailable_count;
860 continue;
861 }
862 if (recent.item_type == "ROM") {
863 ++rom_count;
864 } else if (recent.item_type == "Project") {
865 ++project_count;
866 }
867 }
868 {
869 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
870 ImGui::TextWrapped(
871 tr("%zu recent entries • %zu ROMs • %zu projects%s"), entries.size(),
872 rom_count, project_count,
873 unavailable_count > 0 ? " • some entries need re-open permission" : "");
874 }
875 ImGui::Spacing();
876
877 const float scale = ImGui::GetFontSize() / 16.0f;
878 const float button_height = std::max(38.0f, 40.0f * scale);
879 const float action_width = ImGui::GetContentRegionAvail().x;
880 float button_width = action_width;
881
882 // Animated button colors (compact height)
883 auto draw_action_button = [&](const char* icon, const char* text,
884 const ImVec4& color, bool enabled,
885 std::function<void()> callback) {
886 gui::StyleColorGuard button_colors({
887 {ImGuiCol_Button,
888 ImVec4(color.x * 0.6f, color.y * 0.6f, color.z * 0.6f, 0.8f)},
889 {ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 1.0f)},
890 {ImGuiCol_ButtonActive,
891 ImVec4(color.x * 1.2f, color.y * 1.2f, color.z * 1.2f, 1.0f)},
892 });
893
894 if (!enabled)
895 ImGui::BeginDisabled();
896
897 bool clicked = ImGui::Button(absl::StrFormat("%s %s", icon, text).c_str(),
898 ImVec2(button_width, button_height));
899
900 if (!enabled)
901 ImGui::EndDisabled();
902
903 if (clicked && enabled && callback) {
904 callback();
905 }
906
907 return clicked;
908 };
909
910 // Unified startup open path.
911 if (draw_action_button(ICON_MD_FOLDER_OPEN, "Open ROM / Project",
912 kHyruleGreen, true, open_rom_callback_)) {
913 // Handled by callback
914 }
915 if (ImGui::IsItemHovered()) {
916 ImGui::SetTooltip(ICON_MD_INFO
917 " Open .sfc/.smc ROMs and .yaze/.yazeproj project files");
918 }
919
920 ImGui::Spacing();
921
923 if (draw_action_button(ICON_MD_CONSTRUCTION, "Prototype Research (no ROM)",
924 kMasterSwordBlue, true,
926 // Handled by callback
927 }
928 if (ImGui::IsItemHovered()) {
929 ImGui::SetTooltip(
931 " Opens the Graphics editor with the prototype import lab — CGX, "
932 "SCR, "
933 "COL, BIN, and clipboard tools work without loading a ROM.");
934 }
935 ImGui::Spacing();
936 }
937
939 if (draw_action_button(ICON_MD_CODE, "Assembly Editor (no ROM)",
940 kTriforceGold, true,
942 // Handled by callback
943 }
944 if (ImGui::IsItemHovered()) {
945 ImGui::SetTooltip(
947 " Opens the Assembly editor — open a folder or files and work on asm "
948 "without loading a ROM. ROM-backed disassembly stays disabled until "
949 "you load a cart.");
950 }
951 ImGui::Spacing();
952 }
953
954 const RecentProject* last_recent = nullptr;
955 for (const auto& recent : recent_projects_model_.entries()) {
956 if (!recent.unavailable) {
957 last_recent = &recent;
958 break;
959 }
960 }
961 if (last_recent && open_project_callback_) {
962 const std::string resume_label = absl::StrFormat(
963 "Resume Last (%s)", last_recent->item_type.empty()
964 ? "File"
965 : last_recent->item_type.c_str());
966 const std::string resume_path = last_recent->filepath;
967 if (draw_action_button(ICON_MD_PLAY_ARROW, resume_label.c_str(),
968 kMasterSwordBlue, true, [this, resume_path]() {
969 if (open_project_callback_) {
970 open_project_callback_(resume_path);
971 }
972 })) {
973 // Handled by callback
974 }
975 if (ImGui::IsItemHovered()) {
976 ImGui::SetTooltip("%s\n%s", last_recent->name.c_str(),
977 last_recent->filepath.c_str());
978 }
979 ImGui::Spacing();
980 }
981
982 // New Project button - Gold like getting a treasure
983 if (draw_action_button(ICON_MD_ADD_CIRCLE, "New Project", kTriforceGold, true,
984 new_project_callback_)) {
985 // Handled by callback
986 }
987 if (ImGui::IsItemHovered()) {
988 ImGui::SetTooltip(
990 " Create a new project for metadata, labels, and workflow settings");
991 }
992
993 {
994 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
995 ImGui::Spacing();
996 ImGui::TextWrapped(tr(
997 "Release highlights and migration notes are now in the panel below."));
998 }
999
1000 // Clean up entry animation styles
1001 if (indent > 0.0f) {
1002 ImGui::Unindent(indent);
1003 }
1004}
1005
1006void WelcomeScreen::DrawRecentProjects() {
1007 // Entry animation for recent projects (section 4)
1008 float recent_progress = GetStaggeredEntryProgress(
1009 entry_time_, 4, kEntryAnimDuration, kEntryStaggerDelay);
1010
1011 if (recent_progress < 0.001f) {
1012 return; // Don't draw yet
1013 }
1014
1015 gui::StyleVarGuard alpha_guard(ImGuiStyleVar_Alpha, recent_progress);
1016
1017 int rom_count = 0;
1018 int project_count = 0;
1019 for (const auto& item : recent_projects_model_.entries()) {
1020 if (item.item_type == "ROM") {
1021 ++rom_count;
1022 } else if (item.item_type == "Project") {
1023 ++project_count;
1024 }
1025 }
1026
1027 ImGui::TextColored(kMasterSwordBlue,
1028 ICON_MD_HISTORY " Recent ROMs & Projects");
1029
1030 const float header_spacing = ImGui::GetStyle().ItemSpacing.x;
1031 const float manage_width = ImGui::CalcTextSize(" Manage").x +
1032 ImGui::CalcTextSize(ICON_MD_FOLDER_SPECIAL).x +
1033 ImGui::GetStyle().FramePadding.x * 2.0f;
1034 const float clear_width = ImGui::CalcTextSize(" Clear").x +
1035 ImGui::CalcTextSize(ICON_MD_DELETE_SWEEP).x +
1036 ImGui::GetStyle().FramePadding.x * 2.0f;
1037 const float total_width = manage_width + clear_width + header_spacing;
1038
1039 ImGui::SameLine();
1040 const float start_x = ImGui::GetCursorPosX();
1041 const float right_edge = start_x + ImGui::GetContentRegionAvail().x;
1042 const float button_start = std::max(start_x, right_edge - total_width);
1043 ImGui::SetCursorPosX(button_start);
1044
1045 bool can_manage = open_project_management_callback_ != nullptr;
1046 if (!can_manage) {
1047 ImGui::BeginDisabled();
1048 }
1049 if (ImGui::SmallButton(
1050 absl::StrFormat("%s Manage", ICON_MD_FOLDER_SPECIAL).c_str())) {
1051 if (open_project_management_callback_) {
1052 open_project_management_callback_();
1053 }
1054 }
1055 if (!can_manage) {
1056 ImGui::EndDisabled();
1057 }
1058 ImGui::SameLine(0.0f, header_spacing);
1059 if (ImGui::SmallButton(
1060 absl::StrFormat("%s Clear", ICON_MD_DELETE_SWEEP).c_str())) {
1061 recent_projects_model_.ClearAll();
1062 RefreshRecentProjects();
1063 }
1064
1065 {
1066 const ImVec4 text_secondary = gui::GetTextSecondaryVec4();
1067 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
1068 ImGui::Text(tr("%d ROMs • %d projects"), rom_count, project_count);
1069 }
1070
1071 DrawUndoRemovalBanner();
1072
1073 ImGui::Spacing();
1074
1075 if (recent_projects_model_.entries().empty()) {
1076 // Simple empty state
1077 const ImVec4 text_secondary = gui::GetTextSecondaryVec4();
1078 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
1079
1080 ImVec2 cursor = ImGui::GetCursorPos();
1081 ImGui::SetCursorPosX(cursor.x + ImGui::GetContentRegionAvail().x * 0.3f);
1082 ImGui::TextColored(
1083 ImVec4(kTriforceGold.x, kTriforceGold.y, kTriforceGold.z, 0.8f),
1085 ImGui::SetCursorPosX(cursor.x);
1086
1087 ImGui::TextWrapped(
1088 tr("No recent files yet.\nOpen a ROM or project to begin."));
1089 return;
1090 }
1091
1092 const float scale = ImGui::GetFontSize() / 16.0f;
1093 const float min_width = kRecentCardBaseWidth * scale;
1094 const float max_width =
1095 kRecentCardBaseWidth * kRecentCardWidthMaxFactor * scale;
1096 const float min_height = kRecentCardBaseHeight * scale;
1097 const float max_height =
1098 kRecentCardBaseHeight * kRecentCardHeightMaxFactor * scale;
1099 const float spacing = ImGui::GetStyle().ItemSpacing.x;
1100 const float aspect_ratio = min_height / std::max(min_width, 1.0f);
1101
1102 GridLayout layout = ComputeGridLayout(
1103 ImGui::GetContentRegionAvail().x, min_width, max_width, min_height,
1104 max_height, min_width, aspect_ratio, spacing);
1105
1106 const auto& entries = recent_projects_model_.entries();
1107 int column = 0;
1108 for (size_t i = 0; i < entries.size(); ++i) {
1109 if (column == 0) {
1110 ImGui::SetCursorPosX(layout.row_start_x);
1111 }
1112
1113 DrawProjectPanel(entries[i], static_cast<int>(i),
1114 ImVec2(layout.item_width, layout.item_height));
1115
1116 column += 1;
1117 if (column < layout.columns) {
1118 ImGui::SameLine(0.0f, layout.spacing);
1119 } else {
1120 column = 0;
1121 ImGui::Spacing();
1122 }
1123 }
1124
1125 if (column != 0) {
1126 ImGui::NewLine();
1127 }
1128
1129 DrawRecentAnnotationPopup();
1130}
1131
1132void WelcomeScreen::DrawRecentAnnotationPopup() {
1133 if (pending_annotation_kind_ == RecentAnnotationKind::None)
1134 return;
1135
1136 // Open once per transition, then keep the modal visible until the user
1137 // hits Save or Cancel. IsPopupOpen gates the OpenPopup call so we don't
1138 // re-open every frame.
1139 const char* kPopupId = "##RecentAnnotationPopup";
1140 if (!ImGui::IsPopupOpen(kPopupId)) {
1141 ImGui::OpenPopup(kPopupId);
1142 }
1143
1144 ImGui::SetNextWindowSize(ImVec2(420, 0), ImGuiCond_Appearing);
1145 if (ImGui::BeginPopupModal(kPopupId, nullptr,
1146 ImGuiWindowFlags_AlwaysAutoResize |
1147 ImGuiWindowFlags_NoSavedSettings)) {
1148 const bool renaming =
1149 pending_annotation_kind_ == RecentAnnotationKind::Rename;
1150 ImGui::TextUnformatted(renaming ? ICON_MD_EDIT " Rename"
1151 : ICON_MD_NOTE " Edit Notes");
1152 const ImVec4 text_secondary = gui::GetTextSecondaryVec4();
1153 {
1154 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
1155 ImGui::TextWrapped("%s", pending_annotation_path_.c_str());
1156 }
1157 ImGui::Spacing();
1158
1159 bool committed = false;
1160 if (renaming) {
1161 ImGui::SetNextItemWidth(-1);
1162 if (ImGui::InputText("##rename_input", rename_buffer_,
1163 sizeof(rename_buffer_),
1164 ImGuiInputTextFlags_EnterReturnsTrue)) {
1165 committed = true;
1166 }
1167 {
1168 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
1169 ImGui::TextWrapped(tr(
1170 "Leave blank to restore the filename. Affects only how this entry "
1171 "is displayed on the welcome screen."));
1172 }
1173 } else {
1174 ImGui::SetNextItemWidth(-1);
1175 ImGui::InputTextMultiline("##notes_input", notes_buffer_,
1176 sizeof(notes_buffer_), ImVec2(-1, 120));
1177 {
1178 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
1179 ImGui::TextWrapped(
1180 tr("Short free-form note shown on hover. Useful for tagging "
1181 "works-in-progress (\"WIP: palette swap\")."));
1182 }
1183 }
1184
1185 ImGui::Spacing();
1186 if (ImGui::Button(ICON_MD_CHECK " Save") || committed) {
1187 if (renaming) {
1188 recent_projects_model_.SetDisplayName(pending_annotation_path_,
1189 std::string(rename_buffer_));
1190 } else {
1191 recent_projects_model_.SetNotes(pending_annotation_path_,
1192 std::string(notes_buffer_));
1193 }
1194 pending_annotation_kind_ = RecentAnnotationKind::None;
1195 pending_annotation_path_.clear();
1196 ImGui::CloseCurrentPopup();
1197 }
1198 ImGui::SameLine();
1199 if (ImGui::Button(ICON_MD_CLOSE " Cancel") ||
1200 ImGui::IsKeyPressed(ImGuiKey_Escape, /*repeat=*/false)) {
1201 pending_annotation_kind_ = RecentAnnotationKind::None;
1202 pending_annotation_path_.clear();
1203 ImGui::CloseCurrentPopup();
1204 }
1205 ImGui::EndPopup();
1206 }
1207}
1208
1209void WelcomeScreen::DrawUndoRemovalBanner() {
1210 if (!recent_projects_model_.HasUndoableRemoval())
1211 return;
1212
1213 const auto pending = recent_projects_model_.PeekLastRemoval();
1214 if (pending.path.empty())
1215 return;
1216
1217 // A single-row inline banner reads as ephemeral feedback, not a dialog.
1218 // We colour it with the theme's warning surface so it visually pairs with
1219 // destructive-action affordances elsewhere.
1220 const ImVec4 warning_bg = gui::ConvertColorToImVec4(
1221 gui::ThemeManager::Get().GetCurrentTheme().warning);
1222 ImVec4 bg = warning_bg;
1223 bg.w = 0.18f;
1224
1225 const ImVec2 avail = ImGui::GetContentRegionAvail();
1226 const float row_height = ImGui::GetFrameHeight() + 6.0f;
1227 const ImVec2 cursor = ImGui::GetCursorScreenPos();
1228 ImDrawList* draw_list = ImGui::GetWindowDrawList();
1229 draw_list->AddRectFilled(cursor,
1230 ImVec2(cursor.x + avail.x, cursor.y + row_height),
1231 ImGui::GetColorU32(bg), 4.0f);
1232
1233 ImGui::Dummy(ImVec2(0, 3.0f));
1234 ImGui::SameLine(8.0f);
1235 ImGui::TextColored(warning_bg, ICON_MD_INFO);
1236 ImGui::SameLine();
1237 ImGui::Text(tr("Removed \"%s\""), pending.display_name.c_str());
1238 ImGui::SameLine();
1239
1240 // Right-align the action buttons inside the banner.
1241 const float undo_width = ImGui::CalcTextSize(ICON_MD_UNDO " Undo").x +
1242 ImGui::GetStyle().FramePadding.x * 2.0f;
1243 const float dismiss_width = ImGui::CalcTextSize(ICON_MD_CLOSE).x +
1244 ImGui::GetStyle().FramePadding.x * 2.0f;
1245 const float spacing = ImGui::GetStyle().ItemSpacing.x;
1246 const float button_row = undo_width + dismiss_width + spacing;
1247 const float right_edge =
1248 ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x;
1249 ImGui::SetCursorPosX(
1250 std::max(ImGui::GetCursorPosX(), right_edge - button_row - 4.0f));
1251
1252 if (ImGui::SmallButton(ICON_MD_UNDO " Undo")) {
1253 recent_projects_model_.UndoLastRemoval();
1254 RefreshRecentProjects(/*force=*/true);
1255 }
1256 ImGui::SameLine(0.0f, spacing);
1257 if (ImGui::SmallButton(ICON_MD_CLOSE "##dismiss_undo")) {
1258 recent_projects_model_.DismissLastRemoval();
1259 }
1260 ImGui::Dummy(ImVec2(0, 2.0f));
1261}
1262
1263void WelcomeScreen::DrawProjectPanel(const RecentProject& project, int index,
1264 const ImVec2& card_size) {
1265 // Disambiguate ImGui IDs without allocating a new std::string every frame
1266 // (the old code called absl::StrFormat("ProjectPanel_%d", ...) per card).
1267 ImGui::PushID(index);
1268 ImGui::BeginGroup();
1269
1270 const ImVec4 surface = gui::GetSurfaceVec4();
1271 const ImVec4 surface_variant = gui::GetSurfaceVariantVec4();
1272 const ImVec4 text_primary = gui::GetOnSurfaceVec4();
1273 const ImVec4 text_secondary = gui::GetTextSecondaryVec4();
1274 const ImVec4 text_disabled = gui::GetTextDisabledVec4();
1275
1276 ImVec2 resolved_card_size = card_size;
1277 ImVec2 cursor_pos = ImGui::GetCursorScreenPos();
1278
1279 // Subtle hover scale.
1280 float hover_scale = card_hover_scale_[index];
1281 if (hover_scale != 1.0f) {
1282 ImVec2 center(cursor_pos.x + resolved_card_size.x / 2,
1283 cursor_pos.y + resolved_card_size.y / 2);
1284 cursor_pos.x = center.x - (resolved_card_size.x * hover_scale) / 2;
1285 cursor_pos.y = center.y - (resolved_card_size.y * hover_scale) / 2;
1286 resolved_card_size.x *= hover_scale;
1287 resolved_card_size.y *= hover_scale;
1288 }
1289
1290 ImVec4 accent = kTriforceGold;
1291 if (project.unavailable) {
1292 accent = kHeartRed;
1293 } else if (project.item_type == "ROM") {
1294 accent = kHyruleGreen;
1295 } else if (project.item_type == "Project") {
1296 accent = kMasterSwordBlue;
1297 }
1298
1299 ImDrawList* draw_list = ImGui::GetWindowDrawList();
1300 ImVec4 color_top = ImLerp(surface_variant, surface, 0.7f);
1301 ImVec4 color_bottom = ImLerp(surface_variant, surface, 0.3f);
1302 ImU32 color_top_u32 = ImGui::GetColorU32(color_top);
1303 ImU32 color_bottom_u32 = ImGui::GetColorU32(color_bottom);
1304 draw_list->AddRectFilledMultiColor(
1305 cursor_pos,
1306 ImVec2(cursor_pos.x + resolved_card_size.x,
1307 cursor_pos.y + resolved_card_size.y),
1308 color_top_u32, color_top_u32, color_bottom_u32, color_bottom_u32);
1309
1310 ImU32 border_color =
1311 ImGui::GetColorU32(ImVec4(accent.x, accent.y, accent.z, 0.6f));
1312
1313 draw_list->AddRect(cursor_pos,
1314 ImVec2(cursor_pos.x + resolved_card_size.x,
1315 cursor_pos.y + resolved_card_size.y),
1316 border_color, 6.0f, 0, 2.0f);
1317
1318 // Make the card clickable
1319 ImGui::SetCursorScreenPos(cursor_pos);
1320 ImGui::InvisibleButton("ProjectPanel", resolved_card_size);
1321 bool is_hovered = ImGui::IsItemHovered();
1322 bool is_clicked = ImGui::IsItemClicked();
1323
1324 hovered_card_ =
1325 is_hovered ? index : (hovered_card_ == index ? -1 : hovered_card_);
1326
1327 if (ImGui::BeginPopupContextItem("ProjectPanelMenu")) {
1328 if (project.is_missing) {
1329 // Missing file: offer relink + forget instead of open. Destructive "Open"
1330 // is hidden because it would just fail.
1331 if (ImGui::MenuItem(ICON_MD_SEARCH " Locate...")) {
1332 const std::string new_path =
1334 if (!new_path.empty() && new_path != project.filepath) {
1335 recent_projects_model_.RelinkRecent(project.filepath, new_path);
1336 }
1337 }
1338 if (ImGui::IsItemHovered()) {
1339 ImGui::SetTooltip(
1340 tr("Point at the new location for this file. Pin/rename/notes are "
1341 "preserved."));
1342 }
1343 } else {
1344 if (ImGui::MenuItem(ICON_MD_OPEN_IN_NEW " Open")) {
1345 if (open_project_callback_) {
1346 open_project_callback_(project.filepath);
1347 }
1348 }
1349 }
1350 ImGui::Separator();
1351 if (ImGui::MenuItem(project.pinned ? ICON_MD_PUSH_PIN " Unpin"
1352 : ICON_MD_PUSH_PIN " Pin")) {
1353 recent_projects_model_.SetPinned(project.filepath, !project.pinned);
1354 }
1355 if (ImGui::MenuItem(ICON_MD_EDIT " Rename...")) {
1356 pending_annotation_kind_ = RecentAnnotationKind::Rename;
1357 pending_annotation_path_ = project.filepath;
1358 // Seed the buffer with the current display name (empty override falls
1359 // back to the filename so the user can start from what they see).
1360 std::snprintf(rename_buffer_, sizeof(rename_buffer_), "%s",
1361 project.display_name_override.empty()
1362 ? project.name.c_str()
1363 : project.display_name_override.c_str());
1364 }
1365 if (ImGui::MenuItem(ICON_MD_NOTE " Edit Notes...")) {
1366 pending_annotation_kind_ = RecentAnnotationKind::EditNotes;
1367 pending_annotation_path_ = project.filepath;
1368 std::snprintf(notes_buffer_, sizeof(notes_buffer_), "%s",
1369 project.notes.c_str());
1370 }
1371 ImGui::Separator();
1372 if (ImGui::MenuItem(ICON_MD_CONTENT_COPY " Copy Path")) {
1373 ImGui::SetClipboardText(project.filepath.c_str());
1374 }
1375 if (ImGui::MenuItem(project.is_missing ? ICON_MD_DELETE_SWEEP " Forget"
1377 " Remove from Recents")) {
1378 recent_projects_model_.RemoveRecent(project.filepath);
1379 }
1380 ImGui::EndPopup();
1381 }
1382
1383 if (is_hovered) {
1384 ImU32 hover_color =
1385 ImGui::GetColorU32(ImVec4(accent.x, accent.y, accent.z, 0.16f));
1386 draw_list->AddRectFilled(cursor_pos,
1387 ImVec2(cursor_pos.x + resolved_card_size.x,
1388 cursor_pos.y + resolved_card_size.y),
1389 hover_color, 6.0f);
1390 }
1391
1392 const float layout_scale = resolved_card_size.y / kRecentCardBaseHeight;
1393 const float padding = 10.0f * layout_scale;
1394 const float icon_radius = 14.0f * layout_scale;
1395 const float icon_spacing = 10.0f * layout_scale;
1396 const float line_spacing = 2.0f * layout_scale;
1397
1398 const ImVec2 icon_center(cursor_pos.x + padding + icon_radius,
1399 cursor_pos.y + padding + icon_radius);
1400 draw_list->AddCircleFilled(icon_center, icon_radius,
1401 ImGui::GetColorU32(accent), 24);
1402
1403 const char* item_icon = project.item_icon.empty() ? ICON_MD_INSERT_DRIVE_FILE
1404 : project.item_icon.c_str();
1405 const ImVec2 icon_size = ImGui::CalcTextSize(item_icon);
1406 ImGui::SetCursorScreenPos(ImVec2(icon_center.x - icon_size.x * 0.5f,
1407 icon_center.y - icon_size.y * 0.5f));
1408 gui::ColoredText(item_icon, text_primary);
1409
1410 const std::string badge_text =
1411 project.item_type.empty() ? "File" : project.item_type;
1412 const ImVec2 badge_text_size = ImGui::CalcTextSize(badge_text.c_str());
1413 const float badge_pad_x = 6.0f * layout_scale;
1414 const float badge_pad_y = 2.0f * layout_scale;
1415 const ImVec2 badge_min(cursor_pos.x + resolved_card_size.x - padding -
1416 badge_text_size.x - (badge_pad_x * 2.0f),
1417 cursor_pos.y + padding);
1418 const ImVec2 badge_max(
1419 badge_min.x + badge_text_size.x + (badge_pad_x * 2.0f),
1420 badge_min.y + badge_text_size.y + (badge_pad_y * 2.0f));
1421 draw_list->AddRectFilled(
1422 badge_min, badge_max,
1423 ImGui::GetColorU32(ImVec4(accent.x, accent.y, accent.z, 0.24f)), 4.0f);
1424 draw_list->AddRect(
1425 badge_min, badge_max,
1426 ImGui::GetColorU32(ImVec4(accent.x, accent.y, accent.z, 0.50f)), 4.0f);
1427 draw_list->AddText(
1428 ImVec2(badge_min.x + badge_pad_x, badge_min.y + badge_pad_y),
1429 ImGui::GetColorU32(text_primary), badge_text.c_str());
1430
1431 const float content_x = icon_center.x + icon_radius + icon_spacing;
1432 const float content_right = badge_min.x - (6.0f * layout_scale);
1433 const float text_max_w = std::max(80.0f, content_right - content_x);
1434
1435 float text_y = cursor_pos.y + padding;
1436 const std::string display_name = EllipsizeText(project.name, text_max_w);
1437 ImGui::SetCursorScreenPos(ImVec2(content_x, text_y));
1438 gui::ColoredText(display_name.c_str(), text_primary);
1439
1440 text_y += ImGui::GetTextLineHeight() + line_spacing;
1441 ImGui::SetCursorScreenPos(ImVec2(content_x, text_y));
1442 gui::ColoredTextF(text_secondary, "%s",
1443 EllipsizeText(project.rom_title, text_max_w).c_str());
1444
1445 const std::string summary = project.metadata_summary.empty()
1446 ? project.last_modified
1447 : project.metadata_summary;
1448 text_y += ImGui::GetTextLineHeight() + line_spacing;
1449 ImGui::SetCursorScreenPos(ImVec2(content_x, text_y));
1450 gui::ColoredTextF(text_secondary, "%s",
1451 EllipsizeText(summary, text_max_w).c_str());
1452
1453 text_y += ImGui::GetTextLineHeight() + line_spacing;
1454 const std::string opened_line =
1455 project.last_modified.empty()
1456 ? ""
1457 : absl::StrFormat("Last opened: %s", project.last_modified.c_str());
1458 ImGui::SetCursorScreenPos(ImVec2(content_x, text_y));
1459 gui::ColoredTextF(text_disabled, "%s",
1460 EllipsizeText(opened_line, text_max_w).c_str());
1461
1462 if (is_hovered) {
1463 ImGui::BeginTooltip();
1464 ImGui::TextColored(kMasterSwordBlue, ICON_MD_INFO " Recent Item");
1465 ImGui::Separator();
1466 ImGui::Text(tr("Type: %s"), badge_text.c_str());
1467 ImGui::Text(tr("Name: %s"), project.name.c_str());
1468 ImGui::Text(tr("Details: %s"), project.rom_title.c_str());
1469 if (!project.metadata_summary.empty()) {
1470 ImGui::Text(tr("Metadata: %s"), project.metadata_summary.c_str());
1471 }
1472 ImGui::Text(tr("Last opened: %s"), project.last_modified.c_str());
1473 ImGui::Text(tr("Path: %s"), project.filepath.c_str());
1474 ImGui::Separator();
1475 ImGui::TextColored(kTriforceGold, ICON_MD_TOUCH_APP " Click to open");
1476 ImGui::EndTooltip();
1477 }
1478
1479 // Handle click
1480 if (is_clicked && open_project_callback_) {
1481 open_project_callback_(project.filepath);
1482 }
1483
1484 ImGui::EndGroup();
1485 ImGui::PopID();
1486}
1487
1488void WelcomeScreen::DrawTemplatesSection() {
1489 // Entry animation for templates (section 3)
1490 float templates_progress = GetStaggeredEntryProgress(
1491 entry_time_, 3, kEntryAnimDuration, kEntryStaggerDelay);
1492
1493 if (templates_progress < 0.001f) {
1494 return; // Don't draw yet
1495 }
1496
1497 gui::StyleVarGuard alpha_guard(ImGuiStyleVar_Alpha, templates_progress);
1498
1499 // Header with visual settings button
1500 float content_width = ImGui::GetContentRegionAvail().x;
1501 ImGui::TextColored(kGanonPurple, ICON_MD_LAYERS " Project Templates");
1502 ImGui::SameLine(content_width - 25);
1503 if (ImGui::SmallButton(show_triforce_settings_ ? ICON_MD_CLOSE
1504 : ICON_MD_TUNE)) {
1505 show_triforce_settings_ = !show_triforce_settings_;
1506 }
1507 if (ImGui::IsItemHovered()) {
1508 ImGui::SetTooltip(ICON_MD_AUTO_AWESOME " Visual Effects Settings");
1509 }
1510
1511 ImGui::Spacing();
1512
1513 // Visual effects settings panel (when opened)
1514 if (show_triforce_settings_) {
1515 {
1516 gui::StyledChild visual_settings(
1517 "VisualSettingsCompact", ImVec2(0, 115),
1518 {.bg = ImVec4(0.18f, 0.15f, 0.22f, 0.4f)}, true,
1519 ImGuiWindowFlags_NoScrollbar);
1520 ImGui::TextColored(kGanonPurple, ICON_MD_AUTO_AWESOME " Visual Effects");
1521 ImGui::Spacing();
1522
1523 // Persist animation tweaks only when the edit is committed (release of
1524 // slider / click of checkbox), so we don't write settings every frame
1525 // while the user is dragging.
1526 bool changed_commit = false;
1527
1528 ImGui::Text(ICON_MD_OPACITY " Visibility");
1529 ImGui::SetNextItemWidth(-1);
1530 ImGui::SliderFloat("##visibility", &triforce_alpha_multiplier_, 0.0f,
1531 3.0f, "%.1fx");
1532 if (ImGui::IsItemDeactivatedAfterEdit())
1533 changed_commit = true;
1534
1535 ImGui::Text(ICON_MD_SPEED " Speed");
1536 ImGui::SetNextItemWidth(-1);
1537 ImGui::SliderFloat("##speed", &triforce_speed_multiplier_, 0.05f, 1.0f,
1538 "%.2fx");
1539 if (ImGui::IsItemDeactivatedAfterEdit())
1540 changed_commit = true;
1541
1542 if (ImGui::Checkbox(ICON_MD_MOUSE " Mouse Interaction",
1543 &triforce_mouse_repel_enabled_)) {
1544 changed_commit = true;
1545 }
1546 ImGui::SameLine();
1547 if (ImGui::Checkbox(ICON_MD_AUTO_FIX_HIGH " Particles",
1548 &particles_enabled_)) {
1549 changed_commit = true;
1550 }
1551
1552 if (ImGui::SmallButton(ICON_MD_REFRESH " Reset")) {
1553 triforce_alpha_multiplier_ = 1.0f;
1554 triforce_speed_multiplier_ = 0.3f;
1555 triforce_size_multiplier_ = 1.0f;
1556 triforce_mouse_repel_enabled_ = true;
1557 particles_enabled_ = true;
1558 particle_spawn_rate_ = 2.0f;
1559 changed_commit = true;
1560 }
1561
1562 if (changed_commit) {
1563 PersistAnimationSettings();
1564 }
1565 }
1566 ImGui::Spacing();
1567 }
1568
1569 ImGui::Spacing();
1570
1571 struct Template {
1572 const char* icon;
1573 const char* name;
1574 const char* use_when; // 1-line "pick this when..."
1575 const char* what_changes; // plain-English summary of ROM impact
1576 int skill_level; // 1 = beginner, 2 = comfortable, 3 = advanced
1577 const char* template_id;
1578 const char** details;
1579 int detail_count;
1580 ImVec4 color;
1581 };
1582
1583 const char* vanilla_details[] = {
1584 "Edits vanilla data tables (rooms, sprites, maps)",
1585 "No custom ASM required — works with any vanilla ROM",
1586 "Overworld layout stays identical to the original"};
1587 const char* zso3_details[] = {
1588 "Enables editor support for wider / taller overworld areas",
1589 "Enables custom entrance, exit, item, and property saves",
1590 "Requires a ROM that already includes the ZSO3 ASM patch"};
1591 const char* zso2_details[] = {
1592 "Older overworld expansion with parent-area system",
1593 "Lighter footprint than v3 — good for ports of legacy hacks",
1594 "Palette + BG color overrides only"};
1595 const char* rando_details[] = {
1596 "Skips the features that break randomizer patches",
1597 "Leaves ASM hook points alone", "Keeps the save layout minimal"};
1598
1599 Template templates[] = {
1600 {ICON_MD_COTTAGE, "Vanilla ROM Hack",
1601 "You want to edit rooms, sprites, or graphics without custom code.",
1602 "Adds project metadata and labels on top of your vanilla ROM. The ROM "
1603 "itself is only changed when you save edits you make in the editors.",
1604 /*skill_level=*/1, "Vanilla ROM Hack", vanilla_details,
1605 static_cast<int>(sizeof(vanilla_details) / sizeof(vanilla_details[0])),
1606 kHyruleGreen},
1607 {ICON_MD_TERRAIN, "ZSCustomOverworld v3",
1608 "You want to resize overworld areas and add custom map features.",
1609 "Configures editor save flags for a ROM that already uses ZSO3. This "
1610 "template does not install the ZSO3 ASM patch.",
1611 /*skill_level=*/2, "ZSCustomOverworld v3", zso3_details,
1612 static_cast<int>(sizeof(zso3_details) / sizeof(zso3_details[0])),
1613 kMasterSwordBlue},
1614 {ICON_MD_MAP, "ZSCustomOverworld v2",
1615 "You're porting an older hack that already uses ZSO v2.",
1616 "Configures editor save flags for an existing ZSO2 ROM. It does not "
1617 "install the patch; use this for compatibility with a legacy hack.",
1618 /*skill_level=*/2, "ZSCustomOverworld v2", zso2_details,
1619 static_cast<int>(sizeof(zso2_details) / sizeof(zso2_details[0])),
1620 kShadowPurple},
1621 {ICON_MD_SHUFFLE, "Randomizer Compatible",
1622 "You're building a ROM that has to work with ALTTPR or similar.",
1623 "Uses conservative save flags that skip ASM hooks and overworld "
1624 "remapping. Validate the finished ROM with your target randomizer.",
1625 /*skill_level=*/3, "Randomizer Compatible", rando_details,
1626 static_cast<int>(sizeof(rando_details) / sizeof(rando_details[0])),
1627 kSpiritOrange},
1628 };
1629
1630 const int template_count =
1631 static_cast<int>(sizeof(templates) / sizeof(templates[0]));
1632 if (selected_template_ < 0 || selected_template_ >= template_count) {
1633 selected_template_ = 0;
1634 }
1635
1636 const ImVec4 text_secondary = gui::GetTextSecondaryVec4();
1637 const float template_width = ImGui::GetContentRegionAvail().x;
1638 const float scale = ImGui::GetFontSize() / 16.0f;
1639 const bool stack_templates = template_width < 520.0f;
1640
1641 auto draw_template_list = [&]() {
1642 for (int i = 0; i < template_count; ++i) {
1643 bool is_selected = (selected_template_ == i);
1644
1645 std::optional<gui::StyleColorGuard> header_guard;
1646 if (is_selected) {
1647 header_guard.emplace(std::initializer_list<gui::StyleColorGuard::Entry>{
1648 {ImGuiCol_Header,
1649 ImVec4(templates[i].color.x * 0.6f, templates[i].color.y * 0.6f,
1650 templates[i].color.z * 0.6f, 0.6f)}});
1651 }
1652
1653 ImGui::PushID(i);
1654 {
1655 gui::StyleColorGuard text_guard(ImGuiCol_Text, templates[i].color);
1656 if (ImGui::Selectable(
1657 absl::StrFormat("%s %s", templates[i].icon, templates[i].name)
1658 .c_str(),
1659 is_selected)) {
1660 selected_template_ = i;
1661 }
1662 }
1663 ImGui::PopID();
1664
1665 if (ImGui::IsItemHovered()) {
1666 ImGui::SetTooltip(tr("%s %s\nUse when: %s"), ICON_MD_INFO,
1667 templates[i].name, templates[i].use_when);
1668 }
1669 }
1670 };
1671
1672 auto draw_template_details = [&]() {
1673 const Template& active = templates[selected_template_];
1674 ImGui::TextColored(active.color, "%s %s", active.icon, active.name);
1675
1676 // Skill dots: filled = required level, empty = headroom. Makes pick-
1677 // ability visible at a glance without a numeric label.
1678 ImGui::SameLine();
1679 const ImVec4 dim =
1680 ImVec4(text_secondary.x, text_secondary.y, text_secondary.z, 0.35f);
1681 for (int i = 1; i <= 3; ++i) {
1682 ImGui::SameLine();
1683 ImGui::TextColored(i <= active.skill_level ? active.color : dim,
1684 ICON_MD_STAR);
1685 }
1686 if (ImGui::IsItemHovered()) {
1687 const char* skill_labels[] = {"Beginner friendly",
1688 "Some familiarity helps",
1689 "Advanced — know the pipeline"};
1690 ImGui::SetTooltip("%s", skill_labels[active.skill_level - 1]);
1691 }
1692
1693 ImGui::Spacing();
1694 {
1695 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
1696 ImGui::TextWrapped(ICON_MD_LIGHTBULB " %s", active.use_when);
1697 }
1698 ImGui::Spacing();
1699 {
1700 gui::StyleColorGuard text_guard(ImGuiCol_Text, text_secondary);
1701 ImGui::TextWrapped(ICON_MD_EDIT " What this changes: %s",
1702 active.what_changes);
1703 }
1704 ImGui::Spacing();
1705 ImGui::TextColored(kTriforceGold, ICON_MD_CHECK_CIRCLE " Includes");
1706 for (int i = 0; i < active.detail_count; ++i) {
1707 ImGui::Bullet();
1708 ImGui::SameLine();
1709 ImGui::TextColored(text_secondary, "%s", active.details[i]);
1710 }
1711 };
1712
1713 if (stack_templates) {
1714 const float row_height = ImGui::GetTextLineHeightWithSpacing() + 4.0f;
1715 const float list_height = std::clamp(row_height * (template_count + 1),
1716 120.0f * scale, 200.0f * scale);
1717 ImGui::BeginChild("TemplateList", ImVec2(0, list_height), false,
1718 ImGuiWindowFlags_NoScrollbar);
1719 draw_template_list();
1720 ImGui::EndChild();
1721 ImGui::Spacing();
1722 ImGui::BeginChild("TemplateDetails", ImVec2(0, 0), false,
1723 ImGuiWindowFlags_NoScrollbar);
1724 draw_template_details();
1725 ImGui::EndChild();
1726 } else if (ImGui::BeginTable("TemplateGrid", 2,
1727 ImGuiTableFlags_SizingStretchProp)) {
1728 ImGui::TableSetupColumn("TemplateList", ImGuiTableColumnFlags_WidthStretch,
1729 0.42f);
1730 ImGui::TableSetupColumn("TemplateDetails",
1731 ImGuiTableColumnFlags_WidthStretch, 0.58f);
1732
1733 ImGui::TableNextColumn();
1734 ImGui::BeginChild("TemplateList", ImVec2(0, 0), false,
1735 ImGuiWindowFlags_NoScrollbar);
1736 draw_template_list();
1737 ImGui::EndChild();
1738
1739 ImGui::TableNextColumn();
1740 ImGui::BeginChild("TemplateDetails", ImVec2(0, 0), false,
1741 ImGuiWindowFlags_NoScrollbar);
1742 draw_template_details();
1743 ImGui::EndChild();
1744
1745 ImGui::EndTable();
1746 }
1747
1748 ImGui::Spacing();
1749
1750 // Use Template button - enabled and functional
1751 {
1752 gui::StyleColorGuard button_colors({
1753 {ImGuiCol_Button, ImVec4(kSpiritOrange.x * 0.6f, kSpiritOrange.y * 0.6f,
1754 kSpiritOrange.z * 0.6f, 0.8f)},
1755 {ImGuiCol_ButtonHovered, kSpiritOrange},
1756 {ImGuiCol_ButtonActive,
1757 ImVec4(kSpiritOrange.x * 1.2f, kSpiritOrange.y * 1.2f,
1758 kSpiritOrange.z * 1.2f, 1.0f)},
1759 });
1760
1761 if (ImGui::Button(
1762 absl::StrFormat("%s Use Template", ICON_MD_ROCKET_LAUNCH).c_str(),
1763 ImVec2(-1, 30))) {
1764 // Trigger template-based project creation
1765 if (new_project_with_template_callback_) {
1766 new_project_with_template_callback_(
1767 templates[selected_template_].template_id);
1768 } else if (new_project_callback_) {
1769 // Fallback to regular new project if template callback not set
1770 new_project_callback_();
1771 }
1772 }
1773 }
1774
1775 if (ImGui::IsItemHovered()) {
1776 ImGui::SetTooltip(tr("%s Create new project with '%s' template\nThis will "
1777 "open a ROM and apply the template settings."),
1778 ICON_MD_INFO, templates[selected_template_].name);
1779 }
1780}
1781
1782void WelcomeScreen::DrawTipsSection() {
1783 // Entry animation for tips (section 6, appears last)
1784 float tips_progress = GetStaggeredEntryProgress(
1785 entry_time_, 6, kEntryAnimDuration, kEntryStaggerDelay);
1786
1787 if (tips_progress < 0.001f) {
1788 return; // Don't draw yet
1789 }
1790
1791 gui::StyleVarGuard alpha_guard(ImGuiStyleVar_Alpha, tips_progress);
1792
1793 // Static tip (or could rotate based on session start time rather than
1794 // animation)
1795 const char* tips[] = {
1796 "Open a ROM first, then save a copy before editing",
1797 "Projects track ROM versions and editor settings",
1798 "Use Project Management to swap ROMs and manage snapshots",
1799 "Press Ctrl+Shift+P for the command palette and F1 for help",
1800 "Shortcuts are configurable in Settings > Keyboard Shortcuts",
1801 "Project + settings data live under ~/.yaze (user profile on Windows)",
1802 "Use the panel browser to find any tool quickly"};
1803 int tip_index = 0; // Show first tip, or could be random on screen open
1804
1805 ImGui::Text(ICON_MD_LIGHTBULB);
1806 ImGui::SameLine();
1807 ImGui::TextColored(kTriforceGold, tr("Tip:"));
1808 ImGui::SameLine();
1809 ImGui::TextColored(ImVec4(0.8f, 0.8f, 0.8f, 1.0f), "%s", tips[tip_index]);
1810
1811 ImGui::SameLine(ImGui::GetWindowWidth() - 220);
1812 {
1813 gui::StyleColorGuard button_guard(ImGuiCol_Button,
1814 ImVec4(0.3f, 0.3f, 0.3f, 0.5f));
1815 if (ImGui::SmallButton(
1816 absl::StrFormat("%s Don't show again", ICON_MD_CLOSE).c_str())) {
1817 manually_closed_ = true;
1818 }
1819 }
1820}
1821
1822void WelcomeScreen::DrawWhatsNew() {
1823 // Entry animation for what's new (section 5)
1824 float whatsnew_progress = GetStaggeredEntryProgress(
1825 entry_time_, 5, kEntryAnimDuration, kEntryStaggerDelay);
1826
1827 if (whatsnew_progress < 0.001f) {
1828 return; // Don't draw yet
1829 }
1830
1831 gui::StyleVarGuard alpha_guard(ImGuiStyleVar_Alpha, whatsnew_progress);
1832
1833 ImGui::TextColored(kHeartRed, ICON_MD_NEW_RELEASES " Release History");
1834 ImGui::Spacing();
1835
1836 // Version badge (no animation)
1837 ImGui::TextColored(kMasterSwordBlue, ICON_MD_VERIFIED " Current: v%s",
1839 ImGui::Spacing();
1840 DrawThemeQuickSwitcher("WelcomeThemeQuickSwitch", ImVec2(-1, 0));
1841 ImGui::Spacing();
1842
1843 struct ReleaseHighlight {
1844 const char* icon;
1845 const char* text;
1846 };
1847
1848 struct ReleaseEntry {
1849 const char* icon;
1850 const char* version;
1851 const char* title;
1852 const char* date;
1853 ImVec4 color;
1854 const ReleaseHighlight* highlights;
1855 int highlight_count;
1856 };
1857
1858 const ReleaseHighlight highlights_071[] = {
1860 "Welcome screen overhaul: guided New Project wizard + template picker"},
1862 "Recent projects: async ROM scan, pin/rename/notes, 8s undo toast"},
1864 "Welcome actions now surfaced through the command palette"},
1866 "Dungeon editor parity: BG1/BG2 layout routing + pit mask fix"},
1868 "Dungeon ROM-backed object parity tests and render snapshots"},
1869 {ICON_MD_TUNE,
1870 "Simplified workbench inspector/navigation + action-oriented selection"},
1872 "Lazy session editors + deferred asset loads trim startup footprint"},
1874 "Editor source map: registry/, shell/, system/*/, hack/oracle/ — easier "
1875 "navigation for contributors"},
1876 };
1877 const ReleaseHighlight highlights_070[] = {
1878 {ICON_MD_TABLET, "iOS Remote Control with Bonjour LAN auto-discovery"},
1880 "Remote Room Viewer: browse all 296 dungeon rooms on iPad"},
1882 "Remote Command Runner: z3ed CLI from iPad with autocomplete"},
1883 {ICON_MD_API, "Desktop HTTP API: command execute/list + annotation CRUD"},
1884 {ICON_MD_UNDO,
1885 "Sprite + Screen editor undo/redo and message replace-all"},
1886 {ICON_MD_ARCHIVE, "Desktop BPS patch export/import with CRC validation"},
1887 {ICON_MD_TUNE, "Themed tab bar and widget adoption across key editors"},
1888 };
1889 const ReleaseHighlight highlights_062[] = {
1890 {ICON_MD_ARCHIVE, ".yazeproj bundle verify/pack/unpack reliability"},
1891 {ICON_MD_SHIELD, "Oracle smoke/preflight workflow hardening"},
1892 {ICON_MD_TUNE, "Dungeon placement feedback and editor UX polish"},
1893 };
1894 const ReleaseHighlight highlights_061[] = {
1895 {ICON_MD_SHIELD, "Oracle smoke/preflight workflow hardening"},
1896 {ICON_MD_ARCHIVE, "Cross-platform .yazeproj verify/pack/unpack flows"},
1897 {ICON_MD_TUNE, "Dungeon placement feedback and workbench UX upgrades"},
1898 {ICON_MD_GRID_VIEW, "Tile selector jump/filter and decimal ID input"},
1899 };
1900 const ReleaseHighlight highlights_060[] = {
1901 {ICON_MD_PALETTE, "GUI modernization with unified themed widgets"},
1902 {ICON_MD_COLOR_LENS, "Semantic theming and smooth editor transitions"},
1903 {ICON_MD_GRID_VIEW, "Visual Object Tile Editor for dungeon rooms"},
1904 {ICON_MD_UNDO, "Unified cross-editor Undo/Redo system"},
1905 };
1906 const ReleaseHighlight highlights_056[] = {
1907 {ICON_MD_TRAM, "Minecart overlays and collision tile validation"},
1908 {ICON_MD_RULE, "Track audit tooling with filler/missing-start checks"},
1909 {ICON_MD_TUNE, "Object preview stability and layer-aware hover"},
1910 };
1911 const ReleaseHighlight highlights_055[] = {
1912 {ICON_MD_ACCOUNT_TREE, "EditorManager architecture refactor"},
1913 {ICON_MD_FACT_CHECK, "Expanded tests for editor and ASAR workflows"},
1914 {ICON_MD_BUILD, "Build cleanup with shared yaze_core_lib target"},
1915 };
1916 const ReleaseHighlight highlights_054[] = {
1917 {ICON_MD_BUG_REPORT, "Mesen2 debug panel + socket controls"},
1918 {ICON_MD_SYNC, "Model registry + API refresh stability"},
1919 {ICON_MD_TERMINAL, "ROM/debug CLI workflows"},
1920 };
1921 const ReleaseHighlight highlights_053[] = {
1922 {ICON_MD_BUILD, "DMG validation + build polish"},
1923 {ICON_MD_PUBLIC, "WASM storage + service worker fixes"},
1924 {ICON_MD_TERMINAL, "Local model support (LM Studio)"},
1925 };
1926 const ReleaseHighlight highlights_052[] = {
1927 {ICON_MD_SHIELD, "AI runtime guard fixes"},
1928 {ICON_MD_BUILD, "Build presets stabilized"},
1929 };
1930 const ReleaseHighlight highlights_051[] = {
1931 {ICON_MD_PALETTE, "ImHex-style UI modernization"},
1932 {ICON_MD_TUNE, "Theme system + layout polish"},
1933 {ICON_MD_DASHBOARD, "Panel registry improvements"},
1934 };
1935 const ReleaseHighlight highlights_050[] = {
1936 {ICON_MD_TABLET, "Platform expansion + iOS scaffolding"},
1937 {ICON_MD_VISIBILITY, "Editor UX + stability"},
1938 {ICON_MD_PUBLIC, "WASM preview hardening"},
1939 };
1940
1941 const ReleaseEntry releases[] = {
1943 "Welcome screen overhaul + dungeon editor parity", "Apr 2026",
1944 kHyruleGreen, highlights_071,
1945 static_cast<int>(sizeof(highlights_071) / sizeof(highlights_071[0]))},
1946 {ICON_MD_ROCKET_LAUNCH, "0.7.0",
1947 "Feature Completion + iOS Remote Control", "Mar 2026", kMasterSwordBlue,
1948 highlights_070,
1949 static_cast<int>(sizeof(highlights_070) / sizeof(highlights_070[0]))},
1950 {ICON_MD_ARCHIVE, "0.6.2",
1951 "Bundle reliability + Oracle workflow hardening", "Feb 2026",
1952 kSpiritOrange, highlights_062,
1953 static_cast<int>(sizeof(highlights_062) / sizeof(highlights_062[0]))},
1954 {ICON_MD_SHIELD, "0.6.1", "Oracle + bundle workflow hardening",
1955 "Feb 24, 2026", kMasterSwordBlue, highlights_061,
1956 static_cast<int>(sizeof(highlights_061) / sizeof(highlights_061[0]))},
1957 {ICON_MD_AUTO_AWESOME, "0.6.0", "GUI Modernization + Tile Editor",
1958 "Feb 13, 2026", kTriforceGold, highlights_060,
1959 static_cast<int>(sizeof(highlights_060) / sizeof(highlights_060[0]))},
1960 {ICON_MD_TRAM, "0.5.6", "Minecart workflow + editor stability",
1961 "Feb 5, 2026", kSpiritOrange, highlights_056,
1962 static_cast<int>(sizeof(highlights_056) / sizeof(highlights_056[0]))},
1963 {ICON_MD_ACCOUNT_TREE, "0.5.5", "Editor architecture + testability",
1964 "Jan 28, 2026", kShadowPurple, highlights_055,
1965 static_cast<int>(sizeof(highlights_055) / sizeof(highlights_055[0]))},
1966 {ICON_MD_BUG_REPORT, "0.5.4", "Stability + Mesen2 debugging",
1967 "Jan 25, 2026", kMasterSwordBlue, highlights_054,
1968 static_cast<int>(sizeof(highlights_054) / sizeof(highlights_054[0]))},
1969 {ICON_MD_BUILD, "0.5.3", "Build + WASM improvements", "Jan 20, 2026",
1970 kMasterSwordBlue, highlights_053,
1971 static_cast<int>(sizeof(highlights_053) / sizeof(highlights_053[0]))},
1972 {ICON_MD_TUNE, "0.5.2", "Runtime guards", "Jan 20, 2026", kSpiritOrange,
1973 highlights_052,
1974 static_cast<int>(sizeof(highlights_052) / sizeof(highlights_052[0]))},
1975 {ICON_MD_AUTO_AWESOME, "0.5.1", "UI polish + templates", "Jan 20, 2026",
1976 kTriforceGold, highlights_051,
1977 static_cast<int>(sizeof(highlights_051) / sizeof(highlights_051[0]))},
1978 {ICON_MD_ROCKET_LAUNCH, "0.5.0", "Platform expansion", "Jan 10, 2026",
1979 kHyruleGreen, highlights_050,
1980 static_cast<int>(sizeof(highlights_050) / sizeof(highlights_050[0]))},
1981 };
1982
1983 const ImVec4 text_secondary = gui::GetTextSecondaryVec4();
1984 for (int i = 0; i < static_cast<int>(sizeof(releases) / sizeof(releases[0]));
1985 ++i) {
1986 const auto& release = releases[i];
1987 ImGui::PushID(release.version);
1988 if (i > 0) {
1989 ImGui::Separator();
1990 }
1991 ImGui::TextColored(release.color, tr("%s v%s"), release.icon,
1992 release.version);
1993 ImGui::SameLine();
1994 ImGui::TextColored(text_secondary, "%s", release.date);
1995 ImGui::TextColored(text_secondary, "%s", release.title);
1996 for (int j = 0; j < release.highlight_count; ++j) {
1997 ImGui::Bullet();
1998 ImGui::SameLine();
1999 ImGui::TextColored(release.color, "%s", release.highlights[j].icon);
2000 ImGui::SameLine();
2001 ImGui::TextColored(text_secondary, "%s", release.highlights[j].text);
2002 }
2003 ImGui::Spacing();
2004 ImGui::PopID();
2005 }
2006
2007 ImGui::Spacing();
2008 {
2009 gui::StyleColorGuard button_colors({
2010 {ImGuiCol_Button,
2011 ImVec4(kMasterSwordBlue.x * 0.6f, kMasterSwordBlue.y * 0.6f,
2012 kMasterSwordBlue.z * 0.6f, 0.8f)},
2013 {ImGuiCol_ButtonHovered, kMasterSwordBlue},
2014 });
2015 if (ImGui::Button(
2016 absl::StrFormat("%s View Full Changelog", ICON_MD_OPEN_IN_NEW)
2017 .c_str(),
2018 ImVec2(-1, 0))) {
2019 // Open changelog or GitHub releases
2020 }
2021 }
2022}
2023
2024} // namespace editor
2025} // namespace yaze
static TimingManager & Get()
Definition timing.h:20
float GetDeltaTime() const
Get the last frame's delta time in seconds.
Definition timing.h:60
const std::vector< RecentProject > & entries() const
Manages user preferences and settings persistence.
std::function< void()> open_rom_callback_
static constexpr float kEntryStaggerDelay
RecentProjectsModel recent_projects_model_
static constexpr int kNumTriforces
static constexpr float kEntryAnimDuration
void RefreshRecentProjects(bool force=false)
Refresh recent projects list from the project manager.
ImVec2 triforce_base_positions_[kNumTriforces]
Particle particles_[kMaxParticles]
void UpdateAnimations()
Update animation time for dynamic effects.
static constexpr int kMaxParticles
bool Show(bool *p_open)
Show the welcome screen.
ImVec2 triforce_positions_[kNumTriforces]
std::function< void(const std::string &) open_project_callback_)
std::function< void()> open_prototype_research_callback_
void SetUserSettings(UserSettings *settings)
Wire persisted user settings so animation tweaks survive restart.
std::function< void()> open_assembly_editor_no_rom_callback_
RAII guard for ImGui style colors.
Definition style_guard.h:27
RAII guard for ImGui style vars.
Definition style_guard.h:68
RAII guard for ImGui child windows with optional styling.
static ThemeManager & Get()
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
#define YAZE_VERSION_STRING
#define ICON_MD_ROCKET_LAUNCH
Definition icons.h:1612
#define ICON_MD_GRID_VIEW
Definition icons.h:897
#define ICON_MD_TRAM
Definition icons.h:2006
#define ICON_MD_SHUFFLE
Definition icons.h:1738
#define ICON_MD_INSERT_DRIVE_FILE
Definition icons.h:999
#define ICON_MD_FOLDER_OPEN
Definition icons.h:813
#define ICON_MD_ACCOUNT_TREE
Definition icons.h:83
#define ICON_MD_INFO
Definition icons.h:993
#define ICON_MD_MEMORY
Definition icons.h:1195
#define ICON_MD_SHIELD
Definition icons.h:1724
#define ICON_MD_FOLDER_SPECIAL
Definition icons.h:815
#define ICON_MD_SEARCH
Definition icons.h:1673
#define ICON_MD_LIGHTBULB
Definition icons.h:1083
#define ICON_MD_TABLET
Definition icons.h:1937
#define ICON_MD_TERRAIN
Definition icons.h:1952
#define ICON_MD_STAR
Definition icons.h:1848
#define ICON_MD_NEW_RELEASES
Definition icons.h:1291
#define ICON_MD_PLAY_ARROW
Definition icons.h:1479
#define ICON_MD_CHECK
Definition icons.h:397
#define ICON_MD_CONSTRUCTION
Definition icons.h:458
#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_AUTO_AWESOME
Definition icons.h:214
#define ICON_MD_CODE
Definition icons.h:434
#define ICON_MD_VISIBILITY
Definition icons.h:2101
#define ICON_MD_BUG_REPORT
Definition icons.h:327
#define ICON_MD_EDIT
Definition icons.h:645
#define ICON_MD_PUBLIC
Definition icons.h:1524
#define ICON_MD_SPEED
Definition icons.h:1817
#define ICON_MD_VERIFIED
Definition icons.h:2055
#define ICON_MD_CASTLE
Definition icons.h:380
#define ICON_MD_AUTO_FIX_HIGH
Definition icons.h:218
#define ICON_MD_API
Definition icons.h:161
#define ICON_MD_FACT_CHECK
Definition icons.h:721
#define ICON_MD_LAYERS
Definition icons.h:1068
#define ICON_MD_BOLT
Definition icons.h:282
#define ICON_MD_NOTE
Definition icons.h:1329
#define ICON_MD_CHECK_CIRCLE
Definition icons.h:400
#define ICON_MD_TERMINAL
Definition icons.h:1951
#define ICON_MD_BUILD
Definition icons.h:328
#define ICON_MD_TOUCH_APP
Definition icons.h:2000
#define ICON_MD_ARCHIVE
Definition icons.h:171
#define ICON_MD_DASHBOARD
Definition icons.h:517
#define ICON_MD_MOUSE
Definition icons.h:1251
#define ICON_MD_PALETTE
Definition icons.h:1370
#define ICON_MD_OPEN_IN_NEW
Definition icons.h:1354
#define ICON_MD_CONTENT_COPY
Definition icons.h:465
#define ICON_MD_SYNC
Definition icons.h:1919
#define ICON_MD_PUSH_PIN
Definition icons.h:1529
#define ICON_MD_RULE
Definition icons.h:1633
#define ICON_MD_COLOR_LENS
Definition icons.h:440
#define ICON_MD_CLOSE
Definition icons.h:418
#define ICON_MD_COTTAGE
Definition icons.h:480
#define ICON_MD_UNDO
Definition icons.h:2039
#define ICON_MD_ADD_CIRCLE
Definition icons.h:95
#define ICON_MD_OPACITY
Definition icons.h:1351
#define ICON_MD_HISTORY
Definition icons.h:946
#define ICON_MD_DELETE_SWEEP
Definition icons.h:533
#define ICON_MD_EXPLORE
Definition icons.h:705
#define LOG_WARN(category, format,...)
Definition log.h:107
std::string EllipsizeText(const std::string &text, float max_width)
void DrawTriforceBackground(ImDrawList *draw_list, ImVec2 pos, float size, float alpha, float glow)
GridLayout ComputeGridLayout(float avail_width, float min_width, float max_width, float min_height, float max_height, float preferred_width, float aspect_ratio, float spacing)
void DrawThemeQuickSwitcher(const char *popup_id, const ImVec2 &button_size)
float GetStaggeredEntryProgress(float entry_time, int section_index, float duration, float stagger_delay)
ImVec4 ConvertColorToImVec4(const Color &color)
Definition color.h:134
void ColoredText(const char *text, const ImVec4 &color)
bool ThemedButton(const char *label, const ImVec2 &size, const char *panel_id, const char *anim_id)
Draw a standard text button with theme colors.
ImVec4 GetSurfaceVariantVec4()
ImVec4 GetSurfaceVec4()
ImVec4 GetTextDisabledVec4()
ImVec4 GetTextSecondaryVec4()
void ColoredTextF(const ImVec4 &color, const char *fmt,...)
ImVec4 GetOnSurfaceVec4()
#define M_PI