2022-05-10 23:57:47 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
2023-05-04 19:52:48 +01:00
|
|
|
* Prism Launcher - Minecraft Launcher
|
2023-04-21 22:47:51 +01:00
|
|
|
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
2023-05-04 19:52:48 +01:00
|
|
|
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
|
2023-04-21 22:47:51 +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/>.
|
|
|
|
*/
|
2022-05-10 23:57:47 +01:00
|
|
|
|
2022-03-02 21:35:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
#include <QMetaType>
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QVector>
|
2023-05-27 03:21:07 +01:00
|
|
|
#include <memory>
|
2022-03-02 21:35:59 +00:00
|
|
|
|
2022-07-24 03:11:09 +01:00
|
|
|
class QIODevice;
|
|
|
|
|
2022-03-02 21:35:59 +00:00
|
|
|
namespace ModPlatform {
|
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
enum class ResourceProvider { MODRINTH, FLAME };
|
|
|
|
|
2022-12-30 17:06:07 +00:00
|
|
|
enum class ResourceType { MOD, RESOURCE_PACK, SHADER_PACK };
|
2022-04-13 23:16:36 +01:00
|
|
|
|
2023-06-18 22:36:37 +01:00
|
|
|
enum class DependencyType { REQUIRED, OPTIONAL, INCOMPATIBLE, EMBEDDED, TOOL, INCLUDE, UNKNOWN };
|
2023-04-09 22:04:35 +01:00
|
|
|
|
2022-04-13 23:16:36 +01:00
|
|
|
class ProviderCapabilities {
|
|
|
|
public:
|
2022-11-25 12:23:46 +00:00
|
|
|
auto name(ResourceProvider) -> const char*;
|
|
|
|
auto readableName(ResourceProvider) -> QString;
|
|
|
|
auto hashType(ResourceProvider) -> QStringList;
|
|
|
|
auto hash(ResourceProvider, QIODevice*, QString type = "") -> QString;
|
2022-04-13 23:16:36 +01:00
|
|
|
};
|
|
|
|
|
2022-03-02 21:35:59 +00:00
|
|
|
struct ModpackAuthor {
|
|
|
|
QString name;
|
|
|
|
QString url;
|
|
|
|
};
|
|
|
|
|
2022-05-24 13:38:48 +01:00
|
|
|
struct DonationData {
|
|
|
|
QString id;
|
|
|
|
QString platform;
|
|
|
|
QString url;
|
|
|
|
};
|
|
|
|
|
2023-04-09 22:04:35 +01:00
|
|
|
struct Dependency {
|
|
|
|
QVariant addonId;
|
|
|
|
DependencyType type;
|
|
|
|
QString version;
|
|
|
|
};
|
|
|
|
|
2022-03-02 21:35:59 +00:00
|
|
|
struct IndexedVersion {
|
|
|
|
QVariant addonId;
|
|
|
|
QVariant fileId;
|
|
|
|
QString version;
|
2022-06-04 01:26:26 +01:00
|
|
|
QString version_number = {};
|
2022-06-19 18:31:44 +01:00
|
|
|
QStringList mcVersion;
|
2022-03-02 21:35:59 +00:00
|
|
|
QString downloadUrl;
|
|
|
|
QString date;
|
|
|
|
QString fileName;
|
2022-06-19 18:31:44 +01:00
|
|
|
QStringList loaders = {};
|
2022-05-06 16:42:01 +01:00
|
|
|
QString hash_type;
|
2022-04-21 19:45:20 +01:00
|
|
|
QString hash;
|
2022-06-03 23:04:49 +01:00
|
|
|
bool is_preferred = true;
|
2022-06-04 00:45:44 +01:00
|
|
|
QString changelog;
|
2023-04-09 22:04:35 +01:00
|
|
|
QList<Dependency> dependencies;
|
2022-12-18 18:41:46 +00:00
|
|
|
|
|
|
|
// For internal use, not provided by APIs
|
|
|
|
bool is_currently_selected = false;
|
2022-03-02 21:35:59 +00:00
|
|
|
};
|
|
|
|
|
2022-05-24 13:38:48 +01:00
|
|
|
struct ExtraPackData {
|
|
|
|
QList<DonationData> donate;
|
2022-05-24 15:58:11 +01:00
|
|
|
|
|
|
|
QString issuesUrl;
|
|
|
|
QString sourceUrl;
|
|
|
|
QString wikiUrl;
|
|
|
|
QString discordUrl;
|
2022-06-17 00:46:47 +01:00
|
|
|
|
|
|
|
QString body;
|
2022-05-24 13:38:48 +01:00
|
|
|
};
|
|
|
|
|
2022-03-02 21:35:59 +00:00
|
|
|
struct IndexedPack {
|
2023-05-27 03:21:07 +01:00
|
|
|
using Ptr = std::shared_ptr<IndexedPack>;
|
|
|
|
|
2022-03-02 21:35:59 +00:00
|
|
|
QVariant addonId;
|
2022-11-25 12:23:46 +00:00
|
|
|
ResourceProvider provider;
|
2022-03-02 21:35:59 +00:00
|
|
|
QString name;
|
2022-06-19 18:31:44 +01:00
|
|
|
QString slug;
|
2022-03-02 21:35:59 +00:00
|
|
|
QString description;
|
|
|
|
QList<ModpackAuthor> authors;
|
|
|
|
QString logoName;
|
|
|
|
QString logoUrl;
|
|
|
|
QString websiteUrl;
|
|
|
|
|
|
|
|
bool versionsLoaded = false;
|
|
|
|
QVector<IndexedVersion> versions;
|
2022-05-24 13:38:48 +01:00
|
|
|
|
|
|
|
// Don't load by default, since some modplatform don't have that info
|
|
|
|
bool extraDataLoaded = true;
|
|
|
|
ExtraPackData extraData;
|
2022-12-18 18:41:46 +00:00
|
|
|
|
|
|
|
// For internal use, not provided by APIs
|
|
|
|
[[nodiscard]] bool isVersionSelected(size_t index) const
|
|
|
|
{
|
|
|
|
if (!versionsLoaded)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return versions.at(index).is_currently_selected;
|
|
|
|
}
|
|
|
|
[[nodiscard]] bool isAnyVersionSelected() const
|
|
|
|
{
|
|
|
|
if (!versionsLoaded)
|
|
|
|
return false;
|
|
|
|
|
2023-04-21 22:47:51 +01:00
|
|
|
return std::any_of(versions.constBegin(), versions.constEnd(), [](auto const& v) { return v.is_currently_selected; });
|
2022-12-18 18:41:46 +00:00
|
|
|
}
|
2022-03-02 21:35:59 +00:00
|
|
|
};
|
|
|
|
|
2023-06-19 19:20:35 +01:00
|
|
|
struct OverrideDep {
|
|
|
|
QString quilt;
|
|
|
|
QString fabric;
|
|
|
|
QString slug;
|
|
|
|
ModPlatform::ResourceProvider provider;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline auto getOverrideDeps() -> QList<OverrideDep>
|
|
|
|
{
|
|
|
|
return { { "634179", "306612", "API", ModPlatform::ResourceProvider::FLAME },
|
|
|
|
{ "720410", "308769", "KotlinLibraries", ModPlatform::ResourceProvider::FLAME },
|
|
|
|
|
|
|
|
{ "qvIfYCYJ", "P7dR8mSH", "API", ModPlatform::ResourceProvider::MODRINTH },
|
|
|
|
{ "lwVhp9o5", "Ha28R6CL", "KotlinLibraries", ModPlatform::ResourceProvider::MODRINTH } };
|
|
|
|
};
|
|
|
|
|
2022-03-02 21:35:59 +00:00
|
|
|
} // namespace ModPlatform
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(ModPlatform::IndexedPack)
|
2023-05-28 16:27:02 +01:00
|
|
|
Q_DECLARE_METATYPE(ModPlatform::IndexedPack::Ptr)
|
2022-11-25 12:23:46 +00:00
|
|
|
Q_DECLARE_METATYPE(ModPlatform::ResourceProvider)
|