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 custom_objects_folder; // Folder containing custom object .bin files
103
104 // Consolidated settings (previously scattered across multiple files)
107 std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
109
110 // Embedded labels flag - when true, resource_labels contains all default
111 // Zelda3 labels
113
114 // Build and deployment
115 std::string build_script;
116 std::string output_folder;
117 std::vector<std::string> build_configurations;
118 std::string build_target;
119 std::string asm_entry_point;
120 std::vector<std::string> asm_sources;
121
122 // Version control integration
123 std::string git_repository;
124 bool track_changes = true;
125 std::string last_build_hash;
127
128 // AI Agent Settings
130 std::string ai_provider = "auto"; // auto, gemini, ollama, mock
131 std::string ai_model; // e.g., "gemini-2.5-flash", "llama3:latest"
132 std::string ollama_host = "http://localhost:11434";
133 std::string gemini_api_key; // Optional, can use env var
134 std::string
135 custom_system_prompt; // Path to custom prompt (relative to project)
136 bool use_custom_prompt = false;
137 bool show_reasoning = true;
138 bool verbose = false;
141 float temperature = 0.25f;
142 float top_p = 0.95f;
144 bool stream_responses = false;
145 std::vector<std::string> favorite_models;
146 std::vector<std::string> model_chain;
147 int chain_mode = 0;
153 bool enable_tool_gui = true;
154 bool enable_tool_music = true;
157 std::string builder_blueprint_path; // Saved agent builder configuration
159
160 // ZScream compatibility (for importing existing projects)
161 std::string zscream_project_file; // Path to original .zsproj if importing
162 std::map<std::string, std::string> zscream_mappings; // Field mappings
163
164 // WASM persistence (project + music state in IndexedDB)
170
171 // Methods
172 absl::Status Create(const std::string& project_name,
173 const std::string& base_path);
174 absl::Status Open(const std::string& project_path);
175 absl::Status Save();
176 absl::Status SaveAs(const std::string& new_path);
177 absl::Status ImportZScreamProject(const std::string& zscream_project_path);
178 absl::Status ExportForZScream(const std::string& target_path);
179
180 // Settings management
181 absl::Status LoadAllSettings();
182 absl::Status SaveAllSettings();
183 absl::Status ResetToDefaults();
184
185 // Labels management
186 absl::Status InitializeEmbeddedLabels(
187 const std::unordered_map<std::string,
188 std::unordered_map<std::string, std::string>>&
189 labels); // Load all default Zelda3 labels
190 std::string GetLabel(const std::string& resource_type, int id,
191 const std::string& default_value = "") const;
192
198 absl::Status ImportLabelsFromZScream(const std::string& filepath);
199
205 absl::Status ImportLabelsFromZScreamContent(const std::string& content);
206
211
212 // Validation and integrity
213 absl::Status Validate() const;
214 std::vector<std::string> GetMissingFiles() const;
215 absl::Status RepairProject();
216
217 // Utilities
218 std::string GetDisplayName() const;
219 std::string GetRelativePath(const std::string& absolute_path) const;
220 std::string GetAbsolutePath(const std::string& relative_path) const;
221 bool IsEmpty() const;
222 std::string MakeStorageKey(absl::string_view suffix) const;
223
224 // Project state
225 bool project_opened() const { return !name.empty() && !filepath.empty(); }
226
227 private:
228 absl::StatusOr<std::string> SerializeToString() const;
229 absl::Status ParseFromString(const std::string& content);
230 absl::Status LoadFromYazeFormat(const std::string& project_path);
231 absl::Status SaveToYazeFormat();
232 absl::Status ImportFromZScreamFormat(const std::string& project_path);
233
234#ifdef YAZE_ENABLE_JSON_PROJECT_FORMAT
235 absl::Status LoadFromJsonFormat(const std::string& project_path);
236 absl::Status SaveToJsonFormat();
237#endif
238
239 void InitializeDefaults();
240 std::string GenerateProjectId() const;
241};
242
248 public:
249 // Project templates
251 std::string name;
252 std::string description;
253 std::string icon;
255 };
256
257 static std::vector<ProjectTemplate> GetProjectTemplates();
258 static absl::StatusOr<YazeProject> CreateFromTemplate(
259 const std::string& template_name, const std::string& project_name,
260 const std::string& base_path);
261
262 // Project discovery and management
263 static std::vector<std::string> FindProjectsInDirectory(
264 const std::string& directory);
265 static absl::Status BackupProject(const YazeProject& project);
266 static absl::Status RestoreProject(const std::string& backup_path);
267
268 // Format conversion utilities
269 static absl::Status ConvertProject(const std::string& source_path,
270 const std::string& target_path,
271 ProjectFormat target_format);
272
273 // Validation and repair
274 static absl::Status ValidateProjectStructure(const YazeProject& project);
275 static std::vector<std::string> GetRecommendedFixesForProject(
276 const YazeProject& project);
277};
278
279// Compatibility - ResourceLabelManager (still used by ROM class)
281 bool LoadLabels(const std::string& filename);
282 bool SaveLabels();
283 void DisplayLabels(bool* p_open);
284 void EditLabel(const std::string& type, const std::string& key,
285 const std::string& newValue);
286 void SelectableLabelWithNameEdit(bool selected, const std::string& type,
287 const std::string& key,
288 const std::string& defaultValue);
289 std::string GetLabel(const std::string& type, const std::string& key);
290 std::string CreateOrGetLabel(const std::string& type, const std::string& key,
291 const std::string& defaultValue);
292
293 bool labels_loaded_ = false;
294 std::string filename_;
296 std::string key_name;
298 };
299
300 std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
302};
303
304// Compatibility - RecentFilesManager
305const std::string kRecentFilesFilename = "recent_files.txt";
306
308 public:
309 // Singleton pattern - get the global instance
311 static RecentFilesManager instance;
312 return instance;
313 }
314
315 // Delete copy constructor and assignment operator
318
319 void AddFile(const std::string& file_path) {
320 // Add a file to the list, avoiding duplicates
321 // Move to front if already exists (MRU - Most Recently Used)
322 auto it = std::find(recent_files_.begin(), recent_files_.end(), file_path);
323 if (it != recent_files_.end()) {
324 recent_files_.erase(it);
325 }
326 recent_files_.insert(recent_files_.begin(), file_path);
327
328 // Limit to 20 most recent files
329 if (recent_files_.size() > 20) {
330 recent_files_.resize(20);
331 }
332 }
333
334 void RemoveFile(const std::string& file_path) {
335 auto it = std::find(recent_files_.begin(), recent_files_.end(), file_path);
336 if (it != recent_files_.end()) {
337 recent_files_.erase(it);
338 }
339 }
340
341 void Save();
342
343 void Load();
344
345 const std::vector<std::string>& GetRecentFiles() const {
346 return recent_files_;
347 }
348
349 void Clear() { recent_files_.clear(); }
350
351 private:
353 Load(); // Load on construction
354 }
355
356 std::string GetFilePath() const;
357
358 std::vector<std::string> recent_files_;
359};
360
361} // namespace project
362} // namespace yaze
363
364#endif // YAZE_CORE_PROJECT_H
Enhanced project management with templates and validation.
Definition project.h:247
static std::vector< std::string > FindProjectsInDirectory(const std::string &directory)
Definition project.cc:1106
static absl::Status ValidateProjectStructure(const YazeProject &project)
Definition project.cc:1164
static absl::StatusOr< YazeProject > CreateFromTemplate(const std::string &template_name, const std::string &project_name, const std::string &base_path)
Definition project.cc:1064
static std::vector< std::string > GetRecommendedFixesForProject(const YazeProject &project)
Definition project.cc:1169
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:1131
void RemoveFile(const std::string &file_path)
Definition project.h:334
std::string GetFilePath() const
Definition project.cc:1721
void AddFile(const std::string &file_path)
Definition project.h:319
static RecentFilesManager & GetInstance()
Definition project.h:310
const std::vector< std::string > & GetRecentFiles() const
Definition project.h:345
RecentFilesManager(const RecentFilesManager &)=delete
std::vector< std::string > recent_files_
Definition project.h:358
RecentFilesManager & operator=(const RecentFilesManager &)=delete
const std::string kRecentFilesFilename
Definition project.h:305
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:1319
std::string GetLabel(const std::string &type, const std::string &key)
Definition project.cc:1306
void EditLabel(const std::string &type, const std::string &key, const std::string &newValue)
Definition project.cc:1288
bool LoadLabels(const std::string &filename)
Definition project.cc:1204
void SelectableLabelWithNameEdit(bool selected, const std::string &type, const std::string &key, const std::string &defaultValue)
Definition project.cc:1294
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > labels_
Definition project.h:301
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:145
std::vector< std::string > model_chain
Definition project.h:146
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:102
absl::Status RepairProject()
Definition project.cc:794
std::string MakeStorageKey(absl::string_view suffix) const
Definition project.cc:210
struct yaze::project::YazeProject::MusicPersistence music_persistence
bool project_opened() const
Definition project.h:225
absl::StatusOr< std::string > SerializeToString() const
Definition project.cc:226
std::string zscream_project_file
Definition project.h:161
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:1428
std::string git_repository
Definition project.h:123
void InitializeResourceLabelProvider()
Initialize the global ResourceLabelProvider with this project's labels.
Definition project.cc:1451
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:108
std::string GenerateProjectId() const
Definition project.cc:924
absl::Status Create(const std::string &project_name, const std::string &base_path)
Definition project.cc:99
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:120
std::string GetDisplayName() const
Definition project.cc:828
std::vector< std::string > GetMissingFiles() const
Definition project.cc:773
WorkspaceSettings workspace_settings
Definition project.h:106
std::string output_folder
Definition project.h:116
std::string asm_entry_point
Definition project.h:119
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:1334
absl::Status SaveAs(const std::string &new_path)
Definition project.cc:198
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:1393
absl::Status Open(const std::string &project_path)
Definition project.cc:151
absl::Status ImportLabelsFromZScream(const std::string &filepath)
Import labels from a ZScream DefaultNames.txt file.
Definition project.cc:1408
std::string last_build_hash
Definition project.h:125
ProjectFormat format
Definition project.h:89
std::map< std::string, std::string > zscream_mappings
Definition project.h:162
std::string code_folder
Definition project.h:97
absl::Status Validate() const
Definition project.cc:738
core::FeatureFlags::Flags feature_flags
Definition project.h:105
std::vector< std::string > build_configurations
Definition project.h:117
std::string symbols_filename
Definition project.h:101