mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-13 13:30:00 -08:00
Merge 2e77270cb8 into c72192fd81
This commit is contained in:
commit
dfded56931
4 changed files with 179 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "pages.h"
|
||||
|
||||
#include "client/settings/cache_settings.h"
|
||||
#include "libcockatrice/utility/system_memory_querier.h"
|
||||
#include "main.h"
|
||||
#include "oracleimporter.h"
|
||||
#include "oraclewizard.h"
|
||||
|
|
@ -70,6 +71,7 @@ class QWidget;
|
|||
#define MTGJSON_V4_URL_COMPONENT "mtgjson.com/files/"
|
||||
#define ALLSETS_URL_FALLBACK "https://www.mtgjson.com/api/v5/AllPrintings.json"
|
||||
#define MTGJSON_VERSION_URL "https://www.mtgjson.com/api/v5/Meta.json"
|
||||
#define MTGXML_URL "https://github.com/ebbit1q/mtgxml/releases/latest/download/mtg.xml.xz"
|
||||
|
||||
#ifdef HAS_LZMA
|
||||
#define ALLSETS_URL "https://www.mtgjson.com/api/v5/AllPrintings.json.xz"
|
||||
|
|
@ -317,6 +319,32 @@ void LoadSetsPage::initializePage()
|
|||
{
|
||||
urlLineEdit->setText(wizard()->settings->value("allsetsurl", ALLSETS_URL).toString());
|
||||
|
||||
// Memory check because Oracle parsing fails on systems with less than 4GiB for MTGJsons allPrintings.json
|
||||
// The fallback URL is xz-compressed, so only offer it in builds that can read it.
|
||||
// During background (automatic) updates there is no user to answer, so switch silently.
|
||||
#ifdef HAS_LZMA
|
||||
if (!SystemMemoryQuerier::hasAtLeastGiB(4) && urlLineEdit->text() == ALLSETS_URL) {
|
||||
if (wizard()->backgroundMode) {
|
||||
urlLineEdit->setText(MTGXML_URL);
|
||||
} else {
|
||||
// Ask user whether to switch URL
|
||||
QMessageBox msgBox(
|
||||
QMessageBox::Question, tr("Low Memory Detected"),
|
||||
tr("Your system has less than 4 GiB of memory.\n"
|
||||
"Using the default AllPrintings URL may cause high memory usage and is known to fail as a "
|
||||
"result.\n\n"
|
||||
"Would you like to switch to the direct-download pre-parsed URL instead? (Updated daily)"),
|
||||
QMessageBox::Yes | QMessageBox::No, this);
|
||||
|
||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||
|
||||
if (msgBox.exec() == QMessageBox::Yes) {
|
||||
urlLineEdit->setText(MTGXML_URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
progressLabel->hide();
|
||||
progressBar->hide();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue