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

Method CheckProjectUpgrade

Source/Editor/Editor.cpp:49–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49bool Editor::CheckProjectUpgrade()
50{
51 PROFILE_MEM(Editor);
52 const auto versionFilePath = Globals::ProjectCacheFolder / TEXT("version");
53
54 // Load version cache file
55 struct VersionCache
56 {
57 // When changing this ensure that Flax Launcher properly reads the version
58 int32 Major = FLAXENGINE_VERSION_MAJOR;
59 int32 Minor = FLAXENGINE_VERSION_MINOR;
60 int32 Build = FLAXENGINE_VERSION_BUILD;
61 int32 RealSize = sizeof(Real); // Rebuild when changing between Large Worlds
62 };
63 VersionCache lastVersion;
64 if (FileSystem::FileExists(versionFilePath))
65 {
66 auto file = FileReadStream::Open(versionFilePath);
67 if (file)
68 {
69 file->ReadBytes(&lastVersion, sizeof(lastVersion));
70
71 // Invalidate results if data has issues
72 if (file->HasError() || lastVersion.Major < 0 || lastVersion.Minor < 0 || lastVersion.Major > 100 || lastVersion.Minor > 1000)
73 {
74 lastVersion = VersionCache();
75 LOG(Warning, "Invalid version cache data");
76 }
77 else
78 {
79 LOG(Info, "Last project open version: {0}.{1}.{2}", lastVersion.Major, lastVersion.Minor, lastVersion.Build);
80 LastProjectOpenedEngineBuild = lastVersion.Build;
81 }
82
83 Delete(file);
84 }
85 }
86
87 // Check if project is in the old, deprecated layout
88 if (EditorImpl::IsOldProjectXmlFormat)
89 {
90 // [Deprecated: 16.04.2020, expires 16.04.2021]
91 LOG(Warning, "The project is in an old format and will be upgraded.");
92 const auto result = MessageBox::Show(TEXT("The Flax project is in an old format and will be upgraded. Loading it may modify existing data so older editor version won't open it. Do you want to perform a backup before or cancel operation?"), TEXT("Project upgrade"), MessageBoxButtons::YesNoCancel, MessageBoxIcon::Question);
93 if (result == DialogResult::Yes)
94 {
95 if (BackupProject())
96 {
97 LOG(Warning, "Backup failed");
98 return true;
99 }
100 }
101 else if (result == DialogResult::No)
102 {
103 // Don't backup, just load
104 }
105 else
106 {

Callers

nothing calls this directly

Calls 8

VersionCacheClass · 0.85
DeleteFunction · 0.85
SaveProjectMethod · 0.80
FormatFunction · 0.50
ReadBytesMethod · 0.45
LengthMethod · 0.45
ContainsMethod · 0.45
WriteBytesMethod · 0.45

Tested by

no test coverage detected