From b0c79a42c559723c7210ba965c52e50a929030b9 Mon Sep 17 00:00:00 2001 From: Justin Scofield Date: Tue, 19 Jul 2022 20:31:49 -0400 Subject: [PATCH] Rename Editor class to MasterEditor --- src/CMakeLists.txt | 2 +- src/app/core/controller.cc | 6 ++-- src/app/core/controller.h | 4 +-- .../editor/{editor.cc => master_editor.cc} | 33 ++++++++----------- src/app/editor/{editor.h => master_editor.h} | 20 +++++------ 5 files changed, 28 insertions(+), 37 deletions(-) rename src/app/editor/{editor.cc => master_editor.cc} (90%) rename src/app/editor/{editor.h => master_editor.h} (84%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2bd096c..7377fc6f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,7 +40,7 @@ add_executable( gui/style.cc gui/widgets.cc gui/canvas.cc - app/editor/editor.cc + app/editor/master_editor.cc app/editor/assembly_editor.cc app/editor/dungeon_editor.cc app/editor/overworld_editor.cc diff --git a/src/app/core/controller.cc b/src/app/core/controller.cc index eaa7feb9..c56a2e47 100644 --- a/src/app/core/controller.cc +++ b/src/app/core/controller.cc @@ -8,7 +8,7 @@ #include -#include "app/editor/editor.h" +#include "app/editor/master_editor.h" #include "gui/icons.h" #include "gui/style.h" @@ -22,7 +22,7 @@ void Controller::onEntry() { CreateWindow(); CreateRenderer(); CreateGuiContext(); - editor_.SetupScreen(sdl_renderer_); + master_editor_.SetupScreen(sdl_renderer_); ImGuiIO &io = ImGui::GetIO(); io.KeyMap[ImGuiKey_Backspace] = SDL_GetScancodeFromKey(SDLK_BACKSPACE); io.KeyMap[ImGuiKey_Enter] = SDL_GetScancodeFromKey(SDLK_RETURN); @@ -98,7 +98,7 @@ void Controller::onInput() { io.MouseWheel = static_cast(wheel); } -void Controller::onLoad() { editor_.UpdateScreen(); } +void Controller::onLoad() { master_editor_.UpdateScreen(); } void Controller::doRender() const { SDL_RenderClear(sdl_renderer_.get()); diff --git a/src/app/core/controller.h b/src/app/core/controller.h index 3d4b8381..a32b1485 100644 --- a/src/app/core/controller.h +++ b/src/app/core/controller.h @@ -10,7 +10,7 @@ #include -#include "app/editor/editor.h" +#include "app/editor/master_editor.h" #include "gui/icons.h" #include "gui/style.h" @@ -45,7 +45,7 @@ class Controller { }; bool active_; - editor::Editor editor_; + editor::MasterEditor master_editor_; std::shared_ptr sdl_window_; std::shared_ptr sdl_renderer_; }; diff --git a/src/app/editor/editor.cc b/src/app/editor/master_editor.cc similarity index 90% rename from src/app/editor/editor.cc rename to src/app/editor/master_editor.cc index 46ba0b23..702daaf2 100644 --- a/src/app/editor/editor.cc +++ b/src/app/editor/master_editor.cc @@ -1,4 +1,4 @@ -#include "editor.h" +#include "master_editor.h" #include #include @@ -22,7 +22,7 @@ namespace yaze { namespace app { namespace editor { -Editor::Editor() { +MasterEditor::MasterEditor() { for (int i = 0; i < 8; i++) { current_palette_[i].x = (i * 0.21f); current_palette_[i].y = (i * 0.21f); @@ -31,19 +31,14 @@ Editor::Editor() { } } -Editor::~Editor() { - for (auto &each : image_cache_) { - SDL_DestroyTexture(each.second); - } - rom_.Close(); -} +MasterEditor::~MasterEditor() { rom_.Close(); } -void Editor::SetupScreen(std::shared_ptr renderer) { +void MasterEditor::SetupScreen(std::shared_ptr renderer) { sdl_renderer_ = renderer; rom_.SetupRenderer(renderer); } -void Editor::UpdateScreen() { +void MasterEditor::UpdateScreen() { const ImGuiIO &io = ImGui::GetIO(); ImGui::NewFrame(); ImGui::SetNextWindowPos(ImVec2(0, 0)); @@ -67,7 +62,7 @@ void Editor::UpdateScreen() { ImGui::End(); } -void Editor::DrawYazeMenu() { +void MasterEditor::DrawYazeMenu() { MENU_BAR() DrawFileMenu(); DrawEditMenu(); @@ -86,7 +81,7 @@ void Editor::DrawYazeMenu() { } } -void Editor::DrawFileMenu() const { +void MasterEditor::DrawFileMenu() const { if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem("Open", "Ctrl+O")) { ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Open ROM", @@ -119,7 +114,7 @@ void Editor::DrawFileMenu() const { } } -void Editor::DrawEditMenu() const { +void MasterEditor::DrawEditMenu() const { if (ImGui::BeginMenu("Edit")) { if (ImGui::MenuItem("Undo", "Ctrl+Z")) { // TODO: Implement this @@ -145,7 +140,7 @@ void Editor::DrawEditMenu() const { } } -void Editor::DrawViewMenu() { +void MasterEditor::DrawViewMenu() { static bool show_imgui_metrics = false; static bool show_imgui_style_editor = false; static bool show_memory_editor = false; @@ -191,7 +186,7 @@ void Editor::DrawViewMenu() { } } -void Editor::DrawHelpMenu() const { +void MasterEditor::DrawHelpMenu() const { if (ImGui::BeginMenu("Help")) { if (ImGui::MenuItem("About")) { // insert the about window here @@ -202,25 +197,25 @@ void Editor::DrawHelpMenu() const { } } -void Editor::DrawOverworldEditor() { +void MasterEditor::DrawOverworldEditor() { TAB_ITEM("Overworld") overworld_editor_.Update(); END_TAB_ITEM() } -void Editor::DrawDungeonEditor() { +void MasterEditor::DrawDungeonEditor() { TAB_ITEM("Dungeon") dungeon_editor_.Update(); END_TAB_ITEM() } -void Editor::DrawScreenEditor() { +void MasterEditor::DrawScreenEditor() { TAB_ITEM("Screens") screen_editor_.Update(); END_TAB_ITEM() } -void Editor::DrawSpriteEditor() { +void MasterEditor::DrawSpriteEditor() { TAB_ITEM("Sprites") END_TAB_ITEM() } diff --git a/src/app/editor/editor.h b/src/app/editor/master_editor.h similarity index 84% rename from src/app/editor/editor.h rename to src/app/editor/master_editor.h index e9220e3c..cbac0e20 100644 --- a/src/app/editor/editor.h +++ b/src/app/editor/master_editor.h @@ -1,5 +1,5 @@ -#ifndef YAZE_APP_VIEW_EDITOR_H -#define YAZE_APP_VIEW_EDITOR_H +#ifndef YAZE_APP_EDITOR_MASTER_EDITOR_H +#define YAZE_APP_EDITOR_MASTER_EDITOR_H #include #include @@ -23,10 +23,10 @@ namespace yaze { namespace app { namespace editor { -class Editor { +class MasterEditor { public: - Editor(); - ~Editor(); + MasterEditor(); + ~MasterEditor(); void SetupScreen(std::shared_ptr renderer); void UpdateScreen(); @@ -42,17 +42,11 @@ class Editor { void DrawScreenEditor(); void DrawSpriteEditor(); - bool is_loaded_ = true; - bool asm_is_loaded = false; - ROM rom_; - gui::Canvas canvas_; AssemblyEditor assembly_editor_; OverworldEditor overworld_editor_; DungeonEditor dungeon_editor_; ScreenEditor screen_editor_; - std::shared_ptr sdl_renderer_; - std::unordered_map image_cache_; ImVec4 current_palette_[8]; @@ -61,10 +55,12 @@ class Editor { ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoTitleBar; ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit; + + std::shared_ptr sdl_renderer_; }; } // namespace editor } // namespace app } // namespace yaze -#endif // YAZE_APP_VIEW_EDITOR_H \ No newline at end of file +#endif // YAZE_APP_EDITOR_MASTER_EDITOR_H \ No newline at end of file