From 7021b64c806e1c5cba8612b8b0e6de6e8636ff35 Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 13 Jul 2024 18:54:51 -0400 Subject: [PATCH] add NewProjectMenu for create, save, open --- src/app/core/project.h | 6 ++---- src/app/editor/master_editor.cc | 35 +++++++++++++++++++++++++++++++++ src/app/editor/master_editor.h | 6 ++++-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/app/core/project.h b/src/app/core/project.h index acd3c7fa..bb5e1c93 100644 --- a/src/app/core/project.h +++ b/src/app/core/project.h @@ -37,11 +37,9 @@ struct Project { * @return An absl::Status indicating the success or failure of the project * creation. */ - absl::Status Create(const std::string &project_name, - const std::string &project_path) { + absl::Status Create(const std::string &project_name) { name = project_name; - filepath = project_path; - + return absl::OkStatus(); } diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index 1c08b0f9..7c707cbd 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -441,6 +441,7 @@ void MasterEditor::DrawYazeMenu() { void MasterEditor::DrawFileMenu() { static bool save_as_menu = false; + static bool new_project_menu = false; if (BeginMenu("File")) { if (MenuItem("Open", "Ctrl+O")) { @@ -479,6 +480,24 @@ void MasterEditor::DrawFileMenu() { ImGui::Separator(); + if (BeginMenu("Project")) { + if (MenuItem("Create New Project")) { + // Create a new project + new_project_menu = true; + } + if (MenuItem("Open Project")) { + // Open an existing project + status_ = + current_project_.Open(FileDialogWrapper::ShowOpenFileDialog()); + } + if (MenuItem("Save Project")) { + // Save the current project + status_ = current_project_.Save(); + } + + ImGui::EndMenu(); + } + if (BeginMenu("Options")) { MenuItem("Backup ROM", "", &backup_rom_); MenuItem("Save New Auto", "", &save_new_auto_); @@ -554,6 +573,22 @@ void MasterEditor::DrawFileMenu() { } ImGui::End(); } + + if (new_project_menu) { + ImGui::Begin("New Project", &new_project_menu, + ImGuiWindowFlags_AlwaysAutoResize); + static std::string save_as_filename = ""; + ImGui::InputText("Project Name", &save_as_filename); + if (ImGui::Button("Create", gui::kDefaultModalSize)) { + new_project_menu = false; + status_ = current_project_.Create(save_as_filename); + } + ImGui::SameLine(); + if (ImGui::Button("Cancel", gui::kDefaultModalSize)) { + new_project_menu = false; + } + ImGui::End(); + } } void MasterEditor::DrawEditMenu() { diff --git a/src/app/editor/master_editor.h b/src/app/editor/master_editor.h index a17de6c6..260d88d2 100644 --- a/src/app/editor/master_editor.h +++ b/src/app/editor/master_editor.h @@ -12,6 +12,7 @@ #include "absl/status/status.h" #include "app/core/common.h" #include "app/core/constants.h" +#include "app/core/project.h" #include "app/editor/code/assembly_editor.h" #include "app/editor/context/gfx_context.h" #include "app/editor/dungeon_editor.h" @@ -97,6 +98,8 @@ class MasterEditor : public SharedRom, emu::Emulator emulator_; + Project current_project_; + AssemblyEditor assembly_editor_; DungeonEditor dungeon_editor_; GraphicsEditor graphics_editor_; @@ -106,9 +109,8 @@ class MasterEditor : public SharedRom, ScreenEditor screen_editor_; SpriteEditor sprite_editor_; - std::vector active_editors_; ImVector active_tabs_; - + std::vector active_editors_; Editor* current_editor_ = nullptr; };