yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
welcome_screen.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SHELL_COORDINATOR_WELCOME_SCREEN_H_
2#define YAZE_APP_EDITOR_SHELL_COORDINATOR_WELCOME_SCREEN_H_
3
4#include <cstdint>
5#include <functional>
6#include <string>
7#include <vector>
8
10#include "imgui/imgui.h"
11
12namespace yaze {
13namespace editor {
14
15class UserSettings;
16
22 public:
24
30 bool Show(bool* p_open);
31
35 void SetOpenRomCallback(std::function<void()> callback) {
36 open_rom_callback_ = callback;
37 }
38
42 void SetNewProjectCallback(std::function<void()> callback) {
43 new_project_callback_ = callback;
44 }
45
50 std::function<void(const std::string&)> callback) {
51 open_project_callback_ = callback;
52 }
53
57 void SetOpenPrototypeResearchCallback(std::function<void()> callback) {
58 open_prototype_research_callback_ = std::move(callback);
59 }
60
64 void SetOpenAssemblyEditorNoRomCallback(std::function<void()> callback) {
65 open_assembly_editor_no_rom_callback_ = std::move(callback);
66 }
67
71 void SetOpenProjectManagementCallback(std::function<void()> callback) {
73 }
74
76 void SetComingFromZScreamCallback(std::function<void()> callback) {
77 coming_from_zscream_callback_ = std::move(callback);
78 }
79
87 void RefreshRecentProjects(bool force = false);
88
92 void UpdateAnimations();
93
97 bool ShouldShow() const { return !manually_closed_; }
98
103
109 void SetLayoutOffsets(float left, float right) {
110 left_offset_ = left;
111 right_offset_ = right;
112 }
113
117 void SetContextState(bool has_rom) { has_rom_ = has_rom; }
118
122 void SetUserSettings(UserSettings* settings);
123
132
133 private:
135
136 void DrawHeader();
137 void DrawQuickActions();
138 void DrawRecentProjects();
139 void DrawProjectPanel(const RecentProject& project, int index,
140 const ImVec2& card_size);
141 void DrawFooterBar();
142 void DrawFirstRunGuide();
145 static bool ShouldUseStackedLayout(float content_width, float content_height,
146 float layout_scale);
147 static int CalculateVisibleRecentCount(int entry_count,
148 float available_height,
149 float row_height, float row_gap,
150 float more_line_height);
151 static const RecentProject* FindResumeProject(
152 const std::vector<RecentProject>& entries);
153
155 bool manually_closed_ = false;
156
157 // Callbacks
158 std::function<void()> open_rom_callback_;
159 std::function<void()> new_project_callback_;
160 std::function<void(const std::string&)> open_project_callback_;
164 std::function<void()> coming_from_zscream_callback_;
165
166 // Animation state
167 float animation_time_ = 0.0f;
168 // Staggered entry animations
170 float entry_time_ = 0.0f; // Time since welcome screen opened
171 static constexpr float kEntryAnimDuration = 0.4f; // Duration per section
172 static constexpr float kEntryStaggerDelay = 0.08f; // Delay between sections
173
174 // Interactive triforce positions (smooth interpolation)
175 static constexpr int kNumTriforces = 6;
179
180 // Particle system
181 static constexpr int kMaxParticles = 50;
182 struct Particle {
183 ImVec2 position;
184 ImVec2 velocity;
185 float size;
186 float alpha;
187 float lifetime;
189 };
192 // Fractional accumulator for particle spawning. Previously a static local
193 // inside Show(), which silently shared state between (hypothetical) multiple
194 // WelcomeScreen instances and couldn't be reset.
196
197 // Triforce animation settings
199 float triforce_speed_multiplier_ = 0.3f; // Default slower speed
203 float particle_spawn_rate_ = 2.0f; // Particles per second
204
205 // Layout offsets for sidebar awareness (so welcome screen centers in dockspace)
206 float left_offset_ = 0.0f;
207 float right_offset_ = 0.0f;
208
209 // Context state for gating actions
210 bool has_rom_ = false;
212
213 // Inline popup state for rename / edit-notes flows triggered from the
214 // recent-project context menu. Single-slot (one popup at a time).
218 char rename_buffer_[256] = {};
219 char notes_buffer_[1024] = {};
220};
221
222} // namespace editor
223} // namespace yaze
224
225#endif // YAZE_APP_EDITOR_SHELL_COORDINATOR_WELCOME_SCREEN_H_
Manages user preferences and settings persistence.
Modern welcome screen with project grid and quick actions.
std::function< void()> open_rom_callback_
std::function< void()> new_project_callback_
void SetNewProjectCallback(std::function< void()> callback)
Set callback for creating new project.
void MarkManuallyClosed()
Mark as manually closed (don't show again this session)
static int CalculateVisibleRecentCount(int entry_count, float available_height, float row_height, float row_gap, float more_line_height)
static constexpr float kEntryStaggerDelay
RecentProjectsModel recent_projects_model_
static constexpr int kNumTriforces
const RecentProjectsModel & recent_projects() const
void SetLayoutOffsets(float left, float right)
Set layout offsets for sidebar awareness.
RecentAnnotationKind pending_annotation_kind_
static constexpr float kEntryAnimDuration
void SetOpenAssemblyEditorNoRomCallback(std::function< void()> callback)
Open the assembly editor for file/folder work (no ROM required).
void RefreshRecentProjects(bool force=false)
Refresh recent projects list from the project manager.
bool ShouldShow() const
Check if screen should be shown.
void DrawProjectPanel(const RecentProject &project, int index, const ImVec2 &card_size)
void SetOpenRomCallback(std::function< void()> callback)
Set callback for opening ROM.
RecentProjectsModel & recent_projects()
Accessor used by command-palette wiring so the same recent list drives both the visual cards and the ...
ImVec2 triforce_base_positions_[kNumTriforces]
Particle particles_[kMaxParticles]
void SetOpenPrototypeResearchCallback(std::function< void()> callback)
Open the graphics editor focused on prototype research (no ROM).
static bool ShouldUseStackedLayout(float content_width, float content_height, float layout_scale)
void UpdateAnimations()
Update animation time for dynamic effects.
void SetOpenProjectManagementCallback(std::function< void()> callback)
Set callback for showing project management.
static constexpr int kMaxParticles
void SetContextState(bool has_rom)
Set whether a ROM is currently loaded for first-run guidance.
bool Show(bool *p_open)
Show the welcome screen.
static const RecentProject * FindResumeProject(const std::vector< RecentProject > &entries)
ImVec2 triforce_positions_[kNumTriforces]
std::function< void(const std::string &) open_project_callback_)
void SetOpenProjectCallback(std::function< void(const std::string &)> callback)
Set callback for opening project.
std::function< void()> open_prototype_research_callback_
void SetUserSettings(UserSettings *settings)
Load persisted Welcome-screen animation preferences.
std::function< void()> open_assembly_editor_no_rom_callback_
void SetComingFromZScreamCallback(std::function< void()> callback)
Open the migration guide for users coming from ZScream.
std::function< void()> open_project_management_callback_
std::function< void()> coming_from_zscream_callback_