From f0d8e595cbbbf580dbd27b97177e835e1092d0d7 Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 13 Jul 2024 19:17:34 -0400 Subject: [PATCH] update project creation modal --- src/app/core/project.h | 2 +- src/app/editor/master_editor.cc | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/app/core/project.h b/src/app/core/project.h index 24f537be..9336f353 100644 --- a/src/app/core/project.h +++ b/src/app/core/project.h @@ -47,7 +47,7 @@ struct Project { filepath = project_path; name = project_path.substr(project_path.find_last_of("/") + 1); - std::ifstream in(project_path + "/" + name + ".yaze"); + std::ifstream in(project_path); if (!in.good()) { return absl::InternalError("Could not open project file."); diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index 3f7dd4e5..ac350e53 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -496,6 +496,9 @@ void MasterEditor::DrawFileMenu() { // Open an existing project status_ = current_project_.Open(FileDialogWrapper::ShowOpenFileDialog()); + if (status_.ok()) { + status_ = rom()->LoadFromFile(current_project_.rom_filename_); + } } if (MenuItem("Save Project")) { // Save the current project @@ -586,6 +589,29 @@ void MasterEditor::DrawFileMenu() { ImGuiWindowFlags_AlwaysAutoResize); static std::string save_as_filename = ""; ImGui::InputText("Project Name", &save_as_filename); + if (ImGui::Button("Destination Filepath", gui::kDefaultModalSize)) { + current_project_.filepath = FileDialogWrapper::ShowOpenFolderDialog(); + } + ImGui::SameLine(); + ImGui::Text("%s", current_project_.filepath.c_str()); + if (ImGui::Button("ROM File", gui::kDefaultModalSize)) { + current_project_.rom_filename_ = FileDialogWrapper::ShowOpenFileDialog(); + } + ImGui::SameLine(); + ImGui::Text("%s", current_project_.rom_filename_.c_str()); + if (ImGui::Button("Labels File", gui::kDefaultModalSize)) { + current_project_.labels_filename_ = + FileDialogWrapper::ShowOpenFileDialog(); + } + ImGui::SameLine(); + ImGui::Text("%s", current_project_.labels_filename_.c_str()); + if (ImGui::Button("Code Folder", gui::kDefaultModalSize)) { + current_project_.code_folder_ = FileDialogWrapper::ShowOpenFolderDialog(); + } + ImGui::SameLine(); + ImGui::Text("%s", current_project_.code_folder_.c_str()); + + ImGui::Separator(); if (ImGui::Button("Create", gui::kDefaultModalSize)) { new_project_menu = false; status_ = current_project_.Create(save_as_filename);