mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 00:14:40 -07:00
[PictureLoader] Add the localized picture URL explicitly, not implicitly
Address review: silently prepending the Scryfall named-picture URL to the download list whenever a non-English card language was active was surprising, consumed quota per card when it failed, and could grab the wrong (canon) art on name collisions, with no way to turn it off. The insert is now opt-in and user-controlled: changing the card language adds the template to the top of the download URLs once (persisted, documented in the re-import prompt, and editable/removable in the deck editor settings), while the picture loader no longer injects it at request time.
This commit is contained in:
parent
5c8535dae5
commit
fa89662172
4 changed files with 38 additions and 23 deletions
|
|
@ -9,6 +9,9 @@ const QStringList DownloadSettings::DEFAULT_DOWNLOAD_URLS = {
|
|||
"https://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!set:muid!&type=card",
|
||||
"https://gatherer.wizards.com/Handlers/Image.ashx?name=!name!&type=card"};
|
||||
|
||||
const QString DownloadSettings::SCRYFALL_NAMED_LOCALIZED_URL =
|
||||
"https://api.scryfall.com/cards/named?fuzzy=!localizedName!&lang=!sflang!&format=image&face=!prop:side!";
|
||||
|
||||
DownloadSettings::DownloadSettings(const QString &settingPath, QObject *parent = nullptr)
|
||||
: SettingsManager(settingPath + "downloads.ini", "downloads", QString(), parent)
|
||||
{
|
||||
|
|
@ -29,6 +32,18 @@ void DownloadSettings::resetToDefaultURLs()
|
|||
setValue(QVariant::fromValue(DEFAULT_DOWNLOAD_URLS), "urls");
|
||||
}
|
||||
|
||||
bool DownloadSettings::addLocalizedScryfallUrl()
|
||||
{
|
||||
const QStringList urls = getAllURLs();
|
||||
if (urls.contains(SCRYFALL_NAMED_LOCALIZED_URL)) {
|
||||
return false;
|
||||
}
|
||||
QStringList updated = urls;
|
||||
updated.prepend(SCRYFALL_NAMED_LOCALIZED_URL);
|
||||
setDownloadUrls(updated);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DownloadSettings::getPicDownload() const
|
||||
{
|
||||
return getValue("pictureDownload", QString(), QString(), true).toBool();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class DownloadSettings : public SettingsManager
|
|||
friend class SettingsCache;
|
||||
|
||||
static const QStringList DEFAULT_DOWNLOAD_URLS;
|
||||
static const QString SCRYFALL_NAMED_LOCALIZED_URL;
|
||||
|
||||
public:
|
||||
explicit DownloadSettings(const QString &, QObject *);
|
||||
|
|
@ -22,6 +23,7 @@ public:
|
|||
QStringList getAllURLs() const;
|
||||
void setDownloadUrls(const QStringList &downloadURLs);
|
||||
void resetToDefaultURLs();
|
||||
[[nodiscard]] bool addLocalizedScryfallUrl();
|
||||
[[nodiscard]] bool getPicDownload() const;
|
||||
void setPicDownload(bool _picDownload);
|
||||
[[nodiscard]] bool getDownloadSpoilersStatus() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue