dung editor cleanup

This commit is contained in:
scawful
2024-07-19 22:32:23 -04:00
parent 0600443c61
commit 48a72d1eae
2 changed files with 130 additions and 132 deletions

View File

@@ -18,15 +18,26 @@ namespace yaze {
namespace app { namespace app {
namespace editor { namespace editor {
constexpr ImGuiTableFlags kDungeonObjectTableFlags = using ImGui::BeginChild;
ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | using ImGui::BeginTabBar;
ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersOuter | using ImGui::BeginTabItem;
ImGuiTableFlags_BordersV; using ImGui::BeginTable;
using ImGui::Button;
using ImGui::EndChild;
using ImGui::EndTabBar;
using ImGui::EndTabItem;
using ImGui::RadioButton;
using ImGui::SameLine;
using ImGui::TableHeadersRow; using ImGui::TableHeadersRow;
using ImGui::TableNextColumn; using ImGui::TableNextColumn;
using ImGui::TableNextRow; using ImGui::TableNextRow;
using ImGui::TableSetupColumn; using ImGui::TableSetupColumn;
using ImGui::Text;
constexpr ImGuiTableFlags kDungeonObjectTableFlags =
ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersOuter |
ImGuiTableFlags_BordersV;
absl::Status DungeonEditor::Update() { absl::Status DungeonEditor::Update() {
if (!is_loaded_ && rom()->is_loaded()) { if (!is_loaded_ && rom()->is_loaded()) {
@@ -82,7 +93,14 @@ absl::Status DungeonEditor::Initialize() {
} }
LoadDungeonRoomSize(); LoadDungeonRoomSize();
LoadRoomEntrances(); // LoadRoomEntrances
for (int i = 0; i < 0x07; ++i) {
entrances_.emplace_back(zelda3::dungeon::RoomEntrance(*rom(), i, true));
}
for (int i = 0; i < 0x85; ++i) {
entrances_.emplace_back(zelda3::dungeon::RoomEntrance(*rom(), i, false));
}
// Load the palette group and palette for the dungeon // Load the palette group and palette for the dungeon
full_palette_ = dungeon_man_pal_group[current_palette_group_id_]; full_palette_ = dungeon_man_pal_group[current_palette_group_id_];
@@ -168,8 +186,7 @@ absl::Status DungeonEditor::UpdateDungeonRoomView() {
ImGui::End(); ImGui::End();
} }
if (ImGui::BeginTable("#DungeonEditTable", 3, kDungeonTableFlags, if (BeginTable("#DungeonEditTable", 3, kDungeonTableFlags, ImVec2(0, 0))) {
ImVec2(0, 0))) {
TableSetupColumn("Room Selector"); TableSetupColumn("Room Selector");
TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch, TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x); ImGui::GetContentRegionAvail().x);
@@ -198,7 +215,7 @@ absl::Status DungeonEditor::UpdateDungeonRoomView() {
} }
void DungeonEditor::DrawToolset() { void DungeonEditor::DrawToolset() {
if (ImGui::BeginTable("DWToolset", 13, ImGuiTableFlags_SizingFixedFit, if (BeginTable("DWToolset", 13, ImGuiTableFlags_SizingFixedFit,
ImVec2(0, 0))) { ImVec2(0, 0))) {
TableSetupColumn("#undoTool"); TableSetupColumn("#undoTool");
TableSetupColumn("#redoTool"); TableSetupColumn("#redoTool");
@@ -215,47 +232,43 @@ void DungeonEditor::DrawToolset() {
TableSetupColumn("#blockTool"); TableSetupColumn("#blockTool");
TableNextColumn(); TableNextColumn();
if (ImGui::Button(ICON_MD_UNDO)) { if (Button(ICON_MD_UNDO)) {
PRINT_IF_ERROR(Undo()); PRINT_IF_ERROR(Undo());
} }
TableNextColumn(); TableNextColumn();
if (ImGui::Button(ICON_MD_REDO)) { if (Button(ICON_MD_REDO)) {
PRINT_IF_ERROR(Redo()); PRINT_IF_ERROR(Redo());
} }
TableNextColumn(); TableNextColumn();
ImGui::Text(ICON_MD_MORE_VERT); Text(ICON_MD_MORE_VERT);
TableNextColumn(); TableNextColumn();
if (ImGui::RadioButton(ICON_MD_FILTER_NONE, if (RadioButton(ICON_MD_FILTER_NONE, background_type_ == kBackgroundAny)) {
background_type_ == kBackgroundAny)) {
background_type_ = kBackgroundAny; background_type_ = kBackgroundAny;
} }
TableNextColumn(); TableNextColumn();
if (ImGui::RadioButton(ICON_MD_FILTER_1, if (RadioButton(ICON_MD_FILTER_1, background_type_ == kBackground1)) {
background_type_ == kBackground1)) {
background_type_ = kBackground1; background_type_ = kBackground1;
} }
TableNextColumn(); TableNextColumn();
if (ImGui::RadioButton(ICON_MD_FILTER_2, if (RadioButton(ICON_MD_FILTER_2, background_type_ == kBackground2)) {
background_type_ == kBackground2)) {
background_type_ = kBackground2; background_type_ = kBackground2;
} }
TableNextColumn(); TableNextColumn();
if (ImGui::RadioButton(ICON_MD_FILTER_3, if (RadioButton(ICON_MD_FILTER_3, background_type_ == kBackground3)) {
background_type_ == kBackground3)) {
background_type_ = kBackground3; background_type_ = kBackground3;
} }
TableNextColumn(); TableNextColumn();
ImGui::Text(ICON_MD_MORE_VERT); Text(ICON_MD_MORE_VERT);
TableNextColumn(); TableNextColumn();
if (ImGui::RadioButton(ICON_MD_PEST_CONTROL, placement_type_ == kSprite)) { if (RadioButton(ICON_MD_PEST_CONTROL, placement_type_ == kSprite)) {
placement_type_ = kSprite; placement_type_ = kSprite;
} }
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
@@ -263,7 +276,7 @@ void DungeonEditor::DrawToolset() {
} }
TableNextColumn(); TableNextColumn();
if (ImGui::RadioButton(ICON_MD_GRASS, placement_type_ == kItem)) { if (RadioButton(ICON_MD_GRASS, placement_type_ == kItem)) {
placement_type_ = kItem; placement_type_ = kItem;
} }
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
@@ -271,7 +284,7 @@ void DungeonEditor::DrawToolset() {
} }
TableNextColumn(); TableNextColumn();
if (ImGui::RadioButton(ICON_MD_SENSOR_DOOR, placement_type_ == kDoor)) { if (RadioButton(ICON_MD_SENSOR_DOOR, placement_type_ == kDoor)) {
placement_type_ = kDoor; placement_type_ = kDoor;
} }
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
@@ -279,7 +292,7 @@ void DungeonEditor::DrawToolset() {
} }
TableNextColumn(); TableNextColumn();
if (ImGui::RadioButton(ICON_MD_SQUARE, placement_type_ == kBlock)) { if (RadioButton(ICON_MD_SQUARE, placement_type_ == kBlock)) {
placement_type_ = kBlock; placement_type_ = kBlock;
} }
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
@@ -287,7 +300,7 @@ void DungeonEditor::DrawToolset() {
} }
TableNextColumn(); TableNextColumn();
if (ImGui::Button(ICON_MD_PALETTE)) { if (Button(ICON_MD_PALETTE)) {
palette_showing_ = !palette_showing_; palette_showing_ = !palette_showing_;
} }
@@ -301,7 +314,7 @@ void DungeonEditor::DrawRoomSelector() {
gui::InputHex("Palette ID", &current_palette_id_); gui::InputHex("Palette ID", &current_palette_id_);
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)9); if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)9);
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true, BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar)) { ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
int i = 0; int i = 0;
for (const auto each_room_name : zelda3::dungeon::kRoomNames) { for (const auto each_room_name : zelda3::dungeon::kRoomNames) {
@@ -318,7 +331,7 @@ void DungeonEditor::DrawRoomSelector() {
i += 1; i += 1;
} }
} }
ImGui::EndChild(); EndChild();
} }
} }
@@ -329,37 +342,37 @@ void DungeonEditor::DrawEntranceSelector() {
gui::InputHexWord("Room ID", &entrances_[current_entrance_id_].room_, 50.f, gui::InputHexWord("Room ID", &entrances_[current_entrance_id_].room_, 50.f,
true); true);
ImGui::SameLine(); SameLine();
gui::InputHexByte("Dungeon ID", gui::InputHexByte("Dungeon ID",
&entrances_[current_entrance_id_].dungeon_id_, 50.f, &entrances_[current_entrance_id_].dungeon_id_, 50.f,
true); true);
gui::InputHexByte("Blockset", &entrances_[current_entrance_id_].blockset_, gui::InputHexByte("Blockset", &entrances_[current_entrance_id_].blockset_,
50.f, true); 50.f, true);
ImGui::SameLine(); SameLine();
gui::InputHexByte("Music", &entrances_[current_entrance_id_].music_, 50.f, gui::InputHexByte("Music", &entrances_[current_entrance_id_].music_, 50.f,
true); true);
ImGui::SameLine(); SameLine();
gui::InputHexByte("Floor", &entrances_[current_entrance_id_].floor_); gui::InputHexByte("Floor", &entrances_[current_entrance_id_].floor_);
ImGui::Separator(); ImGui::Separator();
gui::InputHexWord("Player X ", gui::InputHexWord("Player X ",
&entrances_[current_entrance_id_].x_position_); &entrances_[current_entrance_id_].x_position_);
ImGui::SameLine(); SameLine();
gui::InputHexWord("Player Y ", gui::InputHexWord("Player Y ",
&entrances_[current_entrance_id_].y_position_); &entrances_[current_entrance_id_].y_position_);
gui::InputHexWord("Camera X", gui::InputHexWord("Camera X",
&entrances_[current_entrance_id_].camera_trigger_x_); &entrances_[current_entrance_id_].camera_trigger_x_);
ImGui::SameLine(); SameLine();
gui::InputHexWord("Camera Y", gui::InputHexWord("Camera Y",
&entrances_[current_entrance_id_].camera_trigger_y_); &entrances_[current_entrance_id_].camera_trigger_y_);
gui::InputHexWord("Scroll X ", gui::InputHexWord("Scroll X ",
&entrances_[current_entrance_id_].camera_x_); &entrances_[current_entrance_id_].camera_x_);
ImGui::SameLine(); SameLine();
gui::InputHexWord("Scroll Y ", gui::InputHexWord("Scroll Y ",
&entrances_[current_entrance_id_].camera_y_); &entrances_[current_entrance_id_].camera_y_);
@@ -367,36 +380,36 @@ void DungeonEditor::DrawEntranceSelector() {
true); true);
ImGui::Separator(); ImGui::Separator();
ImGui::Text("Camera Boundaries"); Text("Camera Boundaries");
ImGui::Separator(); ImGui::Separator();
ImGui::Text("\t\t\t\t\tNorth East South West"); Text("\t\t\t\t\tNorth East South West");
gui::InputHexByte("Quadrant", gui::InputHexByte("Quadrant",
&entrances_[current_entrance_id_].camera_boundary_qn_, &entrances_[current_entrance_id_].camera_boundary_qn_,
50.f, true); 50.f, true);
ImGui::SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qe_, gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qe_,
50.f, true); 50.f, true);
ImGui::SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qs_, gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qs_,
50.f, true); 50.f, true);
ImGui::SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qw_, gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_qw_,
50.f, true); 50.f, true);
gui::InputHexByte("Full room", gui::InputHexByte("Full room",
&entrances_[current_entrance_id_].camera_boundary_fn_, &entrances_[current_entrance_id_].camera_boundary_fn_,
50.f, true); 50.f, true);
ImGui::SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fe_, gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fe_,
50.f, true); 50.f, true);
ImGui::SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fs_, gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fs_,
50.f, true); 50.f, true);
ImGui::SameLine(); SameLine();
gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fw_, gui::InputHexByte("", &entrances_[current_entrance_id_].camera_boundary_fw_,
50.f, true); 50.f, true);
if (ImGui::BeginChild("EntranceSelector", ImVec2(0, 0), true, if (BeginChild("EntranceSelector", ImVec2(0, 0), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar)) { ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
for (int i = 0; i < 0x85 + 7; i++) { for (int i = 0; i < 0x85 + 7; i++) {
rom()->resource_label()->SelectableLabelWithNameEdit( rom()->resource_label()->SelectableLabelWithNameEdit(
@@ -412,14 +425,14 @@ void DungeonEditor::DrawEntranceSelector() {
} }
} }
} }
ImGui::EndChild(); EndChild();
} }
} }
void DungeonEditor::DrawDungeonTabView() { void DungeonEditor::DrawDungeonTabView() {
static int next_tab_id = 0; static int next_tab_id = 0;
if (ImGui::BeginTabBar("MyTabBar", kDungeonTabBarFlags)) { if (BeginTabBar("MyTabBar", kDungeonTabBarFlags)) {
if (ImGui::TabItemButton(ICON_MD_ADD, kDungeonTabFlags)) { if (ImGui::TabItemButton(ICON_MD_ADD, kDungeonTabFlags)) {
if (std::find(active_rooms_.begin(), active_rooms_.end(), if (std::find(active_rooms_.begin(), active_rooms_.end(),
current_room_id_) != active_rooms_.end()) { current_room_id_) != active_rooms_.end()) {
@@ -438,11 +451,10 @@ void DungeonEditor::DrawDungeonTabView() {
continue; continue;
} }
if (ImGui::BeginTabItem( if (BeginTabItem(zelda3::dungeon::kRoomNames[active_rooms_[n]].data(),
zelda3::dungeon::kRoomNames[active_rooms_[n]].data(), &open, &open, ImGuiTabItemFlags_None)) {
ImGuiTabItemFlags_None)) {
DrawDungeonCanvas(active_rooms_[n]); DrawDungeonCanvas(active_rooms_[n]);
ImGui::EndTabItem(); EndTabItem();
} }
if (!open) if (!open)
@@ -451,7 +463,7 @@ void DungeonEditor::DrawDungeonTabView() {
n++; n++;
} }
ImGui::EndTabBar(); EndTabBar();
} }
ImGui::Separator(); ImGui::Separator();
} }
@@ -460,24 +472,24 @@ void DungeonEditor::DrawDungeonCanvas(int room_id) {
ImGui::BeginGroup(); ImGui::BeginGroup();
gui::InputHexByte("Layout", &rooms_[room_id].layout); gui::InputHexByte("Layout", &rooms_[room_id].layout);
ImGui::SameLine(); SameLine();
gui::InputHexByte("Blockset", &rooms_[room_id].blockset); gui::InputHexByte("Blockset", &rooms_[room_id].blockset);
ImGui::SameLine(); SameLine();
gui::InputHexByte("Spriteset", &rooms_[room_id].spriteset); gui::InputHexByte("Spriteset", &rooms_[room_id].spriteset);
ImGui::SameLine(); SameLine();
gui::InputHexByte("Palette", &rooms_[room_id].palette); gui::InputHexByte("Palette", &rooms_[room_id].palette);
gui::InputHexByte("Floor1", &rooms_[room_id].floor1); gui::InputHexByte("Floor1", &rooms_[room_id].floor1);
ImGui::SameLine(); SameLine();
gui::InputHexByte("Floor2", &rooms_[room_id].floor2); gui::InputHexByte("Floor2", &rooms_[room_id].floor2);
ImGui::SameLine(); SameLine();
gui::InputHexWord("Message ID", &rooms_[room_id].message_id_); gui::InputHexWord("Message ID", &rooms_[room_id].message_id_);
ImGui::SameLine(); SameLine();
ImGui::EndGroup(); ImGui::EndGroup();
@@ -517,34 +529,34 @@ void DungeonEditor::DrawRoomGraphics() {
} }
void DungeonEditor::DrawTileSelector() { void DungeonEditor::DrawTileSelector() {
if (ImGui::BeginTabBar("##TabBar", ImGuiTabBarFlags_FittingPolicyScroll)) { if (BeginTabBar("##TabBar", ImGuiTabBarFlags_FittingPolicyScroll)) {
if (ImGui::BeginTabItem("Room Graphics")) { if (BeginTabItem("Room Graphics")) {
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)3); if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)3);
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true, BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar)) { ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
DrawRoomGraphics(); DrawRoomGraphics();
} }
ImGui::EndChild(); EndChild();
ImGui::EndTabItem(); EndTabItem();
} }
if (ImGui::BeginTabItem("Object Renderer")) { if (BeginTabItem("Object Renderer")) {
DrawObjectRenderer(); DrawObjectRenderer();
ImGui::EndTabItem(); EndTabItem();
} }
ImGui::EndTabBar(); EndTabBar();
} }
} }
void DungeonEditor::DrawObjectRenderer() { void DungeonEditor::DrawObjectRenderer() {
if (ImGui::BeginTable("DungeonObjectEditorTable", 2, kDungeonObjectTableFlags, if (BeginTable("DungeonObjectEditorTable", 2, kDungeonObjectTableFlags,
ImVec2(0, 0))) { ImVec2(0, 0))) {
TableSetupColumn("Dungeon Objects", ImGuiTableColumnFlags_WidthStretch, TableSetupColumn("Dungeon Objects", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x); ImGui::GetContentRegionAvail().x);
TableSetupColumn("Canvas"); TableSetupColumn("Canvas");
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("DungeonObjectButtons", ImVec2(250, 0), true); BeginChild("DungeonObjectButtons", ImVec2(250, 0), true);
int selected_object = 0; int selected_object = 0;
int i = 0; int i = 0;
@@ -560,12 +572,11 @@ void DungeonEditor::DrawObjectRenderer() {
i += 1; i += 1;
} }
ImGui::EndChild(); EndChild();
// Right side of the table - Canvas // Right side of the table - Canvas
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("DungeonObjectCanvas", ImVec2(276, 0x10 * 0x40 + 1), BeginChild("DungeonObjectCanvas", ImVec2(276, 0x10 * 0x40 + 1), true);
true);
object_canvas_.DrawBackground(ImVec2(256 + 1, 0x10 * 0x40 + 1)); object_canvas_.DrawBackground(ImVec2(256 + 1, 0x10 * 0x40 + 1));
object_canvas_.DrawContextMenu(); object_canvas_.DrawContextMenu();
@@ -576,7 +587,7 @@ void DungeonEditor::DrawObjectRenderer() {
object_canvas_.DrawGrid(32.0f); object_canvas_.DrawGrid(32.0f);
object_canvas_.DrawOverlay(); object_canvas_.DrawOverlay();
ImGui::EndChild(); EndChild();
ImGui::EndTable(); ImGui::EndTable();
} }
@@ -589,16 +600,6 @@ void DungeonEditor::DrawObjectRenderer() {
} }
} }
void DungeonEditor::LoadRoomEntrances() {
for (int i = 0; i < 0x07; ++i) {
entrances_.emplace_back(zelda3::dungeon::RoomEntrance(*rom(), i, true));
}
for (int i = 0; i < 0x85; ++i) {
entrances_.emplace_back(zelda3::dungeon::RoomEntrance(*rom(), i, false));
}
}
// ============================================================================ // ============================================================================
void DungeonEditor::CalculateUsageStats() { void DungeonEditor::CalculateUsageStats() {
@@ -663,16 +664,16 @@ void RenderUnusedSets(const absl::flat_hash_map<T, int>& usage_map, int max_set,
} }
for (const auto& set : unused_sets) { for (const auto& set : unused_sets) {
if (spriteset_offset != 0x00) { if (spriteset_offset != 0x00) {
ImGui::Text("%#02x, %#02x", set, (set + spriteset_offset)); Text("%#02x, %#02x", set, (set + spriteset_offset));
} else { } else {
ImGui::Text("%#02x", set); Text("%#02x", set);
} }
} }
} }
} // namespace } // namespace
void DungeonEditor::DrawUsageStats() { void DungeonEditor::DrawUsageStats() {
if (ImGui::Button("Refresh")) { if (Button("Refresh")) {
selected_blockset_ = 0xFFFF; selected_blockset_ = 0xFFFF;
selected_spriteset_ = 0xFFFF; selected_spriteset_ = 0xFFFF;
selected_palette_ = 0xFFFF; selected_palette_ = 0xFFFF;
@@ -684,7 +685,7 @@ void DungeonEditor::DrawUsageStats() {
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
if (ImGui::BeginTable("DungeonUsageStatsTable", 8, if (BeginTable("DungeonUsageStatsTable", 8,
kDungeonTableFlags | ImGuiTableFlags_SizingFixedFit, kDungeonTableFlags | ImGuiTableFlags_SizingFixedFit,
ImGui::GetContentRegionAvail())) { ImGui::GetContentRegionAvail())) {
TableSetupColumn("Blockset Usage"); TableSetupColumn("Blockset Usage");
@@ -699,51 +700,50 @@ void DungeonEditor::DrawUsageStats() {
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("BlocksetUsageScroll", ImVec2(0, 0), true, BeginChild("BlocksetUsageScroll", ImVec2(0, 0), true,
ImGuiWindowFlags_HorizontalScrollbar); ImGuiWindowFlags_HorizontalScrollbar);
RenderSetUsage(blockset_usage_, selected_blockset_); RenderSetUsage(blockset_usage_, selected_blockset_);
ImGui::EndChild(); EndChild();
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("UnusedBlocksetScroll", ImVec2(0, 0), true, BeginChild("UnusedBlocksetScroll", ImVec2(0, 0), true,
ImGuiWindowFlags_HorizontalScrollbar); ImGuiWindowFlags_HorizontalScrollbar);
RenderUnusedSets(blockset_usage_, 0x25); RenderUnusedSets(blockset_usage_, 0x25);
ImGui::EndChild(); EndChild();
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("PaletteUsageScroll", ImVec2(0, 0), true, BeginChild("PaletteUsageScroll", ImVec2(0, 0), true,
ImGuiWindowFlags_HorizontalScrollbar); ImGuiWindowFlags_HorizontalScrollbar);
RenderSetUsage(palette_usage_, selected_palette_); RenderSetUsage(palette_usage_, selected_palette_);
ImGui::EndChild(); EndChild();
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("UnusedPaletteScroll", ImVec2(0, 0), true, BeginChild("UnusedPaletteScroll", ImVec2(0, 0), true,
ImGuiWindowFlags_HorizontalScrollbar); ImGuiWindowFlags_HorizontalScrollbar);
RenderUnusedSets(palette_usage_, 0x48); RenderUnusedSets(palette_usage_, 0x48);
ImGui::EndChild(); EndChild();
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("SpritesetUsageScroll", ImVec2(0, 0), true, BeginChild("SpritesetUsageScroll", ImVec2(0, 0), true,
ImGuiWindowFlags_HorizontalScrollbar); ImGuiWindowFlags_HorizontalScrollbar);
RenderSetUsage(spriteset_usage_, selected_spriteset_, 0x40); RenderSetUsage(spriteset_usage_, selected_spriteset_, 0x40);
ImGui::EndChild(); EndChild();
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("UnusedSpritesetScroll", ImVec2(0, 0), true, BeginChild("UnusedSpritesetScroll", ImVec2(0, 0), true,
ImGuiWindowFlags_HorizontalScrollbar); ImGuiWindowFlags_HorizontalScrollbar);
RenderUnusedSets(spriteset_usage_, 0x90, 0x40); RenderUnusedSets(spriteset_usage_, 0x90, 0x40);
ImGui::EndChild(); EndChild();
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("UsageGrid", ImVec2(0, 0), true, BeginChild("UsageGrid", ImVec2(0, 0), true,
ImGuiWindowFlags_HorizontalScrollbar); ImGuiWindowFlags_HorizontalScrollbar);
ImGui::Text("%s", Text("%s", absl::StrFormat("Total size of all rooms: %d hex format: %#06x",
absl::StrFormat("Total size of all rooms: %d hex format: %#06x",
total_room_size_, total_room_size_) total_room_size_, total_room_size_)
.c_str()); .c_str());
DrawUsageGrid(); DrawUsageGrid();
ImGui::EndChild(); EndChild();
TableNextColumn(); TableNextColumn();
if (selected_blockset_ < 0x25) { if (selected_blockset_ < 0x25) {
@@ -801,8 +801,8 @@ void DungeonEditor::DrawUsageGrid() {
ImGuiCol_Button, ImGuiCol_Button,
ImVec4(1.0f, 0.5f, 0.0f, 1.0f)); // Or any highlight color ImVec4(1.0f, 0.5f, 0.0f, 1.0f)); // Or any highlight color
} }
if (ImGui::Button(absl::StrFormat( if (Button(absl::StrFormat("%#x",
"%#x", rooms_[row * squaresWide + col].room_size()) rooms_[row * squaresWide + col].room_size())
.c_str(), .c_str(),
ImVec2(55, 30))) { ImVec2(55, 30))) {
// Switch over to the room editor tab // Switch over to the room editor tab
@@ -826,20 +826,20 @@ void DungeonEditor::DrawUsageGrid() {
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
// Display a tooltip with all the room properties // Display a tooltip with all the room properties
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::Text("Room ID: %d", row * squaresWide + col); Text("Room ID: %d", row * squaresWide + col);
ImGui::Text("Blockset: %#02x", room.blockset); Text("Blockset: %#02x", room.blockset);
ImGui::Text("Spriteset: %#02x", room.spriteset); Text("Spriteset: %#02x", room.spriteset);
ImGui::Text("Palette: %#02x", room.palette); Text("Palette: %#02x", room.palette);
ImGui::Text("Floor1: %#02x", room.floor1); Text("Floor1: %#02x", room.floor1);
ImGui::Text("Floor2: %#02x", room.floor2); Text("Floor2: %#02x", room.floor2);
ImGui::Text("Message ID: %#04x", room.message_id_); Text("Message ID: %#04x", room.message_id_);
ImGui::Text("Size: %#016llx", room.room_size()); Text("Size: %#016llx", room.room_size());
ImGui::Text("Size Pointer: %#016llx", room.room_size_ptr()); Text("Size Pointer: %#016llx", room.room_size_ptr());
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
// Keep squares in the same line // Keep squares in the same line
ImGui::SameLine(); SameLine();
} }
} }
} }

View File

@@ -76,8 +76,6 @@ class DungeonEditor : public Editor,
void DrawTileSelector(); void DrawTileSelector();
void DrawObjectRenderer(); void DrawObjectRenderer();
void LoadRoomEntrances();
void CalculateUsageStats(); void CalculateUsageStats();
void DrawUsageStats(); void DrawUsageStats();
void DrawUsageGrid(); void DrawUsageGrid();