From 20289483abb02288793885a6b5ab780ad7c61c07 Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 10 Aug 2024 12:23:28 -0400 Subject: [PATCH] rename MasterEditor to EditorManager --- docs/infrastructure.md | 2 +- src/app/core/controller.cc | 22 +++++++------- src/app/core/controller.h | 8 ++--- src/app/editor/CMakeLists.txt | 2 +- .../{master_editor.cc => editor_manager.cc} | 30 +++++++++---------- .../{master_editor.h => editor_manager.h} | 20 ++++++------- src/ios/main.mm | 2 +- 7 files changed, 43 insertions(+), 43 deletions(-) rename src/app/editor/{master_editor.cc => editor_manager.cc} (97%) rename src/app/editor/{master_editor.h => editor_manager.h} (88%) diff --git a/docs/infrastructure.md b/docs/infrastructure.md index 95e9bd40..ed7b7db6 100644 --- a/docs/infrastructure.md +++ b/docs/infrastructure.md @@ -53,7 +53,7 @@ For developers to reference. - Updates `editor::MasterEditor` - Renders the output to the screen. - Handles the teardown of SDL and ImGui resources. -- [app/editor/master_editor.cc](../src/app/editor/master_editor.cc) +- [app/editor/editor_manager.cc](../src/app/editor/editor_manager.cc) - Handles the main menu bar - Handles `absl::Status` errors as popups delivered to the user. - Update all the editors in a tab view. diff --git a/src/app/core/controller.cc b/src/app/core/controller.cc index 4d11684a..b2762bdd 100644 --- a/src/app/core/controller.cc +++ b/src/app/core/controller.cc @@ -13,7 +13,7 @@ #include "absl/strings/str_format.h" #include "app/core/platform/file_path.h" #include "app/core/platform/font_loader.h" -#include "app/editor/master_editor.h" +#include "app/editor/editor_manager.h" #include "app/gui/icons.h" #include "app/gui/style.h" @@ -133,7 +133,7 @@ void InitializeClipboard() { io.ClipboardUserData = nullptr; } -void HandleKeyDown(SDL_Event &event, editor::MasterEditor &editor) { +void HandleKeyDown(SDL_Event &event, editor::EditorManager &editor) { ImGuiIO &io = ImGui::GetIO(); io.KeysDown[event.key.keysym.scancode] = (event.type == SDL_KEYDOWN); io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0); @@ -189,7 +189,7 @@ void HandleKeyDown(SDL_Event &event, editor::MasterEditor &editor) { } } -void HandleKeyUp(SDL_Event &event, editor::MasterEditor &editor) { +void HandleKeyUp(SDL_Event &event, editor::EditorManager &editor) { ImGuiIO &io = ImGui::GetIO(); int key = event.key.keysym.scancode; IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown)); @@ -282,11 +282,11 @@ absl::Status Controller::OnEntry(std::string filename) { RETURN_IF_ERROR(CreateGuiContext()) if (flags()->kLoadAudioDevice) { RETURN_IF_ERROR(LoadAudioDevice()) - master_editor_.emulator().set_audio_buffer(audio_buffer_); - master_editor_.emulator().set_audio_device_id(audio_device_); + editor_manager_.emulator().set_audio_buffer(audio_buffer_); + editor_manager_.emulator().set_audio_device_id(audio_device_); } InitializeKeymap(); - master_editor_.SetupScreen(filename); + editor_manager_.SetupScreen(filename); active_ = true; return absl::OkStatus(); } @@ -299,10 +299,10 @@ void Controller::OnInput() { while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: - HandleKeyDown(event, master_editor_); + HandleKeyDown(event, editor_manager_); break; case SDL_KEYUP: - HandleKeyUp(event, master_editor_); + HandleKeyUp(event, editor_manager_); break; case SDL_TEXTINPUT: io.AddInputCharactersUTF8(event.text.text); @@ -331,7 +331,7 @@ void Controller::OnInput() { } absl::Status Controller::OnLoad() { - if (master_editor_.quit()) { + if (editor_manager_.quit()) { active_ = false; } #if TARGET_OS_IPHONE != 1 @@ -339,7 +339,7 @@ absl::Status Controller::OnLoad() { NewMasterFrame(); } #endif - RETURN_IF_ERROR(master_editor_.Update()); + RETURN_IF_ERROR(editor_manager_.Update()); #if TARGET_OS_IPHONE != 1 if (platform_ != Platform::kiOS) { End(); @@ -544,7 +544,7 @@ absl::Status Controller::LoadAudioDevice() { absl::StrFormat("Failed to open audio: %s\n", SDL_GetError())); } audio_buffer_ = new int16_t[audio_frequency_ / 50 * 4]; - master_editor_.emulator().set_audio_buffer(audio_buffer_); + editor_manager_.emulator().set_audio_buffer(audio_buffer_); SDL_PauseAudioDevice(audio_device_, 0); return absl::OkStatus(); } diff --git a/src/app/core/controller.h b/src/app/core/controller.h index 72fe6b64..527cdb96 100644 --- a/src/app/core/controller.h +++ b/src/app/core/controller.h @@ -13,7 +13,7 @@ #include "absl/status/status.h" #include "app/core/common.h" #include "app/core/platform/renderer.h" -#include "app/editor/master_editor.h" +#include "app/editor/editor_manager.h" #include "app/editor/utils/editor.h" #include "app/gui/icons.h" #include "app/gui/style.h" @@ -47,8 +47,8 @@ class Controller : public ExperimentFlags { absl::Status LoadFontFamilies() const; absl::Status LoadAudioDevice(); - void SetupScreen() { master_editor_.SetupScreen(); } - auto master_editor() -> editor::MasterEditor & { return master_editor_; } + void SetupScreen() { editor_manager_.SetupScreen(); } + auto editor_manager() -> editor::EditorManager & { return editor_manager_; } auto renderer() -> SDL_Renderer * { return Renderer::GetInstance().renderer(); } @@ -59,7 +59,7 @@ class Controller : public ExperimentFlags { bool active_; Platform platform_; - editor::MasterEditor master_editor_; + editor::EditorManager editor_manager_; int audio_frequency_ = 48000; int16_t *audio_buffer_; diff --git a/src/app/editor/CMakeLists.txt b/src/app/editor/CMakeLists.txt index 3337a518..0e5ded5c 100644 --- a/src/app/editor/CMakeLists.txt +++ b/src/app/editor/CMakeLists.txt @@ -1,7 +1,7 @@ set( YAZE_APP_EDITOR_SRC + app/editor/editor_manager.cc app/editor/dungeon/dungeon_editor.cc - app/editor/master_editor.cc app/editor/settings_editor.cc app/editor/overworld/overworld_editor.cc app/editor/sprite/sprite_editor.cc diff --git a/src/app/editor/master_editor.cc b/src/app/editor/editor_manager.cc similarity index 97% rename from src/app/editor/master_editor.cc rename to src/app/editor/editor_manager.cc index a6c52891..ee66a4d3 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/editor_manager.cc @@ -1,4 +1,4 @@ -#include "master_editor.h" +#include "editor_manager.h" #include "ImGuiColorTextEdit/TextEditor.h" #include "ImGuiFileDialog/ImGuiFileDialog.h" @@ -59,14 +59,14 @@ bool IsEditorActive(Editor* editor, std::vector& active_editors) { } // namespace -void MasterEditor::SetupScreen(std::string filename) { +void EditorManager::SetupScreen(std::string filename) { if (!filename.empty()) { PRINT_IF_ERROR(rom()->LoadFromFile(filename)); } overworld_editor_.InitializeZeml(); } -absl::Status MasterEditor::Update() { +absl::Status EditorManager::Update() { ManageKeyboardShortcuts(); DrawYazeMenu(); @@ -88,7 +88,7 @@ absl::Status MasterEditor::Update() { return absl::OkStatus(); } -void MasterEditor::ManageActiveEditors() { +void EditorManager::ManageActiveEditors() { // Show popup pane to select an editor to add static bool show_add_editor = false; if (show_add_editor) OpenPopup("AddEditor"); @@ -251,7 +251,7 @@ void MasterEditor::ManageActiveEditors() { } } -void MasterEditor::ManageKeyboardShortcuts() { +void EditorManager::ManageKeyboardShortcuts() { bool ctrl_or_super = (GetIO().KeyCtrl || GetIO().KeySuper); // If CMD + R is pressed, reload the top result of recent files @@ -309,7 +309,7 @@ void MasterEditor::ManageKeyboardShortcuts() { } } -void MasterEditor::DrawFileDialog() { +void EditorManager::DrawFileDialog() { gui::FileDialogPipeline("ChooseFileDlgKey", ".sfc,.smc", std::nullopt, [&]() { std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName(); status_ = rom()->LoadFromFile(filePathName); @@ -326,7 +326,7 @@ void MasterEditor::DrawFileDialog() { }); } -void MasterEditor::DrawStatusPopup() { +void EditorManager::DrawStatusPopup() { if (!status_.ok()) { show_status_ = true; prev_status_ = status_; @@ -354,7 +354,7 @@ void MasterEditor::DrawStatusPopup() { } } -void MasterEditor::DrawAboutPopup() { +void EditorManager::DrawAboutPopup() { if (about_) OpenPopup("About"); if (BeginPopupModal("About", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { Text("Yet Another Zelda3 Editor - v%s", core::kYazeVersion.data()); @@ -371,7 +371,7 @@ void MasterEditor::DrawAboutPopup() { } } -void MasterEditor::DrawInfoPopup() { +void EditorManager::DrawInfoPopup() { if (rom_info_) OpenPopup("ROM Information"); if (BeginPopupModal("ROM Information", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { @@ -387,7 +387,7 @@ void MasterEditor::DrawInfoPopup() { } } -void MasterEditor::DrawYazeMenu() { +void EditorManager::DrawYazeMenu() { static bool show_display_settings = false; static bool show_command_line_interface = false; @@ -426,7 +426,7 @@ void MasterEditor::DrawYazeMenu() { } } -void MasterEditor::OpenRomOrProject(const std::string& filename) { +void EditorManager::OpenRomOrProject(const std::string& filename) { if (absl::StrContains(filename, ".yaze")) { status_ = current_project_.Open(filename); if (status_.ok()) { @@ -437,7 +437,7 @@ void MasterEditor::OpenRomOrProject(const std::string& filename) { } } -void MasterEditor::DrawYazeMenuBar() { +void EditorManager::DrawYazeMenuBar() { static bool save_as_menu = false; static bool new_project_menu = false; @@ -755,7 +755,7 @@ void MasterEditor::DrawYazeMenuBar() { } } -void MasterEditor::LoadRom() { +void EditorManager::LoadRom() { if (flags()->kNewFileDialogWrapper) { auto file_name = FileDialogWrapper::ShowOpenFileDialog(); PRINT_IF_ERROR(rom()->LoadFromFile(file_name)); @@ -769,7 +769,7 @@ void MasterEditor::LoadRom() { } } -void MasterEditor::SaveRom() { +void EditorManager::SaveRom() { if (flags()->kSaveDungeonMaps) { status_ = screen_editor_.SaveDungeonMaps(); RETURN_VOID_IF_ERROR(status_); @@ -804,7 +804,7 @@ void MasterEditor::SaveRom() { status_ = rom()->SaveToFile(backup_rom_, save_new_auto_); } -absl::Status MasterEditor::OpenProject() { +absl::Status EditorManager::OpenProject() { RETURN_IF_ERROR(rom()->LoadFromFile(current_project_.rom_filename_)); if (!rom()->resource_label()->LoadLabels(current_project_.labels_filename_)) { diff --git a/src/app/editor/master_editor.h b/src/app/editor/editor_manager.h similarity index 88% rename from src/app/editor/master_editor.h rename to src/app/editor/editor_manager.h index e8b5b9a3..e66bb34f 100644 --- a/src/app/editor/master_editor.h +++ b/src/app/editor/editor_manager.h @@ -1,5 +1,5 @@ -#ifndef YAZE_APP_EDITOR_MASTER_EDITOR_H -#define YAZE_APP_EDITOR_MASTER_EDITOR_H +#ifndef YAZE_APP_EDITOR_EDITOR_MANAGER_H +#define YAZE_APP_EDITOR_EDITOR_MANAGER_H #define IMGUI_DEFINE_MATH_OPERATORS @@ -39,8 +39,8 @@ namespace app { namespace editor { /** - * @class MasterEditor - * @brief The MasterEditor class represents the main editor for a Rom in the + * @class EditorManager + * @brief The EditorManager class represents the main editor for a Rom in the * Yaze application. * * This class inherits from SharedRom, GfxContext, and ExperimentFlags, and @@ -48,7 +48,7 @@ namespace editor { * shutting down the editor. It also includes methods for drawing various menus * and popups, saving the Rom, and managing editor-specific flags. * - * The MasterEditor class contains instances of various editor classes such as + * The EditorManager class contains instances of various editor classes such as * AssemblyEditor, DungeonEditor, GraphicsEditor, MusicEditor, OverworldEditor, * PaletteEditor, ScreenEditor, and SpriteEditor. The current_editor_ member * variable points to the currently active editor in the tab view. @@ -56,11 +56,11 @@ namespace editor { * @note This class assumes the presence of an SDL_Renderer object for rendering * graphics. */ -class MasterEditor : public SharedRom, - public context::GfxContext, - public core::ExperimentFlags { +class EditorManager : public SharedRom, + public context::GfxContext, + public core::ExperimentFlags { public: - MasterEditor() { + EditorManager() { current_editor_ = &overworld_editor_; active_editors_.push_back(&overworld_editor_); active_editors_.push_back(&dungeon_editor_); @@ -133,4 +133,4 @@ class MasterEditor : public SharedRom, } // namespace app } // namespace yaze -#endif // YAZE_APP_EDITOR_MASTER_EDITOR_H +#endif // YAZE_APP_EDITOR_EDITOR_MANAGER_H diff --git a/src/ios/main.mm b/src/ios/main.mm index 0a523308..bd2dc09c 100644 --- a/src/ios/main.mm +++ b/src/ios/main.mm @@ -90,7 +90,7 @@ ImGui_ImplSDL2_InitForSDLRenderer(_controller->window(), _controller->renderer()); ImGui_ImplSDLRenderer2_Init(_controller->renderer()); - _controller->master_editor().overworld_editor().InitializeZeml(); + _controller->editor_manager().overworld_editor().InitializeZeml(); if (!_controller->LoadFontFamilies().ok()) { abort(); }