NOISSUE Support installing CurseForge packs on modpacks.ch

There should be all the needed changes to install CurseForge modpacks
through modpacks.ch in place now.

Now the effort will need to move towards getting the GUI aspects to play
nice.
This commit is contained in:
Jamie Mansfield
2022-05-02 15:24:44 +01:00
committed by Petr Mrázek
parent 8c1d95b484
commit f7acde4389
5 changed files with 76 additions and 5 deletions

View File

@@ -30,10 +30,11 @@
namespace ModpacksCH {
PackInstallTask::PackInstallTask(Modpack pack, QString version)
PackInstallTask::PackInstallTask(Modpack pack, QString version, PackType type)
{
m_pack = pack;
m_version_name = version;
m_pack_type = type;
}
bool PackInstallTask::abort()
@@ -65,7 +66,10 @@ void PackInstallTask::executeTask()
}
auto *netJob = new NetJob("ModpacksCH::VersionFetch", APPLICATION->network());
auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/%1/%2").arg(m_pack.id).arg(version.id);
auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/%1/%2/%3")
.arg(getRealmForPackType(m_pack_type))
.arg(m_pack.id)
.arg(version.id);
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
jobPtr = netJob;
jobPtr->start();
@@ -78,14 +82,13 @@ void PackInstallTask::onDownloadSucceeded()
{
jobPtr.reset();
QJsonParseError parse_error;
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;