yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
project.h
Go to the documentation of this file.
1#ifndef YAZE_CORE_PROJECT_H
2#define YAZE_CORE_PROJECT_H
3
4#include <algorithm>
5#include <map>
6#include <string>
7#include <unordered_map>
8#include <vector>
9
10#include "absl/status/status.h"
11#include "absl/status/statusor.h"
12#include "absl/strings/string_view.h"
13#include "core/features.h"
15
16namespace yaze {
17namespace project {
18
23enum class ProjectFormat {
24 kYazeNative, // .yaze - YAZE native format
25 kZScreamCompat // .zsproj - ZScream compatibility format
26};
27
33 std::string version = "2.0";
34 std::string created_by = "YAZE";
35 std::string created_date;
36 std::string last_modified;
37 std::string yaze_version;
38 std::string description;
39 std::vector<std::string> tags;
40 std::string author;
41 std::string license;
42 std::string project_id;
43
44 // ZScream compatibility
45 bool zscream_compatible = false;
46 std::string zscream_version;
47};
48
54 // Display settings
55 float font_global_scale = 1.0f;
56 bool dark_mode = true;
57 std::string ui_theme = "default";
58
59 // Layout settings
60 std::string last_layout_preset;
61 std::vector<std::string> saved_layouts;
62 std::string window_layout_data; // ImGui .ini data
63
64 // Editor preferences
65 bool autosave_enabled = true;
66 float autosave_interval_secs = 300.0f; // 5 minutes
67 bool backup_on_save = true;
68 bool show_grid = true;
69 bool show_collision = false;
70
71 // Label preferences
72 bool prefer_hmagic_names = true; // Prefer Hyrule Magic sprite names
73
74 // Advanced settings
75 std::map<std::string, std::string> custom_keybindings;
76 std::vector<std::string> recent_files;
77 std::map<std::string, bool> editor_visibility;
78};
79
85 // Basic project info
87 std::string name;
88 std::string filepath;
90
91 // ROM and resources
92 std::string rom_filename;
93 std::string rom_backup_folder;
94 std::vector<std::string> additional_roms; // For multi-ROM projects
95
96 // Code and assets
97 std::string code_folder;
98 std::string assets_folder;
99 std::string patches_folder;
100 std::string labels_filename;
101 std::string symbols_filename;
102 std::string
103 custom_objects_folder; // Folder containing custom object .bin files
104
105 // Consolidated settings (previously scattered across multiple files)
108 std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
110
111 // Embedded labels flag - when true, resource_labels contains all default
112 // Zelda3 labels
114
115 // Build and deployment
116 std::string build_script;
117 std::string output_folder;
118 std::vector<std::string> build_configurations;
119 std::string build_target;
120 std::string asm_entry_point;
121 std::vector<std::string> asm_sources;
122
123 // Version control integration
124 std::string git_repository;
125 bool track_changes = true;
126 std::string last_build_hash;
128
129 // AI Agent Settings
131 std::string ai_provider =
132 "auto"; // auto, gemini, anthropic, openai, ollama, mock
133 std::string ai_model; // e.g., "gemini-2.5-flash", "llama3:latest"
134 std::string ollama_host = "http://localhost:11434";
135 std::string gemini_api_key; // Optional, can use env var
136 std::string
137 custom_system_prompt; // Path to custom prompt (relative to project)
138 bool use_custom_prompt = false;
139 bool show_reasoning = true;
140 bool verbose = false;
143 float temperature = 0.25f;
144 float top_p = 0.95f;
146 bool stream_responses = false;
147 std::vector<std::string> favorite_models;
148 std::vector<std::string> model_chain;
149 int chain_mode = 0;
155 bool enable_tool_gui = true;
156 bool enable_tool_music = true;
159 std::string builder_blueprint_path; // Saved agent builder configuration
161
162 // ZScream compatibility (for importing existing projects)
163 std::string zscream_project_file; // Path to original .zsproj if importing
164 std::map<std::string, std::string> zscream_mappings; // Field mappings
165
166 // WASM persistence (project + music state in IndexedDB)
172
173 // Methods
174 absl::Status Create(const std::string& project_name,
175 const std::string& base_path);
176 absl::Status Open(const std::string& project_path);
177 absl::Status Save();
178 absl::Status SaveAs(const std::string& new_path);
179 absl::Status ImportZScreamProject(const std::string& zscream_project_path);
180 absl::Status ExportForZScream(const std::string& target_path);
181
182 // Settings management
183 absl::Status LoadAllSettings();
184 absl::Status SaveAllSettings();
185 absl::Status ResetToDefaults();
186
187 // Labels management
188 absl::Status InitializeEmbeddedLabels(
189 const std::unordered_map<std::string,
190 std::unordered_map<std::string, std::string>>&
191 labels); // Load all default Zelda3 labels
192 std::string GetLabel(const std::string& resource_type, int id,
193 const std::string& default_value = "") const;
194
200 absl::Status ImportLabelsFromZScream(const std::string& filepath);
201
207 absl::Status ImportLabelsFromZScreamContent(const std::string& content);
208
213
214 // Validation and integrity
215 absl::Status Validate() const;
216 std::vector<std::string> GetMissingFiles() const;
217 absl::Status RepairProject();
218
219 // Utilities
220 std::string GetDisplayName() const;
221 std::string GetRelativePath(const std::string& absolute_path) const;
222 std::string GetAbsolutePath(const std::string& relative_path) const;
223 bool IsEmpty() const;
224 std::string MakeStorageKey(absl::string_view suffix) const;
225
226 // Project state
227 bool project_opened() const { return !name.empty() && !filepath.empty(); }
228
229 private:
230 absl::StatusOr<std::string> SerializeToString() const;
231 absl::Status ParseFromString(const std::string& content);
232 absl::Status LoadFromYazeFormat(const std::string& project_path);
233 absl::Status SaveToYazeFormat();
234 absl::Status ImportFromZScreamFormat(const std::string& project_path);
235
236#ifdef YAZE_ENABLE_JSON_PROJECT_FORMAT
237 absl::Status LoadFromJsonFormat(const std::string& project_path);
238 absl::Status SaveToJsonFormat();
239#endif
240
241 void InitializeDefaults();
242 std::string GenerateProjectId() const;
243};
244
250 public:
251 // Project templates
253 std::string name;
254 std::string description;
255 std::string icon;
257 };
258
259 static std::vector<ProjectTemplate> GetProjectTemplates();
260 static absl::StatusOr<YazeProject> CreateFromTemplate(
261 const std::string& template_name, const std::string& project_name,
262 const std::string& base_path);
263
264 // Project discovery and management
265 static std::vector<std::string> FindProjectsInDirectory(
266 const std::string& directory);
267 static absl::Status BackupProject(const YazeProject& project);
268 static absl::Status RestoreProject(const std::string& backup_path);
269
270 // Format conversion utilities
271 static absl::Status ConvertProject(const std::string& source_path,
272 const std::string& target_path,
273 ProjectFormat target_format);
274
275 // Validation and repair
276 static absl::Status ValidateProjectStructure(const YazeProject& project);
277 static std::vector<std::string> GetRecommendedFixesForProject(
278 const YazeProject& project);
279};
280
281// Compatibility - ResourceLabelManager (still used by ROM class)
283 bool LoadLabels(const std::string& filename);
284 bool SaveLabels();
285 void DisplayLabels(bool* p_open);
286 void EditLabel(const std::string& type, const std::string& key,
287 const std::string& newValue);
288 void SelectableLabelWithNameEdit(bool selected, const std::string& type,
289 const std::string& key,
290 const std::string& defaultValue);
291 std::string GetLabel(const std::string& type, const std::string& key);
292 std::string CreateOrGetLabel(const std::string& type, const std::string& key,
293 const std::string& defaultValue);
294
295 bool labels_loaded_ = false;
296 std::string filename_;
298 std::string key_name;
300 };
301
302 std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
304};
305
306// Compatibility - RecentFilesManager
307const std::string kRecentFilesFilename = "recent_files.txt";
308
310 public:
311 // Singleton pattern - get the global instance
313 static RecentFilesManager instance;
314 return instance;
315 }
316
317 // Delete copy constructor and assignment operator
320
321 void AddFile(const std::string& file_path) {
322 // Add a file to the list, avoiding duplicates
323 // Move to front if already exists (MRU - Most Recently Used)
324 auto it = std::find(recent_files_.begin(), recent_files_.end(), file_path);
325 if (it != recent_files_.end()) {
326 recent_files_.erase(it);
327 }
328 recent_files_.insert(recent_files_.begin(), file_path);
329
330 // Limit to 20 most recent files
331 if (recent_files_.size() > 20) {
332 recent_files_.resize(20);
333 }
334 }
335
336 void RemoveFile(const std::string& file_path) {
337 auto it = std::find(recent_files_.begin(), recent_files_.end(), file_path);
338 if (it != recent_files_.end()) {
339 recent_files_.erase(it);
340 }
341 }
342
343 void Save();
344
345 void Load();
346
347 const std::vector<std::string>& GetRecentFiles() const {
348 return recent_files_;
349 }
350
351 void Clear() { recent_files_.clear(); }
352
353 private:
355 Load(); // Load on construction
356 }
357
358 std::string GetFilePath() const;
359
360 std::vector<std::string> recent_files_;
361};
362
363} // namespace project
364} // namespace yaze
365
366#endif // YAZE_CORE_PROJECT_H
Enhanced project management with templates and validation.
Definition project.h:249
static std::vector< std::string > FindProjectsInDirectory(const std::string &directory)
Definition project.cc:1122
static absl::Status ValidateProjectStructure(const YazeProject &project)
Definition project.cc:1180
static absl::StatusOr< YazeProject > CreateFromTemplate(const std::string &template_name, const std::string &project_name, const std::string &base_path)
Definition project.cc:1080
static std::vector< std::string > GetRecommendedFixesForProject(const YazeProject &project)
Definition project.cc:1185
static std::vector< ProjectTemplate > GetProjectTemplates()
Definition project.cc:933
static absl::Status RestoreProject(const std::string &backup_path)
static absl::Status ConvertProject(const std::string &source_path, const std::string &target_path, ProjectFormat target_format)
static absl::Status BackupProject(const YazeProject &project)
Definition project.cc:1147
void RemoveFile(const std::string &file_path)
Definition project.h:336
std::string GetFilePath() const
Definition project.cc:1736
void AddFile(const std::string &file_path)
Definition project.h:321
static RecentFilesManager & GetInstance()
Definition project.h:312
const std::vector< std::string > & GetRecentFiles() const
Definition project.h:347
RecentFilesManager(const RecentFilesManager &)=delete
std::vector< std::string > recent_files_
Definition project.h:360
RecentFilesManager & operator=(const RecentFilesManager &)=delete
const std::string kRecentFilesFilename
Definition project.h:307
ProjectFormat
Supported project file formats.
Definition project.h:23
Enhanced metadata for project tracking.
Definition project.h:32
std::vector< std::string > tags
Definition project.h:39
std::string CreateOrGetLabel(const std::string &type, const std::string &key, const std::string &defaultValue)
Definition project.cc:1335
std::string GetLabel(const std::string &type, const std::string &key)
Definition project.cc:1322
void EditLabel(const std::string &type, const std::string &key, const std::string &newValue)
Definition project.cc:1304
bool LoadLabels(const std::string &filename)
Definition project.cc:1220
void SelectableLabelWithNameEdit(bool selected, const std::string &type, const std::string &key, const std::string &defaultValue)
Definition project.cc:1310
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > labels_
Definition project.h:303
Consolidated workspace and UI settings.
Definition project.h:53
std::map< std::string, std::string > custom_keybindings
Definition project.h:75
std::vector< std::string > saved_layouts
Definition project.h:61
std::map< std::string, bool > editor_visibility
Definition project.h:77
std::vector< std::string > recent_files
Definition project.h:76
std::vector< std::string > favorite_models
Definition project.h:147
std::vector< std::string > model_chain
Definition project.h:148
Modern project structure with comprehensive settings consolidation.
Definition project.h:84
std::string rom_backup_folder
Definition project.h:93
absl::Status ResetToDefaults()
Definition project.cc:733
std::string custom_objects_folder
Definition project.h:103
absl::Status RepairProject()
Definition project.cc:794
std::string MakeStorageKey(absl::string_view suffix) const
Definition project.cc:209
struct yaze::project::YazeProject::MusicPersistence music_persistence
bool project_opened() const
Definition project.h:227
absl::StatusOr< std::string > SerializeToString() const
Definition project.cc:225
std::string zscream_project_file
Definition project.h:163
absl::Status ExportForZScream(const std::string &target_path)
Definition project.cc:700
ProjectMetadata metadata
Definition project.h:86
absl::Status ImportZScreamProject(const std::string &zscream_project_path)
Definition project.cc:677
absl::Status SaveAllSettings()
Definition project.cc:728
absl::Status ImportLabelsFromZScreamContent(const std::string &content)
Import labels from ZScream format content directly.
Definition project.cc:1443
std::string git_repository
Definition project.h:124
void InitializeResourceLabelProvider()
Initialize the global ResourceLabelProvider with this project's labels.
Definition project.cc:1467
std::string rom_filename
Definition project.h:92
absl::Status ParseFromString(const std::string &content)
Definition project.cc:413
std::vector< std::string > additional_roms
Definition project.h:94
std::string patches_folder
Definition project.h:99
absl::Status LoadFromYazeFormat(const std::string &project_path)
Definition project.cc:622
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > resource_labels
Definition project.h:109
std::string GenerateProjectId() const
Definition project.cc:924
absl::Status Create(const std::string &project_name, const std::string &base_path)
Definition project.cc:98
std::string assets_folder
Definition project.h:98
absl::Status SaveToYazeFormat()
Definition project.cc:643
absl::Status LoadAllSettings()
Definition project.cc:722
std::string labels_filename
Definition project.h:100
std::vector< std::string > asm_sources
Definition project.h:121
std::string GetDisplayName() const
Definition project.cc:828
std::vector< std::string > GetMissingFiles() const
Definition project.cc:773
WorkspaceSettings workspace_settings
Definition project.h:107
std::string output_folder
Definition project.h:117
std::string asm_entry_point
Definition project.h:120
std::string GetRelativePath(const std::string &absolute_path) const
Definition project.cc:835
absl::Status InitializeEmbeddedLabels(const std::unordered_map< std::string, std::unordered_map< std::string, std::string > > &labels)
Definition project.cc:1350
absl::Status SaveAs(const std::string &new_path)
Definition project.cc:197
struct yaze::project::YazeProject::AgentSettings agent_settings
absl::Status ImportFromZScreamFormat(const std::string &project_path)
Definition project.cc:869
std::string GetAbsolutePath(const std::string &relative_path) const
Definition project.cc:853
std::string GetLabel(const std::string &resource_type, int id, const std::string &default_value="") const
Definition project.cc:1408
absl::Status Open(const std::string &project_path)
Definition project.cc:150
absl::Status ImportLabelsFromZScream(const std::string &filepath)
Import labels from a ZScream DefaultNames.txt file.
Definition project.cc:1423
std::string last_build_hash
Definition project.h:126
ProjectFormat format
Definition project.h:89
std::map< std::string, std::string > zscream_mappings
Definition project.h:164
std::string code_folder
Definition project.h:97
absl::Status Validate() const
Definition project.cc:738
core::FeatureFlags::Flags feature_flags
Definition project.h:106
std::vector< std::string > build_configurations
Definition project.h:118
std::string symbols_filename
Definition project.h:101