MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / LoadProduct

Method LoadProduct

Source/Editor/Editor.cpp:369–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367}
368
369int32 Editor::LoadProduct()
370{
371 PROFILE_MEM(Editor);
372
373 // Flax Editor product
374 Globals::ProductName = TEXT("Flax Editor");
375 Globals::CompanyName = TEXT("Flax");
376
377#if FLAX_TESTS
378 // Flax Tests use auto-generated temporary project
379 CommandLine::Options.Project = Globals::TemporaryFolder / TEXT("Project");
380 CommandLine::Options.NewProject = true;
381#endif
382
383 // Gather project directory from the command line
384 String projectPath = CommandLine::Options.Project.TrimTrailing();
385 const int32 startIndex = projectPath.StartsWith('\"') || projectPath.StartsWith('\'') ? 1 : 0;
386 const int32 length = projectPath.Length() - (projectPath.EndsWith('\"') || projectPath.EndsWith('\'') ? 1 : 0) - startIndex;
387 if (length > 0)
388 {
389 projectPath = projectPath.Substring(startIndex, length - startIndex);
390 StringUtils::PathRemoveRelativeParts(projectPath);
391 if (FileSystem::IsRelative(projectPath))
392 {
393 projectPath = Platform::GetWorkingDirectory() / projectPath;
394 StringUtils::PathRemoveRelativeParts(projectPath);
395 }
396 if (projectPath.EndsWith(TEXT(".flaxproj")))
397 {
398 projectPath = StringUtils::GetDirectoryName(projectPath);
399 }
400 }
401 else
402 {
403 projectPath.Clear();
404 }
405
406 // Create new project option
407 if (CommandLine::Options.NewProject.IsTrue())
408 {
409 Array<String> projectFiles;
410 FileSystem::DirectoryGetFiles(projectFiles, projectPath, TEXT("*.flaxproj"), DirectorySearchOption::TopDirectoryOnly);
411 if (projectFiles.Count() > 1)
412 {
413 Platform::Fatal(TEXT("Too many project files."));
414 return -2;
415 }
416 else if (projectFiles.Count() == 1)
417 {
418 LOG(Info, "Skip creating new project because it already exists");
419 CommandLine::Options.NewProject.Reset();
420 }
421 else
422 {
423 Array<String> files;
424 FileSystem::DirectoryGetFiles(files, projectPath, TEXT("*"), DirectorySearchOption::TopDirectoryOnly);
425 if (files.Count() > 0)
426 {

Callers

nothing calls this directly

Calls 15

IsRelativeFunction · 0.85
NormalizePathFunction · 0.85
TrimTrailingMethod · 0.80
SubstringMethod · 0.80
AddOneMethod · 0.80
SaveProjectMethod · 0.80
LoadOldProjectMethod · 0.80
LoadProjectMethod · 0.80
FormatFunction · 0.50
VersionFunction · 0.50
StartsWithMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected