From 0c9faa7ac42ce6bcf3a36df6daa58ae71e01eb48 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 25 Aug 2024 16:50:41 -0400 Subject: [PATCH] chore: pass flag to overworld map for loading custom data --- src/app/editor/overworld/overworld_editor.cc | 11 +++++++++-- src/app/editor/overworld/overworld_editor.h | 1 + src/app/zelda3/overworld/overworld.cc | 8 ++++++-- src/app/zelda3/overworld/overworld_map.cc | 5 +++-- src/app/zelda3/overworld/overworld_map.h | 3 ++- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/app/editor/overworld/overworld_editor.cc b/src/app/editor/overworld/overworld_editor.cc index 42965208..182873bc 100644 --- a/src/app/editor/overworld/overworld_editor.cc +++ b/src/app/editor/overworld/overworld_editor.cc @@ -331,6 +331,10 @@ void OverworldEditor::DrawOverworldMapSettings() { } } +void OverworldEditor::DrawCustomOverworldMapSettings() { + // TODO: Add @JaredBrian ZSCustomOverworld features to OverworldEditor +} + void OverworldEditor::DrawOverworldMaps() { int xx = 0; int yy = 0; @@ -564,10 +568,13 @@ void OverworldEditor::CheckForMousePan() { } } -// TODO: Add @JaredBrian ZSCustomOverworld features to OverworldEditor void OverworldEditor::DrawOverworldCanvas() { if (all_gfx_loaded_) { - DrawOverworldMapSettings(); + if (flags()->overworld.kLoadCustomOverworld) { + DrawCustomOverworldMapSettings(); + } else { + DrawOverworldMapSettings(); + } Separator(); } diff --git a/src/app/editor/overworld/overworld_editor.h b/src/app/editor/overworld/overworld_editor.h index 0f015d45..b1f755f6 100644 --- a/src/app/editor/overworld/overworld_editor.h +++ b/src/app/editor/overworld/overworld_editor.h @@ -157,6 +157,7 @@ class OverworldEditor : public Editor, * @brief Draws the overworld map settings. Graphics, palettes, etc. */ void DrawOverworldMapSettings(); + void DrawCustomOverworldMapSettings(); void RefreshChildMap(int i); void RefreshOverworldMap(); diff --git a/src/app/zelda3/overworld/overworld.cc b/src/app/zelda3/overworld/overworld.cc index 4388790b..d2d69235 100644 --- a/src/app/zelda3/overworld/overworld.cc +++ b/src/app/zelda3/overworld/overworld.cc @@ -86,8 +86,10 @@ absl::Status Overworld::Load(Rom &rom) { AssembleMap16Tiles(); RETURN_IF_ERROR(DecompressAllMapTiles()) + const bool load_custom_overworld = flags()->overworld.kLoadCustomOverworld; for (int map_index = 0; map_index < kNumOverworldMaps; ++map_index) - overworld_maps_.emplace_back(map_index, rom_, tiles16_); + overworld_maps_.emplace_back(map_index, rom_, tiles16_, + load_custom_overworld); FetchLargeMaps(); LoadEntrances(); @@ -1516,8 +1518,10 @@ absl::Status Overworld::LoadPrototype(Rom &rom, AssembleMap16Tiles(); RETURN_IF_ERROR(DecompressProtoMapTiles(tilemap_filename)) + const bool load_custom_overworld = flags()->overworld.kLoadCustomOverworld; for (int map_index = 0; map_index < kNumOverworldMaps; ++map_index) - overworld_maps_.emplace_back(map_index, rom_, tiles16_); + overworld_maps_.emplace_back(map_index, rom_, tiles16_, + load_custom_overworld); FetchLargeMaps(); LoadEntrances(); diff --git a/src/app/zelda3/overworld/overworld_map.cc b/src/app/zelda3/overworld/overworld_map.cc index 50999153..917f3951 100644 --- a/src/app/zelda3/overworld/overworld_map.cc +++ b/src/app/zelda3/overworld/overworld_map.cc @@ -19,11 +19,12 @@ namespace zelda3 { namespace overworld { OverworldMap::OverworldMap(int index, Rom& rom, - std::vector& tiles16) + std::vector& tiles16, + bool load_custom_data) : index_(index), parent_(index), rom_(rom), tiles16_(tiles16) { LoadAreaInfo(); - if (flags()->kLoadCustomOverworld) { + if (load_custom_data) { // If the custom overworld ASM has NOT already been applied, manually set // the vanilla values. uint8_t asm_version = rom_[OverworldCustomASMHasBeenApplied]; diff --git a/src/app/zelda3/overworld/overworld_map.h b/src/app/zelda3/overworld/overworld_map.h index 5204ebea..117c78ee 100644 --- a/src/app/zelda3/overworld/overworld_map.h +++ b/src/app/zelda3/overworld/overworld_map.h @@ -67,7 +67,8 @@ constexpr int OverworldCustomTileGFXGroupEnabled = 0x140148; class OverworldMap : public editor::context::GfxContext { public: OverworldMap() = default; - OverworldMap(int index, Rom& rom, std::vector& tiles16); + OverworldMap(int index, Rom& rom, std::vector& tiles16, + bool load_custom_data = false); absl::Status BuildMap(int count, int game_state, int world, OWBlockset& world_blockset);