2022-05-28 23:38:55 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
2021-12-18 00:07:57 +00:00
|
|
|
/*
|
2022-12-06 12:18:50 +00:00
|
|
|
* Prism Launcher - Minecraft Launcher
|
2022-07-25 21:51:30 +01:00
|
|
|
* Copyright (C) 2022 flowln <flowlnlnln@gmail.com>
|
2022-05-28 23:38:55 +01:00
|
|
|
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
2022-06-03 08:45:09 +01:00
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
2021-12-18 00:07:57 +00:00
|
|
|
*
|
2022-05-28 23:38:55 +01:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
2021-12-18 00:07:57 +00:00
|
|
|
*
|
2022-05-28 23:38:55 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2021-12-18 00:07:57 +00:00
|
|
|
*
|
2022-05-28 23:38:55 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following copyright and
|
|
|
|
* permission notice:
|
|
|
|
*
|
|
|
|
* Copyright 2020-2021 Jamie Mansfield <jmansfield@cadixdev.org>
|
|
|
|
* Copyright 2020-2021 Petr Mrazek <peterix@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2021-12-18 00:07:57 +00:00
|
|
|
*/
|
|
|
|
|
2020-08-21 01:40:19 +01:00
|
|
|
#include "FTBPackInstallTask.h"
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
|
|
|
|
#include "FileSystem.h"
|
|
|
|
#include "Json.h"
|
|
|
|
#include "minecraft/MinecraftInstance.h"
|
|
|
|
#include "minecraft/PackProfile.h"
|
2022-06-02 20:23:20 +01:00
|
|
|
#include "modplatform/flame/PackManifest.h"
|
2021-06-28 22:09:52 +01:00
|
|
|
#include "net/ChecksumValidator.h"
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
#include "settings/INISettingsObject.h"
|
|
|
|
|
2021-11-21 22:21:12 +00:00
|
|
|
#include "Application.h"
|
2022-07-25 21:51:30 +01:00
|
|
|
#include "BuildConfig.h"
|
2022-07-31 20:05:47 +01:00
|
|
|
#include "ui/dialogs/BlockedModsDialog.h"
|
2021-11-21 22:21:12 +00:00
|
|
|
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
namespace ModpacksCH {
|
|
|
|
|
2022-06-02 20:23:20 +01:00
|
|
|
PackInstallTask::PackInstallTask(Modpack pack, QString version, QWidget* parent)
|
2022-07-25 20:38:58 +01:00
|
|
|
: m_pack(std::move(pack)), m_version_name(std::move(version)), m_parent(parent)
|
2022-07-25 21:51:30 +01:00
|
|
|
{}
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
|
|
|
|
bool PackInstallTask::abort()
|
|
|
|
{
|
2022-10-13 17:27:52 +01:00
|
|
|
if (!canAbort())
|
|
|
|
return false;
|
|
|
|
|
2022-07-25 20:38:58 +01:00
|
|
|
bool aborted = true;
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
if (m_net_job)
|
|
|
|
aborted &= m_net_job->abort();
|
|
|
|
if (m_mod_id_resolver_task)
|
|
|
|
aborted &= m_mod_id_resolver_task->abort();
|
2022-07-25 20:38:58 +01:00
|
|
|
|
2022-10-13 17:27:52 +01:00
|
|
|
return aborted ? InstanceTask::abort() : false;
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void PackInstallTask::executeTask()
|
|
|
|
{
|
2022-07-25 20:38:58 +01:00
|
|
|
setStatus(tr("Getting the manifest..."));
|
2022-10-13 19:10:35 +01:00
|
|
|
setAbortable(false);
|
2022-07-25 20:38:58 +01:00
|
|
|
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
// Find pack version
|
2022-07-25 21:51:30 +01:00
|
|
|
auto version_it = std::find_if(m_pack.versions.constBegin(), m_pack.versions.constEnd(),
|
|
|
|
[this](ModpacksCH::VersionInfo const& a) { return a.name == m_version_name; });
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
if (version_it == m_pack.versions.constEnd()) {
|
2021-04-08 18:46:22 +01:00
|
|
|
emitFailed(tr("Failed to find pack version %1").arg(m_version_name));
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
auto version = *version_it;
|
2022-07-25 20:38:58 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
auto* netJob = new NetJob("ModpacksCH::VersionFetch", APPLICATION->network());
|
2022-07-25 20:38:58 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
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), &m_response));
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onManifestDownloadSucceeded);
|
|
|
|
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onManifestDownloadFailed);
|
2022-10-13 19:10:35 +01:00
|
|
|
QObject::connect(netJob, &NetJob::aborted, this, &PackInstallTask::abort);
|
2022-07-25 20:38:58 +01:00
|
|
|
QObject::connect(netJob, &NetJob::progress, this, &PackInstallTask::setProgress);
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
m_net_job = netJob;
|
|
|
|
|
2022-10-13 19:10:35 +01:00
|
|
|
setAbortable(true);
|
2022-07-25 21:51:30 +01:00
|
|
|
netJob->start();
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
}
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
void PackInstallTask::onManifestDownloadSucceeded()
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
{
|
2022-07-25 21:51:30 +01:00
|
|
|
m_net_job.reset();
|
|
|
|
|
|
|
|
QJsonParseError parse_error{};
|
|
|
|
QJsonDocument doc = QJsonDocument::fromJson(m_response, &parse_error);
|
|
|
|
if (parse_error.error != QJsonParseError::NoError) {
|
|
|
|
qWarning() << "Error while parsing JSON response from ModpacksCH at " << parse_error.offset
|
|
|
|
<< " reason: " << parse_error.errorString();
|
|
|
|
qWarning() << m_response;
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ModpacksCH::Version version;
|
2022-07-25 20:38:58 +01:00
|
|
|
try {
|
2022-07-25 21:51:30 +01:00
|
|
|
auto obj = Json::requireObject(doc);
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
ModpacksCH::loadVersion(version, obj);
|
2022-07-25 21:51:30 +01:00
|
|
|
} catch (const JSONValidationError& e) {
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
emitFailed(tr("Could not understand pack manifest:\n") + e.cause());
|
|
|
|
return;
|
|
|
|
}
|
2022-07-25 20:38:58 +01:00
|
|
|
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
m_version = version;
|
|
|
|
|
2022-06-02 20:23:20 +01:00
|
|
|
resolveMods();
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
}
|
|
|
|
|
2022-06-02 20:23:20 +01:00
|
|
|
void PackInstallTask::resolveMods()
|
|
|
|
{
|
|
|
|
setStatus(tr("Resolving mods..."));
|
2022-10-13 19:10:35 +01:00
|
|
|
setAbortable(false);
|
2022-07-25 20:38:58 +01:00
|
|
|
setProgress(0, 100);
|
2022-06-02 20:23:20 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
m_file_id_map.clear();
|
2022-07-25 20:38:58 +01:00
|
|
|
|
|
|
|
Flame::Manifest manifest;
|
2022-06-02 20:23:20 +01:00
|
|
|
int index = 0;
|
2022-07-25 20:38:58 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
for (auto const& file : m_version.files) {
|
|
|
|
if (!file.serverOnly && file.url.isEmpty()) {
|
|
|
|
if (file.curseforge.file_id <= 0) {
|
|
|
|
emitFailed(tr("Invalid manifest: There's no information available to download the file '%1'!").arg(file.name));
|
2022-07-25 20:38:58 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-06-02 20:23:20 +01:00
|
|
|
|
2022-07-25 20:38:58 +01:00
|
|
|
Flame::File flame_file;
|
2022-07-25 21:51:30 +01:00
|
|
|
flame_file.projectId = file.curseforge.project_id;
|
|
|
|
flame_file.fileId = file.curseforge.file_id;
|
2022-07-25 20:38:58 +01:00
|
|
|
flame_file.hash = file.sha1;
|
2022-06-02 20:23:20 +01:00
|
|
|
|
2022-07-25 20:38:58 +01:00
|
|
|
manifest.files.insert(flame_file.fileId, flame_file);
|
2022-07-25 21:51:30 +01:00
|
|
|
m_file_id_map.append(flame_file.fileId);
|
|
|
|
} else {
|
|
|
|
m_file_id_map.append(-1);
|
2022-06-02 20:23:20 +01:00
|
|
|
}
|
2022-07-25 21:51:30 +01:00
|
|
|
|
2022-06-02 20:23:20 +01:00
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
m_mod_id_resolver_task = new Flame::FileResolvingTask(APPLICATION->network(), manifest);
|
2022-06-02 20:23:20 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::succeeded, this, &PackInstallTask::onResolveModsSucceeded);
|
|
|
|
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::failed, this, &PackInstallTask::onResolveModsFailed);
|
2022-10-13 19:10:35 +01:00
|
|
|
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::aborted, this, &PackInstallTask::abort);
|
2022-07-25 21:51:30 +01:00
|
|
|
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::progress, this, &PackInstallTask::setProgress);
|
2022-06-02 20:23:20 +01:00
|
|
|
|
2022-10-13 19:10:35 +01:00
|
|
|
setAbortable(true);
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
m_mod_id_resolver_task->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackInstallTask::onResolveModsSucceeded()
|
|
|
|
{
|
|
|
|
auto anyBlocked = false;
|
2022-07-25 20:38:58 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
Flame::Manifest results = m_mod_id_resolver_task->getResults();
|
|
|
|
for (int index = 0; index < m_file_id_map.size(); index++) {
|
|
|
|
auto const file_id = m_file_id_map.at(index);
|
|
|
|
if (file_id < 0)
|
|
|
|
continue;
|
2022-07-25 20:38:58 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
Flame::File results_file = results.files[file_id];
|
|
|
|
VersionFile& local_file = m_version.files[index];
|
2022-07-25 20:38:58 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
// First check for blocked mods
|
|
|
|
if (!results_file.resolved || results_file.url.isEmpty()) {
|
2022-10-24 12:08:38 +01:00
|
|
|
BlockedMod blocked_mod;
|
|
|
|
blocked_mod.name = local_file.name;
|
|
|
|
blocked_mod.websiteUrl = results_file.websiteUrl;
|
|
|
|
blocked_mod.hash = results_file.hash;
|
|
|
|
blocked_mod.matched = false;
|
|
|
|
blocked_mod.localPath = "";
|
|
|
|
|
2022-10-25 18:59:37 +01:00
|
|
|
m_blocked_mods.append(blocked_mod);
|
2022-07-25 20:38:58 +01:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
anyBlocked = true;
|
2022-06-02 20:23:20 +01:00
|
|
|
} else {
|
2022-07-25 21:51:30 +01:00
|
|
|
local_file.url = results_file.url.toString();
|
2022-06-02 20:23:20 +01:00
|
|
|
}
|
2022-07-25 21:51:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
m_mod_id_resolver_task.reset();
|
|
|
|
|
|
|
|
if (anyBlocked) {
|
|
|
|
qDebug() << "Blocked files found, displaying file list";
|
2022-07-25 20:38:58 +01:00
|
|
|
|
2022-12-05 20:33:42 +00:00
|
|
|
BlockedModsDialog message_dialog(m_parent, tr("Blocked files found"),
|
2022-12-06 12:16:27 +00:00
|
|
|
tr("The following files are not available for download in third party launchers.<br/>"
|
|
|
|
"You will need to manually download them and add them to the instance."),
|
|
|
|
m_blocked_mods);
|
2022-06-02 20:23:20 +01:00
|
|
|
|
2022-12-05 20:33:42 +00:00
|
|
|
message_dialog.setModal(true);
|
|
|
|
|
|
|
|
if (message_dialog.exec() == QDialog::Accepted) {
|
2022-11-11 12:41:32 +00:00
|
|
|
qDebug() << "Post dialog blocked mods list: " << m_blocked_mods;
|
2022-10-13 17:27:52 +01:00
|
|
|
createInstance();
|
2022-11-12 01:05:19 +00:00
|
|
|
} else {
|
2022-07-25 21:51:30 +01:00
|
|
|
abort();
|
2022-10-25 18:59:37 +01:00
|
|
|
}
|
2022-11-12 01:05:19 +00:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
} else {
|
2022-10-13 17:27:52 +01:00
|
|
|
createInstance();
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
}
|
2021-02-25 14:34:51 +00:00
|
|
|
}
|
|
|
|
|
2022-10-13 17:27:52 +01:00
|
|
|
void PackInstallTask::createInstance()
|
2022-07-25 21:51:30 +01:00
|
|
|
{
|
2022-10-13 17:27:52 +01:00
|
|
|
setAbortable(false);
|
2021-06-28 22:34:38 +01:00
|
|
|
|
2022-10-13 17:27:52 +01:00
|
|
|
setStatus(tr("Creating the instance..."));
|
2022-07-25 20:48:29 +01:00
|
|
|
QCoreApplication::processEvents();
|
2021-02-25 14:34:51 +00:00
|
|
|
|
|
|
|
auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
|
|
|
auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
|
|
|
|
|
|
|
|
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
|
|
|
auto components = instance.getPackProfile();
|
|
|
|
components->buildingFromScratch();
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
for (auto target : m_version.targets) {
|
|
|
|
if (target.type == "game" && target.name == "minecraft") {
|
2021-02-25 14:34:51 +00:00
|
|
|
components->setComponentVersion("net.minecraft", target.version, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
for (auto target : m_version.targets) {
|
|
|
|
if (target.type != "modloader")
|
|
|
|
continue;
|
2021-02-25 14:34:51 +00:00
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
if (target.name == "forge") {
|
2022-07-07 08:56:28 +01:00
|
|
|
components->setComponentVersion("net.minecraftforge", target.version);
|
2022-07-25 21:51:30 +01:00
|
|
|
} else if (target.name == "fabric") {
|
2022-07-07 08:56:28 +01:00
|
|
|
components->setComponentVersion("net.fabricmc.fabric-loader", target.version);
|
2021-02-25 14:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-25 14:43:04 +00:00
|
|
|
// install any jar mods
|
|
|
|
QDir jarModsDir(FS::PathCombine(m_stagingPath, "minecraft", "jarmods"));
|
|
|
|
if (jarModsDir.exists()) {
|
|
|
|
QStringList jarMods;
|
|
|
|
|
|
|
|
for (const auto& info : jarModsDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) {
|
|
|
|
jarMods.push_back(info.absoluteFilePath());
|
|
|
|
}
|
|
|
|
|
|
|
|
components->installJarMods(jarMods);
|
|
|
|
}
|
|
|
|
|
2021-02-25 14:34:51 +00:00
|
|
|
components->saveNow();
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
|
2022-07-14 20:13:23 +01:00
|
|
|
instance.setName(name());
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
instance.setIconKey(m_instIcon);
|
2022-05-28 23:38:55 +01:00
|
|
|
instance.setManagedPack("modpacksch", QString::number(m_pack.id), m_pack.name, QString::number(m_version.id), m_version.name);
|
2021-02-25 14:34:51 +00:00
|
|
|
|
2022-10-13 17:27:52 +01:00
|
|
|
instance.saveNow();
|
|
|
|
|
|
|
|
onCreateInstanceSucceeded();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackInstallTask::onCreateInstanceSucceeded()
|
|
|
|
{
|
|
|
|
downloadPack();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackInstallTask::downloadPack()
|
|
|
|
{
|
|
|
|
setStatus(tr("Downloading mods..."));
|
2022-10-13 19:10:35 +01:00
|
|
|
setAbortable(false);
|
2022-10-13 17:27:52 +01:00
|
|
|
|
|
|
|
auto* jobPtr = new NetJob(tr("Mod download"), APPLICATION->network());
|
|
|
|
for (auto const& file : m_version.files) {
|
|
|
|
if (file.serverOnly || file.url.isEmpty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
auto path = FS::PathCombine(m_stagingPath, ".minecraft", file.path, file.name);
|
|
|
|
qDebug() << "Will try to download" << file.url << "to" << path;
|
|
|
|
|
|
|
|
QFileInfo file_info(file.name);
|
|
|
|
|
|
|
|
auto dl = Net::Download::makeFile(file.url, path);
|
|
|
|
if (!file.sha1.isEmpty()) {
|
|
|
|
auto rawSha1 = QByteArray::fromHex(file.sha1.toLatin1());
|
|
|
|
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
|
|
|
|
}
|
|
|
|
|
|
|
|
jobPtr->addNetAction(dl);
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(jobPtr, &NetJob::succeeded, this, &PackInstallTask::onModDownloadSucceeded);
|
|
|
|
connect(jobPtr, &NetJob::failed, this, &PackInstallTask::onModDownloadFailed);
|
2022-10-13 19:10:35 +01:00
|
|
|
connect(jobPtr, &NetJob::aborted, this, &PackInstallTask::abort);
|
2022-10-13 17:27:52 +01:00
|
|
|
connect(jobPtr, &NetJob::progress, this, &PackInstallTask::setProgress);
|
|
|
|
|
|
|
|
m_net_job = jobPtr;
|
2022-10-13 19:10:35 +01:00
|
|
|
|
|
|
|
setAbortable(true);
|
2022-10-13 17:27:52 +01:00
|
|
|
jobPtr->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackInstallTask::onModDownloadSucceeded()
|
|
|
|
{
|
|
|
|
m_net_job.reset();
|
2022-10-31 05:42:35 +00:00
|
|
|
if (!m_blocked_mods.isEmpty()) {
|
2022-10-25 18:59:37 +01:00
|
|
|
copyBlockedMods();
|
|
|
|
}
|
2021-02-25 14:34:51 +00:00
|
|
|
emitSucceeded();
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
}
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
void PackInstallTask::onManifestDownloadFailed(QString reason)
|
|
|
|
{
|
|
|
|
m_net_job.reset();
|
|
|
|
emitFailed(reason);
|
GH-3095 New FTB platform support
Models are based on the models from my go-modpacksch library.
License:
========
The MIT License (MIT)
Copyright (c) Jamie Mansfield <https://www.jamiemansfield.me/>
Copyright (c) contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2020-06-07 16:14:47 +01:00
|
|
|
}
|
2022-07-25 21:51:30 +01:00
|
|
|
void PackInstallTask::onResolveModsFailed(QString reason)
|
|
|
|
{
|
|
|
|
m_net_job.reset();
|
|
|
|
emitFailed(reason);
|
|
|
|
}
|
2022-10-13 17:27:52 +01:00
|
|
|
void PackInstallTask::onCreateInstanceFailed(QString reason)
|
|
|
|
{
|
|
|
|
emitFailed(reason);
|
|
|
|
}
|
2022-07-25 21:51:30 +01:00
|
|
|
void PackInstallTask::onModDownloadFailed(QString reason)
|
|
|
|
{
|
|
|
|
m_net_job.reset();
|
|
|
|
emitFailed(reason);
|
|
|
|
}
|
|
|
|
|
2022-10-26 04:18:14 +01:00
|
|
|
/// @brief copy the matched blocked mods to the instance staging area
|
2022-11-01 14:06:36 +00:00
|
|
|
void PackInstallTask::copyBlockedMods()
|
|
|
|
{
|
2022-10-25 18:59:37 +01:00
|
|
|
setStatus(tr("Copying Blocked Mods..."));
|
|
|
|
setAbortable(false);
|
|
|
|
int i = 0;
|
|
|
|
int total = m_blocked_mods.length();
|
|
|
|
setProgress(i, total);
|
2022-11-01 14:06:36 +00:00
|
|
|
for (auto const& mod : m_blocked_mods) {
|
|
|
|
if (!mod.matched) {
|
|
|
|
qDebug() << mod.name << "was not matched to a local file, skipping copy";
|
2022-10-25 18:59:37 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-11-01 14:06:36 +00:00
|
|
|
auto dest_path = FS::PathCombine(m_stagingPath, ".minecraft", "mods", mod.name);
|
2022-10-25 18:59:37 +01:00
|
|
|
|
|
|
|
setStatus(tr("Copying Blocked Mods (%1 out of %2 are done)").arg(QString::number(i), QString::number(total)));
|
|
|
|
|
2022-11-01 14:06:36 +00:00
|
|
|
qDebug() << "Will try to copy" << mod.localPath << "to" << dest_path;
|
2022-10-25 18:59:37 +01:00
|
|
|
|
2022-11-01 14:06:36 +00:00
|
|
|
if (!FS::copy(mod.localPath, dest_path)()) {
|
|
|
|
qDebug() << "Copy of" << mod.localPath << "to" << dest_path << "Failed";
|
|
|
|
}
|
2022-10-25 18:59:37 +01:00
|
|
|
|
2022-11-01 14:06:36 +00:00
|
|
|
i++;
|
|
|
|
setProgress(i, total);
|
2022-10-25 18:59:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setAbortable(true);
|
|
|
|
}
|
|
|
|
|
2022-07-25 21:51:30 +01:00
|
|
|
} // namespace ModpacksCH
|