MasterEditor UI housekeeping

This commit is contained in:
Justin Scofield
2022-07-25 11:27:49 -04:00
parent e5d757e96c
commit 94cfa7e60f
2 changed files with 70 additions and 43 deletions

View File

@@ -82,13 +82,17 @@ void MasterEditor::UpdateScreen() {
DrawYazeMenu(); DrawYazeMenu();
DrawFileDialog(); DrawFileDialog();
DrawStatusPopup(); DrawStatusPopup();
DrawAboutPopup();
DrawInfoPopup();
TAB_BAR("##TabBar") TAB_BAR("##TabBar")
DrawOverworldEditor(); DrawOverworldEditor();
DrawDungeonEditor(); DrawDungeonEditor();
DrawPaletteEditor();
DrawSpriteEditor(); DrawSpriteEditor();
DrawScreenEditor(); DrawScreenEditor();
END_TAB_BAR() END_TAB_BAR()
ImGui::End(); 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() { void MasterEditor::DrawYazeMenu() {
MENU_BAR() MENU_BAR()
DrawFileMenu(); DrawFileMenu();
@@ -124,12 +158,9 @@ void MasterEditor::DrawFileMenu() const {
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Open ROM", ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Open ROM",
".sfc,.smc", "."); ".sfc,.smc", ".");
} }
if (ImGui::MenuItem("Save", "Ctrl+S")) {
// TODO: Implement this MENU_ITEM2("Save", "Ctrl+S")
} MENU_ITEM("Save As..")
if (ImGui::MenuItem("Save As..")) {
// TODO: Implement this
}
ImGui::Separator(); ImGui::Separator();
@@ -151,28 +182,18 @@ void MasterEditor::DrawFileMenu() const {
} }
} }
void MasterEditor::DrawEditMenu() const { void MasterEditor::DrawEditMenu() {
if (ImGui::BeginMenu("Edit")) { if (ImGui::BeginMenu("Edit")) {
if (ImGui::MenuItem("Undo", "Ctrl+Z")) { MENU_ITEM2("Undo", "Ctrl+Z") {}
// TODO: Implement this MENU_ITEM2("Redo", "Ctrl+Y") {}
}
if (ImGui::MenuItem("Redo", "Ctrl+Y")) {
// TODO: Implement this
}
ImGui::Separator(); ImGui::Separator();
if (ImGui::MenuItem("Cut", "Ctrl+X")) { MENU_ITEM2("Cut", "Ctrl+X") {}
// TODO: Implement this MENU_ITEM2("Copy", "Ctrl+C") {}
} MENU_ITEM2("Paste", "Ctrl+V") {}
if (ImGui::MenuItem("Copy", "Ctrl+C")) {
// TODO: Implement this
}
if (ImGui::MenuItem("Paste", "Ctrl+V")) {
// TODO: Implement this
}
ImGui::Separator(); ImGui::Separator();
if (ImGui::MenuItem("Find", "Ctrl+F")) { MENU_ITEM2("Find", "Ctrl+F") {}
// TODO: Implement this ImGui::Separator();
} MENU_ITEM("ROM Information") rom_info_ = true;
ImGui::EndMenu(); ImGui::EndMenu();
} }
} }
@@ -222,13 +243,9 @@ void MasterEditor::DrawViewMenu() {
} }
} }
void MasterEditor::DrawHelpMenu() const { void MasterEditor::DrawHelpMenu() {
if (ImGui::BeginMenu("Help")) { if (ImGui::BeginMenu("Help")) {
if (ImGui::MenuItem("About")) { if (ImGui::MenuItem("About")) about_ = true;
// insert the about window here
}
ImGui::Text("Title: %s", rom_.GetTitle());
ImGui::Text("ROM Size: %ld", rom_.GetSize());
ImGui::EndMenu(); ImGui::EndMenu();
} }
} }
@@ -245,6 +262,12 @@ void MasterEditor::DrawDungeonEditor() {
END_TAB_ITEM() END_TAB_ITEM()
} }
void MasterEditor::DrawPaletteEditor() {
TAB_ITEM("Palettes")
palette_editor_.Update();
END_TAB_ITEM()
}
void MasterEditor::DrawScreenEditor() { void MasterEditor::DrawScreenEditor() {
TAB_ITEM("Screens") TAB_ITEM("Screens")
screen_editor_.Update(); screen_editor_.Update();

View File

@@ -12,6 +12,7 @@
#include "app/editor/assembly_editor.h" #include "app/editor/assembly_editor.h"
#include "app/editor/dungeon_editor.h" #include "app/editor/dungeon_editor.h"
#include "app/editor/overworld_editor.h" #include "app/editor/overworld_editor.h"
#include "app/editor/palette_editor.h"
#include "app/editor/screen_editor.h" #include "app/editor/screen_editor.h"
#include "app/gfx/snes_palette.h" #include "app/gfx/snes_palette.h"
#include "app/gfx/snes_tile.h" #include "app/gfx/snes_tile.h"
@@ -32,30 +33,33 @@ class MasterEditor {
private: private:
void DrawFileDialog(); void DrawFileDialog();
void DrawStatusPopup(); void DrawStatusPopup();
void DrawAboutPopup();
void DrawInfoPopup();
void DrawYazeMenu(); void DrawYazeMenu();
void DrawFileMenu() const; void DrawFileMenu() const;
void DrawEditMenu() const; void DrawEditMenu();
void DrawViewMenu(); void DrawViewMenu();
void DrawHelpMenu() const; void DrawHelpMenu();
void DrawOverworldEditor(); void DrawOverworldEditor();
void DrawDungeonEditor(); void DrawDungeonEditor();
void DrawPaletteEditor();
void DrawScreenEditor(); void DrawScreenEditor();
void DrawSpriteEditor(); void DrawSpriteEditor();
ROM rom_; bool about_ = false;
AssemblyEditor assembly_editor_; bool rom_info_ = false;
OverworldEditor overworld_editor_;
DungeonEditor dungeon_editor_;
ScreenEditor screen_editor_;
absl::Status status_;
ImVec4 current_palette_[8];
ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit;
std::shared_ptr<SDL_Renderer> sdl_renderer_; std::shared_ptr<SDL_Renderer> sdl_renderer_;
absl::Status status_;
AssemblyEditor assembly_editor_;
DungeonEditor dungeon_editor_;
OverworldEditor overworld_editor_;
PaletteEditor palette_editor_;
ScreenEditor screen_editor_;
ROM rom_;
}; };
} // namespace editor } // namespace editor