GUI Updates

Add DisplaySettings, replace ImGui style editor
Update Debugger interface with memory viewer
Decompose SNES initialization routines
Update DungeonObjectRenderer plan
Add DrawObjectRenderer UI mockup fofr DungeonEditor
This commit is contained in:
scawful
2023-11-21 11:07:04 -05:00
parent f7224c3716
commit 59e7dcc7f0
14 changed files with 712 additions and 94 deletions

View File

@@ -7,6 +7,7 @@
#include "app/gui/icons.h"
#include "app/gui/input.h"
#include "app/rom.h"
#include "app/zelda3/dungeon/object_names.h"
#include "app/zelda3/dungeon/room_names.h"
#include "zelda3/dungeon/room.h"
@@ -32,6 +33,7 @@ absl::Status DungeonEditor::Update() {
}
DrawToolset();
DrawObjectRenderer();
ImGui::Separator();
if (ImGui::BeginTable("#DungeonEditTable", 3, toolset_table_flags_,
@@ -197,9 +199,8 @@ void DungeonEditor::DrawToolset() {
ImGui::Button(ICON_MD_PEST_CONTROL_RODENT);
ImGui::TableNextColumn();
if (ImGui::Button("Load Dungeon Objects")) {
// object_renderer_.CreateVramFromRoomBlockset();
object_renderer_.RenderObjectsAsBitmaps();
if (ImGui::Button("Dungeon Object Renderer")) {
show_object_render_ = !show_object_render_;
}
ImGui::EndTable();
}
@@ -229,6 +230,47 @@ void DungeonEditor::DrawTileSelector() {
}
}
void DungeonEditor::DrawObjectRenderer() {
if (show_object_render_) {
ImGui::Begin("Dungeon Object Renderer", &show_object_render_);
// Create an ImGui table where the left side of the table is a matrix of
// buttons which represent each dungeon object. The right side of the table
// is a canvas which will display the selected dungeon object. The canvas
// will also have a tile selector and a grid overlay.
if (ImGui::BeginTable("DungeonObjectEditorTable", 2,
ImGuiTableFlags_SizingFixedFit, ImVec2(0, 0))) {
ImGui::TableSetupColumn("Dungeon Objects",
ImGuiTableColumnFlags_WidthFixed, 150.0f);
ImGui::TableSetupColumn("Canvas");
ImGui::TableNextColumn();
ImGui::BeginChild("DungeonObjectButtons", ImVec2(150.0f, 0), true);
for (const auto each : zelda3::dungeon::Type1RoomObjectNames) {
ImGui::Button(each.data());
if (ImGui::IsItemClicked()) {
}
}
ImGui::EndChild();
// Right side of the table - Canvas
ImGui::TableNextColumn();
ImGui::BeginChild("DungeonObjectCanvas", ImVec2(0, 0), true);
// TODO: Insert code to display canvas, tile selector, and grid overlay
// here
ImGui::EndChild();
ImGui::EndTable();
}
ImGui::End();
}
}
} // namespace editor
} // namespace app
} // namespace yaze

View File

@@ -34,8 +34,11 @@ class DungeonEditor : public Editor,
void DrawRoomGraphics();
void DrawTileSelector();
void DrawObjectRenderer();
uint16_t current_room_id_ = 0;
bool is_loaded_ = false;
bool show_object_render_ = false;
gfx::Bitmap room_gfx_bmp_;
@@ -46,9 +49,9 @@ class DungeonEditor : public Editor,
gui::Canvas canvas_;
gui::Canvas room_gfx_canvas_;
ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit |
ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Resizable;
ImGuiTableFlags toolset_table_flags_ =
ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Hideable | ImGuiTableFlags_Resizable;
};
} // namespace editor

View File

@@ -24,6 +24,7 @@
#include "app/gui/canvas.h"
#include "app/gui/icons.h"
#include "app/gui/input.h"
#include "app/gui/style.h"
#include "app/gui/widgets.h"
#include "app/rom.h"
@@ -176,12 +177,45 @@ void MasterEditor::DrawInfoPopup() {
}
void MasterEditor::DrawYazeMenu() {
static bool show_display_settings = false;
static bool show_command_line_interface = false;
MENU_BAR()
DrawFileMenu();
DrawEditMenu();
DrawViewMenu();
DrawHelpMenu();
ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetStyle().ItemSpacing.x -
ImGui::CalcTextSize(ICON_MD_DISPLAY_SETTINGS).x - 150);
// Modify the style of the button to have no background color
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
if (ImGui::Button(ICON_MD_DISPLAY_SETTINGS)) {
show_display_settings = !show_display_settings;
}
if (ImGui::Button(ICON_MD_TERMINAL)) {
show_command_line_interface = !show_command_line_interface;
}
ImGui::PopStyleColor();
ImGui::Text(absl::StrCat("yaze v", core::kYazeVersion).c_str());
END_MENU_BAR()
if (show_display_settings) {
ImGui::Begin("Display Settings", &show_display_settings,
ImGuiWindowFlags_None);
gui::DrawDisplaySettings();
ImGui::End();
}
if (show_command_line_interface) {
ImGui::Begin("Command Line Interface", &show_command_line_interface,
ImGuiWindowFlags_None);
ImGui::Text("Enter a command:");
ImGui::End();
}
}
void MasterEditor::DrawFileMenu() {
@@ -266,7 +300,6 @@ void MasterEditor::DrawEditMenu() {
void MasterEditor::DrawViewMenu() {
static bool show_imgui_metrics = false;
static bool show_imgui_style_editor = false;
static bool show_memory_editor = false;
static bool show_asm_editor = false;
static bool show_imgui_demo = false;
@@ -303,12 +336,6 @@ void MasterEditor::DrawViewMenu() {
ImGui::End();
}
if (show_imgui_style_editor) {
ImGui::Begin("Style Editor (ImGui)", &show_imgui_style_editor);
ImGui::ShowStyleEditor();
ImGui::End();
}
if (show_memory_viewer) {
ImGui::Begin("Memory Viewer (ImGui)", &show_memory_viewer);
@@ -339,13 +366,7 @@ void MasterEditor::DrawViewMenu() {
ImGui::MenuItem("Palette Editor", nullptr, &show_palette_editor);
ImGui::MenuItem("Memory Viewer", nullptr, &show_memory_viewer);
ImGui::MenuItem("ImGui Demo", nullptr, &show_imgui_demo);
ImGui::Separator();
if (ImGui::BeginMenu("GUI Tools")) {
ImGui::MenuItem("Metrics (ImGui)", nullptr, &show_imgui_metrics);
ImGui::MenuItem("Style Editor (ImGui)", nullptr,
&show_imgui_style_editor);
ImGui::EndMenu();
}
ImGui::MenuItem("ImGui Metrics", nullptr, &show_imgui_metrics);
ImGui::EndMenu();
}
}

View File

@@ -55,7 +55,7 @@ absl::Status OverworldEditor::Update() {
if (ImGui::BeginTable(kOWEditTable.data(), 2, kOWEditFlags, ImVec2(0, 0))) {
TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
ImGui::GetContentRegionAvail().x);
TableSetupColumn("Tile Selector");
TableSetupColumn("Tile Selector", ImGuiTableColumnFlags_WidthFixed, 256);
TableHeadersRow();
TableNextRow();
TableNextColumn();

View File

@@ -48,7 +48,7 @@ static constexpr absl::string_view kOverworldSettingsColumnNames[] = {
constexpr ImGuiTableFlags kOWMapFlags = ImGuiTableFlags_Borders;
constexpr ImGuiTableFlags kToolsetTableFlags = ImGuiTableFlags_SizingFixedFit;
constexpr ImGuiTableFlags kOWEditFlags = ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Resizable |
ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable |
ImGuiTableFlags_SizingStretchSame;
constexpr absl::string_view kWorldList =
@@ -184,10 +184,6 @@ class OverworldEditor : public Editor,
gfx::BitmapTable graphics_bin_;
gfx::BitmapTable current_graphics_set_;
gfx::BitmapTable sprite_previews_;
ImGuiTableFlags ow_edit_flags = ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Resizable |
ImGuiTableFlags_SizingStretchSame;
};
} // namespace editor
} // namespace app