From 4f3328e71cd6478513509d476de86378b8441586 Mon Sep 17 00:00:00 2001 From: kb1000 Date: Tue, 23 Mar 2021 21:54:48 +0100 Subject: [PATCH 01/13] NOISSUE disable datapacks button in the world screen if no world is selected --- application/pages/instance/WorldListPage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/application/pages/instance/WorldListPage.cpp b/application/pages/instance/WorldListPage.cpp index d18c5355..119cff3e 100644 --- a/application/pages/instance/WorldListPage.cpp +++ b/application/pages/instance/WorldListPage.cpp @@ -314,6 +314,7 @@ void WorldListPage::worldChanged(const QModelIndex ¤t, const QModelIndex & ui->actionRemove->setEnabled(enable); ui->actionCopy->setEnabled(enable); ui->actionRename->setEnabled(enable); + ui->actionDatapacks->setEnabled(enable); bool hasIcon = !index.data(WorldList::IconFileRole).isNull(); ui->actionReset_Icon->setEnabled(enable && hasIcon); } From 9d7ba275ab52c63c3ab29a94c10e1eb9f0ae5a60 Mon Sep 17 00:00:00 2001 From: kb1000 Date: Tue, 23 Mar 2021 22:57:39 +0100 Subject: [PATCH 02/13] NOISSUE print information about whether the system GLFW or OpenAL workarounds are active to the instance log --- api/logic/minecraft/MinecraftInstance.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp index b0343316..37cdece7 100644 --- a/api/logic/minecraft/MinecraftInstance.cpp +++ b/api/logic/minecraft/MinecraftInstance.cpp @@ -526,11 +526,23 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session) out << ""; } + auto settings = this->settings(); + bool nativeOpenAL = settings->get("UseNativeOpenAL").toBool(); + bool nativeGLFW = settings->get("UseNativeGLFW").toBool(); + if (nativeOpenAL || nativeGLFW) + { + if (nativeOpenAL) + out << "Using system OpenAL."; + if (nativeGLFW) + out << "Using system GLFW."; + out << ""; + } + // libraries and class path. { out << "Libraries:"; QStringList jars, nativeJars; - auto javaArchitecture = settings()->get("JavaArchitecture").toString(); + auto javaArchitecture = settings->get("JavaArchitecture").toString(); profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot()); auto printLibFile = [&](const QString & path) { @@ -616,14 +628,14 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session) out << ""; QString windowParams; - if (settings()->get("LaunchMaximized").toBool()) + if (settings->get("LaunchMaximized").toBool()) { out << "Window size: max (if available)"; } else { - auto width = settings()->get("MinecraftWinWidth").toInt(); - auto height = settings()->get("MinecraftWinHeight").toInt(); + auto width = settings->get("MinecraftWinWidth").toInt(); + auto height = settings->get("MinecraftWinHeight").toInt(); out << "Window size: " + QString::number(width) + " x " + QString::number(height); } out << ""; From 7acad35c3f749771e26aaa32c658d8b42250ca0d Mon Sep 17 00:00:00 2001 From: kb1000 Date: Tue, 23 Mar 2021 23:05:10 +0100 Subject: [PATCH 03/13] NOISSUE fix MOC warning complaining about an unused MOC file include --- application/pages/instance/GameOptionsPage.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/application/pages/instance/GameOptionsPage.cpp b/application/pages/instance/GameOptionsPage.cpp index 5555fc79..782f2ab3 100644 --- a/application/pages/instance/GameOptionsPage.cpp +++ b/application/pages/instance/GameOptionsPage.cpp @@ -35,6 +35,3 @@ void GameOptionsPage::closedImpl() { // m_model->unobserve(); } - -#include "GameOptionsPage.moc" - From a0cb1a0d427087c84690224b37c2c9d0fba4f6cb Mon Sep 17 00:00:00 2001 From: kb1000 Date: Wed, 24 Mar 2021 00:59:43 +0100 Subject: [PATCH 04/13] NOISSUE rename Twitch to flame internally for consistency and to CurseForge for user displayed strings --- api/logic/Env.cpp | 2 +- application/CMakeLists.txt | 12 +-- application/dialogs/NewInstanceDialog.cpp | 8 +- application/dialogs/NewInstanceDialog.h | 4 +- .../TwitchData.h => flame/FlameData.h} | 4 +- .../TwitchModel.cpp => flame/FlameModel.cpp} | 18 ++--- .../TwitchModel.h => flame/FlameModel.h} | 5 +- .../TwitchPage.cpp => flame/FlamePage.cpp} | 36 ++++----- .../TwitchPage.h => flame/FlamePage.h} | 26 +++---- .../TwitchPage.ui => flame/FlamePage.ui} | 74 ++++++++++++------- application/resources/multimc/multimc.qrc | 5 +- .../resources/multimc/scalable/twitch.svg | 63 ---------------- 12 files changed, 106 insertions(+), 151 deletions(-) rename application/pages/modplatform/{twitch/TwitchData.h => flame/FlameData.h} (90%) rename application/pages/modplatform/{twitch/TwitchModel.cpp => flame/FlameModel.cpp} (92%) rename application/pages/modplatform/{twitch/TwitchModel.h => flame/FlameModel.h} (95%) rename application/pages/modplatform/{twitch/TwitchPage.cpp => flame/FlamePage.cpp} (69%) rename application/pages/modplatform/{twitch/TwitchPage.h => flame/FlamePage.h} (75%) rename application/pages/modplatform/{twitch/TwitchPage.ui => flame/FlamePage.ui} (62%) delete mode 100644 application/resources/multimc/scalable/twitch.svg diff --git a/api/logic/Env.cpp b/api/logic/Env.cpp index 42a1cff7..71b49d95 100644 --- a/api/logic/Env.cpp +++ b/api/logic/Env.cpp @@ -100,7 +100,7 @@ void Env::initHttpMetaCache() m_metacache->addBase("FTBPacks", QDir("cache/FTBPacks").absolutePath()); m_metacache->addBase("ModpacksCHPacks", QDir("cache/ModpacksCHPacks").absolutePath()); m_metacache->addBase("TechnicPacks", QDir("cache/TechnicPacks").absolutePath()); - m_metacache->addBase("TwitchPacks", QDir("cache/TwitchPacks").absolutePath()); + m_metacache->addBase("FlamePacks", QDir("cache/FlamePacks").absolutePath()); m_metacache->addBase("skins", QDir("accounts/skins").absolutePath()); m_metacache->addBase("root", QDir::currentPath()); m_metacache->addBase("translations", QDir("translations").absolutePath()); diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index a81327e3..afd13574 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -145,11 +145,11 @@ SET(MULTIMC_SOURCES pages/modplatform/legacy_ftb/ListModel.h pages/modplatform/legacy_ftb/ListModel.cpp - pages/modplatform/twitch/TwitchData.h - pages/modplatform/twitch/TwitchModel.cpp - pages/modplatform/twitch/TwitchModel.h - pages/modplatform/twitch/TwitchPage.cpp - pages/modplatform/twitch/TwitchPage.h + pages/modplatform/flame/FlameData.h + pages/modplatform/flame/FlameModel.cpp + pages/modplatform/flame/FlameModel.h + pages/modplatform/flame/FlamePage.cpp + pages/modplatform/flame/FlamePage.h pages/modplatform/technic/TechnicModel.cpp pages/modplatform/technic/TechnicModel.h @@ -276,7 +276,7 @@ SET(MULTIMC_UIS pages/modplatform/atlauncher/AtlPage.ui pages/modplatform/ftb/FtbPage.ui pages/modplatform/legacy_ftb/Page.ui - pages/modplatform/twitch/TwitchPage.ui + pages/modplatform/flame/FlamePage.ui pages/modplatform/technic/TechnicPage.ui pages/modplatform/ImportPage.ui diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp index d70cbffe..112e46ff 100644 --- a/application/dialogs/NewInstanceDialog.cpp +++ b/application/dialogs/NewInstanceDialog.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -124,17 +124,17 @@ void NewInstanceDialog::accept() QList NewInstanceDialog::getPages() { importPage = new ImportPage(this); - twitchPage = new TwitchPage(this); + flamePage = new FlamePage(this); auto technicPage = new TechnicPage(this); return { new VanillaPage(this), importPage, new AtlPage(this), + flamePage, new FtbPage(this), new LegacyFTB::Page(this), - technicPage, - twitchPage + technicPage }; } diff --git a/application/dialogs/NewInstanceDialog.h b/application/dialogs/NewInstanceDialog.h index 88ed00e5..f8d96dbf 100644 --- a/application/dialogs/NewInstanceDialog.h +++ b/application/dialogs/NewInstanceDialog.h @@ -29,7 +29,7 @@ class NewInstanceDialog; class PageContainer; class QDialogButtonBox; class ImportPage; -class TwitchPage; +class FlamePage; class NewInstanceDialog : public QDialog, public BasePageProvider { @@ -68,7 +68,7 @@ private: QString InstIconKey; ImportPage *importPage = nullptr; - TwitchPage *twitchPage = nullptr; + FlamePage *flamePage = nullptr; std::unique_ptr creationTask; bool importIcon = false; diff --git a/application/pages/modplatform/twitch/TwitchData.h b/application/pages/modplatform/flame/FlameData.h similarity index 90% rename from application/pages/modplatform/twitch/TwitchData.h rename to application/pages/modplatform/flame/FlameData.h index dd000b84..9245ba8a 100644 --- a/application/pages/modplatform/twitch/TwitchData.h +++ b/application/pages/modplatform/flame/FlameData.h @@ -3,7 +3,7 @@ #include #include -namespace Twitch { +namespace Flame { struct ModpackAuthor { QString name; @@ -35,4 +35,4 @@ struct Modpack }; } -Q_DECLARE_METATYPE(Twitch::Modpack) +Q_DECLARE_METATYPE(Flame::Modpack) diff --git a/application/pages/modplatform/twitch/TwitchModel.cpp b/application/pages/modplatform/flame/FlameModel.cpp similarity index 92% rename from application/pages/modplatform/twitch/TwitchModel.cpp rename to application/pages/modplatform/flame/FlameModel.cpp index 5c6c7858..cd3109e0 100644 --- a/application/pages/modplatform/twitch/TwitchModel.cpp +++ b/application/pages/modplatform/flame/FlameModel.cpp @@ -1,4 +1,4 @@ -#include "TwitchModel.h" +#include "FlameModel.h" #include "MultiMC.h" #include @@ -10,7 +10,7 @@ #include #include -namespace Twitch { +namespace Flame { ListModel::ListModel(QObject *parent) : QAbstractListModel(parent) { @@ -99,8 +99,8 @@ void ListModel::requestLogo(QString logo, QString url) return; } - MetaEntryPtr entry = ENV.metacache()->resolveEntry("TwitchPacks", QString("logos/%1").arg(logo.section(".", 0, 0))); - NetJob *job = new NetJob(QString("Twitch Icon Download %1").arg(logo)); + MetaEntryPtr entry = ENV.metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0))); + NetJob *job = new NetJob(QString("Flame Icon Download %1").arg(logo)); job->addNetAction(Net::Download::makeCached(QUrl(url), entry)); auto fullPath = entry->getFullPath(); @@ -127,7 +127,7 @@ void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallbac { if(m_logoMap.contains(logo)) { - callback(ENV.metacache()->resolveEntry("TwitchPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath()); + callback(ENV.metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath()); } else { @@ -158,7 +158,7 @@ void ListModel::fetchMore(const QModelIndex& parent) void ListModel::performPaginatedSearch() { - NetJob *netJob = new NetJob("Twitch::Search"); + NetJob *netJob = new NetJob("Flame::Search"); auto searchUrl = QString( "https://addons-ecs.forgesvc.net/api/v2/addon/search?" "categoryId=0&" @@ -198,14 +198,14 @@ void ListModel::searchWithTerm(const QString& term) performPaginatedSearch(); } -void Twitch::ListModel::searchRequestFinished() +void Flame::ListModel::searchRequestFinished() { jobPtr.reset(); QJsonParseError parse_error; QJsonDocument doc = QJsonDocument::fromJson(response, &parse_error); if(parse_error.error != QJsonParseError::NoError) { - qWarning() << "Error while parsing JSON response from Twitch at " << parse_error.offset << " reason: " << parse_error.errorString(); + qWarning() << "Error while parsing JSON response from CurseForge at " << parse_error.offset << " reason: " << parse_error.errorString(); qWarning() << response; return; } @@ -292,7 +292,7 @@ void Twitch::ListModel::searchRequestFinished() endInsertRows(); } -void Twitch::ListModel::searchRequestFailed(QString reason) +void Flame::ListModel::searchRequestFailed(QString reason) { jobPtr.reset(); diff --git a/application/pages/modplatform/twitch/TwitchModel.h b/application/pages/modplatform/flame/FlameModel.h similarity index 95% rename from application/pages/modplatform/twitch/TwitchModel.h rename to application/pages/modplatform/flame/FlameModel.h index ad355c64..b4dded76 100644 --- a/application/pages/modplatform/twitch/TwitchModel.h +++ b/application/pages/modplatform/flame/FlameModel.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include @@ -16,9 +15,9 @@ #include #include -#include "TwitchData.h" +#include "FlameData.h" -namespace Twitch { +namespace Flame { typedef QMap LogoMap; diff --git a/application/pages/modplatform/twitch/TwitchPage.cpp b/application/pages/modplatform/flame/FlamePage.cpp similarity index 69% rename from application/pages/modplatform/twitch/TwitchPage.cpp rename to application/pages/modplatform/flame/FlamePage.cpp index 1e9f9dbb..3889f15a 100644 --- a/application/pages/modplatform/twitch/TwitchPage.cpp +++ b/application/pages/modplatform/flame/FlamePage.cpp @@ -1,29 +1,29 @@ -#include "TwitchPage.h" -#include "ui_TwitchPage.h" +#include "FlamePage.h" +#include "ui_FlamePage.h" #include "MultiMC.h" #include "dialogs/NewInstanceDialog.h" #include -#include "TwitchModel.h" +#include "FlameModel.h" #include -TwitchPage::TwitchPage(NewInstanceDialog* dialog, QWidget *parent) - : QWidget(parent), ui(new Ui::TwitchPage), dialog(dialog) +FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget *parent) + : QWidget(parent), ui(new Ui::FlamePage), dialog(dialog) { ui->setupUi(this); - connect(ui->searchButton, &QPushButton::clicked, this, &TwitchPage::triggerSearch); + connect(ui->searchButton, &QPushButton::clicked, this, &FlamePage::triggerSearch); ui->searchEdit->installEventFilter(this); - model = new Twitch::ListModel(this); + model = new Flame::ListModel(this); ui->packView->setModel(model); - connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &TwitchPage::onSelectionChanged); + connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FlamePage::onSelectionChanged); } -TwitchPage::~TwitchPage() +FlamePage::~FlamePage() { delete ui; } -bool TwitchPage::eventFilter(QObject* watched, QEvent* event) +bool FlamePage::eventFilter(QObject* watched, QEvent* event) { if (watched == ui->searchEdit && event->type() == QEvent::KeyPress) { QKeyEvent* keyEvent = static_cast(event); @@ -36,22 +36,22 @@ bool TwitchPage::eventFilter(QObject* watched, QEvent* event) return QWidget::eventFilter(watched, event); } -bool TwitchPage::shouldDisplay() const +bool FlamePage::shouldDisplay() const { return true; } -void TwitchPage::openedImpl() +void FlamePage::openedImpl() { suggestCurrent(); } -void TwitchPage::triggerSearch() +void FlamePage::triggerSearch() { model->searchWithTerm(ui->searchEdit->text()); } -void TwitchPage::onSelectionChanged(QModelIndex first, QModelIndex second) +void FlamePage::onSelectionChanged(QModelIndex first, QModelIndex second) { if(!first.isValid()) { @@ -63,7 +63,7 @@ void TwitchPage::onSelectionChanged(QModelIndex first, QModelIndex second) return; } - current = model->data(first, Qt::UserRole).value(); + current = model->data(first, Qt::UserRole).value(); QString text = ""; QString name = current.name; @@ -72,7 +72,7 @@ void TwitchPage::onSelectionChanged(QModelIndex first, QModelIndex second) else text = "" + name + ""; if (!current.authors.empty()) { - auto authorToStr = [](Twitch::ModpackAuthor & author) { + auto authorToStr = [](Flame::ModpackAuthor & author) { if(author.url.isEmpty()) { return author.name; } @@ -90,7 +90,7 @@ void TwitchPage::onSelectionChanged(QModelIndex first, QModelIndex second) suggestCurrent(); } -void TwitchPage::suggestCurrent() +void FlamePage::suggestCurrent() { if(!isOpened) { @@ -103,7 +103,7 @@ void TwitchPage::suggestCurrent() dialog->setSuggestedPack(current.name, new InstanceImportTask(current.latestFile.downloadUrl)); QString editedLogoName; - editedLogoName = "twitch_" + current.logoName.section(".", 0, 0); + editedLogoName = "curseforge_" + current.logoName.section(".", 0, 0); model->getLogo(current.logoName, current.logoUrl, [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); diff --git a/application/pages/modplatform/twitch/TwitchPage.h b/application/pages/modplatform/flame/FlamePage.h similarity index 75% rename from application/pages/modplatform/twitch/TwitchPage.h rename to application/pages/modplatform/flame/FlamePage.h index 093900ff..e50186f5 100644 --- a/application/pages/modplatform/twitch/TwitchPage.h +++ b/application/pages/modplatform/flame/FlamePage.h @@ -20,41 +20,41 @@ #include "pages/BasePage.h" #include #include "tasks/Task.h" -#include "TwitchData.h" +#include "FlameData.h" namespace Ui { -class TwitchPage; +class FlamePage; } class NewInstanceDialog; -namespace Twitch { +namespace Flame { class ListModel; } -class TwitchPage : public QWidget, public BasePage +class FlamePage : public QWidget, public BasePage { Q_OBJECT public: - explicit TwitchPage(NewInstanceDialog* dialog, QWidget *parent = 0); - virtual ~TwitchPage(); + explicit FlamePage(NewInstanceDialog* dialog, QWidget *parent = 0); + virtual ~FlamePage(); virtual QString displayName() const override { - return tr("Twitch"); + return tr("CurseForge"); } virtual QIcon icon() const override { - return MMC->getThemedIcon("twitch"); + return MMC->getThemedIcon("flame"); } virtual QString id() const override { - return "twitch"; + return "flame"; } virtual QString helpPage() const override { - return "Twitch-platform"; + return "Flame-platform"; } virtual bool shouldDisplay() const override; @@ -70,8 +70,8 @@ private slots: void onSelectionChanged(QModelIndex first, QModelIndex second); private: - Ui::TwitchPage *ui = nullptr; + Ui::FlamePage *ui = nullptr; NewInstanceDialog* dialog = nullptr; - Twitch::ListModel* model = nullptr; - Twitch::Modpack current; + Flame::ListModel* model = nullptr; + Flame::Modpack current; }; diff --git a/application/pages/modplatform/twitch/TwitchPage.ui b/application/pages/modplatform/flame/FlamePage.ui similarity index 62% rename from application/pages/modplatform/twitch/TwitchPage.ui rename to application/pages/modplatform/flame/FlamePage.ui index c78d8ce0..21e23f1f 100644 --- a/application/pages/modplatform/twitch/TwitchPage.ui +++ b/application/pages/modplatform/flame/FlamePage.ui @@ -1,7 +1,7 @@ - TwitchPage - + FlamePage + 0 @@ -10,34 +10,36 @@ 745 - - - - - - - - Search - + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + Search + + + + - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - + Qt::ScrollBarAlwaysOff @@ -53,6 +55,22 @@ + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + diff --git a/application/resources/multimc/multimc.qrc b/application/resources/multimc/multimc.qrc index 4e95869e..249e8e28 100644 --- a/application/resources/multimc/multimc.qrc +++ b/application/resources/multimc/multimc.qrc @@ -11,8 +11,9 @@ scalable/reddit-alien.svg - - scalable/twitch.svg + + 32x32/instances/flame.png + 128x128/instances/flame.png scalable/technic.svg diff --git a/application/resources/multimc/scalable/twitch.svg b/application/resources/multimc/scalable/twitch.svg deleted file mode 100644 index 80999380..00000000 --- a/application/resources/multimc/scalable/twitch.svg +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - image/svg+xml - - Glitch - - - - - - - - Glitch - - From b8ee9a2a8e30dcdc6e8ec0b4343c427d616c6110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 26 Mar 2021 01:46:23 +0100 Subject: [PATCH 05/13] NOISSUE update ubuntu packaging bits --- application/package/ubuntu/README.md | 4 ++-- application/package/ubuntu/multimc/DEBIAN/control | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/package/ubuntu/README.md b/application/package/ubuntu/README.md index 5c0f4eeb..892abd12 100644 --- a/application/package/ubuntu/README.md +++ b/application/package/ubuntu/README.md @@ -6,9 +6,9 @@ It contains a `.desktop` file, an icon, and a simple script that does the heavy This is also the source for the files in the [RPM package](../rpm). If you rename, create or delete files here, you'll likely also have to update the RPM spec file there. # How to build this? -You need dpkg utils. Rename the `multimc` folder to `multimc_1.3-1` and then run: +You need dpkg utils. Rename the `multimc` folder to `multimc_1.5-1` and then run: ``` -fakeroot dpkg-deb --build multimc_1.3-1 +fakeroot dpkg-deb --build multimc_1.5-1 ``` Replace the version with whatever is appropriate. diff --git a/application/package/ubuntu/multimc/DEBIAN/control b/application/package/ubuntu/multimc/DEBIAN/control index 509dfe3c..3e0f570c 100644 --- a/application/package/ubuntu/multimc/DEBIAN/control +++ b/application/package/ubuntu/multimc/DEBIAN/control @@ -1,5 +1,5 @@ Package: multimc -Version: 1.4-1 +Version: 1.5-1 Architecture: all Maintainer: Petr Mrázek Section: games From 73af0f271adba6a4165e0ed36c9ae436f849f9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 26 Mar 2021 01:47:19 +0100 Subject: [PATCH 06/13] NOISSUE fix build - missing includes in RWStorage.h --- api/logic/RWStorage.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/logic/RWStorage.h b/api/logic/RWStorage.h index 5d792367..3028388e 100644 --- a/api/logic/RWStorage.h +++ b/api/logic/RWStorage.h @@ -1,6 +1,9 @@ #pragma once #include #include +#include +#include + template class RWStorage { From ba13e33ccc5e86d3dfdcca34595309479727fa53 Mon Sep 17 00:00:00 2001 From: phit <2097483+phit@users.noreply.github.com> Date: Wed, 24 Mar 2021 19:44:26 +0100 Subject: [PATCH 07/13] GH-3633 assume latest MC version, if CurseForge pack supports multiple right now these are unused anyway --- application/pages/modplatform/flame/FlameModel.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/pages/modplatform/flame/FlameModel.cpp b/application/pages/modplatform/flame/FlameModel.cpp index cd3109e0..6d9dbda7 100644 --- a/application/pages/modplatform/flame/FlameModel.cpp +++ b/application/pages/modplatform/flame/FlameModel.cpp @@ -263,11 +263,12 @@ void Flame::ListModel::searchRequestFinished() } pack.latestFile.addonId = pack.addonId; pack.latestFile.fileId = id; - // FIXME: what to do when there's more than one, or there's no version? auto versionArray = file.value("gameVersion").toArray(); - if(versionArray.size() != 1) { + if(versionArray.size() < 1) { continue; } + + // pick the latest version supported pack.latestFile.mcVersion = versionArray[0].toString(); pack.latestFile.version = file.value("displayName").toString(); pack.latestFile.downloadUrl = file.value("downloadUrl").toString(); From 34bf68847998cdfff1360d6ed04339d36894c00d Mon Sep 17 00:00:00 2001 From: KGB-8375 <60853993+KGB-8375@users.noreply.github.com> Date: Wed, 24 Mar 2021 13:36:48 -0400 Subject: [PATCH 08/13] GH-3666 Fix multi-monitor dpi scaling on windows Disable qt 5.6 DPI scaling and use windows' builtin DPI scaling, which works much better on multi-monitor setups --- application/main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/application/main.cpp b/application/main.cpp index b0360c7e..e29f3453 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -4,6 +4,10 @@ #include #include +#ifdef Q_OS_WIN + #include +#endif + // #define BREAK_INFINITE_LOOP // #define BREAK_EXCEPTION // #define BREAK_RETURN @@ -29,7 +33,19 @@ int main(int argc, char *argv[]) #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + #ifdef Q_OS_WIN + BOOL (__stdcall *pFn)(void); + HINSTANCE hInstance=LoadLibrary("user32.dll"); + if(hInstance) { + pFn = (BOOL (__stdcall*)(void))GetProcAddress(hInstance, "SetProcessDPIAware"); + if(pFn) + pFn(); + FreeLibrary(hInstance); + } + QApplication::setAttribute(Qt::AA_DisableHighDpiScaling); + #else + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + #endif QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif From 8e6400e8d8c3a2ec1b734c4405b27dd2b547a835 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Fri, 26 Mar 2021 20:03:57 +0000 Subject: [PATCH 09/13] NOISSUE Fix edgecase where new searches won't be processed This resolves an issue with the modpacks.ch search functionality, in which a search issued while one is currently in progress won't be made and the UI won't allow for the search to be made after. Reproduction Steps: 1. Open the FTB pane in the Add Instance Dialog 2. Perform a search while MMC is still performing the initial search The search won't be performed, the existing search will have been aborted, and you are unable to try the search again (without trying a different search in the meantime). This was caused by 2 things: 1. A search cannot be re-attempted, and this logic doesn't consider failures. 2. The failure slot wasn't called when the NetJob was aborted, so the search would never be performed - but the term would be stored as if it had (trigering point 1). I have resolved this by doing 2 things: 1. If the failure slot is called, set a searchState of Failed. Allow search re-attempts in this case. 2. If there is a present NetJob, abort and reset it. The immediately continue with the search. --- .../pages/modplatform/ftb/FtbListModel.cpp | 29 +++++++------------ .../pages/modplatform/ftb/FtbListModel.h | 3 +- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/application/pages/modplatform/ftb/FtbListModel.cpp b/application/pages/modplatform/ftb/FtbListModel.cpp index 63236827..98973f2e 100644 --- a/application/pages/modplatform/ftb/FtbListModel.cpp +++ b/application/pages/modplatform/ftb/FtbListModel.cpp @@ -106,21 +106,22 @@ void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallbac void ListModel::searchWithTerm(const QString &term) { - if(currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull()) { + if(searchState != Failed && currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull()) { + // unless the search has failed, then there is no need to perform an identical search. return; } currentSearchTerm = term; + if(jobPtr) { jobPtr->abort(); - searchState = ResetRequested; - return; - } - else { - beginResetModel(); - modpacks.clear(); - endResetModel(); - searchState = None; + jobPtr.reset(); } + + beginResetModel(); + modpacks.clear(); + endResetModel(); + searchState = None; + performSearch(); } @@ -154,15 +155,7 @@ void ListModel::searchRequestFailed(QString reason) jobPtr.reset(); remainingPacks.clear(); - if(searchState == ResetRequested) { - beginResetModel(); - modpacks.clear(); - endResetModel(); - - performSearch(); - } else { - searchState = Finished; - } + searchState = Failed; } void ListModel::requestPack() diff --git a/application/pages/modplatform/ftb/FtbListModel.h b/application/pages/modplatform/ftb/FtbListModel.h index 9c057d73..de94e6ba 100644 --- a/application/pages/modplatform/ftb/FtbListModel.h +++ b/application/pages/modplatform/ftb/FtbListModel.h @@ -57,7 +57,8 @@ private: None, CanPossiblyFetchMore, ResetRequested, - Finished + Finished, + Failed, } searchState = None; NetJobPtr jobPtr; int currentPack; From 43cf647642e448eab755c2df310d0b029ac66b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 28 Mar 2021 19:46:01 +0200 Subject: [PATCH 10/13] Revert "GH-3666 Fix multi-monitor dpi scaling on windows" This reverts commit 34bf68847998cdfff1360d6ed04339d36894c00d. --- application/main.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/application/main.cpp b/application/main.cpp index e29f3453..b0360c7e 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -4,10 +4,6 @@ #include #include -#ifdef Q_OS_WIN - #include -#endif - // #define BREAK_INFINITE_LOOP // #define BREAK_EXCEPTION // #define BREAK_RETURN @@ -33,19 +29,7 @@ int main(int argc, char *argv[]) #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - #ifdef Q_OS_WIN - BOOL (__stdcall *pFn)(void); - HINSTANCE hInstance=LoadLibrary("user32.dll"); - if(hInstance) { - pFn = (BOOL (__stdcall*)(void))GetProcAddress(hInstance, "SetProcessDPIAware"); - if(pFn) - pFn(); - FreeLibrary(hInstance); - } - QApplication::setAttribute(Qt::AA_DisableHighDpiScaling); - #else - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - #endif + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif From 094ed0bc81562606e2eff151d12205b64c2c284e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 29 Mar 2021 21:51:28 +0200 Subject: [PATCH 11/13] NOISSUE fix build issue with QJsonValueRef on macOS 11 This will remove support for macOS 10.7 and 10.8, but their numbers in analytics are 0 --- api/logic/modplatform/flame/PackManifest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/logic/modplatform/flame/PackManifest.cpp b/api/logic/modplatform/flame/PackManifest.cpp index 1db0a161..b928fd16 100644 --- a/api/logic/modplatform/flame/PackManifest.cpp +++ b/api/logic/modplatform/flame/PackManifest.cpp @@ -21,7 +21,7 @@ static void loadMinecraftV1(Flame::Minecraft & m, QJsonObject & minecraft) // intended use is likely hardcoded in the 'Flame' client, the manifest says nothing m.libraries = Json::ensureString(minecraft, QString("libraries"), QString()); auto arr = Json::ensureArray(minecraft, "modLoaders", QJsonArray()); - for (const auto & item : arr) + for (QJsonValueRef item : arr) { auto obj = Json::requireObject(item); Flame::Modloader loader; @@ -38,7 +38,7 @@ static void loadManifestV1(Flame::Manifest & m, QJsonObject & manifest) m.version = Json::ensureString(manifest, QString("version"), QString()); m.author = Json::ensureString(manifest, QString("author"), "Anonymous Coward"); auto arr = Json::ensureArray(manifest, "files", QJsonArray()); - for (const auto & item : arr) + for (QJsonValueRef item : arr) { auto obj = Json::requireObject(item); Flame::File file; From fbe9d158754bcdd12aa8889639bdbac4c125f1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 29 Mar 2021 22:03:52 +0200 Subject: [PATCH 12/13] NOISSUE fix it some more in different file --- api/logic/modplatform/modpacksch/FTBPackManifest.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/logic/modplatform/modpacksch/FTBPackManifest.cpp b/api/logic/modplatform/modpacksch/FTBPackManifest.cpp index 35626cb8..fd99d332 100644 --- a/api/logic/modplatform/modpacksch/FTBPackManifest.cpp +++ b/api/logic/modplatform/modpacksch/FTBPackManifest.cpp @@ -60,7 +60,7 @@ void ModpacksCH::loadModpack(ModpacksCH::Modpack & m, QJsonObject & obj) m.updated = Json::requireInteger(obj, "updated"); m.refreshed = Json::requireInteger(obj, "refreshed"); auto artArr = Json::requireArray(obj, "art"); - for (const auto & artRaw : artArr) + for (QJsonValueRef artRaw : artArr) { auto artObj = Json::requireObject(artRaw); ModpacksCH::Art art; @@ -68,7 +68,7 @@ void ModpacksCH::loadModpack(ModpacksCH::Modpack & m, QJsonObject & obj) m.art.append(art); } auto authorArr = Json::requireArray(obj, "authors"); - for (const auto & authorRaw : authorArr) + for (QJsonValueRef authorRaw : authorArr) { auto authorObj = Json::requireObject(authorRaw); ModpacksCH::Author author; @@ -76,7 +76,7 @@ void ModpacksCH::loadModpack(ModpacksCH::Modpack & m, QJsonObject & obj) m.authors.append(author); } auto versionArr = Json::requireArray(obj, "versions"); - for (const auto & versionRaw : versionArr) + for (QJsonValueRef versionRaw : versionArr) { auto versionObj = Json::requireObject(versionRaw); ModpacksCH::VersionInfo version; @@ -84,7 +84,7 @@ void ModpacksCH::loadModpack(ModpacksCH::Modpack & m, QJsonObject & obj) m.versions.append(version); } auto tagArr = Json::requireArray(obj, "tags"); - for (const auto & tagRaw : tagArr) + for (QJsonValueRef tagRaw : tagArr) { auto tagObj = Json::requireObject(tagRaw); ModpacksCH::Tag tag; @@ -132,7 +132,7 @@ void ModpacksCH::loadVersion(ModpacksCH::Version & m, QJsonObject & obj) auto specs = Json::requireObject(obj, "specs"); loadSpecs(m.specs, specs); auto targetArr = Json::requireArray(obj, "targets"); - for (const auto & targetRaw : targetArr) + for (QJsonValueRef targetRaw : targetArr) { auto versionObj = Json::requireObject(targetRaw); ModpacksCH::VersionTarget target; @@ -140,7 +140,7 @@ void ModpacksCH::loadVersion(ModpacksCH::Version & m, QJsonObject & obj) m.targets.append(target); } auto fileArr = Json::requireArray(obj, "files"); - for (const auto & fileRaw : fileArr) + for (QJsonValueRef fileRaw : fileArr) { auto fileObj = Json::requireObject(fileRaw); ModpacksCH::VersionFile file; From 7246d8a77906d421de4eada95d90843b1b94326b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 1 Apr 2021 03:50:28 +0200 Subject: [PATCH 13/13] NOISSUE improve GradleSpecifier and handle broken library names --- api/logic/minecraft/GradleSpecifier.h | 42 ++++++++++++-------- api/logic/minecraft/GradleSpecifier_test.cpp | 5 ++- api/logic/minecraft/Library.cpp | 8 ++-- api/logic/minecraft/Library_test.cpp | 3 +- api/logic/minecraft/MojangVersionFormat.cpp | 12 ++++-- api/logic/minecraft/MojangVersionFormat.h | 3 +- api/logic/minecraft/OneSixVersionFormat.cpp | 34 +++++++++------- api/logic/minecraft/OneSixVersionFormat.h | 9 +++-- 8 files changed, 68 insertions(+), 48 deletions(-) diff --git a/api/logic/minecraft/GradleSpecifier.h b/api/logic/minecraft/GradleSpecifier.h index 959325c6..60e0a726 100644 --- a/api/logic/minecraft/GradleSpecifier.h +++ b/api/logic/minecraft/GradleSpecifier.h @@ -18,32 +18,35 @@ struct GradleSpecifier { /* org.gradle.test.classifiers : service : 1.0 : jdk15 @ jar - DEBUG 0 "org.gradle.test.classifiers:service:1.0:jdk15@jar" - DEBUG 1 "org.gradle.test.classifiers" - DEBUG 2 "service" - DEBUG 3 "1.0" - DEBUG 4 ":jdk15" - DEBUG 5 "jdk15" - DEBUG 6 "@jar" - DEBUG 7 "jar" + 0 "org.gradle.test.classifiers:service:1.0:jdk15@jar" + 1 "org.gradle.test.classifiers" + 2 "service" + 3 "1.0" + 4 "jdk15" + 5 "jar" */ - QRegExp matcher("([^:@]+):([^:@]+):([^:@]+)" "(:([^:@]+))?" "(@([^:@]+))?"); + QRegExp matcher("([^:@]+):([^:@]+):([^:@]+)" "(?::([^:@]+))?" "(?:@([^:@]+))?"); m_valid = matcher.exactMatch(value); + if(!m_valid) { + m_invalidValue = value; + return *this; + } auto elements = matcher.capturedTexts(); m_groupId = elements[1]; m_artifactId = elements[2]; m_version = elements[3]; - m_classifier = elements[5]; - if(!elements[7].isEmpty()) + m_classifier = elements[4]; + if(!elements[5].isEmpty()) { - m_extension = elements[7]; + m_extension = elements[5]; } return *this; } - operator QString() const + QString serialize() const { - if(!m_valid) - return "INVALID"; + if(!m_valid) { + return m_invalidValue; + } QString retval = m_groupId + ":" + m_artifactId + ":" + m_version; if(!m_classifier.isEmpty()) { @@ -57,6 +60,9 @@ struct GradleSpecifier } QString getFileName() const { + if(!m_valid) { + return QString(); + } QString filename = m_artifactId + '-' + m_version; if(!m_classifier.isEmpty()) { @@ -67,8 +73,9 @@ struct GradleSpecifier } QString toPath(const QString & filenameOverride = QString()) const { - if(!m_valid) - return "INVALID"; + if(!m_valid) { + return QString(); + } QString filename; if(filenameOverride.isEmpty()) { @@ -134,6 +141,7 @@ struct GradleSpecifier return true; } private: + QString m_invalidValue; QString m_groupId; QString m_artifactId; QString m_version; diff --git a/api/logic/minecraft/GradleSpecifier_test.cpp b/api/logic/minecraft/GradleSpecifier_test.cpp index f49ec718..0900c9d8 100644 --- a/api/logic/minecraft/GradleSpecifier_test.cpp +++ b/api/logic/minecraft/GradleSpecifier_test.cpp @@ -31,7 +31,7 @@ slots: { QFETCH(QString, through); - QString converted = GradleSpecifier(through); + QString converted = GradleSpecifier(through).serialize(); QCOMPARE(converted, through); } @@ -68,7 +68,8 @@ slots: GradleSpecifier spec(input); QVERIFY(!spec.valid()); - QCOMPARE(spec.operator QString(), QString("INVALID")); + QCOMPARE(spec.serialize(), input); + QCOMPARE(spec.toPath(), QString()); } }; diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp index b3c7657c..f2293679 100644 --- a/api/logic/minecraft/Library.cpp +++ b/api/logic/minecraft/Library.cpp @@ -94,13 +94,13 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads( auto rawSha1 = QByteArray::fromHex(sha1.toLatin1()); auto dl = Net::Download::makeCached(url, entry, options); dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1)); - qDebug() << "Checksummed Download for:" << rawName() << "storage:" << storage << "url:" << url; + qDebug() << "Checksummed Download for:" << rawName().serialize() << "storage:" << storage << "url:" << url; out.append(dl); } else { out.append(Net::Download::makeCached(url, entry, options)); - qDebug() << "Download for:" << rawName() << "storage:" << storage << "url:" << url; + qDebug() << "Download for:" << rawName().serialize() << "storage:" << storage << "url:" << url; } return true; }; @@ -145,7 +145,7 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads( } else { - qDebug() << "Ignoring native library" << m_name << "because it has no classifier for current OS"; + qDebug() << "Ignoring native library" << m_name.serialize() << "because it has no classifier for current OS"; } } else @@ -157,7 +157,7 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads( } else { - qDebug() << "Ignoring java library" << m_name << "because it has no artifact"; + qDebug() << "Ignoring java library" << m_name.serialize() << "because it has no artifact"; } } } diff --git a/api/logic/minecraft/Library_test.cpp b/api/logic/minecraft/Library_test.cpp index c3d6150d..75bb4db1 100644 --- a/api/logic/minecraft/Library_test.cpp +++ b/api/logic/minecraft/Library_test.cpp @@ -18,7 +18,8 @@ private: jsonFile.open(QIODevice::ReadOnly); auto data = jsonFile.readAll(); jsonFile.close(); - return MojangVersionFormat::libraryFromJson(QJsonDocument::fromJson(data).object(), file); + ProblemContainer problems; + return MojangVersionFormat::libraryFromJson(problems, QJsonDocument::fromJson(data).object(), file); } // get absolute path to expected storage, assuming default cache prefix QStringList getStorage(QString relative) diff --git a/api/logic/minecraft/MojangVersionFormat.cpp b/api/logic/minecraft/MojangVersionFormat.cpp index 33d3c54c..f9cb2228 100644 --- a/api/logic/minecraft/MojangVersionFormat.cpp +++ b/api/logic/minecraft/MojangVersionFormat.cpp @@ -220,7 +220,7 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc { auto libObj = requireObject(libVal); - auto lib = MojangVersionFormat::libraryFromJson(libObj, filename); + auto lib = MojangVersionFormat::libraryFromJson(*out, libObj, filename); out->libraries.append(lib); } } @@ -283,14 +283,18 @@ QJsonDocument MojangVersionFormat::versionFileToJson(const VersionFilePtr &patch } } -LibraryPtr MojangVersionFormat::libraryFromJson(const QJsonObject &libObj, const QString &filename) +LibraryPtr MojangVersionFormat::libraryFromJson(ProblemContainer & problems, const QJsonObject &libObj, const QString &filename) { LibraryPtr out(new Library()); if (!libObj.contains("name")) { throw JSONValidationError(filename + "contains a library that doesn't have a 'name' field"); } - out->m_name = libObj.value("name").toString(); + auto rawName = libObj.value("name").toString(); + out->m_name = rawName; + if(!out->m_name.valid()) { + problems.addProblem(ProblemSeverity::Error, QObject::tr("Library %1 name is broken and cannot be processed.").arg(rawName)); + } Bits::readString(libObj, "url", out->m_repositoryURL); if (libObj.contains("extract")) @@ -333,7 +337,7 @@ LibraryPtr MojangVersionFormat::libraryFromJson(const QJsonObject &libObj, const QJsonObject MojangVersionFormat::libraryToJson(Library *library) { QJsonObject libRoot; - libRoot.insert("name", (QString)library->m_name); + libRoot.insert("name", library->m_name.serialize()); if (!library->m_repositoryURL.isEmpty()) { libRoot.insert("url", library->m_repositoryURL); diff --git a/api/logic/minecraft/MojangVersionFormat.h b/api/logic/minecraft/MojangVersionFormat.h index 76c529e9..2871dae4 100644 --- a/api/logic/minecraft/MojangVersionFormat.h +++ b/api/logic/minecraft/MojangVersionFormat.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "multimc_logic_export.h" @@ -20,6 +21,6 @@ public: static QJsonDocument versionFileToJson(const VersionFilePtr &patch); // libraries - static LibraryPtr libraryFromJson(const QJsonObject &libObj, const QString &filename); + static LibraryPtr libraryFromJson(ProblemContainer & problems, const QJsonObject &libObj, const QString &filename); static QJsonObject libraryToJson(Library *library); }; diff --git a/api/logic/minecraft/OneSixVersionFormat.cpp b/api/logic/minecraft/OneSixVersionFormat.cpp index 7ac9e2db..d6aaa790 100644 --- a/api/logic/minecraft/OneSixVersionFormat.cpp +++ b/api/logic/minecraft/OneSixVersionFormat.cpp @@ -13,9 +13,9 @@ static void readString(const QJsonObject &root, const QString &key, QString &var } } -LibraryPtr OneSixVersionFormat::libraryFromJson(const QJsonObject &libObj, const QString &filename) +LibraryPtr OneSixVersionFormat::libraryFromJson(ProblemContainer & problems, const QJsonObject &libObj, const QString &filename) { - LibraryPtr out = MojangVersionFormat::libraryFromJson(libObj, filename); + LibraryPtr out = MojangVersionFormat::libraryFromJson(problems, libObj, filename); readString(libObj, "MMC-hint", out->m_hint); readString(libObj, "MMC-absulute_url", out->m_absoluteURL); readString(libObj, "MMC-absoluteUrl", out->m_absoluteURL); @@ -115,7 +115,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc { QJsonObject libObj = requireObject(libVal); // parse the jarmod - auto lib = OneSixVersionFormat::jarModFromJson(libObj, filename); + auto lib = OneSixVersionFormat::jarModFromJson(*out, libObj, filename); // and add to jar mods out->jarMods.append(lib); } @@ -126,7 +126,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc { QJsonObject libObj = requireObject(libVal); // parse the jarmod - auto lib = OneSixVersionFormat::plusJarModFromJson(libObj, filename, out->name); + auto lib = OneSixVersionFormat::plusJarModFromJson(*out, libObj, filename, out->name); // and add to jar mods out->jarMods.append(lib); } @@ -138,20 +138,20 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc { QJsonObject libObj = requireObject(libVal); // parse the jarmod - auto lib = OneSixVersionFormat::modFromJson(libObj, filename); + auto lib = OneSixVersionFormat::modFromJson(*out, libObj, filename); // and add to jar mods out->mods.append(lib); } } - auto readLibs = [&](const char * which, QList & out) + auto readLibs = [&](const char * which, QList & outList) { for (auto libVal : requireArray(root.value(which))) { QJsonObject libObj = requireObject(libVal); // parse the library - auto lib = libraryFromJson(libObj, filename); - out.append(lib); + auto lib = libraryFromJson(*out, libObj, filename); + outList.append(lib); } }; bool hasPlusLibs = root.contains("+libraries"); @@ -180,7 +180,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc if(root.contains("mainJar")) { QJsonObject libObj = requireObject(root, "mainJar"); - out->mainJar = libraryFromJson(libObj, filename); + out->mainJar = libraryFromJson(*out, libObj, filename); } // else reconstruct it from downloads and id ... if that's available else if(!out->minecraftVersion.isEmpty()) @@ -330,8 +330,12 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch } } -LibraryPtr OneSixVersionFormat::plusJarModFromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName) -{ +LibraryPtr OneSixVersionFormat::plusJarModFromJson( + ProblemContainer & problems, + const QJsonObject &libObj, + const QString &filename, + const QString &originalName +) { LibraryPtr out(new Library()); if (!libObj.contains("name")) { @@ -366,9 +370,9 @@ LibraryPtr OneSixVersionFormat::plusJarModFromJson(const QJsonObject &libObj, co return out; } -LibraryPtr OneSixVersionFormat::jarModFromJson(const QJsonObject& libObj, const QString& filename) +LibraryPtr OneSixVersionFormat::jarModFromJson(ProblemContainer & problems, const QJsonObject& libObj, const QString& filename) { - return libraryFromJson(libObj, filename); + return libraryFromJson(problems, libObj, filename); } @@ -377,9 +381,9 @@ QJsonObject OneSixVersionFormat::jarModtoJson(Library *jarmod) return libraryToJson(jarmod); } -LibraryPtr OneSixVersionFormat::modFromJson(const QJsonObject& libObj, const QString& filename) +LibraryPtr OneSixVersionFormat::modFromJson(ProblemContainer & problems, const QJsonObject& libObj, const QString& filename) { - return libraryFromJson(libObj, filename); + return libraryFromJson(problems, libObj, filename); } QJsonObject OneSixVersionFormat::modtoJson(Library *jarmod) diff --git a/api/logic/minecraft/OneSixVersionFormat.h b/api/logic/minecraft/OneSixVersionFormat.h index 14ae385c..1a091d88 100644 --- a/api/logic/minecraft/OneSixVersionFormat.h +++ b/api/logic/minecraft/OneSixVersionFormat.h @@ -4,6 +4,7 @@ #include #include #include +#include class OneSixVersionFormat { @@ -13,17 +14,17 @@ public: static QJsonDocument versionFileToJson(const VersionFilePtr &patch); // libraries - static LibraryPtr libraryFromJson(const QJsonObject &libObj, const QString &filename); + static LibraryPtr libraryFromJson(ProblemContainer & problems, const QJsonObject &libObj, const QString &filename); static QJsonObject libraryToJson(Library *library); // DEPRECATED: old 'plus' jar mods generated by the application - static LibraryPtr plusJarModFromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName); + static LibraryPtr plusJarModFromJson(ProblemContainer & problems, const QJsonObject &libObj, const QString &filename, const QString &originalName); // new jar mods derived from libraries - static LibraryPtr jarModFromJson(const QJsonObject &libObj, const QString &filename); + static LibraryPtr jarModFromJson(ProblemContainer & problems, const QJsonObject &libObj, const QString &filename); static QJsonObject jarModtoJson(Library * jarmod); // mods, also derived from libraries - static LibraryPtr modFromJson(const QJsonObject &libObj, const QString &filename); + static LibraryPtr modFromJson(ProblemContainer & problems, const QJsonObject &libObj, const QString &filename); static QJsonObject modtoJson(Library * jarmod); };