Load official parts before unofficial.

This commit is contained in:
Leonardo Zide 2021-03-13 20:01:25 -08:00
parent b0f689df83
commit 32c7964503

View file

@ -1261,21 +1261,18 @@ bool lcPiecesLibrary::LoadPieceData(PieceInfo* Info)
char FileName[LC_MAXPATH];
lcDiskFile PieceFile;
if (mHasUnofficial)
sprintf(FileName, "parts/%s", Info->mFileName);
PieceFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
if (PieceFile.Open(QIODevice::ReadOnly))
Loaded = MeshLoader.LoadMesh(PieceFile, LC_MESHDATA_SHARED);
if (mHasUnofficial && !Loaded)
{
sprintf(FileName, "unofficial/parts/%s", Info->mFileName);
PieceFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
if (PieceFile.Open(QIODevice::ReadOnly))
Loaded = MeshLoader.LoadMesh(PieceFile, LC_MESHDATA_SHARED);
}
if (!Loaded)
{
sprintf(FileName, "parts/%s", Info->mFileName);
PieceFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
if (PieceFile.Open(QIODevice::ReadOnly))
Loaded = MeshLoader.LoadMesh(PieceFile, LC_MESHDATA_SHARED);
}
}
if (mCancelLoading)
@ -1338,20 +1335,17 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
char FileName[LC_MAXPATH];
bool Found = false;
if (mHasUnofficial)
sprintf(FileName, "parts/%s", Info->mFileName);
IncludeFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
Found = IncludeFile.Open(QIODevice::ReadOnly);
if (mHasUnofficial && !Found)
{
sprintf(FileName, "unofficial/parts/%s", Info->mFileName);
IncludeFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
Found = IncludeFile.Open(QIODevice::ReadOnly);
}
if (!Found)
{
sprintf(FileName, "parts/%s", Info->mFileName);
IncludeFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
Found = IncludeFile.Open(QIODevice::ReadOnly);
}
if (Found)
Callback(IncludeFile);
}
@ -1371,7 +1365,12 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
return mZipFiles[static_cast<int>(ZipFileType)]->ExtractFile(IncludeFileName, IncludeFile);
};
if (mHasUnofficial)
Found = LoadIncludeFile("ldraw/parts/%s", lcZipFileType::Official);
if (!Found)
Found = LoadIncludeFile("ldraw/p/%s", lcZipFileType::Official);
if (mHasUnofficial && !Found)
{
Found = LoadIncludeFile("parts/%s", lcZipFileType::Unofficial);
@ -1379,14 +1378,6 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
Found = LoadIncludeFile("p/%s", lcZipFileType::Unofficial);
}
if (!Found)
{
Found = LoadIncludeFile("ldraw/parts/%s", lcZipFileType::Official);
if (!Found)
Found = LoadIncludeFile("ldraw/p/%s", lcZipFileType::Official);
}
if (Found)
Callback(IncludeFile);
}
@ -1410,7 +1401,12 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
#endif
};
if (mHasUnofficial)
Found = LoadIncludeFile(QLatin1String("parts/"));
if (!Found)
Found = LoadIncludeFile(QLatin1String("p/"));
if (mHasUnofficial && !Found)
{
Found = LoadIncludeFile(QLatin1String("unofficial/parts/"));
@ -1418,14 +1414,6 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
Found = LoadIncludeFile(QLatin1String("unofficial/p/"));
}
if (!Found)
{
Found = LoadIncludeFile(QLatin1String("parts/"));
if (!Found)
Found = LoadIncludeFile(QLatin1String("p/"));
}
if (Found)
Callback(IncludeFile);
}