Add Object selector to DungeonEditor

Loads current room gfx from ROM gfx buffer
This commit is contained in:
scawful
2023-03-29 00:10:46 -05:00
parent 9426cd7a87
commit 94a61a13ac
6 changed files with 217 additions and 6 deletions

View File

@@ -8,6 +8,24 @@ namespace editor {
void DungeonEditor::Update() {
DrawToolset();
ImGui::Separator();
if (ImGui::BeginTable("#DungeonEditTable", 2, toolset_table_flags_,
ImVec2(0, 0))) {
ImGui::TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x);
ImGui::TableSetupColumn("Object Selector");
ImGui::TableHeadersRow();
ImGui::TableNextRow();
ImGui::TableNextColumn();
DrawDungeonCanvas();
ImGui::TableNextColumn();
DrawTileSelector();
ImGui::EndTable();
}
}
void DungeonEditor::DrawDungeonCanvas() {
canvas_.DrawBackground();
canvas_.DrawContextMenu();
canvas_.DrawGrid();
@@ -56,6 +74,30 @@ void DungeonEditor::DrawToolset() {
}
}
void DungeonEditor::DrawRoomGraphics() {
room_gfx_canvas_.DrawBackground(ImVec2(256 + 1, 0x10 * 0x40 + 1));
room_gfx_canvas_.DrawContextMenu();
room_gfx_canvas_.DrawTileSelector(32);
room_gfx_canvas_.DrawBitmap(room_gfx_bmp_, 2, is_loaded_);
room_gfx_canvas_.DrawGrid(32.0f);
room_gfx_canvas_.DrawOverlay();
}
void DungeonEditor::DrawTileSelector() {
if (ImGui::BeginTabBar("##TabBar", ImGuiTabBarFlags_FittingPolicyScroll)) {
if (ImGui::BeginTabItem("Room Graphics")) {
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)3);
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
DrawRoomGraphics();
}
ImGui::EndChild();
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
}
} // namespace editor
} // namespace app
} // namespace yaze

View File

@@ -5,6 +5,8 @@
#include "gui/canvas.h"
#include "gui/icons.h"
#include "rom.h"
#include "zelda3/dungeon/room.h"
namespace yaze {
namespace app {
@@ -16,7 +18,18 @@ class DungeonEditor {
private:
void DrawToolset();
void DrawDungeonCanvas();
void DrawRoomGraphics();
void DrawTileSelector();
bool is_loaded_ = false;
gfx::Bitmap room_gfx_bmp_;
std::vector<zelda3::dungeon::Room> rooms_;
gui::Canvas canvas_;
gui::Canvas room_gfx_canvas_;
ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit;
};
} // namespace editor