10#include "absl/strings/str_format.h"
11#include "absl/strings/str_join.h"
12#include "absl/strings/str_split.h"
14#include "imgui/imgui.h"
20#include "yaze_config.h"
37std::pair<std::string, std::string> ParseKeyValue(
const std::string& line) {
38 size_t eq_pos = line.find(
'=');
39 if (eq_pos == std::string::npos)
42 std::string key = line.substr(0, eq_pos);
43 std::string value = line.substr(eq_pos + 1);
46 key.erase(0, key.find_first_not_of(
" \t"));
47 key.erase(key.find_last_not_of(
" \t") + 1);
48 value.erase(0, value.find_first_not_of(
" \t"));
49 value.erase(value.find_last_not_of(
" \t") + 1);
55 return value ==
"true" || value ==
"1" || value ==
"yes";
60 return std::stof(value);
67 std::vector<std::string> result;
71 std::vector<std::string> parts = absl::StrSplit(value,
',');
72 for (
const auto& part : parts) {
73 std::string trimmed = std::string(part);
74 trimmed.erase(0, trimmed.find_first_not_of(
" \t"));
75 trimmed.erase(trimmed.find_last_not_of(
" \t") + 1);
76 if (!trimmed.empty()) {
77 result.push_back(trimmed);
84 std::string key(input);
86 if (!std::isalnum(
static_cast<unsigned char>(c))) {
99 const std::string& base_path) {
101 filepath = base_path +
"/" + project_name +
".yaze";
104 auto now = std::chrono::system_clock::now();
105 auto time_t = std::chrono::system_clock::to_time_t(now);
106 std::stringstream ss;
107 ss << std::put_time(std::localtime(&time_t),
"%Y-%m-%d %H:%M:%S");
118#ifndef __EMSCRIPTEN__
120 std::filesystem::path project_dir(base_path +
"/" + project_name);
121 std::filesystem::create_directories(project_dir);
122 std::filesystem::create_directories(project_dir /
"code");
123 std::filesystem::create_directories(project_dir /
"assets");
124 std::filesystem::create_directories(project_dir /
"patches");
125 std::filesystem::create_directories(project_dir /
"backups");
126 std::filesystem::create_directories(project_dir /
"output");
156 auto storage_or = platform::WasmStorage::LoadProject(storage_key);
157 if (storage_or.ok()) {
163 if (project_path.ends_with(
".yaze")) {
167 std::ifstream file(project_path);
168 if (file.is_open()) {
169 std::stringstream buffer;
170 buffer << file.rdbuf();
171 std::string content = buffer.str();
173#ifdef YAZE_ENABLE_JSON_PROJECT_FORMAT
174 if (!content.empty() && content.front() ==
'{') {
175 LOG_DEBUG(
"Project",
"Detected JSON format project file");
176 return LoadFromJsonFormat(project_path);
183 return absl::InvalidArgumentError(
184 absl::StrFormat(
"Cannot open project file: %s", project_path));
185 }
else if (project_path.ends_with(
".zsproj")) {
190 return absl::InvalidArgumentError(
"Unsupported project file format");
198 std::string old_filepath =
filepath;
201 auto status =
Save();
213 }
else if (!
name.empty()) {
216 base = std::filesystem::path(
filepath).stem().string();
218 base = SanitizeStorageKey(base);
219 if (suffix.empty()) {
222 return absl::StrFormat(
"%s_%s", base, suffix);
226 std::ostringstream file;
229 file <<
"# yaze Project File\n";
230 file <<
"# Format Version: 2.0\n";
235 file <<
"[project]\n";
236 file <<
"name=" <<
name <<
"\n";
246 file <<
"tags=" << absl::StrJoin(
metadata.
tags,
",") <<
"\n\n";
260 file <<
"additional_roms=" << absl::StrJoin(
additional_roms,
",") <<
"\n\n";
263 file <<
"[feature_flags]\n";
264 file <<
"load_custom_overworld="
267 file <<
"apply_zs_custom_overworld_asm="
271 file <<
"save_dungeon_maps="
273 file <<
"save_graphics_sheet="
275 file <<
"enable_custom_objects="
279 file <<
"[workspace]\n";
284 file <<
"autosave_enabled="
288 file <<
"backup_on_save="
292 file <<
"show_collision="
294 file <<
"prefer_hmagic_names="
298 file <<
"saved_layouts="
304 file <<
"[agent_settings]\n";
309 file <<
"custom_system_prompt="
311 file <<
"use_custom_prompt="
313 file <<
"show_reasoning="
321 file <<
"stream_responses="
323 file <<
"favorite_models="
328 file <<
"enable_tool_resources="
330 file <<
"enable_tool_dungeon="
332 file <<
"enable_tool_overworld="
334 file <<
"enable_tool_messages="
336 file <<
"enable_tool_dialogue="
338 file <<
"enable_tool_gui="
340 file <<
"enable_tool_music="
342 file <<
"enable_tool_sprite="
344 file <<
"enable_tool_emulator="
351 file <<
"[keybindings]\n";
353 file << key <<
"=" << value <<
"\n";
360 file <<
"[editor_visibility]\n";
362 file << key <<
"=" << (value ?
"true" :
"false") <<
"\n";
369 if (!labels.empty()) {
370 file <<
"[labels_" << type <<
"]\n";
371 for (
const auto& [key, value] : labels) {
372 file << key <<
"=" << value <<
"\n";
383 file <<
"track_changes=" << (
track_changes ?
"true" :
"false") <<
"\n";
388 file <<
"asm_sources=" << absl::StrJoin(
asm_sources,
",") <<
"\n";
394 file <<
"persist_custom_music="
401 file <<
"[zscream_compatibility]\n";
404 file << key <<
"=" << value <<
"\n";
409 file <<
"# End of YAZE Project File\n";
414 std::istringstream stream(content);
416 std::string current_section;
418 while (std::getline(stream, line)) {
419 if (line.empty() || line[0] ==
'#')
422 if (line.front() ==
'[' && line.back() ==
']') {
423 current_section = line.substr(1, line.length() - 2);
427 auto [key, value] = ParseKeyValue(line);
431 if (current_section ==
"project") {
434 else if (key ==
"description")
436 else if (key ==
"author")
438 else if (key ==
"license")
440 else if (key ==
"version")
442 else if (key ==
"created_date")
444 else if (key ==
"last_modified")
446 else if (key ==
"yaze_version")
448 else if (key ==
"created_by")
450 else if (key ==
"tags")
452 else if (key ==
"project_id")
454 }
else if (current_section ==
"files") {
455 if (key ==
"rom_filename")
457 else if (key ==
"rom_backup_folder")
459 else if (key ==
"code_folder")
461 else if (key ==
"assets_folder")
463 else if (key ==
"patches_folder")
465 else if (key ==
"labels_filename")
467 else if (key ==
"symbols_filename")
469 else if (key ==
"output_folder")
471 else if (key ==
"custom_objects_folder")
473 else if (key ==
"additional_roms")
475 }
else if (current_section ==
"feature_flags") {
476 if (key ==
"load_custom_overworld")
478 else if (key ==
"apply_zs_custom_overworld_asm")
480 else if (key ==
"save_dungeon_maps")
482 else if (key ==
"save_graphics_sheet")
484 else if (key ==
"enable_custom_objects")
486 }
else if (current_section ==
"workspace") {
487 if (key ==
"font_global_scale")
489 else if (key ==
"dark_mode")
491 else if (key ==
"ui_theme")
493 else if (key ==
"autosave_enabled")
495 else if (key ==
"autosave_interval_secs")
497 else if (key ==
"backup_on_save")
499 else if (key ==
"show_grid")
501 else if (key ==
"show_collision")
503 else if (key ==
"prefer_hmagic_names")
505 else if (key ==
"last_layout_preset")
507 else if (key ==
"saved_layouts")
509 else if (key ==
"recent_files")
511 }
else if (current_section ==
"agent_settings") {
512 if (key ==
"ai_provider")
514 else if (key ==
"ai_model")
516 else if (key ==
"ollama_host")
518 else if (key ==
"gemini_api_key")
520 else if (key ==
"custom_system_prompt")
522 else if (key ==
"use_custom_prompt")
524 else if (key ==
"show_reasoning")
526 else if (key ==
"verbose")
528 else if (key ==
"max_tool_iterations")
530 else if (key ==
"max_retry_attempts")
532 else if (key ==
"temperature")
534 else if (key ==
"top_p")
536 else if (key ==
"max_output_tokens")
538 else if (key ==
"stream_responses")
540 else if (key ==
"favorite_models")
542 else if (key ==
"model_chain")
544 else if (key ==
"chain_mode")
546 else if (key ==
"enable_tool_resources")
548 else if (key ==
"enable_tool_dungeon")
550 else if (key ==
"enable_tool_overworld")
552 else if (key ==
"enable_tool_messages")
554 else if (key ==
"enable_tool_dialogue")
556 else if (key ==
"enable_tool_gui")
558 else if (key ==
"enable_tool_music")
560 else if (key ==
"enable_tool_sprite")
562 else if (key ==
"enable_tool_emulator")
564 else if (key ==
"builder_blueprint_path")
566 }
else if (current_section ==
"build") {
567 if (key ==
"build_script")
569 else if (key ==
"output_folder")
571 else if (key ==
"git_repository")
573 else if (key ==
"track_changes")
575 else if (key ==
"build_configurations")
577 else if (key ==
"build_target")
579 else if (key ==
"asm_entry_point")
581 else if (key ==
"asm_sources")
583 else if (key ==
"last_build_hash")
585 else if (key ==
"build_number")
587 }
else if (current_section.rfind(
"labels_", 0) == 0) {
588 std::string label_type = current_section.substr(7);
590 }
else if (current_section ==
"keybindings") {
592 }
else if (current_section ==
"editor_visibility") {
594 }
else if (current_section ==
"zscream_compatibility") {
595 if (key ==
"original_project_file")
599 }
else if (current_section ==
"music") {
600 if (key ==
"persist_custom_music")
602 else if (key ==
"storage_key")
604 else if (key ==
"last_saved_at")
619 return absl::OkStatus();
625 auto storage_or = platform::WasmStorage::LoadProject(storage_key);
626 if (storage_or.ok()) {
631 std::ifstream file(project_path);
632 if (!file.is_open()) {
633 return absl::InvalidArgumentError(
634 absl::StrFormat(
"Cannot open project file: %s", project_path));
637 std::stringstream buffer;
638 buffer << file.rdbuf();
645 auto now = std::chrono::system_clock::now();
646 auto time_t = std::chrono::system_clock::to_time_t(now);
647 std::stringstream ss;
648 ss << std::put_time(std::localtime(&time_t),
"%Y-%m-%d %H:%M:%S");
657 auto storage_status =
658 platform::WasmStorage::SaveProject(
MakeStorageKey(
"project"), serialized);
659 if (!storage_status.ok()) {
660 return storage_status;
665 if (!file.is_open()) {
666 return absl::InvalidArgumentError(
667 absl::StrFormat(
"Cannot create project file: %s",
filepath));
674 return absl::OkStatus();
678 const std::string& zscream_project_path) {
684 std::filesystem::path zs_path(zscream_project_path);
685 name = zs_path.stem().string() +
"_imported";
697 return absl::OkStatus();
702 std::ofstream file(target_path);
703 if (!file.is_open()) {
704 return absl::InvalidArgumentError(
705 absl::StrFormat(
"Cannot create ZScream project file: %s", target_path));
709 file <<
"# ZScream Compatible Project File\n";
711 file <<
"name=" <<
name <<
"\n";
719 return absl::OkStatus();
739 std::vector<std::string> errors;
742 errors.push_back(
"Project name is required");
744 errors.push_back(
"Project file path is required");
746 errors.push_back(
"ROM file is required");
748#ifndef __EMSCRIPTEN__
752 errors.push_back(
"ROM file does not exist: " +
rom_filename);
757 errors.push_back(
"Code folder does not exist: " +
code_folder);
766 if (!errors.empty()) {
767 return absl::InvalidArgumentError(absl::StrJoin(errors,
"; "));
770 return absl::OkStatus();
774 std::vector<std::string> missing;
776#ifndef __EMSCRIPTEN__
797 return absl::OkStatus();
804 for (
const auto& folder : folders) {
805 if (!folder.empty()) {
807 if (!std::filesystem::exists(abs_path)) {
808 std::filesystem::create_directories(abs_path);
816 if (!std::filesystem::exists(abs_labels)) {
817 std::ofstream labels_file(abs_labels);
818 labels_file <<
"# yaze Resource Labels\n";
819 labels_file <<
"# Format: [type] key=value\n\n";
824 return absl::OkStatus();
832 return name.empty() ?
"Untitled Project" :
name;
836 const std::string& absolute_path)
const {
837 if (absolute_path.empty() ||
filepath.empty())
838 return absolute_path;
840 std::filesystem::path project_dir =
841 std::filesystem::path(
filepath).parent_path();
842 std::filesystem::path abs_path(absolute_path);
845 std::filesystem::path relative =
846 std::filesystem::relative(abs_path, project_dir);
847 return relative.string();
849 return absolute_path;
854 const std::string& relative_path)
const {
855 if (relative_path.empty() ||
filepath.empty())
856 return relative_path;
858 std::filesystem::path project_dir =
859 std::filesystem::path(
filepath).parent_path();
860 std::filesystem::path abs_path = project_dir / relative_path;
862 return abs_path.string();
870 const std::string& project_path) {
874 std::filesystem::path zs_path(project_path);
875 name = zs_path.stem().string() +
"_imported";
880 return absl::OkStatus();
925 auto now = std::chrono::system_clock::now().time_since_epoch();
927 std::chrono::duration_cast<std::chrono::milliseconds>(now).count();
928 return absl::StrFormat(
"yaze_project_%lld", timestamp);
932std::vector<ProjectManager::ProjectTemplate>
934 std::vector<ProjectTemplate> templates;
943 t.
name =
"Vanilla ROM Hack";
945 "Standard ROM editing without custom ASM. Limited to vanilla features.";
954 templates.push_back(t);
960 t.
name =
"ZSCustomOverworld v2";
962 "Basic overworld expansion: custom BG colors, main palettes, parent "
975 templates.push_back(t);
981 t.
name =
"ZSCustomOverworld v3 (Recommended)";
983 "Full overworld expansion: wide/tall areas, animated GFX, overlays, "
1000 templates.push_back(t);
1006 t.
name =
"Randomizer Compatible";
1008 "Compatible with ALttP Randomizer. Minimal custom features to avoid "
1017 templates.push_back(t);
1027 t.
name =
"Dungeon Designer";
1028 t.
description =
"Focused on dungeon creation and modification.";
1035 templates.push_back(t);
1041 t.
name =
"Graphics Pack";
1043 "Project focused on graphics, sprites, and visual modifications.";
1052 templates.push_back(t);
1058 t.
name =
"Complete Overhaul";
1059 t.
description =
"Full-scale ROM hack with all features enabled.";
1074 templates.push_back(t);
1081 const std::string& template_name,
const std::string& project_name,
1082 const std::string& base_path) {
1084 auto status = project.
Create(project_name, base_path);
1090 if (template_name ==
"Full Overworld Mod") {
1094 project.
metadata.
tags = {
"overworld",
"maps",
"graphics"};
1095 }
else if (template_name ==
"Dungeon Designer") {
1099 project.
metadata.
tags = {
"dungeons",
"rooms",
"design"};
1100 }
else if (template_name ==
"Graphics Pack") {
1104 project.
metadata.
tags = {
"graphics",
"sprites",
"palettes"};
1105 }
else if (template_name ==
"Complete Overhaul") {
1111 project.
metadata.
tags = {
"complete",
"overhaul",
"full-mod"};
1114 status = project.
Save();
1123 const std::string& directory) {
1124#ifdef __EMSCRIPTEN__
1128 std::vector<std::string> projects;
1131 for (
const auto& entry : std::filesystem::directory_iterator(directory)) {
1132 if (entry.is_regular_file()) {
1133 std::string filename = entry.path().filename().string();
1134 if (filename.ends_with(
".yaze") || filename.ends_with(
".zsproj")) {
1135 projects.push_back(entry.path().string());
1139 }
catch (
const std::filesystem::filesystem_error& e) {
1148#ifdef __EMSCRIPTEN__
1150 return absl::UnimplementedError(
1151 "Project backups are not supported in the web build");
1154 return absl::InvalidArgumentError(
"Project has no file path");
1157 std::filesystem::path project_path(project.
filepath);
1158 std::filesystem::path backup_dir = project_path.parent_path() /
"backups";
1159 std::filesystem::create_directories(backup_dir);
1161 auto now = std::chrono::system_clock::now();
1162 auto time_t = std::chrono::system_clock::to_time_t(now);
1163 std::stringstream ss;
1164 ss << std::put_time(std::localtime(&time_t),
"%Y%m%d_%H%M%S");
1166 std::string backup_filename = project.
name +
"_backup_" + ss.str() +
".yaze";
1167 std::filesystem::path backup_path = backup_dir / backup_filename;
1170 std::filesystem::copy_file(project.
filepath, backup_path);
1171 }
catch (
const std::filesystem::filesystem_error& e) {
1172 return absl::InternalError(
1173 absl::StrFormat(
"Failed to backup project: %s", e.what()));
1176 return absl::OkStatus();
1187 std::vector<std::string> recommendations;
1190 recommendations.push_back(
"Add a ROM file to begin editing");
1194 recommendations.push_back(
"Set up a code folder for assembly patches");
1198 recommendations.push_back(
"Create a labels file for better organization");
1202 recommendations.push_back(
"Add a project description for documentation");
1206 recommendations.push_back(
1207 "Consider setting up version control for your project");
1211 if (!missing_files.empty()) {
1212 recommendations.push_back(
1213 "Some project files are missing - use Project > Repair to fix");
1216 return recommendations;
1222 std::ifstream file(filename);
1223 if (!file.is_open()) {
1230 std::string current_type =
"";
1232 while (std::getline(file, line)) {
1233 if (line.empty() || line[0] ==
'#')
1237 if (line[0] ==
'[' && line.back() ==
']') {
1238 current_type = line.substr(1, line.length() - 2);
1243 size_t eq_pos = line.find(
'=');
1244 if (eq_pos != std::string::npos && !current_type.empty()) {
1245 std::string key = line.substr(0, eq_pos);
1246 std::string value = line.substr(eq_pos + 1);
1247 labels_[current_type][key] = value;
1261 if (!file.is_open())
1264 file <<
"# yaze Resource Labels\n";
1265 file <<
"# Format: [type] followed by key=value pairs\n\n";
1267 for (
const auto& [type, type_labels] :
labels_) {
1268 if (!type_labels.empty()) {
1269 file <<
"[" << type <<
"]\n";
1270 for (
const auto& [key, value] : type_labels) {
1271 file << key <<
"=" << value <<
"\n";
1282 if (!p_open || !*p_open)
1286 if (ImGui::Begin(
"Resource Labels", p_open)) {
1287 ImGui::Text(
"Resource Labels Manager");
1289 ImGui::Text(
"Total types: %zu",
labels_.size());
1291 for (
const auto& [type, type_labels] :
labels_) {
1292 if (ImGui::TreeNode(type.c_str())) {
1293 ImGui::Text(
"Labels: %zu", type_labels.size());
1294 for (
const auto& [key, value] : type_labels) {
1295 ImGui::Text(
"%s = %s", key.c_str(), value.c_str());
1305 const std::string& key,
1306 const std::string& newValue) {
1307 labels_[type][key] = newValue;
1311 bool selected,
const std::string& type,
const std::string& key,
1312 const std::string& defaultValue) {
1314 if (ImGui::Selectable(
1315 absl::StrFormat(
"%s: %s", key.c_str(),
GetLabel(type, key).c_str())
1323 const std::string& key) {
1324 auto type_it =
labels_.find(type);
1328 auto label_it = type_it->second.find(key);
1329 if (label_it == type_it->second.end())
1332 return label_it->second;
1336 const std::string& type,
const std::string& key,
1337 const std::string& defaultValue) {
1338 auto existing =
GetLabel(type, key);
1339 if (!existing.empty())
1342 labels_[type][key] = defaultValue;
1343 return defaultValue;
1351 const std::unordered_map<
1352 std::string, std::unordered_map<std::string, std::string>>& labels) {
1381 LOG_DEBUG(
"Project",
"Initialized embedded labels:");
1383 LOG_DEBUG(
"Project",
" - %d entrance names",
1385 LOG_DEBUG(
"Project",
" - %d sprite names",
1387 LOG_DEBUG(
"Project",
" - %d overlord names",
1390 LOG_DEBUG(
"Project",
" - %d music names",
1392 LOG_DEBUG(
"Project",
" - %d graphics names",
1394 LOG_DEBUG(
"Project",
" - %d room effect names",
1396 LOG_DEBUG(
"Project",
" - %d room tag names",
1398 LOG_DEBUG(
"Project",
" - %d tile type names",
1401 return absl::OkStatus();
1402 }
catch (
const std::exception& e) {
1403 return absl::InternalError(
1404 absl::StrCat(
"Failed to initialize embedded labels: ", e.what()));
1409 const std::string& default_value)
const {
1413 auto label_it = type_it->second.find(std::to_string(
id));
1414 if (label_it != type_it->second.end()) {
1415 return label_it->second;
1419 return default_value.empty() ? resource_type +
"_" + std::to_string(
id)
1424#ifdef __EMSCRIPTEN__
1426 return absl::UnimplementedError(
1427 "File-based label import is not supported in the web build");
1430 if (!file.is_open()) {
1431 return absl::InvalidArgumentError(
1432 absl::StrFormat(
"Cannot open labels file: %s",
filepath));
1435 std::stringstream buffer;
1436 buffer << file.rdbuf();
1444 const std::string& content) {
1451 auto status = provider.ImportFromZScreamFormat(content);
1456 LOG_DEBUG(
"Project",
"Imported ZScream labels:");
1457 LOG_DEBUG(
"Project",
" - %d sprite labels",
1461 LOG_DEBUG(
"Project",
" - %d room tag labels",
1464 return absl::OkStatus();
1472 LOG_DEBUG(
"Project",
"Initialized ResourceLabelProvider with project labels");
1473 LOG_DEBUG(
"Project",
" - prefer_hmagic_names: %s",
1481#ifdef YAZE_ENABLE_JSON_PROJECT_FORMAT
1483absl::Status YazeProject::LoadFromJsonFormat(
const std::string& project_path) {
1484#ifdef __EMSCRIPTEN__
1485 return absl::UnimplementedError(
1486 "JSON project format loading is not supported in the web build");
1488 std::ifstream file(project_path);
1489 if (!file.is_open()) {
1490 return absl::InvalidArgumentError(
1491 absl::StrFormat(
"Cannot open JSON project file: %s", project_path));
1499 if (j.contains(
"yaze_project")) {
1500 auto& proj = j[
"yaze_project"];
1502 if (proj.contains(
"name"))
1503 name = proj[
"name"].get<std::string>();
1504 if (proj.contains(
"description"))
1506 if (proj.contains(
"author"))
1508 if (proj.contains(
"version"))
1510 if (proj.contains(
"created"))
1512 if (proj.contains(
"modified"))
1514 if (proj.contains(
"created_by"))
1518 if (proj.contains(
"rom_filename"))
1519 rom_filename = proj[
"rom_filename"].get<std::string>();
1520 if (proj.contains(
"code_folder"))
1521 code_folder = proj[
"code_folder"].get<std::string>();
1522 if (proj.contains(
"assets_folder"))
1524 if (proj.contains(
"patches_folder"))
1526 if (proj.contains(
"labels_filename"))
1528 if (proj.contains(
"symbols_filename"))
1532 if (proj.contains(
"use_embedded_labels")) {
1537 if (proj.contains(
"feature_flags")) {
1538 auto& flags = proj[
"feature_flags"];
1541 if (flags.contains(
"kSaveDungeonMaps"))
1543 flags[
"kSaveDungeonMaps"].get<
bool>();
1544 if (flags.contains(
"kSaveGraphicsSheet"))
1546 flags[
"kSaveGraphicsSheet"].get<
bool>();
1550 if (proj.contains(
"workspace_settings")) {
1551 auto& ws = proj[
"workspace_settings"];
1552 if (ws.contains(
"auto_save_enabled"))
1554 ws[
"auto_save_enabled"].get<
bool>();
1555 if (ws.contains(
"auto_save_interval"))
1557 ws[
"auto_save_interval"].get<
float>();
1560 if (proj.contains(
"agent_settings") &&
1561 proj[
"agent_settings"].is_object()) {
1562 auto& agent = proj[
"agent_settings"];
1589 if (agent.contains(
"favorite_models") &&
1590 agent[
"favorite_models"].is_array()) {
1592 for (
const auto& model : agent[
"favorite_models"]) {
1593 if (model.is_string())
1595 model.get<std::string>());
1598 if (agent.contains(
"model_chain") && agent[
"model_chain"].is_array()) {
1600 for (
const auto& model : agent[
"model_chain"]) {
1601 if (model.is_string())
1630 if (proj.contains(
"build_script"))
1631 build_script = proj[
"build_script"].get<std::string>();
1632 if (proj.contains(
"output_folder"))
1634 if (proj.contains(
"git_repository"))
1636 if (proj.contains(
"track_changes"))
1640 return absl::OkStatus();
1641 }
catch (
const json::exception& e) {
1642 return absl::InvalidArgumentError(
1643 absl::StrFormat(
"JSON parse error: %s", e.what()));
1647absl::Status YazeProject::SaveToJsonFormat() {
1648#ifdef __EMSCRIPTEN__
1649 return absl::UnimplementedError(
1650 "JSON project format saving is not supported in the web build");
1653 auto& proj = j[
"yaze_project"];
1657 proj[
"name"] =
name;
1679 proj[
"feature_flags"][
"kSaveGraphicsSheet"] =
1683 proj[
"workspace_settings"][
"auto_save_enabled"] =
1685 proj[
"workspace_settings"][
"auto_save_interval"] =
1688 auto& agent = proj[
"agent_settings"];
1724 if (!file.is_open()) {
1725 return absl::InvalidArgumentError(
1726 absl::StrFormat(
"Cannot write JSON project file: %s",
filepath));
1730 return absl::OkStatus();
1738 if (!config_dir.ok()) {
1745#ifdef __EMSCRIPTEN__
1746 auto status = platform::WasmStorage::SaveProject(
1749 LOG_WARN(
"RecentFilesManager",
"Could not persist recent files: %s",
1750 status.ToString().c_str());
1756 if (!config_dir_status.ok()) {
1757 LOG_ERROR(
"Project",
"Failed to get or create config directory: %s",
1758 config_dir_status.status().ToString().c_str());
1763 std::ofstream file(filepath);
1764 if (!file.is_open()) {
1765 LOG_WARN(
"RecentFilesManager",
"Could not save recent files to %s",
1771 file << file_path << std::endl;
1776#ifdef __EMSCRIPTEN__
1778 if (!storage_or.ok()) {
1782 std::istringstream stream(storage_or.value());
1784 while (std::getline(stream, line)) {
1785 if (!line.empty()) {
1791 std::ifstream file(filepath);
1792 if (!file.is_open()) {
1799 while (std::getline(file, line)) {
1800 if (!line.empty()) {
static std::vector< std::string > FindProjectsInDirectory(const std::string &directory)
static absl::Status ValidateProjectStructure(const YazeProject &project)
static absl::StatusOr< YazeProject > CreateFromTemplate(const std::string &template_name, const std::string &project_name, const std::string &base_path)
static std::vector< std::string > GetRecommendedFixesForProject(const YazeProject &project)
static std::vector< ProjectTemplate > GetProjectTemplates()
static absl::Status BackupProject(const YazeProject &project)
std::string GetFilePath() const
std::vector< std::string > recent_files_
#define ICON_MD_VIDEOGAME_ASSET
#define LOG_DEBUG(category, format,...)
#define LOG_ERROR(category, format,...)
#define LOG_WARN(category, format,...)
#define ASSIGN_OR_RETURN(type_variable_name, expression)
float ParseFloat(const std::string &value)
bool ParseBool(const std::string &value)
std::string SanitizeStorageKey(absl::string_view input)
std::vector< std::string > ParseStringList(const std::string &value)
const std::string kRecentFilesFilename
ResourceLabelProvider & GetResourceLabels()
Get the global ResourceLabelProvider instance.
bool kSaveOverworldProperties
bool kApplyZSCustomOverworldASM
bool kLoadCustomOverworld
bool kSaveOverworldEntrances
bool kEnableCustomObjects
struct yaze::core::FeatureFlags::Flags::Overworld overworld
YazeProject template_project
std::string CreateOrGetLabel(const std::string &type, const std::string &key, const std::string &defaultValue)
void DisplayLabels(bool *p_open)
std::string GetLabel(const std::string &type, const std::string &key)
void EditLabel(const std::string &type, const std::string &key, const std::string &newValue)
bool LoadLabels(const std::string &filename)
void SelectableLabelWithNameEdit(bool selected, const std::string &type, const std::string &key, const std::string &defaultValue)
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > labels_
std::string last_layout_preset
std::map< std::string, std::string > custom_keybindings
std::vector< std::string > saved_layouts
std::map< std::string, bool > editor_visibility
float autosave_interval_secs
std::vector< std::string > recent_files
std::string custom_system_prompt
std::string gemini_api_key
bool enable_tool_emulator
std::vector< std::string > favorite_models
bool enable_tool_resources
bool enable_tool_messages
std::vector< std::string > model_chain
std::string builder_blueprint_path
bool enable_tool_dialogue
bool enable_tool_overworld
std::string last_saved_at
bool persist_custom_music
Modern project structure with comprehensive settings consolidation.
std::string rom_backup_folder
absl::Status ResetToDefaults()
std::string custom_objects_folder
absl::Status RepairProject()
std::string MakeStorageKey(absl::string_view suffix) const
struct yaze::project::YazeProject::MusicPersistence music_persistence
absl::StatusOr< std::string > SerializeToString() const
std::string zscream_project_file
absl::Status ExportForZScream(const std::string &target_path)
absl::Status ImportZScreamProject(const std::string &zscream_project_path)
absl::Status SaveAllSettings()
absl::Status ImportLabelsFromZScreamContent(const std::string &content)
Import labels from ZScream format content directly.
std::string git_repository
void InitializeResourceLabelProvider()
Initialize the global ResourceLabelProvider with this project's labels.
absl::Status ParseFromString(const std::string &content)
std::vector< std::string > additional_roms
std::string patches_folder
absl::Status LoadFromYazeFormat(const std::string &project_path)
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > resource_labels
std::string GenerateProjectId() const
absl::Status Create(const std::string &project_name, const std::string &base_path)
std::string assets_folder
absl::Status SaveToYazeFormat()
absl::Status LoadAllSettings()
std::string labels_filename
std::vector< std::string > asm_sources
std::string GetDisplayName() const
std::vector< std::string > GetMissingFiles() const
WorkspaceSettings workspace_settings
std::string output_folder
std::string asm_entry_point
std::string GetRelativePath(const std::string &absolute_path) const
absl::Status InitializeEmbeddedLabels(const std::unordered_map< std::string, std::unordered_map< std::string, std::string > > &labels)
absl::Status SaveAs(const std::string &new_path)
struct yaze::project::YazeProject::AgentSettings agent_settings
absl::Status ImportFromZScreamFormat(const std::string &project_path)
void InitializeDefaults()
std::string GetAbsolutePath(const std::string &relative_path) const
std::string GetLabel(const std::string &resource_type, int id, const std::string &default_value="") const
absl::Status Open(const std::string &project_path)
absl::Status ImportLabelsFromZScream(const std::string &filepath)
Import labels from a ZScream DefaultNames.txt file.
std::string last_build_hash
std::map< std::string, std::string > zscream_mappings
absl::Status Validate() const
core::FeatureFlags::Flags feature_flags
std::vector< std::string > build_configurations
std::string symbols_filename