Creating New Project doesn't add .project

This commit is contained in:
emerycp
2023-07-07 18:24:55 -04:00
parent 53e5e9e071
commit 1885f1a853
4 changed files with 25 additions and 11 deletions

View File

@@ -166,28 +166,31 @@ namespace Nuake
if (ImGui::Button("New Project", buttonSize))
{
std::string selectedProject = FileDialog::SaveFile("Project file\0*.project");
if (!selectedProject.empty())
{
if(!String::EndsWith(selectedProject, ".project"))
selectedProject += ".project";
auto backslashSplits = String::Split(selectedProject, '\\');
auto fileName = backslashSplits[backslashSplits.size() - 1];
std::string finalPath = selectedProject;
std::string finalPath = String::Split(selectedProject, '.')[0];
if (String::EndsWith(fileName, ".project"))
{
// We need to create a folder
if (const auto& dirPath = selectedProject;
std::filesystem::create_directory(dirPath))
if (const auto& dirPath = finalPath;
!std::filesystem::create_directory(dirPath))
{
// Should we continue?
Logger::Log("Failed creating project directory: " + dirPath);
}
finalPath += "\\" + fileName + ".project";
finalPath += "\\" + fileName;
}
auto project = Project::New(fileName, "no description", finalPath);
auto project = Project::New(String::Split(fileName, '.')[0], "no description", finalPath);
Engine::LoadProject(project);
Engine::LoadScene(Scene::New());
project->Save();