Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix local image path when compression is enabled #28

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/include/fp/fp-install.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ enum class Edition {Ultimate, Infinity, Core};
static inline const QString VER_TXT_PATH = u"version.txt"_s;

// File Info
static inline const QString IMAGE_UC_EXT = u".png"_s;
static inline const QString IMAGE_C_EXT = u".jpg"_s;
static inline const QString IMAGE_C_URL_SUFFIX = u"?type=jpg"_s;
static inline const QString IMAGE_EXT = u".png"_s;
static inline const QString IMAGE_COMPRESSED_URL_SUFFIX = u"?type=jpg"_s;

// Dynamic path file names
static inline const QString SERVICES_JSON_NAME = u"services.json"_s;
Expand Down
9 changes: 4 additions & 5 deletions lib/src/fp-install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,15 @@ QDir Install::extrasDirectory() const { return mExtrasDirectory; }

QString Install::platformLogoPath(const QString& platform)
{
QString path = mPlatformLogosDirectory.absoluteFilePath(platform + IMAGE_UC_EXT);
QString path = mPlatformLogosDirectory.absoluteFilePath(platform + IMAGE_EXT);
return QFile::exists(path) ? path : QString();
}

QString Install::entryImageLocalPath(ImageType imageType, const QUuid& gameId) const
{
// Defaults to using compression if the setting isn't present
const QDir& sourceDir = imageType == ImageType::Logo ? mEntryLogosDirectory : mEntryScreenshotsDirectory;
bool compressed = !mPreferences.onDemandImagesCompressed.has_value() || mPreferences.onDemandImagesCompressed.value();
QString localSubPath = standardImageSubPath(gameId) + (compressed ? IMAGE_C_EXT : IMAGE_UC_EXT);
QString localSubPath = standardImageSubPath(gameId) + IMAGE_EXT;

return sourceDir.absolutePath() + '/' + localSubPath;
}
Expand All @@ -290,10 +289,10 @@ QUrl Install::entryImageRemoteUrl(ImageType imageType, const QUuid& gameId) cons
// Defaults to using compression if the setting isn't present
const QString typeFolder = (imageType == ImageType::Logo ? LOGOS_FOLDER_NAME : SCREENSHOTS_FOLDER_NAME);
bool compressed = !mPreferences.onDemandImagesCompressed.has_value() || mPreferences.onDemandImagesCompressed.value();
QString remoteSubPath = standardImageSubPath(gameId) + IMAGE_UC_EXT;
QString remoteSubPath = standardImageSubPath(gameId) + IMAGE_EXT;

if(compressed)
remoteSubPath += IMAGE_C_URL_SUFFIX;
remoteSubPath += IMAGE_COMPRESSED_URL_SUFFIX;

return QUrl(mPreferences.onDemandBaseUrl + typeFolder + '/' + remoteSubPath);
}
Expand Down
Loading