refactor: Improve OverworldEditor File Handling and Code Clarity
- Added file utility header for improved resource path management. - Enhanced ASM file handling by utilizing GetResourcePath for better compatibility across deployment scenarios. - Cleaned up code formatting and comments for clarity, ensuring consistent indentation and readability. - Deprecated feature flag for ZSCustomOverworld ASM application, simplifying the logic for version gating.
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#include "app/zelda3/overworld/overworld_map.h"
|
#include "app/zelda3/overworld/overworld_map.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "imgui_memory_editor.h"
|
#include "imgui_memory_editor.h"
|
||||||
|
#include "util/file_util.h"
|
||||||
#include "util/hex.h"
|
#include "util/hex.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/macro.h"
|
#include "util/macro.h"
|
||||||
@@ -2453,10 +2454,8 @@ absl::Status OverworldEditor::Clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::Status OverworldEditor::ApplyZSCustomOverworldASM(int target_version) {
|
absl::Status OverworldEditor::ApplyZSCustomOverworldASM(int target_version) {
|
||||||
if (!core::FeatureFlags::get().overworld.kApplyZSCustomOverworldASM) {
|
// Feature flag deprecated - ROM version gating is sufficient
|
||||||
return absl::FailedPreconditionError(
|
// User explicitly clicked upgrade button, so respect their request
|
||||||
"ZSCustomOverworld ASM application is disabled in feature flags");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate target version
|
// Validate target version
|
||||||
if (target_version < 2 || target_version > 3) {
|
if (target_version < 2 || target_version > 3) {
|
||||||
@@ -2483,18 +2482,23 @@ absl::Status OverworldEditor::ApplyZSCustomOverworldASM(int target_version) {
|
|||||||
std::vector<uint8_t> working_rom_data = original_rom_data;
|
std::vector<uint8_t> working_rom_data = original_rom_data;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Determine which ASM file to apply
|
// Determine which ASM file to apply and use GetResourcePath for proper resolution
|
||||||
std::string asm_file_path;
|
std::string asm_file_name = (target_version == 3)
|
||||||
if (target_version == 3) {
|
? "asm/yaze.asm" // Master file with v3
|
||||||
asm_file_path = "assets/asm/yaze.asm"; // Master file with v3
|
: "asm/ZSCustomOverworld.asm"; // v2 standalone
|
||||||
} else {
|
|
||||||
asm_file_path = "assets/asm/ZSCustomOverworld.asm"; // v2 standalone
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if ASM file exists
|
// Use GetResourcePath to handle app bundles and various deployment scenarios
|
||||||
|
std::string asm_file_path = util::GetResourcePath(asm_file_name);
|
||||||
|
|
||||||
|
LOG_INFO("OverworldEditor", "Using ASM file: %s", asm_file_path.c_str());
|
||||||
|
|
||||||
|
// Verify file exists
|
||||||
if (!std::filesystem::exists(asm_file_path)) {
|
if (!std::filesystem::exists(asm_file_path)) {
|
||||||
return absl::NotFoundError(
|
return absl::NotFoundError(absl::StrFormat(
|
||||||
absl::StrFormat("ASM file not found: %s", asm_file_path));
|
"ASM file not found at: %s\n\n"
|
||||||
|
"Expected location: assets/%s\n"
|
||||||
|
"Make sure the assets directory is accessible.",
|
||||||
|
asm_file_path, asm_file_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the ASM patch
|
// Apply the ASM patch
|
||||||
|
|||||||
Reference in New Issue
Block a user