mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-03 08:41:42 +00:00
NOISSUE Support cf-extract file type on modpacks.ch
This makes a start on supporting CurseForge pack installation through the modpacks.ch API.
This commit is contained in:
committed by
Petr Mrázek
parent
cad522fe41
commit
863cf3807e
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2021 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright 2020-2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright 2020-2021 Petr Mrazek <peterix@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "Json.h"
|
||||
#include "MMCZip.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "net/ChecksumValidator.h"
|
||||
@@ -122,6 +123,10 @@ void PackInstallTask::downloadPack()
|
||||
auto entry = APPLICATION->metacache()->resolveEntry("ModpacksCHPacks", cacheName);
|
||||
entry->setStale(true);
|
||||
|
||||
if (file.type == "cf-extract") {
|
||||
filesToExtract[entry->getFullPath()] = file;
|
||||
}
|
||||
else {
|
||||
auto relpath = FS::PathCombine("minecraft", file.path, file.name);
|
||||
auto path = FS::PathCombine(m_stagingPath, relpath);
|
||||
|
||||
@@ -131,6 +136,7 @@ void PackInstallTask::downloadPack()
|
||||
}
|
||||
qDebug() << "Will download" << file.url << "to" << path;
|
||||
filesToCopy[path] = entry->getFullPath();
|
||||
}
|
||||
|
||||
auto dl = Net::Download::makeCached(file.url, entry);
|
||||
if (!file.sha1.isEmpty()) {
|
||||
@@ -163,6 +169,7 @@ void PackInstallTask::downloadPack()
|
||||
|
||||
void PackInstallTask::install()
|
||||
{
|
||||
if (!filesToCopy.isEmpty()) {
|
||||
setStatus(tr("Copying modpack files"));
|
||||
|
||||
for (auto iter = filesToCopy.begin(); iter != filesToCopy.end(); iter++) {
|
||||
@@ -175,6 +182,25 @@ void PackInstallTask::install()
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!filesToExtract.isEmpty()) {
|
||||
setStatus(tr("Extracting modpack files"));
|
||||
|
||||
for (auto iter = filesToExtract.begin(); iter != filesToExtract.end(); iter++) {
|
||||
auto& filePath = iter.key();
|
||||
auto& file = iter.value();
|
||||
|
||||
auto relpath = FS::PathCombine("minecraft", file.path);
|
||||
auto path = FS::PathCombine(m_stagingPath, relpath);
|
||||
|
||||
if (!MMCZip::extractDir(filePath, "overrides/", path)) {
|
||||
qWarning() << "Failed to extract files from" << filePath << "to" << path;
|
||||
emitFailed(tr("Failed to extract files"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setStatus(tr("Installing modpack"));
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2021 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright 2020-2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright 2020-2021 Petr Mrazek <peterix@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -56,6 +56,7 @@ private:
|
||||
QString m_version_name;
|
||||
Version m_version;
|
||||
|
||||
QMap<QString, VersionFile> filesToExtract;
|
||||
QMap<QString, QString> filesToCopy;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user