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
82 void RefreshRecentProjects(bool force = false);
83
87 void UpdateAnimations();
88
92 bool ShouldShow() const { return !manually_closed_; }
93
98
104 void SetLayoutOffsets(float left, float right) {
105 left_offset_ = left;
106 right_offset_ = right;
107 }
108
112 void SetContextState(bool has_rom) { has_rom_ = has_rom; }
113
117 void SetUserSettings(UserSettings* settings);
118
127
128 private:
130
131 void DrawHeader();
132 void DrawQuickActions();
133 void DrawRecentProjects();
134 void DrawProjectPanel(const RecentProject& project, int index,
135 const ImVec2& card_size);
136 void DrawFooterBar();
137 void DrawFirstRunGuide();
140 static bool ShouldUseStackedLayout(float content_width, float content_height,
141 float layout_scale);
142 static int CalculateVisibleRecentCount(int entry_count,
143 float available_height,
144 float row_height, float row_gap,
145 float more_line_height);
146 static const RecentProject* FindResumeProject(
147 const std::vector<RecentProject>& entries);
148
150 bool manually_closed_ = false;
151
152 // Callbacks
153 std::function<void()> open_rom_callback_;
154 std::function<void()> new_project_callback_;
155 std::function<void(const std::string&)> open_project_callback_;
159
160 // Animation state
161 float animation_time_ = 0.0f;
162 // Staggered entry animations
164 float entry_time_ = 0.0f; // Time since welcome screen opened
165 static constexpr float kEntryAnimDuration = 0.4f; // Duration per section
166 static constexpr float kEntryStaggerDelay = 0.08f; // Delay between sections
167
168 // Interactive triforce positions (smooth interpolation)
169 static constexpr int kNumTriforces = 6;
173
174 // Particle system
175 static constexpr int kMaxParticles = 50;
176 struct Particle {
177 ImVec2 position;
178 ImVec2 velocity;
179 float size;
180 float alpha;
181 float lifetime;
183 };
186 // Fractional accumulator for particle spawning. Previously a static local
187 // inside Show(), which silently shared state between (hypothetical) multiple
188 // WelcomeScreen instances and couldn't be reset.
190
191 // Triforce animation settings
193 float triforce_speed_multiplier_ = 0.3f; // Default slower speed
197 float particle_spawn_rate_ = 2.0f; // Particles per second
198
199 // Layout offsets for sidebar awareness (so welcome screen centers in dockspace)
200 float left_offset_ = 0.0f;
201 float right_offset_ = 0.0f;
202
203 // Context state for gating actions
204 bool has_rom_ = false;
206
207 // Inline popup state for rename / edit-notes flows triggered from the
208 // recent-project context menu. Single-slot (one popup at a time).
212 char rename_buffer_[256] = {};
213 char notes_buffer_[1024] = {};
214};
215
216} // namespace editor
217} // namespace yaze
218
219#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_
std::function< void()> open_project_management_callback_