diff options
author | Jamie Mansfield <jmansfield@cadixdev.org> | 2021-02-25 14:34:51 +0000 |
---|---|---|
committer | Jamie Mansfield <jmansfield@cadixdev.org> | 2021-02-25 14:34:51 +0000 |
commit | 9d91cd496f6c43ae0098632fe1ba8bf29ac0ba4b (patch) | |
tree | c9d627b2309155bda1b98c0d215463409328737b /api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp | |
parent | 384680ca135eb8fbe5fe366af7c2328e36e7b12c (diff) | |
download | PrismLauncher-9d91cd496f6c43ae0098632fe1ba8bf29ac0ba4b.tar.gz PrismLauncher-9d91cd496f6c43ae0098632fe1ba8bf29ac0ba4b.tar.bz2 PrismLauncher-9d91cd496f6c43ae0098632fe1ba8bf29ac0ba4b.zip |
NOISSUE Download all mods before writing the instance for modpacks.ch
This is prepatory work for implementing jarmods support for
modpacks.ch, where we will need to look through files in a directory -
which would require that those files are present at such time.
This might even fix some weird bugs, maybe - I've not encountered any
bugs from how this previously worked, but I feel that what's going on
is slightly clearer now.
Diffstat (limited to 'api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp')
-rw-r--r-- | api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp index 73b8975a..bbf60912 100644 --- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -76,7 +76,7 @@ void PackInstallTask::onDownloadSucceeded() } m_version = version; - install(); + downloadPack(); } void PackInstallTask::onDownloadFailed(QString reason) @@ -85,38 +85,9 @@ void PackInstallTask::onDownloadFailed(QString reason) emitFailed(reason); } -void PackInstallTask::install() +void PackInstallTask::downloadPack() { - setStatus(tr("Installing modpack")); - - auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg"); - auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath); - instanceSettings->suspendSave(); - 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); - break; - } - } - - for(auto target : m_version.targets) { - if(target.type != "modloader") continue; - - if(target.name == "forge") { - components->setComponentVersion("net.minecraftforge", target.version, true); - } - else if(target.name == "fabric") { - components->setComponentVersion("net.fabricmc.fabric-loader", target.version, true); - } - } - components->saveNow(); + setStatus(tr("Downloading mods...")); jobPtr.reset(new NetJob(tr("Mod download"))); for(auto file : m_version.files) { @@ -133,7 +104,7 @@ void PackInstallTask::install() connect(jobPtr.get(), &NetJob::succeeded, this, [&]() { jobPtr.reset(); - emitSucceeded(); + install(); }); connect(jobPtr.get(), &NetJob::failed, [&](QString reason) { @@ -142,19 +113,56 @@ void PackInstallTask::install() // FIXME: Temporarily ignore file download failures (matching FTB's installer), // while FTB's data is fucked. qWarning() << "Failed to download files for modpack: " + reason; - emitSucceeded(); + + install(); }); connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total) { setProgress(current, total); }); - setStatus(tr("Downloading mods...")); jobPtr->start(); +} + +void PackInstallTask::install() +{ + setStatus(tr("Installing modpack")); + + auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg"); + auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath); + instanceSettings->suspendSave(); + 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); + break; + } + } + + for(auto target : m_version.targets) { + if(target.type != "modloader") continue; + + if(target.name == "forge") { + components->setComponentVersion("net.minecraftforge", target.version, true); + } + else if(target.name == "fabric") { + components->setComponentVersion("net.fabricmc.fabric-loader", target.version, true); + } + } + + components->saveNow(); instance.setName(m_instName); instance.setIconKey(m_instIcon); instanceSettings->resumeSave(); + + emitSucceeded(); } } |