From 6b50b25601b28ee590f6eca7e2795a4014a4cd02 Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 13 Jul 2024 11:19:04 -0400 Subject: [PATCH] gui cleanup --- src/app/editor/master_editor.cc | 40 ++++++++++++++++++++++++--------- src/app/editor/screen_editor.cc | 9 +++----- src/app/gui/input.h | 2 +- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index e54b3976..d6e21602 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -173,27 +173,47 @@ absl::Status MasterEditor::Update() { auto current_tab_bar = ImGui::GetCurrentContext()->CurrentTabBar; if (overworld_editor_.jump_to_tab() == -1) { - gui::RenderTabItem("Overworld", [&]() { + if (ImGui::BeginTabItem("Overworld")) { current_editor_ = &overworld_editor_; status_ = overworld_editor_.Update(); - }); + ImGui::EndTabItem(); + } } - gui::RenderTabItem("Dungeon", [&]() { + if (ImGui::BeginTabItem("Dungeon")) { current_editor_ = &dungeon_editor_; status_ = dungeon_editor_.Update(); if (overworld_editor_.jump_to_tab() != -1) { dungeon_editor_.add_room(overworld_editor_.jump_to_tab()); overworld_editor_.jump_to_tab_ = -1; } - }); + ImGui::EndTabItem(); + } - gui::RenderTabItem("Graphics", - [&]() { status_ = graphics_editor_.Update(); }); - gui::RenderTabItem("Sprites", [&]() { status_ = sprite_editor_.Update(); }); - gui::RenderTabItem("Palettes", [&]() { status_ = palette_editor_.Update(); }); - gui::RenderTabItem("Screens", [&]() { screen_editor_.Update(); }); - gui::RenderTabItem("Music", [&]() { music_editor_.Update(); }); + if (ImGui::BeginTabItem("Graphics")) { + status_ = graphics_editor_.Update(); + ImGui::EndTabItem(); + } + + if (ImGui::BeginTabItem("Sprites")) { + status_ = sprite_editor_.Update(); + ImGui::EndTabItem(); + } + + if (ImGui::BeginTabItem("Palettes")) { + status_ = palette_editor_.Update(); + ImGui::EndTabItem(); + } + + if (ImGui::BeginTabItem("Screens")) { + screen_editor_.Update(); + ImGui::EndTabItem(); + } + + if (ImGui::BeginTabItem("Music")) { + music_editor_.Update(); + ImGui::EndTabItem(); + } END_TAB_BAR() ImGui::End(); diff --git a/src/app/editor/screen_editor.cc b/src/app/editor/screen_editor.cc index 0fa15bb4..a42f5519 100644 --- a/src/app/editor/screen_editor.cc +++ b/src/app/editor/screen_editor.cc @@ -293,13 +293,7 @@ void ScreenEditor::DrawDungeonMapsTabs() { std::string label = dungeon_map_labels_[selected_dungeon][floor_number][j]; screen_canvas_.DrawText(label, (posX * 2), (posY * 2)); - // GFX.drawText( - // e.Graphics, 16 + ((i % 5) * 32), 20 + ((i / 5) * 32), } - - // if (dungmapSelectedTile == i) - // Constants.AzurePen2, - // 10 + ((i % 5) * 32), 12 + ((i / 5) * 32), 32, 32)); } screen_canvas_.DrawGrid(64.f, 5); @@ -369,6 +363,9 @@ void ScreenEditor::DrawDungeonMapsEditor() { rom()->resource_label()->SelectableLabelWithNameEdit( selected_dungeon == i, "Dungeon Names", absl::StrFormat("%d", i), dungeon_names[i]); + if (ImGui::IsItemClicked()) { + selected_dungeon = i; + } } // Map column diff --git a/src/app/gui/input.h b/src/app/gui/input.h index 8548ae93..6e1adeaa 100644 --- a/src/app/gui/input.h +++ b/src/app/gui/input.h @@ -43,7 +43,7 @@ using ItemLabelFlags = enum ItemLabelFlag { IMGUI_API void ItemLabel(absl::string_view title, ItemLabelFlags flags); -IMGUI_API ImGuiID GetID(const std::string &id); +IMGUI_API ImGuiID GetID(const std::string& id); } // namespace gui } // namespace app