MCPcopy Create free account
hub / github.com/antopilo/Nuake / NewProject

Function NewProject

Editor/Source/Editor/Windows/EditorInterface.cpp:2202–2235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 1

DrawMenuBarMethod · 0.85

Calls 9

SplitFunction · 0.85
LogFunction · 0.85
GetCurrentWindowFunction · 0.85
FileExistMethod · 0.80
EndsWithFunction · 0.50
SaveMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
SetTitleMethod · 0.45

Tested by

no test coverage detected