From 95a5201a97787857edaaf985c25c2bd4e7bd45e0 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 25 Aug 2024 17:01:18 -0400 Subject: [PATCH] feat: Add custom overworld map settings UI to OverworldEditor --- src/app/editor/overworld/overworld_editor.cc | 73 +++++++++++++++++++- src/app/zelda3/overworld/overworld_map.h | 23 ++++++ 2 files changed, 95 insertions(+), 1 deletion(-) diff --git a/src/app/editor/overworld/overworld_editor.cc b/src/app/editor/overworld/overworld_editor.cc index 182873bc..977d8e35 100644 --- a/src/app/editor/overworld/overworld_editor.cc +++ b/src/app/editor/overworld/overworld_editor.cc @@ -332,7 +332,78 @@ void OverworldEditor::DrawOverworldMapSettings() { } void OverworldEditor::DrawCustomOverworldMapSettings() { - // TODO: Add @JaredBrian ZSCustomOverworld features to OverworldEditor + if (BeginTable(kOWMapTable.data(), 15, kOWMapFlags, ImVec2(0, 0), -1)) { + for (const auto &name : kMapSettingsColumnNames) + ImGui::TableSetupColumn(name); + + TableNextColumn(); + ImGui::SetNextItemWidth(120.f); + ImGui::Combo("##world", ¤t_world_, kWorldList.data(), 3); + + static const std::array kCustomMapSettingsColumnNames = { + "TileGfx0", "TileGfx1", "TileGfx2", "TileGfx3", + "TileGfx4", "TileGfx5", "TileGfx6", "TileGfx7"}; + for (int i = 0; i < 8; ++i) { + TableNextColumn(); + ImGui::BeginGroup(); + if (gui::InputHexByte(kCustomMapSettingsColumnNames[i].data(), + overworld_.mutable_overworld_map(current_map_) + ->mutable_custom_tileset(i), + kInputFieldSize)) { + RefreshMapProperties(); + RefreshOverworldMap(); + } + ImGui::EndGroup(); + } + + TableNextColumn(); + ImGui::BeginGroup(); + if (gui::InputHexByte("Palette", + overworld_.mutable_overworld_map(current_map_) + ->mutable_area_palette(), + kInputFieldSize)) { + RefreshMapProperties(); + status_ = RefreshMapPalette(); + RefreshOverworldMap(); + } + ImGui::EndGroup(); + + TableNextColumn(); + ImGui::BeginGroup(); + gui::InputHexByte("Spr Gfx", + overworld_.mutable_overworld_map(current_map_) + ->mutable_sprite_graphics(game_state_), + kInputFieldSize); + ImGui::EndGroup(); + + TableNextColumn(); + ImGui::BeginGroup(); + gui::InputHexByte("Spr Palette", + overworld_.mutable_overworld_map(current_map_) + ->mutable_sprite_palette(game_state_), + kInputFieldSize); + ImGui::EndGroup(); + + TableNextColumn(); + ImGui::BeginGroup(); + gui::InputHexWord( + "Msg Id", + overworld_.mutable_overworld_map(current_map_)->mutable_message_id(), + kInputFieldSize + 20); + ImGui::EndGroup(); + + TableNextColumn(); + ImGui::SetNextItemWidth(100.f); + ImGui::Combo("##World", &game_state_, kGamePartComboString.data(), 3); + + TableNextColumn(); + ImGui::Checkbox( + "##mosaic", + overworld_.mutable_overworld_map(current_map_)->mutable_mosaic()); + HOVER_HINT("Enable Mosaic effect for the current map"); + + ImGui::EndTable(); + } } void OverworldEditor::DrawOverworldMaps() { diff --git a/src/app/zelda3/overworld/overworld_map.h b/src/app/zelda3/overworld/overworld_map.h index 117c78ee..b1c093a2 100644 --- a/src/app/zelda3/overworld/overworld_map.h +++ b/src/app/zelda3/overworld/overworld_map.h @@ -118,6 +118,29 @@ class OverworldMap : public editor::context::GfxContext { auto set_sprite_palette(int i, uint8_t value) { sprite_palette_[i] = value; } auto set_message_id(uint16_t value) { message_id_ = value; } + uint8_t* mutable_custom_tileset(int index) { + switch (index) { + case 0: + return &custom_tileset_.TileGFX0; + case 1: + return &custom_tileset_.TileGFX1; + case 2: + return &custom_tileset_.TileGFX2; + case 3: + return &custom_tileset_.TileGFX3; + case 4: + return &custom_tileset_.TileGFX4; + case 5: + return &custom_tileset_.TileGFX5; + case 6: + return &custom_tileset_.TileGFX6; + case 7: + return &custom_tileset_.TileGFX7; + default: + return &custom_tileset_.TileGFX0; + } + } + void SetAsLargeMap(int parent_index, int quadrant) { parent_ = parent_index; large_index_ = quadrant;