2022-05-26 22:18:54 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following copyright and
|
|
|
|
* permission notice:
|
|
|
|
*
|
|
|
|
* Copyright 2013-2021 MultiMC Contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-04-20 04:22:04 +01:00
|
|
|
#pragma once
|
|
|
|
|
2022-07-14 20:41:49 +01:00
|
|
|
#include <QJsonObject>
|
2022-05-28 20:53:12 +01:00
|
|
|
#include <QMap>
|
2022-07-14 20:41:49 +01:00
|
|
|
#include <QString>
|
2018-01-21 02:49:54 +00:00
|
|
|
#include <QUrl>
|
2022-07-14 20:41:49 +01:00
|
|
|
#include <QVector>
|
2017-04-20 04:22:04 +01:00
|
|
|
|
2017-04-22 17:51:04 +01:00
|
|
|
namespace Flame
|
2017-04-20 04:22:04 +01:00
|
|
|
{
|
|
|
|
struct File
|
|
|
|
{
|
2019-06-30 10:03:59 +01:00
|
|
|
// NOTE: throws JSONValidationError
|
2022-07-21 20:41:44 +01:00
|
|
|
bool parseFromObject(const QJsonObject& object, bool throw_on_blocked = true);
|
2019-06-30 10:03:59 +01:00
|
|
|
|
2017-04-20 04:22:04 +01:00
|
|
|
int projectId = 0;
|
|
|
|
int fileId = 0;
|
2017-09-08 08:02:27 +01:00
|
|
|
// NOTE: the opposite to 'optional'. This is at the time of writing unused.
|
2017-04-20 04:22:04 +01:00
|
|
|
bool required = true;
|
2022-05-28 20:53:12 +01:00
|
|
|
QString hash;
|
|
|
|
// NOTE: only set on blocked files ! Empty otherwise.
|
|
|
|
QString websiteUrl;
|
2017-04-20 04:22:04 +01:00
|
|
|
|
|
|
|
// our
|
|
|
|
bool resolved = false;
|
|
|
|
QString fileName;
|
2018-01-21 02:49:54 +00:00
|
|
|
QUrl url;
|
2022-05-02 18:10:45 +01:00
|
|
|
QString targetFolder = QStringLiteral("mods");
|
2017-09-08 08:02:27 +01:00
|
|
|
enum class Type
|
|
|
|
{
|
|
|
|
Unknown,
|
|
|
|
Folder,
|
|
|
|
Ctoc,
|
|
|
|
SingleFile,
|
|
|
|
Cmod2,
|
|
|
|
Modpack,
|
|
|
|
Mod
|
|
|
|
} type = Type::Mod;
|
2017-04-20 04:22:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Modloader
|
|
|
|
{
|
|
|
|
QString id;
|
|
|
|
bool primary = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Minecraft
|
|
|
|
{
|
|
|
|
QString version;
|
2017-04-21 23:29:24 +01:00
|
|
|
QString libraries;
|
2017-04-22 17:51:04 +01:00
|
|
|
QVector<Flame::Modloader> modLoaders;
|
2017-04-20 04:22:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Manifest
|
|
|
|
{
|
|
|
|
QString manifestType;
|
|
|
|
int manifestVersion = 0;
|
2017-04-22 17:51:04 +01:00
|
|
|
Flame::Minecraft minecraft;
|
2017-04-20 04:22:04 +01:00
|
|
|
QString name;
|
|
|
|
QString version;
|
|
|
|
QString author;
|
2022-05-28 20:53:12 +01:00
|
|
|
//File id -> File
|
|
|
|
QMap<int,Flame::File> files;
|
2017-04-20 04:22:04 +01:00
|
|
|
QString overrides;
|
2022-07-14 20:41:49 +01:00
|
|
|
|
|
|
|
bool is_loaded = false;
|
2017-04-20 04:22:04 +01:00
|
|
|
};
|
|
|
|
|
2017-04-22 17:51:04 +01:00
|
|
|
void loadManifest(Flame::Manifest & m, const QString &filepath);
|
2017-04-20 04:22:04 +01:00
|
|
|
}
|