2023-04-11 22:45:44 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
2023-05-04 19:52:48 +01:00
|
|
|
* Prism Launcher - Minecraft Launcher
|
|
|
|
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
|
2023-04-11 22:45:44 +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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QDir>
|
2023-04-14 21:18:37 +01:00
|
|
|
#include <QEventLoop>
|
2023-04-19 22:57:09 +01:00
|
|
|
#include <QList>
|
2023-04-20 20:35:10 +01:00
|
|
|
#include <QVariant>
|
2023-04-11 22:45:44 +01:00
|
|
|
#include <functional>
|
2023-04-19 22:57:09 +01:00
|
|
|
#include <memory>
|
2023-04-11 22:45:44 +01:00
|
|
|
|
|
|
|
#include "minecraft/mod/MetadataHandler.h"
|
2023-04-19 22:57:09 +01:00
|
|
|
#include "minecraft/mod/ModFolderModel.h"
|
2023-04-11 22:45:44 +01:00
|
|
|
#include "modplatform/ModIndex.h"
|
2023-04-19 22:57:09 +01:00
|
|
|
#include "modplatform/ResourceAPI.h"
|
2023-04-11 22:45:44 +01:00
|
|
|
#include "tasks/SequentialTask.h"
|
|
|
|
#include "tasks/Task.h"
|
2023-04-19 22:57:09 +01:00
|
|
|
#include "ui/pages/modplatform/ModModel.h"
|
2023-04-11 22:45:44 +01:00
|
|
|
|
2023-04-19 22:57:09 +01:00
|
|
|
class GetModDependenciesTask : public SequentialTask {
|
2023-04-11 22:45:44 +01:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
using Ptr = shared_qobject_ptr<GetModDependenciesTask>;
|
|
|
|
|
2023-05-04 19:52:48 +01:00
|
|
|
struct PackDependency {
|
2023-04-19 22:57:09 +01:00
|
|
|
ModPlatform::Dependency dependency;
|
2023-05-28 16:22:55 +01:00
|
|
|
ModPlatform::IndexedPack::Ptr pack;
|
2023-04-19 22:57:09 +01:00
|
|
|
ModPlatform::IndexedVersion version;
|
2023-06-18 22:36:37 +01:00
|
|
|
PackDependency() = default;
|
2023-05-28 16:22:55 +01:00
|
|
|
PackDependency(const ModPlatform::IndexedPack::Ptr p, const ModPlatform::IndexedVersion& v)
|
2023-04-19 22:57:09 +01:00
|
|
|
{
|
|
|
|
pack = p;
|
|
|
|
version = v;
|
|
|
|
}
|
|
|
|
};
|
2023-04-11 22:45:44 +01:00
|
|
|
|
2023-04-19 22:57:09 +01:00
|
|
|
struct Provider {
|
|
|
|
ModPlatform::ResourceProvider name;
|
|
|
|
std::shared_ptr<ResourceDownload::ModModel> mod;
|
|
|
|
std::shared_ptr<ResourceAPI> api;
|
|
|
|
};
|
2023-04-11 22:45:44 +01:00
|
|
|
|
2023-04-19 22:57:09 +01:00
|
|
|
explicit GetModDependenciesTask(QObject* parent,
|
|
|
|
BaseInstance* instance,
|
|
|
|
ModFolderModel* folder,
|
2023-05-04 19:52:48 +01:00
|
|
|
QList<std::shared_ptr<PackDependency>> selected);
|
2023-04-11 22:45:44 +01:00
|
|
|
|
2023-05-04 19:52:48 +01:00
|
|
|
auto getDependecies() const -> QList<std::shared_ptr<PackDependency>> { return m_pack_dependencies; }
|
2023-06-24 22:24:08 +01:00
|
|
|
QHash<QString, QStringList> getRequiredBy();
|
2023-04-14 21:02:33 +01:00
|
|
|
|
2023-04-11 22:45:44 +01:00
|
|
|
protected slots:
|
2023-05-04 21:54:46 +01:00
|
|
|
Task::Ptr prepareDependencyTask(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider, int);
|
2023-04-19 22:57:09 +01:00
|
|
|
QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&,
|
|
|
|
const ModPlatform::ResourceProvider providerName);
|
|
|
|
void prepare();
|
2023-06-19 15:42:16 +01:00
|
|
|
Task::Ptr getProjectInfoTask(std::shared_ptr<PackDependency> pDep);
|
2023-06-19 19:32:19 +01:00
|
|
|
ModPlatform::Dependency getOverride(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider providerName);
|
2023-06-20 11:28:57 +01:00
|
|
|
void removePack(const QVariant addonId);
|
2023-04-11 22:45:44 +01:00
|
|
|
|
|
|
|
private:
|
2023-05-04 19:52:48 +01:00
|
|
|
QList<std::shared_ptr<PackDependency>> m_pack_dependencies;
|
2023-04-19 22:57:09 +01:00
|
|
|
QList<std::shared_ptr<Metadata::ModStruct>> m_mods;
|
2023-05-04 19:52:48 +01:00
|
|
|
QList<std::shared_ptr<PackDependency>> m_selected;
|
2023-04-20 20:35:10 +01:00
|
|
|
Provider m_flame_provider;
|
|
|
|
Provider m_modrinth_provider;
|
2023-04-11 22:45:44 +01:00
|
|
|
|
2023-04-19 22:57:09 +01:00
|
|
|
Version m_version;
|
|
|
|
ResourceAPI::ModLoaderTypes m_loaderType;
|
2023-04-11 22:45:44 +01:00
|
|
|
};
|