Rename Editor class to MasterEditor

This commit is contained in:
Justin Scofield
2022-07-19 20:31:49 -04:00
parent 8af096c1ae
commit b0c79a42c5
5 changed files with 28 additions and 37 deletions

View File

@@ -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

View File

@@ -8,7 +8,7 @@
#include <memory>
#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<float>(wheel);
}
void Controller::onLoad() { editor_.UpdateScreen(); }
void Controller::onLoad() { master_editor_.UpdateScreen(); }
void Controller::doRender() const {
SDL_RenderClear(sdl_renderer_.get());

View File

@@ -10,7 +10,7 @@
#include <memory>
#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> sdl_window_;
std::shared_ptr<SDL_Renderer> sdl_renderer_;
};

View File

@@ -1,4 +1,4 @@
#include "editor.h"
#include "master_editor.h"
#include <ImGuiColorTextEdit/TextEditor.h>
#include <ImGuiFileDialog/ImGuiFileDialog.h>
@@ -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<SDL_Renderer> renderer) {
void MasterEditor::SetupScreen(std::shared_ptr<SDL_Renderer> 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()
}

View File

@@ -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 <ImGuiColorTextEdit/TextEditor.h>
#include <ImGuiFileDialog/ImGuiFileDialog.h>
@@ -23,10 +23,10 @@ namespace yaze {
namespace app {
namespace editor {
class Editor {
class MasterEditor {
public:
Editor();
~Editor();
MasterEditor();
~MasterEditor();
void SetupScreen(std::shared_ptr<SDL_Renderer> 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> sdl_renderer_;
std::unordered_map<uint, SDL_Texture *> 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> sdl_renderer_;
};
} // namespace editor
} // namespace app
} // namespace yaze
#endif // YAZE_APP_VIEW_EDITOR_H
#endif // YAZE_APP_EDITOR_MASTER_EDITOR_H