11#include "absl/strings/match.h"
12#include "absl/strings/str_format.h"
13#include "absl/strings/str_join.h"
14#include "absl/strings/str_split.h"
16#include "imgui/imgui.h"
22#include "yaze_config.h"
25#if defined(YAZE_WITH_Z3DK) && __has_include("z3dk_core/config.h")
26#include "z3dk_core/config.h"
44 value.begin(), value.end(), value.begin(),
45 [](
unsigned char c) { return static_cast<char>(std::tolower(c)); });
50std::pair<std::string, std::string> ParseKeyValue(
const std::string& line) {
51 size_t eq_pos = line.find(
'=');
52 if (eq_pos == std::string::npos)
55 std::string key = line.substr(0, eq_pos);
56 std::string value = line.substr(eq_pos + 1);
59 key.erase(0, key.find_first_not_of(
" \t"));
60 key.erase(key.find_last_not_of(
" \t") + 1);
61 value.erase(0, value.find_first_not_of(
" \t"));
62 value.erase(value.find_last_not_of(
" \t") + 1);
68 return value ==
"true" || value ==
"1" || value ==
"yes";
73 return std::stof(value);
80 std::vector<std::string> result;
84 std::vector<std::string> parts = absl::StrSplit(value,
',');
85 for (
const auto& part : parts) {
86 std::string trimmed = std::string(part);
87 trimmed.erase(0, trimmed.find_first_not_of(
" \t"));
88 trimmed.erase(trimmed.find_last_not_of(
" \t") + 1);
89 if (!trimmed.empty()) {
90 result.push_back(trimmed);
97 std::vector<uint16_t> result;
103 result.reserve(parts.size());
104 for (
const auto& part : parts) {
105 std::string token = part;
106 if (token.rfind(
"0x", 0) == 0 || token.rfind(
"0X", 0) == 0) {
107 token = token.substr(2);
109 result.push_back(
static_cast<uint16_t
>(std::stoul(token,
nullptr, 16)));
115 result.push_back(
static_cast<uint16_t
>(std::stoul(token,
nullptr, 10)));
128 std::string token = value;
129 if (token.rfind(
"0x", 0) == 0 || token.rfind(
"0X", 0) == 0) {
130 token = token.substr(2);
132 return static_cast<uint32_t
>(std::stoul(token,
nullptr, 16));
138 return static_cast<uint32_t
>(std::stoul(token,
nullptr, 10));
145 return absl::StrJoin(values,
",", [](std::string* out, uint16_t value) {
146 out->append(absl::StrFormat(
"0x%02X", value));
151 return absl::StrFormat(
"0x%06X", value);
155 std::string key(input);
156 for (
char& c : key) {
157 if (!std::isalnum(
static_cast<unsigned char>(c))) {
168 auto [key, parsed_value] = ParseKeyValue(value);
172 return {key, parsed_value.empty() ?
"1" : parsed_value};
176 const std::string& value) {
180 std::filesystem::path path(value);
181 if (path.is_absolute()) {
182 return path.lexically_normal().string();
184 return (base_dir / path).lexically_normal().string();
188 return ToLowerCopy(std::filesystem::path(path).filename().
string());
207 std::string lower = ToLowerCopy(std::string(value));
208 if (lower ==
"base") {
211 if (lower ==
"patched") {
214 if (lower ==
"release") {
233 std::string lower = ToLowerCopy(std::string(value));
234 if (lower ==
"allow") {
237 if (lower ==
"block") {
245 const std::string& base_path) {
247 filepath = base_path +
"/" + project_name +
".yaze";
250 auto now = std::chrono::system_clock::now();
251 auto time_t = std::chrono::system_clock::to_time_t(now);
252 std::stringstream ss;
253 ss << std::put_time(std::localtime(&time_t),
"%Y-%m-%d %H:%M:%S");
264#ifndef __EMSCRIPTEN__
266 std::filesystem::path project_dir(base_path +
"/" + project_name);
267 std::filesystem::create_directories(project_dir);
268 std::filesystem::create_directories(project_dir /
"code");
269 std::filesystem::create_directories(project_dir /
"assets");
270 std::filesystem::create_directories(project_dir /
"patches");
271 std::filesystem::create_directories(project_dir /
"backups");
272 std::filesystem::create_directories(project_dir /
"output");
305 auto current = std::filesystem::path(path).lexically_normal();
307 for (; !current.empty(); current = current.parent_path()) {
308 if (current.extension() ==
".yazeproj") {
310 if (std::filesystem::is_directory(current, ec) && !ec) {
311 return current.string();
315 if (current == current.parent_path()) {
327 std::string resolved_path = project_path;
329 if (!bundle_root.empty() && bundle_root != project_path) {
331 resolved_path = bundle_root;
339 auto storage_or = platform::WasmStorage::LoadProject(storage_key);
340 if (storage_or.ok()) {
346 absl::Status load_status;
347 if (resolved_path.ends_with(
".yazeproj")) {
350 const std::filesystem::path bundle_path(resolved_path);
352 if (!std::filesystem::exists(bundle_path, ec) || ec ||
353 !std::filesystem::is_directory(bundle_path, ec) || ec) {
354 return absl::InvalidArgumentError(
355 absl::StrFormat(
"Project bundle does not exist: %s", resolved_path));
360 const std::filesystem::path project_file = bundle_path /
"project.yaze";
363 if (!std::filesystem::exists(project_file, ec) || ec) {
366 name = bundle_path.stem().string();
369 auto now = std::chrono::system_clock::now();
370 auto time_t = std::chrono::system_clock::to_time_t(now);
371 std::stringstream ss;
372 ss << std::put_time(std::localtime(&time_t),
"%Y-%m-%d %H:%M:%S");
392 const std::filesystem::path rom_candidate = bundle_path /
"rom";
399 const std::filesystem::path project_dir = bundle_path /
"project";
400 const std::filesystem::path code_dir = bundle_path /
"code";
401 if (std::filesystem::exists(project_dir, ec) &&
402 std::filesystem::is_directory(project_dir, ec) && !ec) {
404 }
else if (std::filesystem::exists(code_dir, ec) &&
405 std::filesystem::is_directory(code_dir, ec) && !ec) {
420 }
else if (resolved_path.ends_with(
".yaze")) {
424 std::ifstream file(resolved_path);
425 if (file.is_open()) {
426 std::stringstream buffer;
427 buffer << file.rdbuf();
428 std::string content = buffer.str();
430#ifdef YAZE_ENABLE_JSON_PROJECT_FORMAT
431 if (!content.empty() && content.front() ==
'{') {
432 LOG_DEBUG(
"Project",
"Detected JSON format project file");
433 load_status = LoadFromJsonFormat(resolved_path);
441 return absl::InvalidArgumentError(
442 absl::StrFormat(
"Cannot open project file: %s", resolved_path));
444 }
else if (resolved_path.ends_with(
".zsproj")) {
448 return absl::InvalidArgumentError(
"Unsupported project file format");
451 if (!load_status.ok()) {
465 return absl::OkStatus();
473 std::string old_filepath =
filepath;
476 auto status =
Save();
488 }
else if (!
name.empty()) {
491 base = std::filesystem::path(
filepath).stem().string();
493 base = SanitizeStorageKey(base);
494 if (suffix.empty()) {
497 return absl::StrFormat(
"%s_%s", base, suffix);
501 std::ostringstream file;
504 file <<
"# yaze Project File\n";
505 file <<
"# Format Version: 2.0\n";
510 file <<
"[project]\n";
511 file <<
"name=" <<
name <<
"\n";
521 file <<
"tags=" << absl::StrJoin(
metadata.
tags,
",") <<
"\n\n";
536 file <<
"additional_roms=" << absl::StrJoin(
additional_roms,
",") <<
"\n\n";
546 file <<
"[feature_flags]\n";
547 file <<
"load_custom_overworld="
550 file <<
"apply_zs_custom_overworld_asm="
554 file <<
"save_dungeon_maps="
556 file <<
"save_overworld_maps="
559 file <<
"save_overworld_entrances="
562 file <<
"save_overworld_exits="
565 file <<
"save_overworld_items="
568 file <<
"save_overworld_properties="
571 file <<
"save_dungeon_objects="
573 file <<
"save_dungeon_sprites="
575 file <<
"save_dungeon_room_headers="
577 file <<
"save_dungeon_torches="
579 file <<
"save_dungeon_pits="
581 file <<
"save_dungeon_blocks="
583 file <<
"save_dungeon_collision="
585 file <<
"save_dungeon_chests="
587 file <<
"save_dungeon_pot_items="
589 file <<
"save_dungeon_palettes="
591 file <<
"save_graphics_sheet="
593 file <<
"save_all_palettes="
595 file <<
"save_gfx_groups="
599 file <<
"enable_custom_objects="
603 file <<
"[workspace]\n";
608 file <<
"autosave_enabled="
612 file <<
"backup_on_save="
616 file <<
"backup_keep_daily="
622 file <<
"show_collision="
624 file <<
"prefer_hmagic_names="
628 file <<
"saved_layouts="
635 if (track_tiles.empty()) {
636 for (uint16_t tile = 0xB0; tile <= 0xBE; ++tile) {
637 track_tiles.push_back(tile);
641 if (track_stop_tiles.empty()) {
642 track_stop_tiles = {0xB7, 0xB8, 0xB9, 0xBA};
645 if (track_switch_tiles.empty()) {
646 track_switch_tiles = {0xD0, 0xD1, 0xD2, 0xD3};
649 if (track_object_ids.empty()) {
650 track_object_ids = {0x31};
653 if (minecart_sprite_ids.empty()) {
654 minecart_sprite_ids = {0xA3};
656 file <<
"[dungeon_overlay]\n";
657 file <<
"track_tiles=" << FormatHexUintList(track_tiles) <<
"\n";
658 file <<
"track_stop_tiles=" << FormatHexUintList(track_stop_tiles) <<
"\n";
659 file <<
"track_switch_tiles=" << FormatHexUintList(track_switch_tiles)
661 file <<
"track_object_ids=" << FormatHexUintList(track_object_ids) <<
"\n";
662 file <<
"minecart_sprite_ids=" << FormatHexUintList(minecart_sprite_ids)
666 file <<
"[rom_addresses]\n";
668 file << key <<
"=" << FormatHexUint32(value) <<
"\n";
674 file <<
"[custom_objects]\n";
676 file << absl::StrFormat(
"object_0x%X", object_id) <<
"="
677 << absl::StrJoin(files,
",") <<
"\n";
683 file <<
"[agent_settings]\n";
688 file <<
"custom_system_prompt="
690 file <<
"use_custom_prompt="
692 file <<
"show_reasoning="
700 file <<
"stream_responses="
702 file <<
"favorite_models="
707 file <<
"enable_tool_resources="
709 file <<
"enable_tool_dungeon="
711 file <<
"enable_tool_overworld="
713 file <<
"enable_tool_messages="
715 file <<
"enable_tool_dialogue="
717 file <<
"enable_tool_gui="
719 file <<
"enable_tool_music="
721 file <<
"enable_tool_sprite="
723 file <<
"enable_tool_emulator="
725 file <<
"enable_tool_memory_inspector="
733 file <<
"[keybindings]\n";
735 file << key <<
"=" << value <<
"\n";
742 file <<
"[editor_visibility]\n";
744 file << key <<
"=" << (value ?
"true" :
"false") <<
"\n";
751 if (!labels.empty()) {
752 file <<
"[labels_" << type <<
"]\n";
753 for (
const auto& [key, value] : labels) {
754 file << key <<
"=" << value <<
"\n";
765 file <<
"track_changes=" << (
track_changes ?
"true" :
"false") <<
"\n";
770 file <<
"asm_sources=" << absl::StrJoin(
asm_sources,
",") <<
"\n";
776 file <<
"persist_custom_music="
783 file <<
"[zscream_compatibility]\n";
786 file << key <<
"=" << value <<
"\n";
791 file <<
"# End of YAZE Project File\n";
796 std::istringstream stream(content);
798 std::string current_section;
800 while (std::getline(stream, line)) {
801 if (line.empty() || line[0] ==
'#')
804 if (line.front() ==
'[' && line.back() ==
']') {
805 current_section = line.substr(1, line.length() - 2);
809 auto [key, value] = ParseKeyValue(line);
813 if (current_section ==
"project") {
816 else if (key ==
"description")
818 else if (key ==
"author")
820 else if (key ==
"license")
822 else if (key ==
"version")
824 else if (key ==
"created_date")
826 else if (key ==
"last_modified")
828 else if (key ==
"yaze_version")
830 else if (key ==
"created_by")
832 else if (key ==
"tags")
834 else if (key ==
"project_id")
836 }
else if (current_section ==
"files") {
837 if (key ==
"rom_filename")
839 else if (key ==
"rom_backup_folder")
841 else if (key ==
"code_folder")
843 else if (key ==
"assets_folder")
845 else if (key ==
"patches_folder")
847 else if (key ==
"labels_filename")
849 else if (key ==
"symbols_filename")
851 else if (key ==
"output_folder")
853 else if (key ==
"custom_objects_folder")
855 else if (key ==
"hack_manifest_file")
857 else if (key ==
"additional_roms")
859 }
else if (current_section ==
"rom") {
862 else if (key ==
"expected_hash")
864 else if (key ==
"write_policy")
866 }
else if (current_section ==
"feature_flags") {
867 if (key ==
"load_custom_overworld")
869 else if (key ==
"apply_zs_custom_overworld_asm")
871 else if (key ==
"save_dungeon_maps")
873 else if (key ==
"save_overworld_maps")
875 else if (key ==
"save_overworld_entrances")
877 else if (key ==
"save_overworld_exits")
879 else if (key ==
"save_overworld_items")
881 else if (key ==
"save_overworld_properties")
883 else if (key ==
"save_dungeon_objects")
885 else if (key ==
"save_dungeon_sprites")
887 else if (key ==
"save_dungeon_room_headers")
889 else if (key ==
"save_dungeon_torches")
891 else if (key ==
"save_dungeon_pits")
893 else if (key ==
"save_dungeon_blocks")
895 else if (key ==
"save_dungeon_collision")
897 else if (key ==
"save_dungeon_chests")
899 else if (key ==
"save_dungeon_pot_items")
901 else if (key ==
"save_dungeon_palettes")
903 else if (key ==
"save_graphics_sheet")
905 else if (key ==
"save_all_palettes")
907 else if (key ==
"save_gfx_groups")
909 else if (key ==
"save_messages")
911 else if (key ==
"enable_custom_objects")
913 }
else if (current_section ==
"workspace") {
914 if (key ==
"font_global_scale")
916 else if (key ==
"dark_mode")
918 else if (key ==
"ui_theme")
920 else if (key ==
"autosave_enabled")
922 else if (key ==
"autosave_interval_secs")
924 else if (key ==
"backup_on_save")
926 else if (key ==
"backup_retention_count")
928 else if (key ==
"backup_keep_daily")
930 else if (key ==
"backup_keep_daily_days")
932 else if (key ==
"show_grid")
934 else if (key ==
"show_collision")
936 else if (key ==
"prefer_hmagic_names")
938 else if (key ==
"last_layout_preset")
940 else if (key ==
"saved_layouts")
942 else if (key ==
"recent_files")
944 }
else if (current_section ==
"dungeon_overlay") {
945 if (key ==
"track_tiles")
947 else if (key ==
"track_stop_tiles")
949 else if (key ==
"track_switch_tiles")
951 else if (key ==
"track_object_ids")
953 else if (key ==
"minecart_sprite_ids")
955 }
else if (current_section ==
"rom_addresses") {
956 auto parsed = ParseHexUint32(value);
957 if (parsed.has_value()) {
960 }
else if (current_section ==
"custom_objects") {
961 std::string id_token = key;
962 if (absl::StartsWith(id_token,
"object_")) {
963 id_token = id_token.substr(7);
965 auto parsed = ParseHexUint32(id_token);
966 if (parsed.has_value()) {
969 }
else if (current_section ==
"agent_settings") {
970 if (key ==
"ai_provider")
972 else if (key ==
"ai_model")
974 else if (key ==
"ollama_host")
976 else if (key ==
"gemini_api_key")
978 else if (key ==
"custom_system_prompt")
980 else if (key ==
"use_custom_prompt")
982 else if (key ==
"show_reasoning")
984 else if (key ==
"verbose")
986 else if (key ==
"max_tool_iterations")
988 else if (key ==
"max_retry_attempts")
990 else if (key ==
"temperature")
992 else if (key ==
"top_p")
994 else if (key ==
"max_output_tokens")
996 else if (key ==
"stream_responses")
998 else if (key ==
"favorite_models")
1000 else if (key ==
"model_chain")
1002 else if (key ==
"chain_mode")
1004 else if (key ==
"enable_tool_resources")
1006 else if (key ==
"enable_tool_dungeon")
1008 else if (key ==
"enable_tool_overworld")
1010 else if (key ==
"enable_tool_messages")
1012 else if (key ==
"enable_tool_dialogue")
1014 else if (key ==
"enable_tool_gui")
1016 else if (key ==
"enable_tool_music")
1018 else if (key ==
"enable_tool_sprite")
1020 else if (key ==
"enable_tool_emulator")
1022 else if (key ==
"enable_tool_memory_inspector")
1024 else if (key ==
"builder_blueprint_path")
1026 }
else if (current_section ==
"build") {
1027 if (key ==
"build_script")
1029 else if (key ==
"output_folder")
1031 else if (key ==
"git_repository")
1033 else if (key ==
"track_changes")
1035 else if (key ==
"build_configurations")
1037 else if (key ==
"build_target")
1039 else if (key ==
"asm_entry_point")
1041 else if (key ==
"asm_sources")
1043 else if (key ==
"last_build_hash")
1045 else if (key ==
"build_number")
1047 }
else if (current_section.rfind(
"labels_", 0) == 0) {
1048 std::string label_type = current_section.substr(7);
1050 }
else if (current_section ==
"keybindings") {
1052 }
else if (current_section ==
"editor_visibility") {
1054 }
else if (current_section ==
"zscream_compatibility") {
1055 if (key ==
"original_project_file")
1059 }
else if (current_section ==
"music") {
1060 if (key ==
"persist_custom_music")
1062 else if (key ==
"storage_key")
1064 else if (key ==
"last_saved_at")
1079 return absl::OkStatus();
1083#ifdef __EMSCRIPTEN__
1085 auto storage_or = platform::WasmStorage::LoadProject(storage_key);
1086 if (storage_or.ok()) {
1091 std::ifstream file(project_path);
1092 if (!file.is_open()) {
1093 return absl::InvalidArgumentError(
1094 absl::StrFormat(
"Cannot open project file: %s", project_path));
1097 std::stringstream buffer;
1098 buffer << file.rdbuf();
1105 auto now = std::chrono::system_clock::now();
1106 auto time_t = std::chrono::system_clock::to_time_t(now);
1107 std::stringstream ss;
1108 ss << std::put_time(std::localtime(&time_t),
"%Y-%m-%d %H:%M:%S");
1120#ifdef __EMSCRIPTEN__
1121 auto storage_status =
1122 platform::WasmStorage::SaveProject(
MakeStorageKey(
"project"), serialized);
1123 if (!storage_status.ok()) {
1124 return storage_status;
1129 if (!file.is_open()) {
1130 return absl::InvalidArgumentError(
1131 absl::StrFormat(
"Cannot create project file: %s",
filepath));
1138 return absl::OkStatus();
1142 const std::string& zscream_project_path) {
1148 std::filesystem::path zs_path(zscream_project_path);
1149 name = zs_path.stem().string() +
"_imported";
1161 return absl::OkStatus();
1166 std::ofstream file(target_path);
1167 if (!file.is_open()) {
1168 return absl::InvalidArgumentError(
1169 absl::StrFormat(
"Cannot create ZScream project file: %s", target_path));
1173 file <<
"# ZScream Compatible Project File\n";
1175 file <<
"name=" <<
name <<
"\n";
1183 return absl::OkStatus();
1203 std::vector<std::string> errors;
1206 errors.push_back(
"Project name is required");
1208 errors.push_back(
"Project file path is required");
1210 errors.push_back(
"ROM file is required");
1212#ifndef __EMSCRIPTEN__
1216 errors.push_back(
"ROM file does not exist: " +
rom_filename);
1221 errors.push_back(
"Code folder does not exist: " +
code_folder);
1230 if (!errors.empty()) {
1231 return absl::InvalidArgumentError(absl::StrJoin(errors,
"; "));
1234 return absl::OkStatus();
1238 std::vector<std::string> missing;
1240#ifndef __EMSCRIPTEN__
1259#ifdef __EMSCRIPTEN__
1261 return absl::OkStatus();
1268 for (
const auto& folder : folders) {
1269 if (!folder.empty()) {
1271 if (!std::filesystem::exists(abs_path)) {
1272 std::filesystem::create_directories(abs_path);
1280 if (!std::filesystem::exists(abs_labels)) {
1281 std::ofstream labels_file(abs_labels);
1282 labels_file <<
"# yaze Resource Labels\n";
1283 labels_file <<
"# Format: [type] key=value\n\n";
1284 labels_file.close();
1288 return absl::OkStatus();
1296 return name.empty() ?
"Untitled Project" :
name;
1300 const std::string& absolute_path)
const {
1301 if (absolute_path.empty() ||
filepath.empty())
1302 return absolute_path;
1304 std::filesystem::path project_dir =
1305 std::filesystem::path(
filepath).parent_path();
1306 std::filesystem::path abs_path(absolute_path);
1309 std::filesystem::path relative =
1310 std::filesystem::relative(abs_path.lexically_normal(), project_dir);
1312 return relative.generic_string();
1315 return abs_path.lexically_normal().generic_string();
1320 const std::string& relative_path)
const {
1321 if (relative_path.empty() ||
filepath.empty())
1322 return relative_path;
1324 std::filesystem::path project_dir =
1325 std::filesystem::path(
filepath).parent_path();
1326 std::filesystem::path abs_path(relative_path);
1327 if (abs_path.is_absolute()) {
1328 abs_path = abs_path.lexically_normal();
1329 abs_path.make_preferred();
1330 return abs_path.string();
1332 abs_path = (project_dir / abs_path).lexically_normal();
1333 abs_path.make_preferred();
1335 return abs_path.string();
1339#ifdef __EMSCRIPTEN__
1347 auto normalize = [
this](std::string* path) {
1348 if (!path || path->empty()) {
1366 if (!rom_path.empty()) {
1377 const std::string& project_path) {
1381 std::filesystem::path zs_path(project_path);
1382 name = zs_path.stem().string() +
"_imported";
1387 return absl::OkStatus();
1399 absl::string_view artifact_name)
const {
1400 std::filesystem::path base_dir;
1408 base_dir = std::filesystem::path(
filepath).parent_path();
1411 if (base_dir.empty()) {
1412 return std::string(artifact_name);
1414 return (base_dir / std::string(artifact_name)).lexically_normal().string();
1420#if defined(YAZE_WITH_Z3DK) && __has_include("z3dk_core/config.h")
1421 std::vector<std::filesystem::path> candidates;
1422 auto add_candidate = [&candidates](
const std::filesystem::path& candidate) {
1423 if (candidate.empty()) {
1426 auto normalized = candidate.lexically_normal();
1427 if (std::find(candidates.begin(), candidates.end(), normalized) ==
1429 candidates.push_back(normalized);
1435 if (!std::filesystem::is_directory(code_path)) {
1436 code_path = code_path.parent_path();
1438 add_candidate(code_path /
"z3dk.toml");
1447 add_candidate(std::filesystem::path(
filepath).parent_path() /
"z3dk.toml");
1450 for (
const auto& candidate : candidates) {
1451 if (!std::filesystem::exists(candidate)) {
1456 z3dk::Config config = z3dk::LoadConfigFile(candidate.string(), &error);
1457 if (!error.empty()) {
1458 LOG_WARN(
"Project",
"Failed to parse z3dk config '%s': %s",
1459 candidate.string().c_str(), error.c_str());
1463 const std::filesystem::path base_dir = candidate.parent_path();
1466 if (config.preset.has_value()) {
1471 for (
const auto& include_path : config.include_paths) {
1473 ResolveOptionalPath(base_dir, include_path));
1477 for (
const auto& define : config.defines) {
1482 for (
const auto& main_file : config.main_files) {
1484 ResolveOptionalPath(base_dir, main_file));
1487 if (config.std_includes_path.has_value()) {
1489 ResolveOptionalPath(base_dir, *config.std_includes_path);
1491 if (config.std_defines_path.has_value()) {
1493 ResolveOptionalPath(base_dir, *config.std_defines_path);
1495 if (config.mapper.has_value()) {
1498 if (config.rom_size.has_value()) {
1501 if (config.symbols_format.has_value()) {
1505 if (config.lsp_log_path.has_value()) {
1507 ResolveOptionalPath(base_dir, *config.lsp_log_path);
1511 for (
const auto& emit_path : config.emits) {
1515 for (
const auto& range : config.prohibited_memory_ranges) {
1517 {.start = range.start, .end = range.end, .reason = range.reason});
1521 config.warn_unused_symbols.value_or(
true);
1523 config.warn_branch_outside_bank.value_or(
true);
1527 config.warn_unauthorized_hook.value_or(
true);
1531 if (config.rom_path.has_value()) {
1534 if (config.symbols_path.has_value()) {
1536 ResolveOptionalPath(base_dir, *config.symbols_path);
1540 const std::string basename = BasenameLower(emit_path);
1541 if (basename.ends_with(
".mlb") &&
1544 }
else if (basename ==
"sourcemap.json") {
1546 }
else if (basename ==
"annotations.json") {
1548 }
else if (basename ==
"hooks.json") {
1550 }
else if (basename ==
"lint.json") {
1581 "Loaded z3dk config from %s (%zu include paths, %zu defines)",
1590#ifdef __EMSCRIPTEN__
1600 std::filesystem::path loaded_manifest_path;
1601 auto load_manifest = [&](
const std::filesystem::path& candidate,
1602 bool update_project_setting) ->
bool {
1603 if (candidate.empty() || !std::filesystem::exists(candidate)) {
1608 LOG_WARN(
"Project",
"Failed to load hack manifest %s: %s",
1609 candidate.string().c_str(),
1610 std::string(status.message()).c_str());
1613 loaded_manifest_path = candidate;
1614 if (update_project_setting) {
1617 LOG_DEBUG(
"Project",
"Loaded hack manifest: %s",
1618 candidate.string().c_str());
1631 auto candidate = std::filesystem::path(code_path) /
"hack_manifest.json";
1632 (void)load_manifest(candidate,
true);
1637 const std::filesystem::path project_dir =
1638 std::filesystem::path(
filepath).parent_path();
1639 (void)load_manifest(project_dir /
"hack_manifest.json",
true);
1641 (void)load_manifest(project_dir.parent_path() /
"hack_manifest.json",
1652 auto try_load_registry = [&](
const std::filesystem::path& base) ->
bool {
1656 const auto planning = base /
"Docs" /
"Dev" /
"Planning";
1657 if (!std::filesystem::exists(planning)) {
1662 LOG_WARN(
"Project",
"Failed to load project registry from %s: %s",
1663 base.string().c_str(), std::string(status.message()).c_str());
1669 bool registry_loaded =
false;
1678 if (!registry_loaded && !loaded_manifest_path.empty()) {
1679 registry_loaded = try_load_registry(loaded_manifest_path.parent_path());
1683 if (!registry_loaded && !
filepath.empty()) {
1685 try_load_registry(std::filesystem::path(
filepath).parent_path());
1688 if (!registry_loaded) {
1690 "Hack manifest loaded but project registry was not found "
1691 "(code_folder='%s', manifest='%s')",
1692 code_folder.c_str(), loaded_manifest_path.string().c_str());
1697 size_t injected = 0;
1698 for (
const auto& [type_key, labels] :
1700 for (
const auto& [id_str, label] : labels) {
1705 LOG_DEBUG(
"Project",
"Loaded project registry: %zu resource labels injected",
1746 for (uint16_t tile = 0xB0; tile <= 0xBE; ++tile) {
1778 auto now = std::chrono::system_clock::now().time_since_epoch();
1780 std::chrono::duration_cast<std::chrono::milliseconds>(now).count();
1781 return absl::StrFormat(
"yaze_project_%lld", timestamp);
1785std::vector<ProjectManager::ProjectTemplate>
1787 std::vector<ProjectTemplate> templates;
1796 t.
name =
"Vanilla ROM Hack";
1798 "Standard ROM editing without custom ASM. Limited to vanilla features.";
1807 templates.push_back(t);
1813 t.
name =
"ZSCustomOverworld v2";
1815 "Basic overworld expansion: custom BG colors, main palettes, parent "
1828 templates.push_back(t);
1834 t.
name =
"ZSCustomOverworld v3 (Recommended)";
1836 "Full overworld expansion: wide/tall areas, animated GFX, overlays, "
1853 templates.push_back(t);
1859 t.
name =
"Randomizer Compatible";
1861 "Compatible with ALttP Randomizer. Minimal custom features to avoid "
1870 templates.push_back(t);
1880 t.
name =
"Dungeon Designer";
1881 t.
description =
"Focused on dungeon creation and modification.";
1888 templates.push_back(t);
1894 t.
name =
"Graphics Pack";
1896 "Project focused on graphics, sprites, and visual modifications.";
1905 templates.push_back(t);
1911 t.
name =
"Complete Overhaul";
1912 t.
description =
"Full-scale ROM hack with all features enabled.";
1927 templates.push_back(t);
1934 const std::string& template_name,
const std::string& project_name,
1935 const std::string& base_path) {
1937 auto status = project.
Create(project_name, base_path);
1943 if (template_name ==
"Full Overworld Mod") {
1947 project.
metadata.
tags = {
"overworld",
"maps",
"graphics"};
1948 }
else if (template_name ==
"Dungeon Designer") {
1952 project.
metadata.
tags = {
"dungeons",
"rooms",
"design"};
1953 }
else if (template_name ==
"Graphics Pack") {
1957 project.
metadata.
tags = {
"graphics",
"sprites",
"palettes"};
1958 }
else if (template_name ==
"Complete Overhaul") {
1964 project.
metadata.
tags = {
"complete",
"overhaul",
"full-mod"};
1967 status = project.
Save();
1976 const std::string& directory) {
1977#ifdef __EMSCRIPTEN__
1981 std::vector<std::string> projects;
1984 for (
const auto& entry : std::filesystem::directory_iterator(directory)) {
1985 if (entry.is_regular_file()) {
1986 std::string filename = entry.path().filename().string();
1987 if (filename.ends_with(
".yaze") || filename.ends_with(
".zsproj")) {
1988 projects.push_back(entry.path().string());
1990 }
else if (entry.is_directory()) {
1991 std::string filename = entry.path().filename().string();
1992 if (filename.ends_with(
".yazeproj")) {
1993 projects.push_back(entry.path().string());
1997 }
catch (
const std::filesystem::filesystem_error& e) {
2006#ifdef __EMSCRIPTEN__
2008 return absl::UnimplementedError(
2009 "Project backups are not supported in the web build");
2012 return absl::InvalidArgumentError(
"Project has no file path");
2015 std::filesystem::path project_path(project.
filepath);
2016 std::filesystem::path backup_dir = project_path.parent_path() /
"backups";
2017 std::filesystem::create_directories(backup_dir);
2019 auto now = std::chrono::system_clock::now();
2020 auto time_t = std::chrono::system_clock::to_time_t(now);
2021 std::stringstream ss;
2022 ss << std::put_time(std::localtime(&time_t),
"%Y%m%d_%H%M%S");
2024 std::string backup_filename = project.
name +
"_backup_" + ss.str() +
".yaze";
2025 std::filesystem::path backup_path = backup_dir / backup_filename;
2028 std::filesystem::copy_file(project.
filepath, backup_path);
2029 }
catch (
const std::filesystem::filesystem_error& e) {
2030 return absl::InternalError(
2031 absl::StrFormat(
"Failed to backup project: %s", e.what()));
2034 return absl::OkStatus();
2045 std::vector<std::string> recommendations;
2048 recommendations.push_back(
"Add a ROM file to begin editing");
2052 recommendations.push_back(
"Set up a code folder for assembly patches");
2056 recommendations.push_back(
"Create a labels file for better organization");
2060 recommendations.push_back(
"Add a project description for documentation");
2064 recommendations.push_back(
2065 "Consider setting up version control for your project");
2069 if (!missing_files.empty()) {
2070 recommendations.push_back(
2071 "Some project files are missing - use Project > Repair to fix");
2074 return recommendations;
2080 std::ifstream file(filename);
2081 if (!file.is_open()) {
2088 std::string current_type =
"";
2090 while (std::getline(file, line)) {
2091 if (line.empty() || line[0] ==
'#')
2095 if (line[0] ==
'[' && line.back() ==
']') {
2096 current_type = line.substr(1, line.length() - 2);
2101 size_t eq_pos = line.find(
'=');
2102 if (eq_pos != std::string::npos && !current_type.empty()) {
2103 std::string key = line.substr(0, eq_pos);
2104 std::string value = line.substr(eq_pos + 1);
2105 labels_[current_type][key] = value;
2119 if (!file.is_open())
2122 file <<
"# yaze Resource Labels\n";
2123 file <<
"# Format: [type] followed by key=value pairs\n\n";
2125 for (
const auto& [type, type_labels] :
labels_) {
2126 if (!type_labels.empty()) {
2127 file <<
"[" << type <<
"]\n";
2128 for (
const auto& [key, value] : type_labels) {
2129 file << key <<
"=" << value <<
"\n";
2140 if (!p_open || !*p_open)
2144 if (ImGui::Begin(
"Resource Labels", p_open)) {
2145 ImGui::Text(
"Resource Labels Manager");
2147 ImGui::Text(
"Total types: %zu",
labels_.size());
2149 for (
const auto& [type, type_labels] :
labels_) {
2150 if (ImGui::TreeNode(type.c_str())) {
2151 ImGui::Text(
"Labels: %zu", type_labels.size());
2152 for (
const auto& [key, value] : type_labels) {
2153 ImGui::Text(
"%s = %s", key.c_str(), value.c_str());
2163 const std::string& key,
2164 const std::string& newValue) {
2165 labels_[type][key] = newValue;
2169 bool selected,
const std::string& type,
const std::string& key,
2170 const std::string& defaultValue) {
2172 if (ImGui::Selectable(
2173 absl::StrFormat(
"%s: %s", key.c_str(),
GetLabel(type, key).c_str())
2181 const std::string& key) {
2182 auto type_it =
labels_.find(type);
2186 auto label_it = type_it->second.find(key);
2187 if (label_it == type_it->second.end())
2190 return label_it->second;
2194 const std::string& type,
const std::string& key,
2195 const std::string& defaultValue) {
2196 auto existing =
GetLabel(type, key);
2197 if (!existing.empty())
2200 labels_[type][key] = defaultValue;
2201 return defaultValue;
2209 const std::unordered_map<
2210 std::string, std::unordered_map<std::string, std::string>>& labels) {
2239 LOG_DEBUG(
"Project",
"Initialized embedded labels:");
2241 LOG_DEBUG(
"Project",
" - %d entrance names",
2243 LOG_DEBUG(
"Project",
" - %d sprite names",
2245 LOG_DEBUG(
"Project",
" - %d overlord names",
2248 LOG_DEBUG(
"Project",
" - %d music names",
2250 LOG_DEBUG(
"Project",
" - %d graphics names",
2252 LOG_DEBUG(
"Project",
" - %d room effect names",
2254 LOG_DEBUG(
"Project",
" - %d room tag names",
2256 LOG_DEBUG(
"Project",
" - %d tile type names",
2259 return absl::OkStatus();
2260 }
catch (
const std::exception& e) {
2261 return absl::InternalError(
2262 absl::StrCat(
"Failed to initialize embedded labels: ", e.what()));
2267 const std::string& default_value)
const {
2271 auto label_it = type_it->second.find(std::to_string(
id));
2272 if (label_it != type_it->second.end()) {
2273 return label_it->second;
2277 return default_value.empty() ? resource_type +
"_" + std::to_string(
id)
2282#ifdef __EMSCRIPTEN__
2284 return absl::UnimplementedError(
2285 "File-based label import is not supported in the web build");
2288 if (!file.is_open()) {
2289 return absl::InvalidArgumentError(
2290 absl::StrFormat(
"Cannot open labels file: %s",
filepath));
2293 std::stringstream buffer;
2294 buffer << file.rdbuf();
2302 const std::string& content) {
2309 auto status = provider.ImportFromZScreamFormat(content);
2314 LOG_DEBUG(
"Project",
"Imported ZScream labels:");
2315 LOG_DEBUG(
"Project",
" - %d sprite labels",
2319 LOG_DEBUG(
"Project",
" - %d room tag labels",
2322 return absl::OkStatus();
2331 LOG_DEBUG(
"Project",
"Initialized ResourceLabelProvider with project labels");
2332 LOG_DEBUG(
"Project",
" - prefer_hmagic_names: %s",
2334 LOG_DEBUG(
"Project",
" - hack_manifest: %s",
2342#ifdef YAZE_ENABLE_JSON_PROJECT_FORMAT
2344absl::Status YazeProject::LoadFromJsonFormat(
const std::string& project_path) {
2345#ifdef __EMSCRIPTEN__
2346 return absl::UnimplementedError(
2347 "JSON project format loading is not supported in the web build");
2349 std::ifstream file(project_path);
2350 if (!file.is_open()) {
2351 return absl::InvalidArgumentError(
2352 absl::StrFormat(
"Cannot open JSON project file: %s", project_path));
2360 if (j.contains(
"yaze_project")) {
2361 auto& proj = j[
"yaze_project"];
2363 if (proj.contains(
"name"))
2364 name = proj[
"name"].get<std::string>();
2365 if (proj.contains(
"description"))
2367 if (proj.contains(
"author"))
2369 if (proj.contains(
"version"))
2371 if (proj.contains(
"created"))
2373 if (proj.contains(
"modified"))
2375 if (proj.contains(
"created_by"))
2379 if (proj.contains(
"rom_filename"))
2380 rom_filename = proj[
"rom_filename"].get<std::string>();
2381 if (proj.contains(
"rom_backup_folder"))
2383 if (proj.contains(
"code_folder"))
2384 code_folder = proj[
"code_folder"].get<std::string>();
2385 if (proj.contains(
"assets_folder"))
2387 if (proj.contains(
"patches_folder"))
2389 if (proj.contains(
"labels_filename"))
2391 if (proj.contains(
"symbols_filename"))
2393 if (proj.contains(
"hack_manifest_file"))
2396 if (proj.contains(
"rom") && proj[
"rom"].is_object()) {
2397 auto& rom = proj[
"rom"];
2398 if (rom.contains(
"role"))
2400 if (rom.contains(
"expected_hash"))
2402 if (rom.contains(
"write_policy"))
2408 if (proj.contains(
"use_embedded_labels")) {
2413 if (proj.contains(
"feature_flags")) {
2414 auto& flags = proj[
"feature_flags"];
2417 if (flags.contains(
"kSaveDungeonMaps"))
2419 flags[
"kSaveDungeonMaps"].get<
bool>();
2420 if (flags.contains(
"kSaveOverworldMaps"))
2422 flags[
"kSaveOverworldMaps"].get<
bool>();
2423 if (flags.contains(
"kSaveOverworldEntrances"))
2425 flags[
"kSaveOverworldEntrances"].get<
bool>();
2426 if (flags.contains(
"kSaveOverworldExits"))
2428 flags[
"kSaveOverworldExits"].get<
bool>();
2429 if (flags.contains(
"kSaveOverworldItems"))
2431 flags[
"kSaveOverworldItems"].get<
bool>();
2432 if (flags.contains(
"kSaveOverworldProperties"))
2434 flags[
"kSaveOverworldProperties"].get<
bool>();
2435 if (flags.contains(
"kSaveDungeonObjects"))
2437 flags[
"kSaveDungeonObjects"].get<
bool>();
2438 if (flags.contains(
"kSaveDungeonSprites"))
2440 flags[
"kSaveDungeonSprites"].get<
bool>();
2441 if (flags.contains(
"kSaveDungeonRoomHeaders"))
2443 flags[
"kSaveDungeonRoomHeaders"].get<
bool>();
2444 if (flags.contains(
"kSaveDungeonTorches"))
2446 flags[
"kSaveDungeonTorches"].get<
bool>();
2447 if (flags.contains(
"kSaveDungeonPits"))
2449 flags[
"kSaveDungeonPits"].get<
bool>();
2450 if (flags.contains(
"kSaveDungeonBlocks"))
2452 flags[
"kSaveDungeonBlocks"].get<
bool>();
2453 if (flags.contains(
"kSaveDungeonCollision"))
2455 flags[
"kSaveDungeonCollision"].get<
bool>();
2456 if (flags.contains(
"kSaveDungeonWaterFillZones"))
2458 flags[
"kSaveDungeonWaterFillZones"].get<
bool>();
2459 if (flags.contains(
"kSaveDungeonChests"))
2461 flags[
"kSaveDungeonChests"].get<
bool>();
2462 if (flags.contains(
"kSaveDungeonPotItems"))
2464 flags[
"kSaveDungeonPotItems"].get<
bool>();
2465 if (flags.contains(
"kSaveDungeonPalettes"))
2467 flags[
"kSaveDungeonPalettes"].get<
bool>();
2468 if (flags.contains(
"kSaveGraphicsSheet"))
2470 flags[
"kSaveGraphicsSheet"].get<
bool>();
2471 if (flags.contains(
"kSaveAllPalettes"))
2473 flags[
"kSaveAllPalettes"].get<
bool>();
2474 if (flags.contains(
"kSaveGfxGroups"))
2476 if (flags.contains(
"kSaveMessages"))
2481 if (proj.contains(
"workspace_settings")) {
2482 auto& ws = proj[
"workspace_settings"];
2483 if (ws.contains(
"auto_save_enabled"))
2485 ws[
"auto_save_enabled"].get<
bool>();
2486 if (ws.contains(
"auto_save_interval"))
2488 ws[
"auto_save_interval"].get<
float>();
2489 if (ws.contains(
"backup_on_save"))
2491 if (ws.contains(
"backup_retention_count"))
2493 ws[
"backup_retention_count"].get<
int>();
2494 if (ws.contains(
"backup_keep_daily"))
2496 ws[
"backup_keep_daily"].get<
bool>();
2497 if (ws.contains(
"backup_keep_daily_days"))
2499 ws[
"backup_keep_daily_days"].get<
int>();
2502 if (proj.contains(
"rom_addresses") && proj[
"rom_addresses"].is_object()) {
2504 for (
auto it = proj[
"rom_addresses"].begin();
2505 it != proj[
"rom_addresses"].end(); ++it) {
2506 if (it.value().is_number_unsigned()) {
2508 it.value().get<uint32_t>();
2509 }
else if (it.value().is_string()) {
2511 if (parsed.has_value()) {
2518 if (proj.contains(
"custom_objects") &&
2519 proj[
"custom_objects"].is_object()) {
2521 for (
auto it = proj[
"custom_objects"].begin();
2522 it != proj[
"custom_objects"].end(); ++it) {
2523 if (!it.value().is_array())
2526 if (!parsed.has_value()) {
2529 std::vector<std::string> files;
2530 for (
const auto& entry : it.value()) {
2531 if (entry.is_string()) {
2532 files.push_back(entry.get<std::string>());
2535 if (!files.empty()) {
2541 if (proj.contains(
"agent_settings") &&
2542 proj[
"agent_settings"].is_object()) {
2543 auto& agent = proj[
"agent_settings"];
2570 if (agent.contains(
"favorite_models") &&
2571 agent[
"favorite_models"].is_array()) {
2573 for (
const auto& model : agent[
"favorite_models"]) {
2574 if (model.is_string())
2576 model.get<std::string>());
2579 if (agent.contains(
"model_chain") && agent[
"model_chain"].is_array()) {
2581 for (
const auto& model : agent[
"model_chain"]) {
2582 if (model.is_string())
2607 agent.value(
"enable_tool_memory_inspector",
2614 if (proj.contains(
"build_script"))
2615 build_script = proj[
"build_script"].get<std::string>();
2616 if (proj.contains(
"output_folder"))
2618 if (proj.contains(
"git_repository"))
2620 if (proj.contains(
"track_changes"))
2624 return absl::OkStatus();
2625 }
catch (
const json::exception& e) {
2626 return absl::InvalidArgumentError(
2627 absl::StrFormat(
"JSON parse error: %s", e.what()));
2631absl::Status YazeProject::SaveToJsonFormat() {
2632#ifdef __EMSCRIPTEN__
2633 return absl::UnimplementedError(
2634 "JSON project format saving is not supported in the web build");
2637 auto& proj = j[
"yaze_project"];
2641 proj[
"name"] =
name;
2661 proj[
"rom"][
"write_policy"] =
2670 proj[
"feature_flags"][
"kSaveOverworldMaps"] =
2672 proj[
"feature_flags"][
"kSaveOverworldEntrances"] =
2674 proj[
"feature_flags"][
"kSaveOverworldExits"] =
2676 proj[
"feature_flags"][
"kSaveOverworldItems"] =
2678 proj[
"feature_flags"][
"kSaveOverworldProperties"] =
2680 proj[
"feature_flags"][
"kSaveDungeonObjects"] =
2682 proj[
"feature_flags"][
"kSaveDungeonSprites"] =
2684 proj[
"feature_flags"][
"kSaveDungeonRoomHeaders"] =
2686 proj[
"feature_flags"][
"kSaveDungeonTorches"] =
2689 proj[
"feature_flags"][
"kSaveDungeonBlocks"] =
2691 proj[
"feature_flags"][
"kSaveDungeonCollision"] =
2693 proj[
"feature_flags"][
"kSaveDungeonWaterFillZones"] =
2695 proj[
"feature_flags"][
"kSaveDungeonChests"] =
2697 proj[
"feature_flags"][
"kSaveDungeonPotItems"] =
2699 proj[
"feature_flags"][
"kSaveDungeonPalettes"] =
2701 proj[
"feature_flags"][
"kSaveGraphicsSheet"] =
2708 proj[
"workspace_settings"][
"auto_save_enabled"] =
2710 proj[
"workspace_settings"][
"auto_save_interval"] =
2712 proj[
"workspace_settings"][
"backup_on_save"] =
2714 proj[
"workspace_settings"][
"backup_retention_count"] =
2716 proj[
"workspace_settings"][
"backup_keep_daily"] =
2718 proj[
"workspace_settings"][
"backup_keep_daily_days"] =
2721 auto& agent = proj[
"agent_settings"];
2748 agent[
"enable_tool_memory_inspector"] =
2753 auto& addrs = proj[
"rom_addresses"];
2760 auto& objs = proj[
"custom_objects"];
2762 objs[absl::StrFormat(
"0x%X", object_id)] = files;
2773 if (!file.is_open()) {
2774 return absl::InvalidArgumentError(
2775 absl::StrFormat(
"Cannot write JSON project file: %s",
filepath));
2779 return absl::OkStatus();
2787 if (!config_dir.ok()) {
2794#ifdef __EMSCRIPTEN__
2795 auto status = platform::WasmStorage::SaveProject(
2798 LOG_WARN(
"RecentFilesManager",
"Could not persist recent files: %s",
2799 status.ToString().c_str());
2805 if (!config_dir_status.ok()) {
2806 LOG_ERROR(
"Project",
"Failed to get or create config directory: %s",
2807 config_dir_status.status().ToString().c_str());
2812 std::ofstream file(filepath);
2813 if (!file.is_open()) {
2814 LOG_WARN(
"RecentFilesManager",
"Could not save recent files to %s",
2820 file << file_path << std::endl;
2825#ifdef __EMSCRIPTEN__
2827 if (!storage_or.ok()) {
2831 std::istringstream stream(storage_or.value());
2833 while (std::getline(stream, line)) {
2834 if (!line.empty()) {
2842 std::ifstream file(filepath);
2843 if (!file.is_open()) {
2850 while (std::getline(file, line)) {
2851 if (!line.empty()) {
void Clear()
Clear any loaded manifest state.
const ProjectRegistry & project_registry() const
bool HasProjectRegistry() const
absl::Status LoadProjectRegistry(const std::string &code_folder)
Load project registry data from the code folder.
absl::Status LoadFromFile(const std::string &filepath)
Load manifest from a JSON file path.
bool loaded() const
Check if the manifest has been loaded.
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_
void SetHackManifest(const core::HackManifest *manifest)
Set the hack manifest reference for ASM-defined labels.
#define YAZE_VERSION_STRING
#define ICON_MD_VIDEOGAME_ASSET
#define LOG_DEBUG(category, format,...)
#define LOG_ERROR(category, format,...)
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)
#define ASSIGN_OR_RETURN(type_variable_name, expression)
float ParseFloat(const std::string &value)
std::string ResolveOptionalPath(const std::filesystem::path &base_dir, const std::string &value)
std::vector< uint16_t > ParseHexUintList(const std::string &value)
std::string ToLowerCopy(std::string value)
bool ParseBool(const std::string &value)
std::pair< std::string, std::string > ParseDefineToken(const std::string &value)
std::optional< uint32_t > ParseHexUint32(const std::string &value)
std::string FormatHexUint32(uint32_t value)
std::string SanitizeStorageKey(absl::string_view input)
std::string FormatHexUintList(const std::vector< uint16_t > &values)
std::string BasenameLower(const std::string &path)
std::vector< std::string > ParseStringList(const std::string &value)
std::string RomRoleToString(RomRole role)
RomRole ParseRomRole(absl::string_view value)
const std::string kRecentFilesFilename
RomWritePolicy ParseRomWritePolicy(absl::string_view value)
std::string RomWritePolicyToString(RomWritePolicy policy)
ResourceLabelProvider & GetResourceLabels()
Get the global ResourceLabelProvider instance.
bool kSaveOverworldProperties
bool kApplyZSCustomOverworldASM
bool kLoadCustomOverworld
bool kSaveOverworldEntrances
bool kEnableCustomObjects
struct yaze::core::FeatureFlags::Flags::Dungeon dungeon
struct yaze::core::FeatureFlags::Flags::Overworld overworld
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > all_resource_labels
std::unordered_map< std::string, uint32_t > addresses
std::vector< uint16_t > track_object_ids
std::vector< uint16_t > minecart_sprite_ids
std::vector< uint16_t > track_stop_tiles
std::vector< uint16_t > track_tiles
std::vector< uint16_t > track_switch_tiles
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_
int backup_keep_daily_days
std::string last_layout_preset
std::map< std::string, std::string > custom_keybindings
int backup_retention_count
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
bool enable_tool_memory_inspector
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
std::unordered_map< int, std::vector< std::string > > custom_object_files
absl::Status ResetToDefaults()
std::string custom_objects_folder
absl::Status RepairProject()
std::string MakeStorageKey(absl::string_view suffix) const
static std::string ResolveBundleRoot(const std::string &path)
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()
void NormalizePathsToAbsolute()
absl::Status ImportLabelsFromZScreamContent(const std::string &content)
Import labels from ZScream format content directly.
std::string git_repository
core::HackManifest hack_manifest
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
void ReloadHackManifest()
absl::Status SaveToYazeFormat()
absl::Status LoadAllSettings()
std::string labels_filename
std::vector< std::string > asm_sources
std::string hack_manifest_file
std::string GetDisplayName() const
std::vector< std::string > GetMissingFiles() const
WorkspaceSettings workspace_settings
std::string GetZ3dkArtifactPath(absl::string_view artifact_name) const
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
DungeonOverlaySettings dungeon_overlay
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
void TryLoadHackManifest()
std::map< std::string, std::string > zscream_mappings
absl::Status Validate() const
core::FeatureFlags::Flags feature_flags
std::vector< std::string > build_configurations
void ReloadZ3dkSettings()
core::RomAddressOverrides rom_address_overrides
std::string symbols_filename
Z3dkSettings z3dk_settings
std::string annotations_json
std::string sourcemap_json
std::vector< std::string > include_paths
std::string std_includes_path
std::vector< std::string > main_files
std::vector< std::string > emits
std::vector< std::pair< std::string, std::string > > defines
std::string symbols_format
Z3dkArtifactPaths artifact_paths
bool warn_branch_outside_bank
std::optional< bool > lsp_log_enabled
bool warn_unauthorized_hook
std::vector< Z3dkMemoryRange > prohibited_memory_ranges
std::string std_defines_path