From 94cfa7e60f8342b6967146d482ae743ea991a680 Mon Sep 17 00:00:00 2001 From: Justin Scofield Date: Mon, 25 Jul 2022 11:27:49 -0400 Subject: [PATCH] MasterEditor UI housekeeping --- src/app/editor/master_editor.cc | 85 +++++++++++++++++++++------------ src/app/editor/master_editor.h | 28 ++++++----- 2 files changed, 70 insertions(+), 43 deletions(-) diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index 5072a4c2..64163987 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -82,13 +82,17 @@ void MasterEditor::UpdateScreen() { DrawYazeMenu(); DrawFileDialog(); DrawStatusPopup(); + DrawAboutPopup(); + DrawInfoPopup(); TAB_BAR("##TabBar") DrawOverworldEditor(); DrawDungeonEditor(); + DrawPaletteEditor(); DrawSpriteEditor(); DrawScreenEditor(); END_TAB_BAR() + ImGui::End(); } @@ -109,6 +113,36 @@ void MasterEditor::DrawStatusPopup() { } } +void MasterEditor::DrawAboutPopup() { + if (about_) ImGui::OpenPopup("About"); + if (ImGui::BeginPopupModal("About", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::Text("Yet Another Zelda3 Editor: Version 0.4"); + ImGui::Text("Written by: Justin Scofield (scawful)"); + + if (ImGui::Button("Close", ImVec2(120, 0))) { + about_ = false; + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } +} + +void MasterEditor::DrawInfoPopup() { + if (rom_info_) ImGui::OpenPopup("ROM Information"); + if (ImGui::BeginPopupModal("ROM Information", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::Text("Title: %s", rom_.GetTitle()); + ImGui::Text("ROM Size: %ld", rom_.GetSize()); + + if (ImGui::Button("Close", ImVec2(120, 0))) { + rom_info_ = false; + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } +} + void MasterEditor::DrawYazeMenu() { MENU_BAR() DrawFileMenu(); @@ -124,12 +158,9 @@ void MasterEditor::DrawFileMenu() const { ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Open ROM", ".sfc,.smc", "."); } - if (ImGui::MenuItem("Save", "Ctrl+S")) { - // TODO: Implement this - } - if (ImGui::MenuItem("Save As..")) { - // TODO: Implement this - } + + MENU_ITEM2("Save", "Ctrl+S") + MENU_ITEM("Save As..") ImGui::Separator(); @@ -151,28 +182,18 @@ void MasterEditor::DrawFileMenu() const { } } -void MasterEditor::DrawEditMenu() const { +void MasterEditor::DrawEditMenu() { if (ImGui::BeginMenu("Edit")) { - if (ImGui::MenuItem("Undo", "Ctrl+Z")) { - // TODO: Implement this - } - if (ImGui::MenuItem("Redo", "Ctrl+Y")) { - // TODO: Implement this - } + MENU_ITEM2("Undo", "Ctrl+Z") {} + MENU_ITEM2("Redo", "Ctrl+Y") {} ImGui::Separator(); - if (ImGui::MenuItem("Cut", "Ctrl+X")) { - // TODO: Implement this - } - if (ImGui::MenuItem("Copy", "Ctrl+C")) { - // TODO: Implement this - } - if (ImGui::MenuItem("Paste", "Ctrl+V")) { - // TODO: Implement this - } + MENU_ITEM2("Cut", "Ctrl+X") {} + MENU_ITEM2("Copy", "Ctrl+C") {} + MENU_ITEM2("Paste", "Ctrl+V") {} ImGui::Separator(); - if (ImGui::MenuItem("Find", "Ctrl+F")) { - // TODO: Implement this - } + MENU_ITEM2("Find", "Ctrl+F") {} + ImGui::Separator(); + MENU_ITEM("ROM Information") rom_info_ = true; ImGui::EndMenu(); } } @@ -222,13 +243,9 @@ void MasterEditor::DrawViewMenu() { } } -void MasterEditor::DrawHelpMenu() const { +void MasterEditor::DrawHelpMenu() { if (ImGui::BeginMenu("Help")) { - if (ImGui::MenuItem("About")) { - // insert the about window here - } - ImGui::Text("Title: %s", rom_.GetTitle()); - ImGui::Text("ROM Size: %ld", rom_.GetSize()); + if (ImGui::MenuItem("About")) about_ = true; ImGui::EndMenu(); } } @@ -245,6 +262,12 @@ void MasterEditor::DrawDungeonEditor() { END_TAB_ITEM() } +void MasterEditor::DrawPaletteEditor() { + TAB_ITEM("Palettes") + palette_editor_.Update(); + END_TAB_ITEM() +} + void MasterEditor::DrawScreenEditor() { TAB_ITEM("Screens") screen_editor_.Update(); diff --git a/src/app/editor/master_editor.h b/src/app/editor/master_editor.h index 865c49cc..9cfa77fb 100644 --- a/src/app/editor/master_editor.h +++ b/src/app/editor/master_editor.h @@ -12,6 +12,7 @@ #include "app/editor/assembly_editor.h" #include "app/editor/dungeon_editor.h" #include "app/editor/overworld_editor.h" +#include "app/editor/palette_editor.h" #include "app/editor/screen_editor.h" #include "app/gfx/snes_palette.h" #include "app/gfx/snes_tile.h" @@ -32,30 +33,33 @@ class MasterEditor { private: void DrawFileDialog(); void DrawStatusPopup(); + void DrawAboutPopup(); + void DrawInfoPopup(); void DrawYazeMenu(); void DrawFileMenu() const; - void DrawEditMenu() const; + void DrawEditMenu(); void DrawViewMenu(); - void DrawHelpMenu() const; + void DrawHelpMenu(); void DrawOverworldEditor(); void DrawDungeonEditor(); + void DrawPaletteEditor(); void DrawScreenEditor(); void DrawSpriteEditor(); - ROM rom_; - AssemblyEditor assembly_editor_; - OverworldEditor overworld_editor_; - DungeonEditor dungeon_editor_; - ScreenEditor screen_editor_; - - absl::Status status_; - - ImVec4 current_palette_[8]; - ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit; + bool about_ = false; + bool rom_info_ = false; std::shared_ptr sdl_renderer_; + absl::Status status_; + + AssemblyEditor assembly_editor_; + DungeonEditor dungeon_editor_; + OverworldEditor overworld_editor_; + PaletteEditor palette_editor_; + ScreenEditor screen_editor_; + ROM rom_; }; } // namespace editor