mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
Don't use suffixes.
Took 7 minutes Took 9 seconds
This commit is contained in:
parent
019a7b9565
commit
7ef6ced763
1 changed files with 18 additions and 18 deletions
|
|
@ -83,25 +83,21 @@ QImage PictureLoaderLocal::tryLoadCardImageFromDisk(const QString &setName,
|
|||
QImageReader imgReader;
|
||||
imgReader.setDecideFormatFromContent(true);
|
||||
|
||||
// Most-to-least specific, these will fall through in order.
|
||||
|
||||
QStringList nameVariants;
|
||||
// cardName_providerId
|
||||
|
||||
if (!providerId.isEmpty()) {
|
||||
nameVariants << QString("%1-%2").arg(correctedCardName, providerId);
|
||||
nameVariants << QString("%1_%2").arg(correctedCardName, providerId);
|
||||
nameVariants << QString("%1-%2").arg(correctedCardName, providerId)
|
||||
<< QString("%1_%2").arg(correctedCardName, providerId);
|
||||
}
|
||||
// cardName_setName_collectorNumber & setName-collectorNumber-cardName
|
||||
if (!setName.isEmpty() && !collectorNumber.isEmpty()) {
|
||||
nameVariants << QString("%1_%2_%3").arg(correctedCardName, setName, collectorNumber)
|
||||
<< QString("%1-%2-%3").arg(setName, collectorNumber, correctedCardName);
|
||||
}
|
||||
// cardName_setName
|
||||
if (!setName.isEmpty()) {
|
||||
nameVariants << QString("%1_%2").arg(correctedCardName, setName)
|
||||
<< QString("%1-%2").arg(setName, correctedCardName);
|
||||
}
|
||||
// cardName
|
||||
|
||||
nameVariants << correctedCardName;
|
||||
|
||||
for (const QString &nameVariant : nameVariants) {
|
||||
|
|
@ -109,12 +105,7 @@ QImage PictureLoaderLocal::tryLoadCardImageFromDisk(const QString &setName,
|
|||
continue;
|
||||
}
|
||||
|
||||
QStringList candidatePaths;
|
||||
const auto matches = customFolderIndex.values(nameVariant);
|
||||
|
||||
for (const QString &path : matches) {
|
||||
candidatePaths << path;
|
||||
}
|
||||
QStringList candidatePaths = customFolderIndex.values(nameVariant);
|
||||
|
||||
if (!setName.isEmpty()) {
|
||||
candidatePaths << picsPath + "/" + setName + "/" + nameVariant;
|
||||
|
|
@ -122,14 +113,23 @@ QImage PictureLoaderLocal::tryLoadCardImageFromDisk(const QString &setName,
|
|||
}
|
||||
|
||||
for (const QString &path : candidatePaths) {
|
||||
for (const QString suffix : {"", ".full", ".xlhq"}) {
|
||||
QString fullPath = path + suffix;
|
||||
QFileInfo fi(fullPath);
|
||||
if (!fi.exists() || !fi.isFile()) {
|
||||
QFileInfo fileInfo(path);
|
||||
QDir dir = fileInfo.dir();
|
||||
QString baseName = fileInfo.fileName();
|
||||
|
||||
if (!dir.exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList files = dir.entryList(QDir::Files);
|
||||
for (const QString &file : files) {
|
||||
if (!file.startsWith(baseName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString fullPath = dir.filePath(file);
|
||||
imgReader.setFileName(fullPath);
|
||||
|
||||
if (imgReader.read(&image)) {
|
||||
qCDebug(PictureLoaderLocalLog).nospace()
|
||||
<< "[card: " << correctedCardName << " set: " << setName << "] Found picture at: " << fullPath;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue