2023-04-11 22:45:44 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2023-04-19 22:57:09 +01:00
|
|
|
#include <qlist.h>
|
|
|
|
#include <qvariant.h>
|
2023-04-11 22:45:44 +01:00
|
|
|
#include <QDir>
|
2023-04-14 21:18:37 +01:00
|
|
|
#include <QEventLoop>
|
2023-04-19 22:57:09 +01:00
|
|
|
#include <QList>
|
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-04-19 22:57:09 +01:00
|
|
|
struct PackDependecny {
|
|
|
|
ModPlatform::Dependency dependency;
|
|
|
|
ModPlatform::IndexedPack pack;
|
|
|
|
ModPlatform::IndexedVersion version;
|
|
|
|
PackDependecny(){};
|
|
|
|
PackDependecny(const ModPlatform::IndexedPack& p, const ModPlatform::IndexedVersion& v)
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
QList<std::shared_ptr<PackDependecny>> selected);
|
2023-04-11 22:45:44 +01:00
|
|
|
|
2023-04-19 22:57:09 +01:00
|
|
|
auto getDependecies() const -> QList<std::shared_ptr<PackDependecny>> { return m_pack_dependencies; }
|
2023-04-14 21:02:33 +01:00
|
|
|
|
2023-04-11 22:45:44 +01:00
|
|
|
protected slots:
|
2023-04-19 22:57:09 +01:00
|
|
|
Task::Ptr prepareDependencyTask(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider, int);
|
|
|
|
QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&,
|
|
|
|
const ModPlatform::ResourceProvider providerName);
|
|
|
|
void prepare();
|
2023-04-11 22:45:44 +01:00
|
|
|
|
|
|
|
private:
|
2023-04-19 22:57:09 +01:00
|
|
|
QList<std::shared_ptr<PackDependecny>> m_pack_dependencies;
|
|
|
|
QList<std::shared_ptr<Metadata::ModStruct>> m_mods;
|
|
|
|
QList<std::shared_ptr<PackDependecny>> m_selected;
|
|
|
|
QList<Provider> m_providers;
|
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
|
|
|
};
|