mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Fixed perspective crash and project paths when creating a new project
This commit is contained in:
@@ -167,40 +167,32 @@ namespace Nuake
|
||||
{
|
||||
std::string selectedProject = FileDialog::SaveFile("Project file\0*.project");
|
||||
|
||||
std::string projectPathWithExtension = selectedProject;
|
||||
const bool endsWithExtension = String::EndsWith(projectPathWithExtension, ".project");
|
||||
if(!endsWithExtension)
|
||||
{
|
||||
projectPathWithExtension += ".project";
|
||||
}
|
||||
auto backslashSplits = String::Split(selectedProject, '\\');
|
||||
auto fileName = backslashSplits[backslashSplits.size() - 1];
|
||||
|
||||
std::string finalPath = selectedProject;
|
||||
|
||||
bool endsWithExtension = String::EndsWith(fileName, ".project");
|
||||
if (!endsWithExtension)
|
||||
{
|
||||
// We need to createa folder
|
||||
auto dirPath = selectedProject;
|
||||
bool result = std::filesystem::create_directory(dirPath);
|
||||
if (!result)
|
||||
{
|
||||
// Should we continue?
|
||||
Logger::Log("Failed creating project directoy: " + dirPath);
|
||||
}
|
||||
|
||||
finalPath += "\\" + fileName + ".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];
|
||||
|
||||
// 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 = Project::New(projectFileName, "no description", projectFilePath);
|
||||
auto project = Project::New(fileName, "no description", finalPath);
|
||||
Engine::LoadProject(project);
|
||||
Engine::LoadScene(Scene::New());
|
||||
project->Save();
|
||||
|
||||
Reference in New Issue
Block a user