refactor: move code out of ModIndex.h
Now it's in ModIndex.cpp
This commit is contained in:
parent
ba50765c30
commit
a99858c64d
@ -500,6 +500,9 @@ set(META_SOURCES
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(API_SOURCES
|
set(API_SOURCES
|
||||||
|
modplatform/ModIndex.h
|
||||||
|
modplatform/ModIndex.cpp
|
||||||
|
|
||||||
modplatform/ModAPI.h
|
modplatform/ModAPI.h
|
||||||
|
|
||||||
modplatform/flame/FlameAPI.h
|
modplatform/flame/FlameAPI.h
|
||||||
|
24
launcher/modplatform/ModIndex.cpp
Normal file
24
launcher/modplatform/ModIndex.cpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include "modplatform/ModIndex.h"
|
||||||
|
|
||||||
|
namespace ModPlatform{
|
||||||
|
|
||||||
|
auto ProviderCapabilities::name(Provider p) -> const char*
|
||||||
|
{
|
||||||
|
switch(p){
|
||||||
|
case Provider::MODRINTH:
|
||||||
|
return "modrinth";
|
||||||
|
case Provider::FLAME:
|
||||||
|
return "curseforge";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto ProviderCapabilities::hashType(Provider p) -> QString
|
||||||
|
{
|
||||||
|
switch(p){
|
||||||
|
case Provider::MODRINTH:
|
||||||
|
return "sha512";
|
||||||
|
case Provider::FLAME:
|
||||||
|
return "murmur2";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ModPlatform
|
@ -15,26 +15,8 @@ enum class Provider{
|
|||||||
|
|
||||||
class ProviderCapabilities {
|
class ProviderCapabilities {
|
||||||
public:
|
public:
|
||||||
static QString hashType(Provider p)
|
auto name(Provider) -> const char*;
|
||||||
{
|
auto hashType(Provider) -> QString;
|
||||||
switch(p){
|
|
||||||
case Provider::MODRINTH:
|
|
||||||
return "sha512";
|
|
||||||
case Provider::FLAME:
|
|
||||||
return "murmur2";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
static const char* providerName(Provider p)
|
|
||||||
{
|
|
||||||
switch(p){
|
|
||||||
case Provider::MODRINTH:
|
|
||||||
return "modrinth";
|
|
||||||
case Provider::FLAME:
|
|
||||||
return "curseforge";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ModpackAuthor {
|
struct ModpackAuthor {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
#include "modplatform/helpers/NetworkModAPI.h"
|
#include "modplatform/helpers/NetworkModAPI.h"
|
||||||
|
|
||||||
class FlameAPI : public NetworkModAPI {
|
class FlameAPI : public NetworkModAPI {
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
#include "modplatform/ModAPI.h"
|
#include "modplatform/ModAPI.h"
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
#include "modplatform/helpers/NetworkModAPI.h"
|
#include "modplatform/helpers/NetworkModAPI.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -19,6 +19,8 @@ static inline auto indexFileName(QString const& mod_name) -> QString
|
|||||||
return QString("%1.toml").arg(mod_name);
|
return QString("%1.toml").arg(mod_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||||
|
|
||||||
auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version) -> Mod
|
auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version) -> Mod
|
||||||
{
|
{
|
||||||
Mod mod;
|
Mod mod;
|
||||||
@ -27,7 +29,7 @@ auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, Mo
|
|||||||
mod.filename = mod_version.fileName;
|
mod.filename = mod_version.fileName;
|
||||||
|
|
||||||
mod.url = mod_version.downloadUrl;
|
mod.url = mod_version.downloadUrl;
|
||||||
mod.hash_format = ModPlatform::ProviderCapabilities::hashType(mod_pack.provider);
|
mod.hash_format = ProviderCaps.hashType(mod_pack.provider);
|
||||||
mod.hash = ""; // FIXME
|
mod.hash = ""; // FIXME
|
||||||
|
|
||||||
mod.provider = mod_pack.provider;
|
mod.provider = mod_pack.provider;
|
||||||
@ -92,7 +94,7 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
|
|||||||
addToStream("hash", mod.hash);
|
addToStream("hash", mod.hash);
|
||||||
|
|
||||||
in_stream << QString("\n[update]\n");
|
in_stream << QString("\n[update]\n");
|
||||||
in_stream << QString("[update.%1]\n").arg(ModPlatform::ProviderCapabilities::providerName(mod.provider));
|
in_stream << QString("[update.%1]\n").arg(ProviderCaps.name(mod.provider));
|
||||||
switch(mod.provider){
|
switch(mod.provider){
|
||||||
case(ModPlatform::Provider::FLAME):
|
case(ModPlatform::Provider::FLAME):
|
||||||
in_stream << QString("file-id = %1\n").arg(mod.file_id.toString());
|
in_stream << QString("file-id = %1\n").arg(mod.file_id.toString());
|
||||||
@ -193,7 +195,6 @@ auto V1::getIndexForMod(QDir& index_dir, QString& index_file_name) -> Mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // [update] info
|
{ // [update] info
|
||||||
using ProviderCaps = ModPlatform::ProviderCapabilities;
|
|
||||||
using Provider = ModPlatform::Provider;
|
using Provider = ModPlatform::Provider;
|
||||||
|
|
||||||
toml_table_t* update_table = toml_table_in(table, "update");
|
toml_table_t* update_table = toml_table_in(table, "update");
|
||||||
@ -203,11 +204,11 @@ auto V1::getIndexForMod(QDir& index_dir, QString& index_file_name) -> Mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
toml_table_t* mod_provider_table = nullptr;
|
toml_table_t* mod_provider_table = nullptr;
|
||||||
if ((mod_provider_table = toml_table_in(update_table, ProviderCaps::providerName(Provider::FLAME)))) {
|
if ((mod_provider_table = toml_table_in(update_table, ProviderCaps.name(Provider::FLAME)))) {
|
||||||
mod.provider = Provider::FLAME;
|
mod.provider = Provider::FLAME;
|
||||||
mod.file_id = intEntry(mod_provider_table, "file-id");
|
mod.file_id = intEntry(mod_provider_table, "file-id");
|
||||||
mod.project_id = intEntry(mod_provider_table, "project-id");
|
mod.project_id = intEntry(mod_provider_table, "project-id");
|
||||||
} else if ((mod_provider_table = toml_table_in(update_table, ProviderCaps::providerName(Provider::MODRINTH)))) {
|
} else if ((mod_provider_table = toml_table_in(update_table, ProviderCaps.name(Provider::MODRINTH)))) {
|
||||||
mod.provider = Provider::MODRINTH;
|
mod.provider = Provider::MODRINTH;
|
||||||
mod.mod_id() = stringEntry(mod_provider_table, "mod-id");
|
mod.mod_id() = stringEntry(mod_provider_table, "mod-id");
|
||||||
mod.version() = stringEntry(mod_provider_table, "version");
|
mod.version() = stringEntry(mod_provider_table, "version");
|
||||||
|
Loading…
Reference in New Issue
Block a user