From 90933517c4807e9d47300d71f7c4357205b57d40 Mon Sep 17 00:00:00 2001 From: scawful Date: Mon, 22 Jul 2024 19:26:15 -0400 Subject: [PATCH] cleanup sprite pal and overworld editor --- src/app/editor/dungeon_editor.cc | 87 +++++++++++----------------- src/app/editor/overworld/entity.cc | 7 +-- src/app/editor/overworld_editor.cc | 8 +-- src/app/editor/sprite/zsprite.h | 20 +++---- src/app/zelda3/overworld/overworld.h | 49 ++++++++-------- src/app/zelda3/sprite/sprite.h | 2 +- 6 files changed, 77 insertions(+), 96 deletions(-) diff --git a/src/app/editor/dungeon_editor.cc b/src/app/editor/dungeon_editor.cc index 8e58353e..cbb15489 100644 --- a/src/app/editor/dungeon_editor.cc +++ b/src/app/editor/dungeon_editor.cc @@ -335,79 +335,59 @@ void DungeonEditor::DrawRoomSelector() { } } +using ImGui::Separator; + void DungeonEditor::DrawEntranceSelector() { if (rom()->is_loaded()) { - gui::InputHexWord("Entrance ID", - &entrances_[current_entrance_id_].entrance_id_); - - gui::InputHexWord("Room ID", &entrances_[current_entrance_id_].room_, 50.f, - true); - SameLine(); - gui::InputHexByte("Dungeon ID", - &entrances_[current_entrance_id_].dungeon_id_, 50.f, - true); - - gui::InputHexByte("Blockset", &entrances_[current_entrance_id_].blockset_, - 50.f, true); + auto current_entrance = entrances_[current_entrance_id_]; + gui::InputHexWord("Entrance ID", ¤t_entrance.entrance_id_); + gui::InputHexWord("Room ID", ¤t_entrance.room_, 50.f, true); SameLine(); - gui::InputHexByte("Music", &entrances_[current_entrance_id_].music_, 50.f, - true); + gui::InputHexByte("Dungeon ID", ¤t_entrance.dungeon_id_, 50.f, true); + gui::InputHexByte("Blockset", ¤t_entrance.blockset_, 50.f, true); SameLine(); - gui::InputHexByte("Floor", &entrances_[current_entrance_id_].floor_); - ImGui::Separator(); - - gui::InputHexWord("Player X ", - &entrances_[current_entrance_id_].x_position_); + gui::InputHexByte("Music", ¤t_entrance.music_, 50.f, true); SameLine(); - gui::InputHexWord("Player Y ", - &entrances_[current_entrance_id_].y_position_); + gui::InputHexByte("Floor", ¤t_entrance.floor_); + Separator(); - gui::InputHexWord("Camera X", - &entrances_[current_entrance_id_].camera_trigger_x_); + gui::InputHexWord("Player X ", ¤t_entrance.x_position_); SameLine(); - gui::InputHexWord("Camera Y", - &entrances_[current_entrance_id_].camera_trigger_y_); + gui::InputHexWord("Player Y ", ¤t_entrance.y_position_); - gui::InputHexWord("Scroll X ", - &entrances_[current_entrance_id_].camera_x_); + gui::InputHexWord("Camera X", ¤t_entrance.camera_trigger_x_); SameLine(); - gui::InputHexWord("Scroll Y ", - &entrances_[current_entrance_id_].camera_y_); + gui::InputHexWord("Camera Y", ¤t_entrance.camera_trigger_y_); - gui::InputHexWord("Exit", &entrances_[current_entrance_id_].exit_, 50.f, - true); + gui::InputHexWord("Scroll X ", ¤t_entrance.camera_x_); + SameLine(); + gui::InputHexWord("Scroll Y ", ¤t_entrance.camera_y_); - ImGui::Separator(); + gui::InputHexWord("Exit", ¤t_entrance.exit_, 50.f, true); + + Separator(); Text("Camera Boundaries"); - ImGui::Separator(); + Separator(); Text("\t\t\t\t\tNorth East South West"); - gui::InputHexByte("Quadrant", - &entrances_[current_entrance_id_].camera_boundary_qn_, - 50.f, true); + gui::InputHexByte("Quadrant", ¤t_entrance.camera_boundary_qn_, 50.f, + true); SameLine(); - gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qe_, - 50.f, true); + gui::InputHexByte("", ¤t_entrance.camera_boundary_qe_, 50.f, true); SameLine(); - gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qs_, - 50.f, true); + gui::InputHexByte("", ¤t_entrance.camera_boundary_qs_, 50.f, true); SameLine(); - gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qw_, - 50.f, true); + gui::InputHexByte("", ¤t_entrance.camera_boundary_qw_, 50.f, true); - gui::InputHexByte("Full room", - &entrances_[current_entrance_id_].camera_boundary_fn_, - 50.f, true); + gui::InputHexByte("Full room", ¤t_entrance.camera_boundary_fn_, 50.f, + true); SameLine(); - gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fe_, - 50.f, true); + gui::InputHexByte("", ¤t_entrance.camera_boundary_fe_, 50.f, true); SameLine(); - gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fs_, - 50.f, true); + gui::InputHexByte("", ¤t_entrance.camera_boundary_fs_, 50.f, true); SameLine(); - gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fw_, - 50.f, true); + gui::InputHexByte("", ¤t_entrance.camera_boundary_fw_, 50.f, true); if (BeginChild("EntranceSelector", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar)) { @@ -465,7 +445,7 @@ void DungeonEditor::DrawDungeonTabView() { EndTabBar(); } - ImGui::Separator(); + Separator(); } void DungeonEditor::DrawDungeonCanvas(int room_id) { @@ -504,7 +484,8 @@ void DungeonEditor::DrawDungeonCanvas(int room_id) { void DungeonEditor::DrawRoomGraphics() { const auto height = 0x40; - room_gfx_canvas_.DrawBackground(ImVec2(0x100 + 1, 0x10 * 0x40 + 1)); + const int num_sheets = 0x10; + room_gfx_canvas_.DrawBackground(ImVec2(0x100 + 1, num_sheets * height + 1)); room_gfx_canvas_.DrawContextMenu(); room_gfx_canvas_.DrawTileSelector(32); if (is_loaded_) { diff --git a/src/app/editor/overworld/entity.cc b/src/app/editor/overworld/entity.cc index 97fed143..3d5227fd 100644 --- a/src/app/editor/overworld/entity.cc +++ b/src/app/editor/overworld/entity.cc @@ -376,7 +376,6 @@ bool DrawItemEditorPopup(zelda3::overworld::OverworldItem &item) { const ImGuiTableSortSpecs *SpriteItem::s_current_sort_specs = nullptr; - void DrawSpriteTable(std::function onSpriteSelect) { static ImGuiTextFilter filter; static int selected_id = 0; @@ -432,8 +431,7 @@ void DrawSpriteInserterPopup() { Text("Add Sprite"); BeginChild("ScrollRegion", ImVec2(250, 250), true, ImGuiWindowFlags_AlwaysVerticalScrollbar); - DrawSpriteTable( - [](int selected_id) { new_sprite_id = selected_id; }); + DrawSpriteTable([](int selected_id) { new_sprite_id = selected_id; }); EndChild(); if (Button(ICON_MD_DONE)) { @@ -461,7 +459,7 @@ bool DrawSpriteEditorPopup(zelda3::Sprite &sprite) { BeginChild("ScrollRegion", ImVec2(350, 350), true, ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGui::BeginGroup(); - Text("%s", sprite.Name().c_str()); + Text("%s", sprite.name().c_str()); DrawSpriteTable([&sprite](int selected_id) { sprite.set_id(selected_id); @@ -487,7 +485,6 @@ bool DrawSpriteEditorPopup(zelda3::Sprite &sprite) { return set_done; } - } // namespace editor } // namespace app } // namespace yaze diff --git a/src/app/editor/overworld_editor.cc b/src/app/editor/overworld_editor.cc index 6f2e0754..25035e71 100644 --- a/src/app/editor/overworld_editor.cc +++ b/src/app/editor/overworld_editor.cc @@ -947,7 +947,7 @@ void OverworldEditor::DrawOverworldSprites() { } } - ow_map_canvas_.DrawText(absl::StrFormat("%s", sprite.Name()), map_x, + ow_map_canvas_.DrawText(absl::StrFormat("%s", sprite.name()), map_x, map_y); } i++; @@ -1028,9 +1028,9 @@ absl::Status OverworldEditor::LoadGraphics() { maps_bmp_[i], palette)); } - // if (flags()->overworld.kDrawOverworldSprites) { - // RETURN_IF_ERROR(LoadSpriteGraphics()); - // } + if (flags()->overworld.kDrawOverworldSprites) { + RETURN_IF_ERROR(LoadSpriteGraphics()); + } return absl::OkStatus(); } diff --git a/src/app/editor/sprite/zsprite.h b/src/app/editor/sprite/zsprite.h index 0fbd081f..1903e602 100644 --- a/src/app/editor/sprite/zsprite.h +++ b/src/app/editor/sprite/zsprite.h @@ -25,8 +25,8 @@ struct OamTile { bool s, uint8_t p) : x(x), y(y), - mirrorX(mx), - mirrorY(my), + mirror_x(mx), + mirror_y(my), id(id), palette(pal), size(s), @@ -34,8 +34,8 @@ struct OamTile { uint8_t x; uint8_t y; - bool mirrorX; - bool mirrorY; + bool mirror_x; + bool mirror_y; uint16_t id; uint8_t palette; bool size; @@ -254,12 +254,12 @@ struct ZSprite { fs.write( reinterpret_cast(&editor.Frames[i].Tiles[j].palette), sizeof(uint8_t)); - fs.write( - reinterpret_cast(&editor.Frames[i].Tiles[j].mirrorX), - sizeof(bool)); - fs.write( - reinterpret_cast(&editor.Frames[i].Tiles[j].mirrorY), - sizeof(bool)); + fs.write(reinterpret_cast( + &editor.Frames[i].Tiles[j].mirror_x), + sizeof(bool)); + fs.write(reinterpret_cast( + &editor.Frames[i].Tiles[j].mirror_y), + sizeof(bool)); fs.write(reinterpret_cast( &editor.Frames[i].Tiles[j].priority), sizeof(uint8_t)); diff --git a/src/app/zelda3/overworld/overworld.h b/src/app/zelda3/overworld/overworld.h index 6f78acfd..affb48d8 100644 --- a/src/app/zelda3/overworld/overworld.h +++ b/src/app/zelda3/overworld/overworld.h @@ -372,7 +372,6 @@ class OverworldEntrance : public OverworldEntity { constexpr int kCompressedAllMap32PointersHigh = 0x1794D; constexpr int kCompressedAllMap32PointersLow = 0x17B2D; -constexpr int overworldgfxGroups = 0x05D97; constexpr int overworldPalGroup1 = 0xDE6C8; constexpr int overworldPalGroup2 = 0xDE86C; constexpr int overworldPalGroup3 = 0xDE604; @@ -433,33 +432,37 @@ constexpr int transition_target_west = 0x13F62; constexpr int overworldCustomMosaicASM = 0x1301D0; constexpr int overworldCustomMosaicArray = 0x1301F0; -constexpr int OverworldCustomASMHasBeenApplied = - 0x140145; // 1 byte, not 0 if enabled +// 1 byte, not 0 if enabled +constexpr int OverworldCustomASMHasBeenApplied = 0x140145; -constexpr int OverworldCustomAreaSpecificBGPalette = - 0x140000; // 2 bytes for each overworld area (0x140) -constexpr int OverworldCustomAreaSpecificBGEnabled = - 0x140140; // 1 byte, not 0 if enabled +// 2 bytes for each overworld area (0x140) +constexpr int OverworldCustomAreaSpecificBGPalette = 0x140000; -constexpr int OverworldCustomMainPaletteArray = - 0x140160; // 1 byte for each overworld area (0xA0) -constexpr int OverworldCustomMainPaletteEnabled = - 0x140141; // 1 byte, not 0 if enabled +// 1 byte, not 0 if enabled +constexpr int OverworldCustomAreaSpecificBGEnabled = 0x140140; -constexpr int OverworldCustomMosaicArray = - 0x140200; // 1 byte for each overworld area (0xA0) -constexpr int OverworldCustomMosaicEnabled = - 0x140142; // 1 byte, not 0 if enabled +// 1 byte for each overworld area (0xA0) +constexpr int OverworldCustomMainPaletteArray = 0x140160; +// 1 byte, not 0 if enabled +constexpr int OverworldCustomMainPaletteEnabled = 0x140141; -constexpr int OverworldCustomAnimatedGFXArray = - 0x1402A0; // 1 byte for each overworld area (0xA0) -constexpr int OverworldCustomAnimatedGFXEnabled = - 0x140143; // 1 byte, not 0 if enabled +// 1 byte for each overworld area (0xA0) +constexpr int OverworldCustomMosaicArray = 0x140200; -constexpr int OverworldCustomSubscreenOverlayArray = - 0x140340; // 2 bytes for each overworld area (0x140) -constexpr int OverworldCustomSubscreenOverlayEnabled = - 0x140144; // 1 byte, not 0 if enabled +// 1 byte, not 0 if enabled +constexpr int OverworldCustomMosaicEnabled = 0x140142; + +// 1 byte for each overworld area (0xA0) +constexpr int OverworldCustomAnimatedGFXArray = 0x1402A0; + +// 1 byte, not 0 if enabled +constexpr int OverworldCustomAnimatedGFXEnabled = 0x140143; + +// 2 bytes for each overworld area (0x140) +constexpr int OverworldCustomSubscreenOverlayArray = 0x140340; + +// 1 byte, not 0 if enabled +constexpr int OverworldCustomSubscreenOverlayEnabled = 0x140144; constexpr int kMap16Tiles = 0x78000; constexpr int kNumOverworldMaps = 160; diff --git a/src/app/zelda3/sprite/sprite.h b/src/app/zelda3/sprite/sprite.h index 67698f98..f3f824a1 100644 --- a/src/app/zelda3/sprite/sprite.h +++ b/src/app/zelda3/sprite/sprite.h @@ -59,7 +59,7 @@ class Sprite : public OverworldEntity { auto Width() const { return bounding_box_.w; } auto Height() const { return bounding_box_.h; } - std::string& Name() { return name_; } + auto name() { return name_; } auto deleted() const { return deleted_; } auto set_deleted(bool deleted) { deleted_ = deleted; }