2022-05-11 04:27:47 +05:30
|
|
|
// 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/>.
|
|
|
|
*/
|
|
|
|
|
2022-03-03 03:05:59 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
#include <QMetaType>
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QVector>
|
|
|
|
|
2022-07-24 07:41:09 +05:30
|
|
|
class QIODevice;
|
|
|
|
|
2022-03-03 03:05:59 +05:30
|
|
|
namespace ModPlatform {
|
|
|
|
|
2022-11-25 17:53:46 +05:30
|
|
|
enum class ResourceProvider { MODRINTH, FLAME };
|
|
|
|
|
|
|
|
enum class ResourceType { MOD, RESOURCE_PACK };
|
2022-04-14 03:46:36 +05:30
|
|
|
|
|
|
|
class ProviderCapabilities {
|
|
|
|
public:
|
2022-11-25 17:53:46 +05:30
|
|
|
auto name(ResourceProvider) -> const char*;
|
|
|
|
auto readableName(ResourceProvider) -> QString;
|
|
|
|
auto hashType(ResourceProvider) -> QStringList;
|
|
|
|
auto hash(ResourceProvider, QIODevice*, QString type = "") -> QString;
|
2022-04-14 03:46:36 +05:30
|
|
|
};
|
|
|
|
|
2022-03-03 03:05:59 +05:30
|
|
|
struct ModpackAuthor {
|
|
|
|
QString name;
|
|
|
|
QString url;
|
|
|
|
};
|
|
|
|
|
2022-05-24 18:08:48 +05:30
|
|
|
struct DonationData {
|
|
|
|
QString id;
|
|
|
|
QString platform;
|
|
|
|
QString url;
|
|
|
|
};
|
|
|
|
|
2022-03-03 03:05:59 +05:30
|
|
|
struct IndexedVersion {
|
|
|
|
QVariant addonId;
|
|
|
|
QVariant fileId;
|
|
|
|
QString version;
|
2022-06-04 05:56:26 +05:30
|
|
|
QString version_number = {};
|
2022-06-19 23:01:44 +05:30
|
|
|
QStringList mcVersion;
|
2022-03-03 03:05:59 +05:30
|
|
|
QString downloadUrl;
|
|
|
|
QString date;
|
|
|
|
QString fileName;
|
2022-06-19 23:01:44 +05:30
|
|
|
QStringList loaders = {};
|
2022-05-06 21:12:01 +05:30
|
|
|
QString hash_type;
|
2022-04-22 00:15:20 +05:30
|
|
|
QString hash;
|
2022-06-04 03:34:49 +05:30
|
|
|
bool is_preferred = true;
|
2022-06-04 05:15:44 +05:30
|
|
|
QString changelog;
|
2022-12-19 00:11:46 +05:30
|
|
|
|
|
|
|
// For internal use, not provided by APIs
|
|
|
|
bool is_currently_selected = false;
|
2023-01-08 21:03:10 +05:30
|
|
|
QString custom_target_folder;
|
2022-03-03 03:05:59 +05:30
|
|
|
};
|
|
|
|
|
2022-05-24 18:08:48 +05:30
|
|
|
struct ExtraPackData {
|
|
|
|
QList<DonationData> donate;
|
2022-05-24 20:28:11 +05:30
|
|
|
|
|
|
|
QString issuesUrl;
|
|
|
|
QString sourceUrl;
|
|
|
|
QString wikiUrl;
|
|
|
|
QString discordUrl;
|
2022-06-17 05:16:47 +05:30
|
|
|
|
|
|
|
QString body;
|
2022-05-24 18:08:48 +05:30
|
|
|
};
|
|
|
|
|
2022-03-03 03:05:59 +05:30
|
|
|
struct IndexedPack {
|
|
|
|
QVariant addonId;
|
2022-11-25 17:53:46 +05:30
|
|
|
ResourceProvider provider;
|
2022-03-03 03:05:59 +05:30
|
|
|
QString name;
|
2022-06-19 23:01:44 +05:30
|
|
|
QString slug;
|
2022-03-03 03:05:59 +05:30
|
|
|
QString description;
|
|
|
|
QList<ModpackAuthor> authors;
|
|
|
|
QString logoName;
|
|
|
|
QString logoUrl;
|
|
|
|
QString websiteUrl;
|
|
|
|
|
|
|
|
bool versionsLoaded = false;
|
|
|
|
QVector<IndexedVersion> versions;
|
2022-05-24 18:08:48 +05:30
|
|
|
|
|
|
|
// Don't load by default, since some modplatform don't have that info
|
|
|
|
bool extraDataLoaded = true;
|
|
|
|
ExtraPackData extraData;
|
2022-12-19 00:11:46 +05:30
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
return std::any_of(versions.constBegin(), versions.constEnd(),
|
|
|
|
[](auto const& v) { return v.is_currently_selected; });
|
|
|
|
}
|
2022-03-03 03:05:59 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ModPlatform
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(ModPlatform::IndexedPack)
|
2022-11-25 17:53:46 +05:30
|
|
|
Q_DECLARE_METATYPE(ModPlatform::ResourceProvider)
|