2020-08-25 03:43:43 +05:30
|
|
|
#include "ATLPackIndex.h"
|
|
|
|
|
|
|
|
#include <QRegularExpression>
|
|
|
|
|
|
|
|
#include "Json.h"
|
|
|
|
|
|
|
|
static void loadIndexedVersion(ATLauncher::IndexedVersion & v, QJsonObject & obj)
|
|
|
|
{
|
|
|
|
v.version = Json::requireString(obj, "version");
|
|
|
|
v.minecraft = Json::requireString(obj, "minecraft");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATLauncher::loadIndexedPack(ATLauncher::IndexedPack & m, QJsonObject & obj)
|
|
|
|
{
|
|
|
|
m.id = Json::requireInteger(obj, "id");
|
|
|
|
m.position = Json::requireInteger(obj, "position");
|
|
|
|
m.name = Json::requireString(obj, "name");
|
|
|
|
m.type = Json::requireString(obj, "type") == "private" ?
|
|
|
|
ATLauncher::PackType::Private :
|
|
|
|
ATLauncher::PackType::Public;
|
|
|
|
auto versionsArr = Json::requireArray(obj, "versions");
|
|
|
|
for (const auto versionRaw : versionsArr)
|
|
|
|
{
|
|
|
|
auto versionObj = Json::requireObject(versionRaw);
|
|
|
|
ATLauncher::IndexedVersion version;
|
|
|
|
loadIndexedVersion(version, versionObj);
|
|
|
|
m.versions.append(version);
|
|
|
|
}
|
2021-02-08 04:21:10 +05:30
|
|
|
m.system = Json::ensureBoolean(obj, QString("system"), false);
|
2020-08-25 03:43:43 +05:30
|
|
|
m.description = Json::ensureString(obj, "description", "");
|
|
|
|
|
|
|
|
m.safeName = Json::requireString(obj, "name").replace(QRegularExpression("[^A-Za-z0-9]"), "");
|
|
|
|
}
|