2022-04-13 22:16:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-04-13 22:23:12 +00:00
|
|
|
#include "modplatform/ModIndex.h"
|
|
|
|
|
2022-04-13 22:16:36 +00:00
|
|
|
#include <QString>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
class QDir;
|
|
|
|
|
2022-04-16 01:37:10 +00:00
|
|
|
// Mod from launcher/minecraft/mod/Mod.h
|
|
|
|
class Mod;
|
|
|
|
|
2022-04-16 16:27:29 +00:00
|
|
|
namespace Packwiz {
|
|
|
|
|
|
|
|
class V1 {
|
2022-04-13 22:16:36 +00:00
|
|
|
public:
|
|
|
|
struct Mod {
|
2022-04-16 01:37:10 +00:00
|
|
|
QString name {};
|
|
|
|
QString filename {};
|
2022-04-13 22:16:36 +00:00
|
|
|
// FIXME: make side an enum
|
2022-04-16 01:37:10 +00:00
|
|
|
QString side {"both"};
|
2022-04-13 22:16:36 +00:00
|
|
|
|
|
|
|
// [download]
|
2022-04-16 01:37:10 +00:00
|
|
|
QUrl url {};
|
2022-04-13 22:16:36 +00:00
|
|
|
// FIXME: make hash-format an enum
|
2022-04-16 01:37:10 +00:00
|
|
|
QString hash_format {};
|
|
|
|
QString hash {};
|
2022-04-13 22:16:36 +00:00
|
|
|
|
|
|
|
// [update]
|
2022-04-16 01:37:10 +00:00
|
|
|
ModPlatform::Provider provider {};
|
|
|
|
QVariant file_id {};
|
|
|
|
QVariant project_id {};
|
|
|
|
|
|
|
|
public:
|
2022-04-17 14:40:41 +00:00
|
|
|
// This is a totally heuristic, but should work for now.
|
|
|
|
auto isValid() const -> bool { return !name.isEmpty() && !project_id.isNull(); }
|
|
|
|
|
|
|
|
// Different providers can use different names for the same thing
|
|
|
|
// Modrinth-specific
|
|
|
|
auto mod_id() -> QVariant& { return project_id; }
|
|
|
|
auto version() -> QVariant& { return file_id; }
|
2022-04-13 22:16:36 +00:00
|
|
|
};
|
|
|
|
|
2022-04-16 01:37:10 +00:00
|
|
|
/* Generates the object representing the information in a mod.toml file via
|
|
|
|
* its common representation in the launcher, when downloading mods.
|
|
|
|
* */
|
2022-04-13 22:16:36 +00:00
|
|
|
static auto createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version) -> Mod;
|
2022-04-16 01:37:10 +00:00
|
|
|
/* Generates the object representing the information in a mod.toml file via
|
|
|
|
* its common representation in the launcher.
|
|
|
|
* */
|
|
|
|
static auto createModFormat(QDir& index_dir, ::Mod& internal_mod) -> Mod;
|
2022-04-13 22:16:36 +00:00
|
|
|
|
|
|
|
/* Updates the mod index for the provided mod.
|
|
|
|
* This creates a new index if one does not exist already
|
|
|
|
* TODO: Ask the user if they want to override, and delete the old mod's files, or keep the old one.
|
|
|
|
* */
|
|
|
|
static void updateModIndex(QDir& index_dir, Mod& mod);
|
2022-04-14 00:25:08 +00:00
|
|
|
|
2022-04-15 01:02:41 +00:00
|
|
|
/* Deletes the metadata for the mod with the given name. If the metadata doesn't exist, it does nothing. */
|
|
|
|
static void deleteModIndex(QDir& index_dir, QString& mod_name);
|
|
|
|
|
2022-04-14 00:25:08 +00:00
|
|
|
/* Gets the metadata for a mod with a particular name.
|
|
|
|
* If the mod doesn't have a metadata, it simply returns an empty Mod object.
|
|
|
|
* */
|
2022-04-17 14:40:41 +00:00
|
|
|
static auto getIndexForMod(QDir& index_dir, QString& index_file_name) -> Mod;
|
2022-04-13 22:16:36 +00:00
|
|
|
};
|
2022-04-16 16:27:29 +00:00
|
|
|
|
|
|
|
} // namespace Packwiz
|