mirror of
https://github.com/leozide/leocad
synced 2025-02-07 08:45:49 +01:00
Load official parts before unofficial.
This commit is contained in:
parent
b0f689df83
commit
32c7964503
1 changed files with 23 additions and 35 deletions
|
@ -1261,21 +1261,18 @@ bool lcPiecesLibrary::LoadPieceData(PieceInfo* Info)
|
||||||
char FileName[LC_MAXPATH];
|
char FileName[LC_MAXPATH];
|
||||||
lcDiskFile PieceFile;
|
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);
|
sprintf(FileName, "unofficial/parts/%s", Info->mFileName);
|
||||||
PieceFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
|
PieceFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
|
||||||
if (PieceFile.Open(QIODevice::ReadOnly))
|
if (PieceFile.Open(QIODevice::ReadOnly))
|
||||||
Loaded = MeshLoader.LoadMesh(PieceFile, LC_MESHDATA_SHARED);
|
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)
|
if (mCancelLoading)
|
||||||
|
@ -1338,20 +1335,17 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
|
||||||
char FileName[LC_MAXPATH];
|
char FileName[LC_MAXPATH];
|
||||||
bool Found = false;
|
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);
|
sprintf(FileName, "unofficial/parts/%s", Info->mFileName);
|
||||||
IncludeFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
|
IncludeFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
|
||||||
Found = IncludeFile.Open(QIODevice::ReadOnly);
|
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)
|
if (Found)
|
||||||
Callback(IncludeFile);
|
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);
|
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);
|
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);
|
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)
|
if (Found)
|
||||||
Callback(IncludeFile);
|
Callback(IncludeFile);
|
||||||
}
|
}
|
||||||
|
@ -1410,7 +1401,12 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mHasUnofficial)
|
Found = LoadIncludeFile(QLatin1String("parts/"));
|
||||||
|
|
||||||
|
if (!Found)
|
||||||
|
Found = LoadIncludeFile(QLatin1String("p/"));
|
||||||
|
|
||||||
|
if (mHasUnofficial && !Found)
|
||||||
{
|
{
|
||||||
Found = LoadIncludeFile(QLatin1String("unofficial/parts/"));
|
Found = LoadIncludeFile(QLatin1String("unofficial/parts/"));
|
||||||
|
|
||||||
|
@ -1418,14 +1414,6 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
|
||||||
Found = LoadIncludeFile(QLatin1String("unofficial/p/"));
|
Found = LoadIncludeFile(QLatin1String("unofficial/p/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Found)
|
|
||||||
{
|
|
||||||
Found = LoadIncludeFile(QLatin1String("parts/"));
|
|
||||||
|
|
||||||
if (!Found)
|
|
||||||
Found = LoadIncludeFile(QLatin1String("p/"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Found)
|
if (Found)
|
||||||
Callback(IncludeFile);
|
Callback(IncludeFile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue