From 6ae969d345138b49779ae4f52d9cd40b555d8abd Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 12 Nov 2023 10:17:25 -0500 Subject: [PATCH] Move `Emulator` to emu namespace --- src/CMakeLists.txt | 2 +- src/app/CMakeLists.txt | 1 + src/app/editor/master_editor.cc | 22 ++++++++++++++++++++-- src/app/editor/master_editor.h | 4 ++-- src/app/{core => emu}/emulator.cc | 8 +++++--- src/app/{core => emu}/emulator.h | 6 +++--- 6 files changed, 32 insertions(+), 11 deletions(-) rename src/app/{core => emu}/emulator.cc (93%) rename src/app/{core => emu}/emulator.h (93%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c314552..2995a9be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ set( YAZE_APP_CORE_SRC app/core/common.cc app/core/controller.cc - app/core/emulator.cc + app/core/pipeline.cc ) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 8a81fddb..f0634c97 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -2,6 +2,7 @@ add_executable( yaze app/yaze.cc app/rom.cc + app/emu/emulator.cc app/emu/audio/apu.cc app/emu/audio/spc700.cc app/emu/audio/dsp.cc diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index 61f2066c..81a4c7d2 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -7,12 +7,18 @@ #include #include "absl/status/status.h" +#include "app/core/common.h" #include "app/core/constants.h" #include "app/core/pipeline.h" #include "app/editor/dungeon_editor.h" +#include "app/editor/graphics_editor.h" #include "app/editor/modules/assembly_editor.h" #include "app/editor/music_editor.h" #include "app/editor/overworld_editor.h" +#include "app/editor/palette_editor.h" +#include "app/editor/screen_editor.h" +#include "app/editor/sprite_editor.h" +#include "app/emu/emulator.h" #include "app/gfx/snes_palette.h" #include "app/gfx/snes_tile.h" #include "app/gui/canvas.h" @@ -177,11 +183,14 @@ void MasterEditor::DrawYazeMenu() { DrawHelpMenu(); END_MENU_BAR() } - void MasterEditor::DrawFileMenu() { static bool save_as_menu = false; if (ImGui::BeginMenu("File")) { + if (ImGui::MenuItem("New", "Ctrl+N")) { + // TODO: Implement new ROM creation. + } + if (ImGui::MenuItem("Open", "Ctrl+O")) { ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Open ROM", ".sfc,.smc", "."); @@ -206,16 +215,25 @@ void MasterEditor::DrawFileMenu() { &mutable_flags()->kUseBitmapManager); ImGui::EndMenu(); } + + ImGui::Separator(); + + if (ImGui::MenuItem("Quit", "Ctrl+Q")) { + // TODO: Implement quit confirmation dialog. + } + ImGui::EndMenu(); } if (save_as_menu) { static std::string save_as_filename = ""; - ImGui::Begin("Save As..", nullptr, ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Begin("Save As..", &save_as_menu, ImGuiWindowFlags_AlwaysAutoResize); ImGui::InputText("Filename", &save_as_filename); if (ImGui::Button("Save", gui::kDefaultModalSize)) { status_ = rom()->SaveToFile(backup_rom_, save_as_filename); + save_as_menu = false; } + ImGui::SameLine(); if (ImGui::Button("Cancel", gui::kDefaultModalSize)) { save_as_menu = false; } diff --git a/src/app/editor/master_editor.h b/src/app/editor/master_editor.h index b234e240..b40475e9 100644 --- a/src/app/editor/master_editor.h +++ b/src/app/editor/master_editor.h @@ -10,7 +10,6 @@ #include "absl/status/status.h" #include "app/core/common.h" #include "app/core/constants.h" -#include "app/core/emulator.h" #include "app/core/pipeline.h" #include "app/editor/dungeon_editor.h" #include "app/editor/graphics_editor.h" @@ -20,6 +19,7 @@ #include "app/editor/palette_editor.h" #include "app/editor/screen_editor.h" #include "app/editor/sprite_editor.h" +#include "app/emu/emulator.h" #include "app/gfx/snes_palette.h" #include "app/gfx/snes_tile.h" #include "app/gui/canvas.h" @@ -59,7 +59,7 @@ class MasterEditor : public SharedROM, public core::ExperimentFlags { std::shared_ptr sdl_renderer_; - core::Emulator emulator_; + emu::Emulator emulator_; AssemblyEditor assembly_editor_; DungeonEditor dungeon_editor_; GraphicsEditor graphics_editor_; diff --git a/src/app/core/emulator.cc b/src/app/emu/emulator.cc similarity index 93% rename from src/app/core/emulator.cc rename to src/app/emu/emulator.cc index c7a7409d..7bc3adb9 100644 --- a/src/app/core/emulator.cc +++ b/src/app/emu/emulator.cc @@ -1,13 +1,15 @@ -#include "app/core/emulator.h" +#include "app/emu/emulator.h" #include #include #include "app/core/constants.h" +#include "app/emu/snes.h" +#include "app/rom.h" namespace yaze { namespace app { -namespace core { +namespace emu { void Emulator::Run() { // Initialize the emulator if a ROM is loaded @@ -80,6 +82,6 @@ void Emulator::UpdateEmulator() { snes_.Run(); } -} // namespace core +} // namespace emu } // namespace app } // namespace yaze diff --git a/src/app/core/emulator.h b/src/app/emu/emulator.h similarity index 93% rename from src/app/core/emulator.h rename to src/app/emu/emulator.h index 2f2ca100..05b2dc87 100644 --- a/src/app/core/emulator.h +++ b/src/app/emu/emulator.h @@ -9,7 +9,7 @@ namespace yaze { namespace app { -namespace core { +namespace emu { class Emulator : public SharedROM { public: @@ -30,13 +30,13 @@ class Emulator : public SharedROM { void UpdateEmulator(); // Member variables to store internal state and resources - emu::SNES snes_; + SNES snes_; bool running_ = false; bool show_ppu_reg_viewer_ = false; }; -} // namespace core +} // namespace emu } // namespace app } // namespace yaze