1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: 2026 Project Tick
// SPDX-FileContributor: Project Tick Team
/*
* ProjT Launcher - Minecraft Launcher
* Copyright (C) 2026 Project Tick
*
* 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, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* === Upstream License Block (Do Not Modify) ==============================
*
*
*
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (c) 2023 Trial97 <alexandru.tripon97@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, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ======================================================================== */
#pragma once
#include <QList>
#include <QMetaType>
#include <QString>
#include <QVariant>
#include <memory>
class QIODevice;
namespace ModPlatform
{
enum ModLoaderType
{
NeoForge = 1 << 0,
Forge = 1 << 1,
Cauldron = 1 << 2,
LiteLoader = 1 << 3,
Fabric = 1 << 4,
Quilt = 1 << 5,
DataPack = 1 << 6,
Babric = 1 << 7,
BTA = 1 << 8,
LegacyFabric = 1 << 9,
Ornithe = 1 << 10,
Rift = 1 << 11,
Risugami = 1 << 12,
StationLoader = 1 << 13,
ModLoaderMP = 1 << 14,
Optifine = 1 << 15
};
Q_DECLARE_FLAGS(ModLoaderTypes, ModLoaderType)
QList<ModLoaderType> modLoaderTypesToList(ModLoaderTypes flags);
enum class ResourceProvider
{
MODRINTH,
FLAME
};
enum class DependencyType
{
REQUIRED,
OPTIONAL,
INCOMPATIBLE,
EMBEDDED,
TOOL,
INCLUDE,
UNKNOWN
};
enum class Side
{
NoSide = 0,
ClientSide = 1 << 0,
ServerSide = 1 << 1,
UniversalSide = ClientSide | ServerSide
};
namespace SideUtils
{
QString toString(Side side);
Side fromString(QString side);
} // namespace SideUtils
namespace ProviderCapabilities
{
const char* name(ResourceProvider);
QString readableName(ResourceProvider);
QStringList hashType(ResourceProvider);
} // namespace ProviderCapabilities
struct ModpackAuthor
{
QString name;
QString url;
};
struct DonationData
{
QString id;
QString platform;
QString url;
};
struct IndexedVersionType
{
enum class VersionType
{
Release = 1,
Beta,
Alpha,
Unknown
};
IndexedVersionType(const QString& type);
IndexedVersionType(const IndexedVersionType::VersionType& type);
IndexedVersionType(const IndexedVersionType& type);
IndexedVersionType() : IndexedVersionType(IndexedVersionType::VersionType::Unknown)
{}
static const QString toString(const IndexedVersionType::VersionType& type);
static IndexedVersionType::VersionType enumFromString(const QString& type);
bool isValid() const
{
return m_type != IndexedVersionType::VersionType::Unknown;
}
IndexedVersionType& operator=(const IndexedVersionType& other);
bool operator==(const IndexedVersionType& other) const
{
return m_type == other.m_type;
}
bool operator==(const IndexedVersionType::VersionType& type) const
{
return m_type == type;
}
bool operator!=(const IndexedVersionType& other) const
{
return m_type != other.m_type;
}
bool operator!=(const IndexedVersionType::VersionType& type) const
{
return m_type != type;
}
bool operator<(const IndexedVersionType& other) const
{
return m_type < other.m_type;
}
bool operator<(const IndexedVersionType::VersionType& type) const
{
return m_type < type;
}
bool operator<=(const IndexedVersionType& other) const
{
return m_type <= other.m_type;
}
bool operator<=(const IndexedVersionType::VersionType& type) const
{
return m_type <= type;
}
bool operator>(const IndexedVersionType& other) const
{
return m_type > other.m_type;
}
bool operator>(const IndexedVersionType::VersionType& type) const
{
return m_type > type;
}
bool operator>=(const IndexedVersionType& other) const
{
return m_type >= other.m_type;
}
bool operator>=(const IndexedVersionType::VersionType& type) const
{
return m_type >= type;
}
QString toString() const
{
return toString(m_type);
}
IndexedVersionType::VersionType m_type;
};
struct Dependency
{
QVariant addonId;
DependencyType type;
QString version;
};
struct IndexedVersion
{
QVariant addonId;
QVariant fileId;
QString version;
QString version_number = {};
IndexedVersionType version_type;
QStringList mcVersion;
QString downloadUrl;
QString date;
QString fileName;
ModLoaderTypes loaders = {};
QString hash_type;
QString hash;
bool is_preferred = true;
QString changelog;
QList<Dependency> dependencies;
Side side; // this is for flame API
QString relativePath; // Generic target path override
// For internal use, not provided by APIs
bool is_currently_selected = false;
QString getVersionDisplayString() const
{
auto release_type = version_type.isValid() ? QString(" [%1]").arg(version_type.toString()) : "";
auto versionStr = !version.contains(version_number) ? version_number : "";
QString gameVersion = "";
for (auto v : mcVersion)
{
if (version.contains(v))
{
gameVersion = "";
break;
}
if (gameVersion.isEmpty())
{
gameVersion = QObject::tr(" for %1").arg(v);
}
}
return QString("%1%2 — %3%4").arg(version, gameVersion, versionStr, release_type);
}
};
struct ExtraPackData
{
QList<DonationData> donate;
QString issuesUrl;
QString sourceUrl;
QString wikiUrl;
QString discordUrl;
QString status;
QString body;
};
struct IndexedPack
{
using Ptr = std::shared_ptr<IndexedPack>;
QVariant addonId;
ResourceProvider provider;
QString name;
QString slug;
QString description;
QList<ModpackAuthor> authors;
QString logoName;
QString logoUrl;
QString websiteUrl;
Side side;
bool versionsLoaded = false;
QList<IndexedVersion> versions;
// Don't load by default, since some modplatform don't have that info
bool extraDataLoaded = true;
ExtraPackData extraData;
// For internal use, not provided by APIs
bool isVersionSelected(int index) const
{
if (!versionsLoaded)
return false;
return versions.at(index).is_currently_selected;
}
bool isAnyVersionSelected() const
{
if (!versionsLoaded)
return false;
return std::any_of(versions.constBegin(),
versions.constEnd(),
[](auto const& v) { return v.is_currently_selected; });
}
};
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 } };
}
QString getMetaURL(ResourceProvider provider, QVariant projectID);
auto getModLoaderAsString(ModLoaderType type) -> const QString;
auto getModLoaderFromString(QString type) -> ModLoaderType;
constexpr bool hasSingleModLoaderSelected(ModLoaderTypes l) noexcept
{
auto x = static_cast<int>(l);
return x && !(x & (x - 1));
}
struct Category
{
QString name;
QString id;
};
} // namespace ModPlatform
Q_DECLARE_METATYPE(ModPlatform::IndexedPack)
Q_DECLARE_METATYPE(ModPlatform::IndexedPack::Ptr)
Q_DECLARE_METATYPE(ModPlatform::ResourceProvider)
|