update editors based on namespace changes

This commit is contained in:
scawful
2025-01-02 10:16:50 -05:00
parent 1f5acc66c9
commit 698b5a43fa
4 changed files with 33 additions and 41 deletions

View File

@@ -327,8 +327,8 @@ void DungeonEditor::DrawRoomSelector() {
int i = 0; int i = 0;
for (const auto each_room_name : zelda3::kRoomNames) { for (const auto each_room_name : zelda3::kRoomNames) {
rom()->resource_label()->SelectableLabelWithNameEdit( rom()->resource_label()->SelectableLabelWithNameEdit(
current_room_id_ == i, "Dungeon Room Names", current_room_id_ == i, "Dungeon Room Names", core::HexByte(i),
core::HexByte(i), each_room_name.data()); each_room_name.data());
if (ImGui::IsItemClicked()) { if (ImGui::IsItemClicked()) {
// TODO: Jump to tab if room is already open // TODO: Jump to tab if room is already open
current_room_id_ = i; current_room_id_ = i;
@@ -402,8 +402,7 @@ void DungeonEditor::DrawEntranceSelector() {
for (int i = 0; i < 0x85 + 7; i++) { for (int i = 0; i < 0x85 + 7; i++) {
rom()->resource_label()->SelectableLabelWithNameEdit( rom()->resource_label()->SelectableLabelWithNameEdit(
current_entrance_id_ == i, "Dungeon Entrance Names", current_entrance_id_ == i, "Dungeon Entrance Names",
core::HexByte(i), core::HexByte(i), zelda3::kEntranceNames[i].data());
zelda3::kEntranceNames[i].data());
if (ImGui::IsItemClicked()) { if (ImGui::IsItemClicked()) {
current_entrance_id_ = i; current_entrance_id_ = i;
@@ -439,8 +438,8 @@ void DungeonEditor::DrawDungeonTabView() {
continue; continue;
} }
if (BeginTabItem(zelda3::kRoomNames[active_rooms_[n]].data(), if (BeginTabItem(zelda3::kRoomNames[active_rooms_[n]].data(), &open,
&open, ImGuiTabItemFlags_None)) { ImGuiTabItemFlags_None)) {
DrawDungeonCanvas(active_rooms_[n]); DrawDungeonCanvas(active_rooms_[n]);
EndTabItem(); EndTabItem();
} }
@@ -589,8 +588,6 @@ void DungeonEditor::DrawObjectRenderer() {
} }
} }
// ============================================================================
void DungeonEditor::CalculateUsageStats() { void DungeonEditor::CalculateUsageStats() {
for (const auto &room : rooms_) { for (const auto &room : rooms_) {
if (blockset_usage_.find(room.blockset) == blockset_usage_.end()) { if (blockset_usage_.find(room.blockset) == blockset_usage_.end()) {

View File

@@ -118,30 +118,25 @@ absl::Status ScreenEditor::LoadDungeonMaps() {
for (int d = 0; d < 14; d++) { for (int d = 0; d < 14; d++) {
current_floor_rooms_d.clear(); current_floor_rooms_d.clear();
current_floor_gfx_d.clear(); current_floor_gfx_d.clear();
ASSIGN_OR_RETURN( ASSIGN_OR_RETURN(int ptr,
int ptr, rom()->ReadWord(zelda3::kDungeonMapRoomsPtr + (d * 2)));
rom()->ReadWord(zelda3::screen::kDungeonMapRoomsPtr + (d * 2))); ASSIGN_OR_RETURN(int ptr_gfx,
ASSIGN_OR_RETURN( rom()->ReadWord(zelda3::kDungeonMapGfxPtr + (d * 2)));
int ptr_gfx,
rom()->ReadWord(zelda3::screen::kDungeonMapGfxPtr + (d * 2)));
ptr |= 0x0A0000; // Add bank to the short ptr ptr |= 0x0A0000; // Add bank to the short ptr
ptr_gfx |= 0x0A0000; // Add bank to the short ptr ptr_gfx |= 0x0A0000; // Add bank to the short ptr
int pc_ptr = core::SnesToPc(ptr); // Contains data for the next 25 rooms int pc_ptr = core::SnesToPc(ptr); // Contains data for the next 25 rooms
int pc_ptr_gfx = int pc_ptr_gfx =
core::SnesToPc(ptr_gfx); // Contains data for the next 25 rooms core::SnesToPc(ptr_gfx); // Contains data for the next 25 rooms
ASSIGN_OR_RETURN( ASSIGN_OR_RETURN(ushort boss_room_d,
ushort boss_room_d, rom()->ReadWord(zelda3::kDungeonMapBossRooms + (d * 2)));
rom()->ReadWord(zelda3::screen::kDungeonMapBossRooms + (d * 2)));
ASSIGN_OR_RETURN( ASSIGN_OR_RETURN(nbr_basement_d,
nbr_basement_d, rom()->ReadByte(zelda3::kDungeonMapFloors + (d * 2)));
rom()->ReadByte(zelda3::screen::kDungeonMapFloors + (d * 2)));
nbr_basement_d &= 0x0F; nbr_basement_d &= 0x0F;
ASSIGN_OR_RETURN( ASSIGN_OR_RETURN(nbr_floor_d,
nbr_floor_d, rom()->ReadByte(zelda3::kDungeonMapFloors + (d * 2)));
rom()->ReadByte(zelda3::screen::kDungeonMapFloors + (d * 2)));
nbr_floor_d &= 0xF0; nbr_floor_d &= 0xF0;
nbr_floor_d = nbr_floor_d >> 4; nbr_floor_d = nbr_floor_d >> 4;
@@ -184,8 +179,8 @@ absl::Status ScreenEditor::LoadDungeonMaps() {
absl::Status ScreenEditor::SaveDungeonMaps() { absl::Status ScreenEditor::SaveDungeonMaps() {
for (int d = 0; d < 14; d++) { for (int d = 0; d < 14; d++) {
int ptr = zelda3::screen::kDungeonMapRoomsPtr + (d * 2); int ptr = zelda3::kDungeonMapRoomsPtr + (d * 2);
int ptr_gfx = zelda3::screen::kDungeonMapGfxPtr + (d * 2); int ptr_gfx = zelda3::kDungeonMapGfxPtr + (d * 2);
int pc_ptr = core::SnesToPc(ptr); int pc_ptr = core::SnesToPc(ptr);
int pc_ptr_gfx = core::SnesToPc(ptr_gfx); int pc_ptr_gfx = core::SnesToPc(ptr_gfx);
@@ -210,9 +205,9 @@ absl::Status ScreenEditor::LoadDungeonMapTile16(
tile16_sheet_.Init(256, 192, gfx::TileType::Tile16); tile16_sheet_.Init(256, 192, gfx::TileType::Tile16);
for (int i = 0; i < 186; i++) { for (int i = 0; i < 186; i++) {
int addr = zelda3::screen::kDungeonMapTile16; int addr = zelda3::kDungeonMapTile16;
if (rom()->data()[zelda3::screen::kDungeonMapExpCheck] != 0xB9) { if (rom()->data()[zelda3::kDungeonMapExpCheck] != 0xB9) {
addr = zelda3::screen::kDungeonMapTile16Expanded; addr = zelda3::kDungeonMapTile16Expanded;
} }
ASSIGN_OR_RETURN(auto tl, rom()->ReadWord(addr + (i * 8))); ASSIGN_OR_RETURN(auto tl, rom()->ReadWord(addr + (i * 8)));
@@ -251,9 +246,9 @@ absl::Status ScreenEditor::LoadDungeonMapTile16(
absl::Status ScreenEditor::SaveDungeonMapTile16() { absl::Status ScreenEditor::SaveDungeonMapTile16() {
for (int i = 0; i < 186; i++) { for (int i = 0; i < 186; i++) {
int addr = zelda3::screen::kDungeonMapTile16; int addr = zelda3::kDungeonMapTile16;
if (rom()->data()[zelda3::screen::kDungeonMapExpCheck] != 0xB9) { if (rom()->data()[zelda3::kDungeonMapExpCheck] != 0xB9) {
addr = zelda3::screen::kDungeonMapTile16Expanded; addr = zelda3::kDungeonMapTile16Expanded;
} }
gfx::TileInfo t1 = tile16_sheet_.tile_info()[i].tiles[0]; gfx::TileInfo t1 = tile16_sheet_.tile_info()[i].tiles[0];

View File

@@ -90,7 +90,7 @@ class ScreenEditor : public SharedRom, public Editor {
std::vector<gfx::Bitmap> tile8_individual_; std::vector<gfx::Bitmap> tile8_individual_;
std::vector<uint8_t> all_gfx_; std::vector<uint8_t> all_gfx_;
std::vector<uint8_t> gfx_bin_data_; std::vector<uint8_t> gfx_bin_data_;
std::vector<zelda3::screen::DungeonMap> dungeon_maps_; std::vector<zelda3::DungeonMap> dungeon_maps_;
std::vector<std::vector<std::array<std::string, 25>>> dungeon_map_labels_; std::vector<std::vector<std::array<std::string, 25>>> dungeon_map_labels_;
absl::Status status_; absl::Status status_;
@@ -107,7 +107,7 @@ class ScreenEditor : public SharedRom, public Editor {
gui::Canvas tilemap_canvas_{"##TilemapCanvas", ImVec2(128 + 2, (192) + 4), gui::Canvas tilemap_canvas_{"##TilemapCanvas", ImVec2(128 + 2, (192) + 4),
gui::CanvasGridSize::k8x8, 2.f}; gui::CanvasGridSize::k8x8, 2.f};
zelda3::screen::Inventory inventory_; zelda3::Inventory inventory_;
}; };
} // namespace editor } // namespace editor

View File

@@ -1407,21 +1407,21 @@ absl::Status OverworldEditor::UpdateUsageStats() {
void OverworldEditor::DrawUsageGrid() { void OverworldEditor::DrawUsageGrid() {
// Create a grid of 8x8 squares // Create a grid of 8x8 squares
int totalSquares = 128; int total_squares = 128;
int squaresWide = 8; int squares_wide = 8;
int squaresTall = (totalSquares + squaresWide - 1) / int squares_tall = (total_squares + squares_wide - 1) /
squaresWide; // Ceiling of totalSquares/squaresWide squares_wide; // Ceiling of total_squares/squares_wide
// Loop through each row // Loop through each row
for (int row = 0; row < squaresTall; ++row) { for (int row = 0; row < squares_tall; ++row) {
NewLine(); NewLine();
for (int col = 0; col < squaresWide; ++col) { for (int col = 0; col < squares_wide; ++col) {
if (row * squaresWide + col >= totalSquares) { if (row * squares_wide + col >= total_squares) {
break; break;
} }
// Determine if this square should be highlighted // Determine if this square should be highlighted
bool highlight = selected_usage_map_ == (row * squaresWide + col); bool highlight = selected_usage_map_ == (row * squares_wide + col);
// Set highlight color if needed // Set highlight color if needed
if (highlight) { if (highlight) {