| 2200 | } |
| 2201 | |
| 2202 | void NewProject() |
| 2203 | { |
| 2204 | if (Engine::GetProject() && Engine::GetProject()->FileExist()) |
| 2205 | Engine::GetProject()->Save(); |
| 2206 | |
| 2207 | std::string selectedProject = FileDialog::SaveFile("Project file\0*.project"); |
| 2208 | |
| 2209 | if (selectedProject.empty()) // Hit cancel |
| 2210 | return; |
| 2211 | |
| 2212 | if(!String::EndsWith(selectedProject, ".project")) |
| 2213 | selectedProject += ".project"; |
| 2214 | |
| 2215 | auto backslashSplits = String::Split(selectedProject, '\\'); |
| 2216 | auto fileName = backslashSplits[backslashSplits.size() - 1]; |
| 2217 | |
| 2218 | std::string finalPath = String::Split(selectedProject, '.')[0]; |
| 2219 | |
| 2220 | // We need to create a folder |
| 2221 | if (const auto& dirPath = finalPath; |
| 2222 | !std::filesystem::create_directory(dirPath)) |
| 2223 | { |
| 2224 | // Should we continue? |
| 2225 | Logger::Log("Failed creating project directory: " + dirPath); |
| 2226 | } |
| 2227 | |
| 2228 | finalPath += "/" + fileName; |
| 2229 | |
| 2230 | Ref<Project> project = Project::New(String::Split(fileName, '.')[0], "no description", finalPath); |
| 2231 | Engine::LoadProject(project); |
| 2232 | Engine::SetCurrentScene(Scene::New()); |
| 2233 | |
| 2234 | Engine::GetCurrentWindow()->SetTitle("Nuake Engine - Editing " + project->Name); |
| 2235 | } |
| 2236 | |
| 2237 | |
| 2238 | ProjectInterface pInterface; |
no test coverage detected