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_APP_CORE_PROJECT_H
2#define YAZE_APP_CORE_PROJECT_H
3
4#include <algorithm>
5#include <map>
6#include <string>
7#include <vector>
8#include <unordered_map>
9
10#include "absl/status/status.h"
11#include "absl/status/statusor.h"
12#include "app/core/features.h"
13
14namespace yaze {
15namespace core {
16
21enum class ProjectFormat {
22 kYazeNative, // .yaze - YAZE native format
23 kZScreamCompat // .zsproj - ZScream compatibility format
24};
25
31 std::string version = "2.0";
32 std::string created_by = "YAZE";
33 std::string created_date;
34 std::string last_modified;
35 std::string yaze_version;
36 std::string description;
37 std::vector<std::string> tags;
38 std::string author;
39 std::string license;
40
41 // ZScream compatibility
42 bool zscream_compatible = false;
43 std::string zscream_version;
44};
45
51 // Display settings
52 float font_global_scale = 1.0f;
53 bool dark_mode = true;
54 std::string ui_theme = "default";
55
56 // Layout settings
57 std::string last_layout_preset;
58 std::vector<std::string> saved_layouts;
59 std::string window_layout_data; // ImGui .ini data
60
61 // Editor preferences
62 bool autosave_enabled = true;
63 float autosave_interval_secs = 300.0f; // 5 minutes
64 bool backup_on_save = true;
65 bool show_grid = true;
66 bool show_collision = false;
67
68 // Advanced settings
69 std::map<std::string, std::string> custom_keybindings;
70 std::vector<std::string> recent_files;
71 std::map<std::string, bool> editor_visibility;
72};
73
79 // Basic project info
81 std::string name;
82 std::string filepath;
84
85 // ROM and resources
86 std::string rom_filename;
87 std::string rom_backup_folder;
88 std::vector<std::string> additional_roms; // For multi-ROM projects
89
90 // Code and assets
91 std::string code_folder;
92 std::string assets_folder;
93 std::string patches_folder;
94 std::string labels_filename;
95 std::string symbols_filename;
96
97 // Consolidated settings (previously scattered across multiple files)
100 std::unordered_map<std::string, std::unordered_map<std::string, std::string>> resource_labels;
101
102 // Embedded labels flag - when true, resource_labels contains all default Zelda3 labels
104
105 // Build and deployment
106 std::string build_script;
107 std::string output_folder;
108 std::vector<std::string> build_configurations;
109
110 // Version control integration
111 std::string git_repository;
112 bool track_changes = true;
113
114 // AI Agent Settings
116 std::string ai_provider = "auto"; // auto, gemini, ollama, mock
117 std::string ai_model; // e.g., "gemini-2.5-flash", "llama3:latest"
118 std::string ollama_host = "http://localhost:11434";
119 std::string gemini_api_key; // Optional, can use env var
120 std::string custom_system_prompt; // Path to custom prompt (relative to project)
121 bool use_custom_prompt = false;
122 bool show_reasoning = true;
123 bool verbose = false;
127
128 // ZScream compatibility (for importing existing projects)
129 std::string zscream_project_file; // Path to original .zsproj if importing
130 std::map<std::string, std::string> zscream_mappings; // Field mappings
131
132 // Methods
133 absl::Status Create(const std::string& project_name, const std::string& base_path);
134 absl::Status Open(const std::string& project_path);
135 absl::Status Save();
136 absl::Status SaveAs(const std::string& new_path);
137 absl::Status ImportZScreamProject(const std::string& zscream_project_path);
138 absl::Status ExportForZScream(const std::string& target_path);
139
140 // Settings management
141 absl::Status LoadAllSettings();
142 absl::Status SaveAllSettings();
143 absl::Status ResetToDefaults();
144
145 // Labels management
146 absl::Status InitializeEmbeddedLabels(); // Load all default Zelda3 labels
147 std::string GetLabel(const std::string& resource_type, int id,
148 const std::string& default_value = "") const;
149
150 // Validation and integrity
151 absl::Status Validate() const;
152 std::vector<std::string> GetMissingFiles() const;
153 absl::Status RepairProject();
154
155 // Utilities
156 std::string GetDisplayName() const;
157 std::string GetRelativePath(const std::string& absolute_path) const;
158 std::string GetAbsolutePath(const std::string& relative_path) const;
159 bool IsEmpty() const;
160
161 // Project state
162 bool project_opened() const { return !name.empty() && !filepath.empty(); }
163
164private:
165 absl::Status LoadFromYazeFormat(const std::string& project_path);
166 absl::Status SaveToYazeFormat();
167 absl::Status ImportFromZScreamFormat(const std::string& project_path);
168
169#ifdef YAZE_ENABLE_JSON_PROJECT_FORMAT
170 absl::Status LoadFromJsonFormat(const std::string& project_path);
171 absl::Status SaveToJsonFormat();
172#endif
173
174 void InitializeDefaults();
175 std::string GenerateProjectId() const;
176};
177
183public:
184 // Project templates
186 std::string name;
187 std::string description;
188 std::string icon;
190 };
191
192 static std::vector<ProjectTemplate> GetProjectTemplates();
193 static absl::StatusOr<YazeProject> CreateFromTemplate(
194 const std::string& template_name,
195 const std::string& project_name,
196 const std::string& base_path);
197
198 // Project discovery and management
199 static std::vector<std::string> FindProjectsInDirectory(const std::string& directory);
200 static absl::Status BackupProject(const YazeProject& project);
201 static absl::Status RestoreProject(const std::string& backup_path);
202
203 // Format conversion utilities
204 static absl::Status ConvertProject(const std::string& source_path,
205 const std::string& target_path,
206 ProjectFormat target_format);
207
208 // Validation and repair
209 static absl::Status ValidateProjectStructure(const YazeProject& project);
210 static std::vector<std::string> GetRecommendedFixesForProject(const YazeProject& project);
211};
212
213// Compatibility - ResourceLabelManager (still used by ROM class)
215 bool LoadLabels(const std::string& filename);
216 bool SaveLabels();
217 void DisplayLabels(bool* p_open);
218 void EditLabel(const std::string& type, const std::string& key,
219 const std::string& newValue);
220 void SelectableLabelWithNameEdit(bool selected, const std::string& type,
221 const std::string& key,
222 const std::string& defaultValue);
223 std::string GetLabel(const std::string& type, const std::string& key);
224 std::string CreateOrGetLabel(const std::string& type, const std::string& key,
225 const std::string& defaultValue);
226
227 bool labels_loaded_ = false;
228 std::string filename_;
230 std::string key_name;
232 };
233
234 std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
236};
237
238// Compatibility - RecentFilesManager
239const std::string kRecentFilesFilename = "recent_files.txt";
240
242 public:
243 // Singleton pattern - get the global instance
245 static RecentFilesManager instance;
246 return instance;
247 }
248
249 // Delete copy constructor and assignment operator
252
253 void AddFile(const std::string& file_path) {
254 // Add a file to the list, avoiding duplicates
255 // Move to front if already exists (MRU - Most Recently Used)
256 auto it = std::find(recent_files_.begin(), recent_files_.end(), file_path);
257 if (it != recent_files_.end()) {
258 recent_files_.erase(it);
259 }
260 recent_files_.insert(recent_files_.begin(), file_path);
261
262 // Limit to 20 most recent files
263 if (recent_files_.size() > 20) {
264 recent_files_.resize(20);
265 }
266 }
267
268 void Save();
269
270 void Load();
271
272 const std::vector<std::string>& GetRecentFiles() const {
273 return recent_files_;
274 }
275
276 void Clear() {
277 recent_files_.clear();
278 }
279
280 private:
282 Load(); // Load on construction
283 }
284
285 std::string GetFilePath() const;
286
287 std::vector<std::string> recent_files_;
288};
289
290} // namespace core
291} // namespace yaze
292
293#endif // YAZE_APP_CORE_PROJECT_H
Enhanced project management with templates and validation.
Definition project.h:182
static std::vector< ProjectTemplate > GetProjectTemplates()
Definition project.cc:610
static absl::Status ValidateProjectStructure(const YazeProject &project)
Definition project.cc:734
static absl::Status ConvertProject(const std::string &source_path, const std::string &target_path, ProjectFormat target_format)
static std::vector< std::string > GetRecommendedFixesForProject(const YazeProject &project)
Definition project.cc:738
static absl::StatusOr< YazeProject > CreateFromTemplate(const std::string &template_name, const std::string &project_name, const std::string &base_path)
Definition project.cc:645
static absl::Status RestoreProject(const std::string &backup_path)
static absl::Status BackupProject(const YazeProject &project)
Definition project.cc:708
static std::vector< std::string > FindProjectsInDirectory(const std::string &directory)
Definition project.cc:689
std::string GetFilePath() const
Definition project.cc:1061
RecentFilesManager(const RecentFilesManager &)=delete
static RecentFilesManager & GetInstance()
Definition project.h:244
std::vector< std::string > recent_files_
Definition project.h:287
RecentFilesManager & operator=(const RecentFilesManager &)=delete
const std::vector< std::string > & GetRecentFiles() const
Definition project.h:272
void AddFile(const std::string &file_path)
Definition project.h:253
ProjectFormat
Supported project file formats.
Definition project.h:21
const std::string kRecentFilesFilename
Definition project.h:239
Main namespace for the application.
Enhanced metadata for project tracking.
Definition project.h:30
std::string last_modified
Definition project.h:34
std::string zscream_version
Definition project.h:43
std::vector< std::string > tags
Definition project.h:37
void SelectableLabelWithNameEdit(bool selected, const std::string &type, const std::string &key, const std::string &defaultValue)
Definition project.cc:855
bool LoadLabels(const std::string &filename)
Definition project.cc:770
void DisplayLabels(bool *p_open)
Definition project.cc:828
std::string GetLabel(const std::string &type, const std::string &key)
Definition project.cc:864
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > labels_
Definition project.h:235
void EditLabel(const std::string &type, const std::string &key, const std::string &newValue)
Definition project.cc:850
std::string CreateOrGetLabel(const std::string &type, const std::string &key, const std::string &defaultValue)
Definition project.cc:874
Consolidated workspace and UI settings.
Definition project.h:50
std::vector< std::string > recent_files
Definition project.h:70
std::map< std::string, std::string > custom_keybindings
Definition project.h:69
std::vector< std::string > saved_layouts
Definition project.h:58
std::string last_layout_preset
Definition project.h:57
std::map< std::string, bool > editor_visibility
Definition project.h:71
std::string window_layout_data
Definition project.h:59
Modern project structure with comprehensive settings consolidation.
Definition project.h:78
absl::Status Open(const std::string &project_path)
Definition project.cc:115
absl::Status SaveToYazeFormat()
Definition project.cc:271
absl::Status LoadAllSettings()
Definition project.cc:445
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > resource_labels
Definition project.h:100
bool project_opened() const
Definition project.h:162
std::map< std::string, std::string > zscream_mappings
Definition project.h:130
std::vector< std::string > additional_roms
Definition project.h:88
WorkspaceSettings workspace_settings
Definition project.h:99
std::string assets_folder
Definition project.h:92
std::string code_folder
Definition project.h:91
struct yaze::core::YazeProject::AgentSettings agent_settings
absl::Status Validate() const
Definition project.cc:461
std::string symbols_filename
Definition project.h:95
std::string build_script
Definition project.h:106
absl::Status LoadFromYazeFormat(const std::string &project_path)
Definition project.cc:166
FeatureFlags::Flags feature_flags
Definition project.h:98
std::string GenerateProjectId() const
Definition project.cc:603
std::string GetLabel(const std::string &resource_type, int id, const std::string &default_value="") const
Definition project.cc:914
std::string GetRelativePath(const std::string &absolute_path) const
Definition project.cc:539
std::string labels_filename
Definition project.h:94
std::string output_folder
Definition project.h:107
std::string git_repository
Definition project.h:111
absl::Status RepairProject()
Definition project.cc:504
bool IsEmpty() const
Definition project.cc:562
absl::Status Save()
Definition project.cc:150
std::string GetDisplayName() const
Definition project.cc:532
absl::Status InitializeEmbeddedLabels()
Definition project.cc:887
absl::Status ImportFromZScreamFormat(const std::string &project_path)
Definition project.cc:566
std::vector< std::string > build_configurations
Definition project.h:108
absl::Status Create(const std::string &project_name, const std::string &base_path)
Definition project.cc:76
std::vector< std::string > GetMissingFiles() const
Definition project.cc:488
std::string GetAbsolutePath(const std::string &relative_path) const
Definition project.cc:553
std::string zscream_project_file
Definition project.h:129
std::string filepath
Definition project.h:82
ProjectFormat format
Definition project.h:83
std::string rom_filename
Definition project.h:86
absl::Status ResetToDefaults()
Definition project.cc:456
absl::Status SaveAllSettings()
Definition project.cc:451
std::string rom_backup_folder
Definition project.h:87
ProjectMetadata metadata
Definition project.h:80
absl::Status ImportZScreamProject(const std::string &zscream_project_path)
Definition project.cc:402
absl::Status ExportForZScream(const std::string &target_path)
Definition project.cc:424
absl::Status SaveAs(const std::string &new_path)
Definition project.cc:154
std::string patches_folder
Definition project.h:93