From c6c9feb3a2006f0b37736799f003a0fb87f68b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 21 Aug 2020 02:40:19 +0200 Subject: NOISSUE attempt to fix build on macOS --- api/logic/CMakeLists.txt | 8 +- .../modplatform/modpacksch/FTBPackInstallTask.cpp | 150 ++++++++++++++++++++ .../modplatform/modpacksch/FTBPackInstallTask.h | 41 ++++++ .../modplatform/modpacksch/FTBPackManifest.cpp | 156 +++++++++++++++++++++ api/logic/modplatform/modpacksch/FTBPackManifest.h | 127 +++++++++++++++++ .../modplatform/modpacksch/PackInstallTask.cpp | 150 -------------------- api/logic/modplatform/modpacksch/PackInstallTask.h | 41 ------ api/logic/modplatform/modpacksch/PackManifest.cpp | 156 --------------------- api/logic/modplatform/modpacksch/PackManifest.h | 127 ----------------- application/pages/modplatform/ftb/FtbModel.h | 2 +- application/pages/modplatform/ftb/FtbPage.cpp | 2 +- 11 files changed, 480 insertions(+), 480 deletions(-) create mode 100644 api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp create mode 100644 api/logic/modplatform/modpacksch/FTBPackInstallTask.h create mode 100644 api/logic/modplatform/modpacksch/FTBPackManifest.cpp create mode 100644 api/logic/modplatform/modpacksch/FTBPackManifest.h delete mode 100644 api/logic/modplatform/modpacksch/PackInstallTask.cpp delete mode 100644 api/logic/modplatform/modpacksch/PackInstallTask.h delete mode 100644 api/logic/modplatform/modpacksch/PackManifest.cpp delete mode 100644 api/logic/modplatform/modpacksch/PackManifest.h diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt index 2a1e51fc..740cd886 100644 --- a/api/logic/CMakeLists.txt +++ b/api/logic/CMakeLists.txt @@ -452,10 +452,10 @@ set(FLAME_SOURCES ) set(MODPACKSCH_SOURCES - modplatform/modpacksch/PackInstallTask.h - modplatform/modpacksch/PackInstallTask.cpp - modplatform/modpacksch/PackManifest.h - modplatform/modpacksch/PackManifest.cpp + modplatform/modpacksch/FTBPackInstallTask.h + modplatform/modpacksch/FTBPackInstallTask.cpp + modplatform/modpacksch/FTBPackManifest.h + modplatform/modpacksch/FTBPackManifest.cpp ) add_unit_test(Index diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp new file mode 100644 index 00000000..fdfe560a --- /dev/null +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -0,0 +1,150 @@ +#include "FTBPackInstallTask.h" + +#include "BuildConfig.h" +#include "FileSystem.h" +#include "Json.h" +#include "minecraft/MinecraftInstance.h" +#include "minecraft/PackProfile.h" +#include "settings/INISettingsObject.h" + +namespace ModpacksCH { + +PackInstallTask::PackInstallTask(Modpack pack, QString version) +{ + m_pack = pack; + m_version_name = version; +} + +bool PackInstallTask::abort() +{ + return true; +} + +void PackInstallTask::executeTask() +{ + // Find pack version + bool found = false; + VersionInfo version; + + for(auto vInfo : m_pack.versions) { + if (vInfo.name == m_version_name) { + found = true; + version = vInfo; + continue; + } + } + + if(!found) { + emitFailed("failed to find pack version " + m_version_name); + return; + } + + auto *netJob = new NetJob("ModpacksCH::VersionFetch"); + auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/%1/%2") + .arg(m_pack.id).arg(version.id); + netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); + jobPtr = netJob; + jobPtr->start(); + + QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded); + QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed); +} + +void PackInstallTask::onDownloadSucceeded() +{ + 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 FTB at " << parse_error.offset << " reason: " << parse_error.errorString(); + qWarning() << response; + return; + } + + auto obj = doc.object(); + + ModpacksCH::Version version; + try + { + ModpacksCH::loadVersion(version, obj); + } + catch (const JSONValidationError &e) + { + emitFailed(tr("Could not understand pack manifest:\n") + e.cause()); + return; + } + m_version = version; + + install(); +} + +void PackInstallTask::onDownloadFailed(QString reason) +{ + jobPtr.reset(); + emitFailed(reason); +} + +void PackInstallTask::install() +{ + setStatus(tr("Installing modpack")); + + auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg"); + auto instanceSettings = std::make_shared(instanceConfigPath); + instanceSettings->registerSetting("InstanceType", "Legacy"); + instanceSettings->set("InstanceType", "OneSix"); + + MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath); + auto components = instance.getPackProfile(); + components->buildingFromScratch(); + + for(auto target : m_version.targets) { + if(target.type == "game" && target.name == "minecraft") { + components->setComponentVersion("net.minecraft", target.version, true); + continue; + } + } + + for(auto target : m_version.targets) { + if(target.type == "modloader" && target.name == "forge") { + components->setComponentVersion("net.minecraftforge", target.version, true); + } + } + components->saveNow(); + + jobPtr.reset(new NetJob(tr("Mod download"))); + for(auto file : m_version.files) { + if(file.serverOnly) continue; + + auto relpath = FS::PathCombine("minecraft", file.path, file.name); + auto path = FS::PathCombine(m_stagingPath , relpath); + + qDebug() << "Will download" << file.url << "to" << path; + auto dl = Net::Download::makeFile(file.url, path); + jobPtr->addNetAction(dl); + } + connect(jobPtr.get(), &NetJob::succeeded, this, [&]() + { + jobPtr.reset(); + emitSucceeded(); + }); + + connect(jobPtr.get(), &NetJob::failed, [&](QString reason) + { + jobPtr.reset(); + emitFailed(reason); + }); + connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total) + { + setProgress(current, total); + }); + + setStatus(tr("Downloading mods...")); + jobPtr->start(); + + instance.setName(m_instName); + instance.setIconKey(m_instIcon); + instanceSettings->resumeSave(); +} + +} diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.h b/api/logic/modplatform/modpacksch/FTBPackInstallTask.h new file mode 100644 index 00000000..c5a80751 --- /dev/null +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.h @@ -0,0 +1,41 @@ +#pragma once + +#include "FTBPackManifest.h" + +#include "InstanceTask.h" +#include "multimc_logic_export.h" +#include "net/NetJob.h" + +namespace ModpacksCH { + +class MULTIMC_LOGIC_EXPORT PackInstallTask : public InstanceTask +{ + Q_OBJECT + +public: + explicit PackInstallTask(Modpack pack, QString version); + virtual ~PackInstallTask(){} + + bool abort() override; + +protected: + virtual void executeTask() override; + +private slots: + void onDownloadSucceeded(); + void onDownloadFailed(QString reason); + +private: + void install(); + +private: + NetJobPtr jobPtr; + QByteArray response; + + Modpack m_pack; + QString m_version_name; + Version m_version; + +}; + +} diff --git a/api/logic/modplatform/modpacksch/FTBPackManifest.cpp b/api/logic/modplatform/modpacksch/FTBPackManifest.cpp new file mode 100644 index 00000000..35626cb8 --- /dev/null +++ b/api/logic/modplatform/modpacksch/FTBPackManifest.cpp @@ -0,0 +1,156 @@ +#include "FTBPackManifest.h" + +#include "Json.h" + +static void loadSpecs(ModpacksCH::Specs & s, QJsonObject & obj) +{ + s.id = Json::requireInteger(obj, "id"); + s.minimum = Json::requireInteger(obj, "minimum"); + s.recommended = Json::requireInteger(obj, "recommended"); +} + +static void loadTag(ModpacksCH::Tag & t, QJsonObject & obj) +{ + t.id = Json::requireInteger(obj, "id"); + t.name = Json::requireString(obj, "name"); +} + +static void loadArt(ModpacksCH::Art & a, QJsonObject & obj) +{ + a.id = Json::requireInteger(obj, "id"); + a.url = Json::requireString(obj, "url"); + a.type = Json::requireString(obj, "type"); + a.width = Json::requireInteger(obj, "width"); + a.height = Json::requireInteger(obj, "height"); + a.compressed = Json::requireBoolean(obj, "compressed"); + a.sha1 = Json::requireString(obj, "sha1"); + a.size = Json::requireInteger(obj, "size"); + a.updated = Json::requireInteger(obj, "updated"); +} + +static void loadAuthor(ModpacksCH::Author & a, QJsonObject & obj) +{ + a.id = Json::requireInteger(obj, "id"); + a.name = Json::requireString(obj, "name"); + a.type = Json::requireString(obj, "type"); + a.website = Json::requireString(obj, "website"); + a.updated = Json::requireInteger(obj, "updated"); +} + +static void loadVersionInfo(ModpacksCH::VersionInfo & v, QJsonObject & obj) +{ + v.id = Json::requireInteger(obj, "id"); + v.name = Json::requireString(obj, "name"); + v.type = Json::requireString(obj, "type"); + v.updated = Json::requireInteger(obj, "updated"); + auto specs = Json::requireObject(obj, "specs"); + loadSpecs(v.specs, specs); +} + +void ModpacksCH::loadModpack(ModpacksCH::Modpack & m, QJsonObject & obj) +{ + m.id = Json::requireInteger(obj, "id"); + m.name = Json::requireString(obj, "name"); + m.synopsis = Json::requireString(obj, "synopsis"); + m.description = Json::requireString(obj, "description"); + m.type = Json::requireString(obj, "type"); + m.featured = Json::requireBoolean(obj, "featured"); + m.installs = Json::requireInteger(obj, "installs"); + m.plays = Json::requireInteger(obj, "plays"); + m.updated = Json::requireInteger(obj, "updated"); + m.refreshed = Json::requireInteger(obj, "refreshed"); + auto artArr = Json::requireArray(obj, "art"); + for (const auto & artRaw : artArr) + { + auto artObj = Json::requireObject(artRaw); + ModpacksCH::Art art; + loadArt(art, artObj); + m.art.append(art); + } + auto authorArr = Json::requireArray(obj, "authors"); + for (const auto & authorRaw : authorArr) + { + auto authorObj = Json::requireObject(authorRaw); + ModpacksCH::Author author; + loadAuthor(author, authorObj); + m.authors.append(author); + } + auto versionArr = Json::requireArray(obj, "versions"); + for (const auto & versionRaw : versionArr) + { + auto versionObj = Json::requireObject(versionRaw); + ModpacksCH::VersionInfo version; + loadVersionInfo(version, versionObj); + m.versions.append(version); + } + auto tagArr = Json::requireArray(obj, "tags"); + for (const auto & tagRaw : tagArr) + { + auto tagObj = Json::requireObject(tagRaw); + ModpacksCH::Tag tag; + loadTag(tag, tagObj); + m.tags.append(tag); + } + m.updated = Json::requireInteger(obj, "updated"); +} + +static void loadVersionTarget(ModpacksCH::VersionTarget & a, QJsonObject & obj) +{ + a.id = Json::requireInteger(obj, "id"); + a.name = Json::requireString(obj, "name"); + a.type = Json::requireString(obj, "type"); + a.version = Json::requireString(obj, "version"); + a.updated = Json::requireInteger(obj, "updated"); +} + +static void loadVersionFile(ModpacksCH::VersionFile & a, QJsonObject & obj) +{ + a.id = Json::requireInteger(obj, "id"); + a.type = Json::requireString(obj, "type"); + a.path = Json::requireString(obj, "path"); + a.name = Json::requireString(obj, "name"); + a.version = Json::requireString(obj, "version"); + a.url = Json::requireString(obj, "url"); + a.sha1 = Json::requireString(obj, "sha1"); + a.size = Json::requireInteger(obj, "size"); + a.clientOnly = Json::requireBoolean(obj, "clientonly"); + a.serverOnly = Json::requireBoolean(obj, "serveronly"); + a.optional = Json::requireBoolean(obj, "optional"); + a.updated = Json::requireInteger(obj, "updated"); +} + +void ModpacksCH::loadVersion(ModpacksCH::Version & m, QJsonObject & obj) +{ + m.id = Json::requireInteger(obj, "id"); + m.parent = Json::requireInteger(obj, "parent"); + m.name = Json::requireString(obj, "name"); + m.type = Json::requireString(obj, "type"); + m.installs = Json::requireInteger(obj, "installs"); + m.plays = Json::requireInteger(obj, "plays"); + m.updated = Json::requireInteger(obj, "updated"); + m.refreshed = Json::requireInteger(obj, "refreshed"); + auto specs = Json::requireObject(obj, "specs"); + loadSpecs(m.specs, specs); + auto targetArr = Json::requireArray(obj, "targets"); + for (const auto & targetRaw : targetArr) + { + auto versionObj = Json::requireObject(targetRaw); + ModpacksCH::VersionTarget target; + loadVersionTarget(target, versionObj); + m.targets.append(target); + } + auto fileArr = Json::requireArray(obj, "files"); + for (const auto & fileRaw : fileArr) + { + auto fileObj = Json::requireObject(fileRaw); + ModpacksCH::VersionFile file; + loadVersionFile(file, fileObj); + m.files.append(file); + } +} + +//static void loadVersionChangelog(ModpacksCH::VersionChangelog & m, QJsonObject & obj) +//{ +// m.content = Json::requireString(obj, "content"); +// m.updated = Json::requireInteger(obj, "updated"); +//} diff --git a/api/logic/modplatform/modpacksch/FTBPackManifest.h b/api/logic/modplatform/modpacksch/FTBPackManifest.h new file mode 100644 index 00000000..518fffbf --- /dev/null +++ b/api/logic/modplatform/modpacksch/FTBPackManifest.h @@ -0,0 +1,127 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "multimc_logic_export.h" + +namespace ModpacksCH +{ + +struct Specs +{ + int id; + int minimum; + int recommended; +}; + +struct Tag +{ + int id; + QString name; +}; + +struct Art +{ + int id; + QString url; + QString type; + int width; + int height; + bool compressed; + QString sha1; + int size; + int64_t updated; +}; + +struct Author +{ + int id; + QString name; + QString type; + QString website; + int64_t updated; +}; + +struct VersionInfo +{ + int id; + QString name; + QString type; + int64_t updated; + Specs specs; +}; + +struct Modpack +{ + int id; + QString name; + QString synopsis; + QString description; + QString type; + bool featured; + int installs; + int plays; + int64_t updated; + int64_t refreshed; + QVector art; + QVector authors; + QVector versions; + QVector tags; +}; + +struct VersionTarget +{ + int id; + QString type; + QString name; + QString version; + int64_t updated; +}; + +struct VersionFile +{ + int id; + QString type; + QString path; + QString name; + QString version; + QString url; + QString sha1; + int size; + bool clientOnly; + bool serverOnly; + bool optional; + int64_t updated; +}; + +struct Version +{ + int id; + int parent; + QString name; + QString type; + int installs; + int plays; + int64_t updated; + int64_t refreshed; + Specs specs; + QVector targets; + QVector files; +}; + +struct VersionChangelog +{ + QString content; + int64_t updated; +}; + +MULTIMC_LOGIC_EXPORT void loadModpack(Modpack & m, QJsonObject & obj); + +MULTIMC_LOGIC_EXPORT void loadVersion(Version & m, QJsonObject & obj); +} + +Q_DECLARE_METATYPE(ModpacksCH::Modpack) diff --git a/api/logic/modplatform/modpacksch/PackInstallTask.cpp b/api/logic/modplatform/modpacksch/PackInstallTask.cpp deleted file mode 100644 index f8572a4d..00000000 --- a/api/logic/modplatform/modpacksch/PackInstallTask.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "PackInstallTask.h" - -#include "BuildConfig.h" -#include "FileSystem.h" -#include "Json.h" -#include "minecraft/MinecraftInstance.h" -#include "minecraft/PackProfile.h" -#include "settings/INISettingsObject.h" - -namespace ModpacksCH { - -PackInstallTask::PackInstallTask(Modpack pack, QString version) -{ - m_pack = pack; - m_version_name = version; -} - -bool PackInstallTask::abort() -{ - return true; -} - -void PackInstallTask::executeTask() -{ - // Find pack version - bool found = false; - VersionInfo version; - - for(auto vInfo : m_pack.versions) { - if (vInfo.name == m_version_name) { - found = true; - version = vInfo; - continue; - } - } - - if(!found) { - emitFailed("failed to find pack version " + m_version_name); - return; - } - - auto *netJob = new NetJob("ModpacksCH::VersionFetch"); - auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/%1/%2") - .arg(m_pack.id).arg(version.id); - netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); - jobPtr = netJob; - jobPtr->start(); - - QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded); - QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed); -} - -void PackInstallTask::onDownloadSucceeded() -{ - 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 FTB at " << parse_error.offset << " reason: " << parse_error.errorString(); - qWarning() << response; - return; - } - - auto obj = doc.object(); - - ModpacksCH::Version version; - try - { - ModpacksCH::loadVersion(version, obj); - } - catch (const JSONValidationError &e) - { - emitFailed(tr("Could not understand pack manifest:\n") + e.cause()); - return; - } - m_version = version; - - install(); -} - -void PackInstallTask::onDownloadFailed(QString reason) -{ - jobPtr.reset(); - emitFailed(reason); -} - -void PackInstallTask::install() -{ - setStatus(tr("Installing modpack")); - - auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg"); - auto instanceSettings = std::make_shared(instanceConfigPath); - instanceSettings->registerSetting("InstanceType", "Legacy"); - instanceSettings->set("InstanceType", "OneSix"); - - MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath); - auto components = instance.getPackProfile(); - components->buildingFromScratch(); - - for(auto target : m_version.targets) { - if(target.type == "game" && target.name == "minecraft") { - components->setComponentVersion("net.minecraft", target.version, true); - continue; - } - } - - for(auto target : m_version.targets) { - if(target.type == "modloader" && target.name == "forge") { - components->setComponentVersion("net.minecraftforge", target.version, true); - } - } - components->saveNow(); - - jobPtr.reset(new NetJob(tr("Mod download"))); - for(auto file : m_version.files) { - if(file.serverOnly) continue; - - auto relpath = FS::PathCombine("minecraft", file.path, file.name); - auto path = FS::PathCombine(m_stagingPath , relpath); - - qDebug() << "Will download" << file.url << "to" << path; - auto dl = Net::Download::makeFile(file.url, path); - jobPtr->addNetAction(dl); - } - connect(jobPtr.get(), &NetJob::succeeded, this, [&]() - { - jobPtr.reset(); - emitSucceeded(); - }); - - connect(jobPtr.get(), &NetJob::failed, [&](QString reason) - { - jobPtr.reset(); - emitFailed(reason); - }); - connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total) - { - setProgress(current, total); - }); - - setStatus(tr("Downloading mods...")); - jobPtr->start(); - - instance.setName(m_instName); - instance.setIconKey(m_instIcon); - instanceSettings->resumeSave(); -} - -} diff --git a/api/logic/modplatform/modpacksch/PackInstallTask.h b/api/logic/modplatform/modpacksch/PackInstallTask.h deleted file mode 100644 index e5969dc8..00000000 --- a/api/logic/modplatform/modpacksch/PackInstallTask.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include "PackManifest.h" - -#include "InstanceTask.h" -#include "multimc_logic_export.h" -#include "net/NetJob.h" - -namespace ModpacksCH { - -class MULTIMC_LOGIC_EXPORT PackInstallTask : public InstanceTask -{ - Q_OBJECT - -public: - explicit PackInstallTask(Modpack pack, QString version); - virtual ~PackInstallTask(){} - - bool abort() override; - -protected: - virtual void executeTask() override; - -private slots: - void onDownloadSucceeded(); - void onDownloadFailed(QString reason); - -private: - void install(); - -private: - NetJobPtr jobPtr; - QByteArray response; - - Modpack m_pack; - QString m_version_name; - Version m_version; - -}; - -} diff --git a/api/logic/modplatform/modpacksch/PackManifest.cpp b/api/logic/modplatform/modpacksch/PackManifest.cpp deleted file mode 100644 index 5ffd18de..00000000 --- a/api/logic/modplatform/modpacksch/PackManifest.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include "PackManifest.h" - -#include "Json.h" - -static void loadSpecs(ModpacksCH::Specs & s, QJsonObject & obj) -{ - s.id = Json::requireInteger(obj, "id"); - s.minimum = Json::requireInteger(obj, "minimum"); - s.recommended = Json::requireInteger(obj, "recommended"); -} - -static void loadTag(ModpacksCH::Tag & t, QJsonObject & obj) -{ - t.id = Json::requireInteger(obj, "id"); - t.name = Json::requireString(obj, "name"); -} - -static void loadArt(ModpacksCH::Art & a, QJsonObject & obj) -{ - a.id = Json::requireInteger(obj, "id"); - a.url = Json::requireString(obj, "url"); - a.type = Json::requireString(obj, "type"); - a.width = Json::requireInteger(obj, "width"); - a.height = Json::requireInteger(obj, "height"); - a.compressed = Json::requireBoolean(obj, "compressed"); - a.sha1 = Json::requireString(obj, "sha1"); - a.size = Json::requireInteger(obj, "size"); - a.updated = Json::requireInteger(obj, "updated"); -} - -static void loadAuthor(ModpacksCH::Author & a, QJsonObject & obj) -{ - a.id = Json::requireInteger(obj, "id"); - a.name = Json::requireString(obj, "name"); - a.type = Json::requireString(obj, "type"); - a.website = Json::requireString(obj, "website"); - a.updated = Json::requireInteger(obj, "updated"); -} - -static void loadVersionInfo(ModpacksCH::VersionInfo & v, QJsonObject & obj) -{ - v.id = Json::requireInteger(obj, "id"); - v.name = Json::requireString(obj, "name"); - v.type = Json::requireString(obj, "type"); - v.updated = Json::requireInteger(obj, "updated"); - auto specs = Json::requireObject(obj, "specs"); - loadSpecs(v.specs, specs); -} - -void ModpacksCH::loadModpack(ModpacksCH::Modpack & m, QJsonObject & obj) -{ - m.id = Json::requireInteger(obj, "id"); - m.name = Json::requireString(obj, "name"); - m.synopsis = Json::requireString(obj, "synopsis"); - m.description = Json::requireString(obj, "description"); - m.type = Json::requireString(obj, "type"); - m.featured = Json::requireBoolean(obj, "featured"); - m.installs = Json::requireInteger(obj, "installs"); - m.plays = Json::requireInteger(obj, "plays"); - m.updated = Json::requireInteger(obj, "updated"); - m.refreshed = Json::requireInteger(obj, "refreshed"); - auto artArr = Json::requireArray(obj, "art"); - for (const auto & artRaw : artArr) - { - auto artObj = Json::requireObject(artRaw); - ModpacksCH::Art art; - loadArt(art, artObj); - m.art.append(art); - } - auto authorArr = Json::requireArray(obj, "authors"); - for (const auto & authorRaw : authorArr) - { - auto authorObj = Json::requireObject(authorRaw); - ModpacksCH::Author author; - loadAuthor(author, authorObj); - m.authors.append(author); - } - auto versionArr = Json::requireArray(obj, "versions"); - for (const auto & versionRaw : versionArr) - { - auto versionObj = Json::requireObject(versionRaw); - ModpacksCH::VersionInfo version; - loadVersionInfo(version, versionObj); - m.versions.append(version); - } - auto tagArr = Json::requireArray(obj, "tags"); - for (const auto & tagRaw : tagArr) - { - auto tagObj = Json::requireObject(tagRaw); - ModpacksCH::Tag tag; - loadTag(tag, tagObj); - m.tags.append(tag); - } - m.updated = Json::requireInteger(obj, "updated"); -} - -static void loadVersionTarget(ModpacksCH::VersionTarget & a, QJsonObject & obj) -{ - a.id = Json::requireInteger(obj, "id"); - a.name = Json::requireString(obj, "name"); - a.type = Json::requireString(obj, "type"); - a.version = Json::requireString(obj, "version"); - a.updated = Json::requireInteger(obj, "updated"); -} - -static void loadVersionFile(ModpacksCH::VersionFile & a, QJsonObject & obj) -{ - a.id = Json::requireInteger(obj, "id"); - a.type = Json::requireString(obj, "type"); - a.path = Json::requireString(obj, "path"); - a.name = Json::requireString(obj, "name"); - a.version = Json::requireString(obj, "version"); - a.url = Json::requireString(obj, "url"); - a.sha1 = Json::requireString(obj, "sha1"); - a.size = Json::requireInteger(obj, "size"); - a.clientOnly = Json::requireBoolean(obj, "clientonly"); - a.serverOnly = Json::requireBoolean(obj, "serveronly"); - a.optional = Json::requireBoolean(obj, "optional"); - a.updated = Json::requireInteger(obj, "updated"); -} - -void ModpacksCH::loadVersion(ModpacksCH::Version & m, QJsonObject & obj) -{ - m.id = Json::requireInteger(obj, "id"); - m.parent = Json::requireInteger(obj, "parent"); - m.name = Json::requireString(obj, "name"); - m.type = Json::requireString(obj, "type"); - m.installs = Json::requireInteger(obj, "installs"); - m.plays = Json::requireInteger(obj, "plays"); - m.updated = Json::requireInteger(obj, "updated"); - m.refreshed = Json::requireInteger(obj, "refreshed"); - auto specs = Json::requireObject(obj, "specs"); - loadSpecs(m.specs, specs); - auto targetArr = Json::requireArray(obj, "targets"); - for (const auto & targetRaw : targetArr) - { - auto versionObj = Json::requireObject(targetRaw); - ModpacksCH::VersionTarget target; - loadVersionTarget(target, versionObj); - m.targets.append(target); - } - auto fileArr = Json::requireArray(obj, "files"); - for (const auto & fileRaw : fileArr) - { - auto fileObj = Json::requireObject(fileRaw); - ModpacksCH::VersionFile file; - loadVersionFile(file, fileObj); - m.files.append(file); - } -} - -//static void loadVersionChangelog(ModpacksCH::VersionChangelog & m, QJsonObject & obj) -//{ -// m.content = Json::requireString(obj, "content"); -// m.updated = Json::requireInteger(obj, "updated"); -//} diff --git a/api/logic/modplatform/modpacksch/PackManifest.h b/api/logic/modplatform/modpacksch/PackManifest.h deleted file mode 100644 index 518fffbf..00000000 --- a/api/logic/modplatform/modpacksch/PackManifest.h +++ /dev/null @@ -1,127 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include "multimc_logic_export.h" - -namespace ModpacksCH -{ - -struct Specs -{ - int id; - int minimum; - int recommended; -}; - -struct Tag -{ - int id; - QString name; -}; - -struct Art -{ - int id; - QString url; - QString type; - int width; - int height; - bool compressed; - QString sha1; - int size; - int64_t updated; -}; - -struct Author -{ - int id; - QString name; - QString type; - QString website; - int64_t updated; -}; - -struct VersionInfo -{ - int id; - QString name; - QString type; - int64_t updated; - Specs specs; -}; - -struct Modpack -{ - int id; - QString name; - QString synopsis; - QString description; - QString type; - bool featured; - int installs; - int plays; - int64_t updated; - int64_t refreshed; - QVector art; - QVector authors; - QVector versions; - QVector tags; -}; - -struct VersionTarget -{ - int id; - QString type; - QString name; - QString version; - int64_t updated; -}; - -struct VersionFile -{ - int id; - QString type; - QString path; - QString name; - QString version; - QString url; - QString sha1; - int size; - bool clientOnly; - bool serverOnly; - bool optional; - int64_t updated; -}; - -struct Version -{ - int id; - int parent; - QString name; - QString type; - int installs; - int plays; - int64_t updated; - int64_t refreshed; - Specs specs; - QVector targets; - QVector files; -}; - -struct VersionChangelog -{ - QString content; - int64_t updated; -}; - -MULTIMC_LOGIC_EXPORT void loadModpack(Modpack & m, QJsonObject & obj); - -MULTIMC_LOGIC_EXPORT void loadVersion(Version & m, QJsonObject & obj); -} - -Q_DECLARE_METATYPE(ModpacksCH::Modpack) diff --git a/application/pages/modplatform/ftb/FtbModel.h b/application/pages/modplatform/ftb/FtbModel.h index b480797f..9c057d73 100644 --- a/application/pages/modplatform/ftb/FtbModel.h +++ b/application/pages/modplatform/ftb/FtbModel.h @@ -2,7 +2,7 @@ #include -#include "modplatform/modpacksch/PackManifest.h" +#include "modplatform/modpacksch/FTBPackManifest.h" #include "net/NetJob.h" #include diff --git a/application/pages/modplatform/ftb/FtbPage.cpp b/application/pages/modplatform/ftb/FtbPage.cpp index 3a09780e..c82508b3 100644 --- a/application/pages/modplatform/ftb/FtbPage.cpp +++ b/application/pages/modplatform/ftb/FtbPage.cpp @@ -4,7 +4,7 @@ #include #include "dialogs/NewInstanceDialog.h" -#include "modplatform/modpacksch/PackInstallTask.h" +#include "modplatform/modpacksch/FTBPackInstallTask.h" FtbPage::FtbPage(NewInstanceDialog* dialog, QWidget *parent) : QWidget(parent), ui(new Ui::FtbPage), dialog(dialog) -- cgit v1.2.3