From 3519b67a729d1657782cafad184c1feb9974afd1 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Sat, 8 Apr 2023 12:52:37 -0400 Subject: [PATCH] Now new projects creates as subfolder with the project inside of it. Also defaulted to procedural skies --- Editor/src/Windows/WelcomeWindow.cpp | 37 +++++++++++++++++++++++--- Nuake/src/Scene/Lighting/Environment.h | 2 +- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Editor/src/Windows/WelcomeWindow.cpp b/Editor/src/Windows/WelcomeWindow.cpp index 47d15e62..93958ba2 100644 --- a/Editor/src/Windows/WelcomeWindow.cpp +++ b/Editor/src/Windows/WelcomeWindow.cpp @@ -166,12 +166,41 @@ namespace Nuake if (ImGui::Button("New Project", buttonSize)) { std::string selectedProject = FileDialog::SaveFile("Project file\0*.project"); - if (selectedProject == "") // Hit cancel - return; - auto pathSplit = String::Split(selectedProject, '/'); + std::string projectPathWithExtension = selectedProject; + const bool endsWithExtension = String::EndsWith(projectPathWithExtension, ".project"); + if(!endsWithExtension) + { + projectPathWithExtension += ".project"; + } + + + if (selectedProject.empty()) + { + return; + } + + auto driveSplit = std::string(selectedProject.begin() + 3, selectedProject.end()); + auto pathSplit = String::Split(driveSplit, '/'); auto projectFileName = pathSplit[pathSplit.size() - 1]; - Ref project = Project::New(projectFileName, "no description", selectedProject + ".project"); + + // We should create a folder now + // We substring minus 8 because we dont want the extension(.project) which is 8 chars. + const std::string directoryName = std::string(driveSplit.begin(), driveSplit.end()); + + const std::string finalProjectPath = + if(!endsWithExtension) + { + bool dirCreated = std::filesystem::create_directory(selectedProject); + if (!dirCreated) + { + Logger::Log("Failed to create project directory: " + selectedProject); + } + } + + + const std::string projectFilePath = selectedProject + "/" + projectFileName + ".project"; + Ref project = Project::New(projectFileName, "no description", projectFilePath); Engine::LoadProject(project); Engine::LoadScene(Scene::New()); project->Save(); diff --git a/Nuake/src/Scene/Lighting/Environment.h b/Nuake/src/Scene/Lighting/Environment.h index 462619f2..2698edd9 100644 --- a/Nuake/src/Scene/Lighting/Environment.h +++ b/Nuake/src/Scene/Lighting/Environment.h @@ -23,7 +23,7 @@ namespace Nuake public: Environment(); - SkyType CurrentSkyType = SkyType::ClearColor; + SkyType CurrentSkyType = SkyType::ProceduralSky; Color AmbientColor = Color(0, 0, 0, 1); Ref ProceduralSkybox;