cleanup sprite pal and overworld editor

This commit is contained in:
scawful
2024-07-22 19:26:15 -04:00
parent b887771593
commit 90933517c4
6 changed files with 77 additions and 96 deletions

View File

@@ -335,79 +335,59 @@ void DungeonEditor::DrawRoomSelector() {
} }
} }
using ImGui::Separator;
void DungeonEditor::DrawEntranceSelector() { void DungeonEditor::DrawEntranceSelector() {
if (rom()->is_loaded()) { if (rom()->is_loaded()) {
gui::InputHexWord("Entrance ID", auto current_entrance = entrances_[current_entrance_id_];
&entrances_[current_entrance_id_].entrance_id_); gui::InputHexWord("Entrance ID", &current_entrance.entrance_id_);
gui::InputHexWord("Room ID", &current_entrance.room_, 50.f, true);
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);
SameLine(); SameLine();
gui::InputHexByte("Music", &entrances_[current_entrance_id_].music_, 50.f, gui::InputHexByte("Dungeon ID", &current_entrance.dungeon_id_, 50.f, true);
true); gui::InputHexByte("Blockset", &current_entrance.blockset_, 50.f, true);
SameLine(); SameLine();
gui::InputHexByte("Floor", &entrances_[current_entrance_id_].floor_);
ImGui::Separator(); gui::InputHexByte("Music", &current_entrance.music_, 50.f, true);
gui::InputHexWord("Player X ",
&entrances_[current_entrance_id_].x_position_);
SameLine(); SameLine();
gui::InputHexWord("Player Y ", gui::InputHexByte("Floor", &current_entrance.floor_);
&entrances_[current_entrance_id_].y_position_); Separator();
gui::InputHexWord("Camera X", gui::InputHexWord("Player X ", &current_entrance.x_position_);
&entrances_[current_entrance_id_].camera_trigger_x_);
SameLine(); SameLine();
gui::InputHexWord("Camera Y", gui::InputHexWord("Player Y ", &current_entrance.y_position_);
&entrances_[current_entrance_id_].camera_trigger_y_);
gui::InputHexWord("Scroll X ", gui::InputHexWord("Camera X", &current_entrance.camera_trigger_x_);
&entrances_[current_entrance_id_].camera_x_);
SameLine(); SameLine();
gui::InputHexWord("Scroll Y ", gui::InputHexWord("Camera Y", &current_entrance.camera_trigger_y_);
&entrances_[current_entrance_id_].camera_y_);
gui::InputHexWord("Exit", &entrances_[current_entrance_id_].exit_, 50.f, gui::InputHexWord("Scroll X ", &current_entrance.camera_x_);
true); SameLine();
gui::InputHexWord("Scroll Y ", &current_entrance.camera_y_);
ImGui::Separator(); gui::InputHexWord("Exit", &current_entrance.exit_, 50.f, true);
Separator();
Text("Camera Boundaries"); Text("Camera Boundaries");
ImGui::Separator(); Separator();
Text("\t\t\t\t\tNorth East South West"); Text("\t\t\t\t\tNorth East South West");
gui::InputHexByte("Quadrant", gui::InputHexByte("Quadrant", &current_entrance.camera_boundary_qn_, 50.f,
&entrances_[current_entrance_id_].camera_boundary_qn_, true);
50.f, true);
SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qe_, gui::InputHexByte("", &current_entrance.camera_boundary_qe_, 50.f, true);
50.f, true);
SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qs_, gui::InputHexByte("", &current_entrance.camera_boundary_qs_, 50.f, true);
50.f, true);
SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qw_, gui::InputHexByte("", &current_entrance.camera_boundary_qw_, 50.f, true);
50.f, true);
gui::InputHexByte("Full room", gui::InputHexByte("Full room", &current_entrance.camera_boundary_fn_, 50.f,
&entrances_[current_entrance_id_].camera_boundary_fn_, true);
50.f, true);
SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fe_, gui::InputHexByte("", &current_entrance.camera_boundary_fe_, 50.f, true);
50.f, true);
SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fs_, gui::InputHexByte("", &current_entrance.camera_boundary_fs_, 50.f, true);
50.f, true);
SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fw_, gui::InputHexByte("", &current_entrance.camera_boundary_fw_, 50.f, true);
50.f, true);
if (BeginChild("EntranceSelector", ImVec2(0, 0), true, if (BeginChild("EntranceSelector", ImVec2(0, 0), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar)) { ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
@@ -465,7 +445,7 @@ void DungeonEditor::DrawDungeonTabView() {
EndTabBar(); EndTabBar();
} }
ImGui::Separator(); Separator();
} }
void DungeonEditor::DrawDungeonCanvas(int room_id) { void DungeonEditor::DrawDungeonCanvas(int room_id) {
@@ -504,7 +484,8 @@ void DungeonEditor::DrawDungeonCanvas(int room_id) {
void DungeonEditor::DrawRoomGraphics() { void DungeonEditor::DrawRoomGraphics() {
const auto height = 0x40; 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_.DrawContextMenu();
room_gfx_canvas_.DrawTileSelector(32); room_gfx_canvas_.DrawTileSelector(32);
if (is_loaded_) { if (is_loaded_) {

View File

@@ -376,7 +376,6 @@ bool DrawItemEditorPopup(zelda3::overworld::OverworldItem &item) {
const ImGuiTableSortSpecs *SpriteItem::s_current_sort_specs = nullptr; const ImGuiTableSortSpecs *SpriteItem::s_current_sort_specs = nullptr;
void DrawSpriteTable(std::function<void(int)> onSpriteSelect) { void DrawSpriteTable(std::function<void(int)> onSpriteSelect) {
static ImGuiTextFilter filter; static ImGuiTextFilter filter;
static int selected_id = 0; static int selected_id = 0;
@@ -432,8 +431,7 @@ void DrawSpriteInserterPopup() {
Text("Add Sprite"); Text("Add Sprite");
BeginChild("ScrollRegion", ImVec2(250, 250), true, BeginChild("ScrollRegion", ImVec2(250, 250), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGuiWindowFlags_AlwaysVerticalScrollbar);
DrawSpriteTable( DrawSpriteTable([](int selected_id) { new_sprite_id = selected_id; });
[](int selected_id) { new_sprite_id = selected_id; });
EndChild(); EndChild();
if (Button(ICON_MD_DONE)) { if (Button(ICON_MD_DONE)) {
@@ -461,7 +459,7 @@ bool DrawSpriteEditorPopup(zelda3::Sprite &sprite) {
BeginChild("ScrollRegion", ImVec2(350, 350), true, BeginChild("ScrollRegion", ImVec2(350, 350), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGuiWindowFlags_AlwaysVerticalScrollbar);
ImGui::BeginGroup(); ImGui::BeginGroup();
Text("%s", sprite.Name().c_str()); Text("%s", sprite.name().c_str());
DrawSpriteTable([&sprite](int selected_id) { DrawSpriteTable([&sprite](int selected_id) {
sprite.set_id(selected_id); sprite.set_id(selected_id);
@@ -487,7 +485,6 @@ bool DrawSpriteEditorPopup(zelda3::Sprite &sprite) {
return set_done; return set_done;
} }
} // namespace editor } // namespace editor
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -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); map_y);
} }
i++; i++;
@@ -1028,9 +1028,9 @@ absl::Status OverworldEditor::LoadGraphics() {
maps_bmp_[i], palette)); maps_bmp_[i], palette));
} }
// if (flags()->overworld.kDrawOverworldSprites) { if (flags()->overworld.kDrawOverworldSprites) {
// RETURN_IF_ERROR(LoadSpriteGraphics()); RETURN_IF_ERROR(LoadSpriteGraphics());
// } }
return absl::OkStatus(); return absl::OkStatus();
} }

View File

@@ -25,8 +25,8 @@ struct OamTile {
bool s, uint8_t p) bool s, uint8_t p)
: x(x), : x(x),
y(y), y(y),
mirrorX(mx), mirror_x(mx),
mirrorY(my), mirror_y(my),
id(id), id(id),
palette(pal), palette(pal),
size(s), size(s),
@@ -34,8 +34,8 @@ struct OamTile {
uint8_t x; uint8_t x;
uint8_t y; uint8_t y;
bool mirrorX; bool mirror_x;
bool mirrorY; bool mirror_y;
uint16_t id; uint16_t id;
uint8_t palette; uint8_t palette;
bool size; bool size;
@@ -254,12 +254,12 @@ struct ZSprite {
fs.write( fs.write(
reinterpret_cast<const char*>(&editor.Frames[i].Tiles[j].palette), reinterpret_cast<const char*>(&editor.Frames[i].Tiles[j].palette),
sizeof(uint8_t)); sizeof(uint8_t));
fs.write( fs.write(reinterpret_cast<const char*>(
reinterpret_cast<const char*>(&editor.Frames[i].Tiles[j].mirrorX), &editor.Frames[i].Tiles[j].mirror_x),
sizeof(bool)); sizeof(bool));
fs.write( fs.write(reinterpret_cast<const char*>(
reinterpret_cast<const char*>(&editor.Frames[i].Tiles[j].mirrorY), &editor.Frames[i].Tiles[j].mirror_y),
sizeof(bool)); sizeof(bool));
fs.write(reinterpret_cast<const char*>( fs.write(reinterpret_cast<const char*>(
&editor.Frames[i].Tiles[j].priority), &editor.Frames[i].Tiles[j].priority),
sizeof(uint8_t)); sizeof(uint8_t));

View File

@@ -372,7 +372,6 @@ class OverworldEntrance : public OverworldEntity {
constexpr int kCompressedAllMap32PointersHigh = 0x1794D; constexpr int kCompressedAllMap32PointersHigh = 0x1794D;
constexpr int kCompressedAllMap32PointersLow = 0x17B2D; constexpr int kCompressedAllMap32PointersLow = 0x17B2D;
constexpr int overworldgfxGroups = 0x05D97;
constexpr int overworldPalGroup1 = 0xDE6C8; constexpr int overworldPalGroup1 = 0xDE6C8;
constexpr int overworldPalGroup2 = 0xDE86C; constexpr int overworldPalGroup2 = 0xDE86C;
constexpr int overworldPalGroup3 = 0xDE604; constexpr int overworldPalGroup3 = 0xDE604;
@@ -433,33 +432,37 @@ constexpr int transition_target_west = 0x13F62;
constexpr int overworldCustomMosaicASM = 0x1301D0; constexpr int overworldCustomMosaicASM = 0x1301D0;
constexpr int overworldCustomMosaicArray = 0x1301F0; constexpr int overworldCustomMosaicArray = 0x1301F0;
constexpr int OverworldCustomASMHasBeenApplied = // 1 byte, not 0 if enabled
0x140145; // 1 byte, not 0 if enabled constexpr int OverworldCustomASMHasBeenApplied = 0x140145;
constexpr int OverworldCustomAreaSpecificBGPalette = // 2 bytes for each overworld area (0x140)
0x140000; // 2 bytes for each overworld area (0x140) constexpr int OverworldCustomAreaSpecificBGPalette = 0x140000;
constexpr int OverworldCustomAreaSpecificBGEnabled =
0x140140; // 1 byte, not 0 if enabled
constexpr int OverworldCustomMainPaletteArray = // 1 byte, not 0 if enabled
0x140160; // 1 byte for each overworld area (0xA0) constexpr int OverworldCustomAreaSpecificBGEnabled = 0x140140;
constexpr int OverworldCustomMainPaletteEnabled =
0x140141; // 1 byte, not 0 if enabled
constexpr int OverworldCustomMosaicArray = // 1 byte for each overworld area (0xA0)
0x140200; // 1 byte for each overworld area (0xA0) constexpr int OverworldCustomMainPaletteArray = 0x140160;
constexpr int OverworldCustomMosaicEnabled = // 1 byte, not 0 if enabled
0x140142; // 1 byte, not 0 if enabled constexpr int OverworldCustomMainPaletteEnabled = 0x140141;
constexpr int OverworldCustomAnimatedGFXArray = // 1 byte for each overworld area (0xA0)
0x1402A0; // 1 byte for each overworld area (0xA0) constexpr int OverworldCustomMosaicArray = 0x140200;
constexpr int OverworldCustomAnimatedGFXEnabled =
0x140143; // 1 byte, not 0 if enabled
constexpr int OverworldCustomSubscreenOverlayArray = // 1 byte, not 0 if enabled
0x140340; // 2 bytes for each overworld area (0x140) constexpr int OverworldCustomMosaicEnabled = 0x140142;
constexpr int OverworldCustomSubscreenOverlayEnabled =
0x140144; // 1 byte, not 0 if enabled // 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 kMap16Tiles = 0x78000;
constexpr int kNumOverworldMaps = 160; constexpr int kNumOverworldMaps = 160;

View File

@@ -59,7 +59,7 @@ class Sprite : public OverworldEntity {
auto Width() const { return bounding_box_.w; } auto Width() const { return bounding_box_.w; }
auto Height() const { return bounding_box_.h; } auto Height() const { return bounding_box_.h; }
std::string& Name() { return name_; } auto name() { return name_; }
auto deleted() const { return deleted_; } auto deleted() const { return deleted_; }
auto set_deleted(bool deleted) { deleted_ = deleted; } auto set_deleted(bool deleted) { deleted_ = deleted; }