aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflow <thiagodonato300@gmail.com>2022-04-19 21:10:12 -0300
committerflow <flowlnlnln@gmail.com>2022-05-23 14:43:07 -0300
commita99858c64d275303a9f91912a2732746ef6a3c8a (patch)
tree1ff9262c039b7d2addf7de4c3557c5c003556150
parentba50765c306d2907e411bc0ed9a10d990cf42fd3 (diff)
downloadPrismLauncher-a99858c64d275303a9f91912a2732746ef6a3c8a.tar.gz
PrismLauncher-a99858c64d275303a9f91912a2732746ef6a3c8a.tar.bz2
PrismLauncher-a99858c64d275303a9f91912a2732746ef6a3c8a.zip
refactor: move code out of ModIndex.h
Now it's in ModIndex.cpp
-rw-r--r--launcher/CMakeLists.txt3
-rw-r--r--launcher/modplatform/ModIndex.cpp24
-rw-r--r--launcher/modplatform/ModIndex.h22
-rw-r--r--launcher/modplatform/flame/FlameAPI.h1
-rw-r--r--launcher/modplatform/modrinth/ModrinthAPI.h1
-rw-r--r--launcher/modplatform/packwiz/Packwiz.cpp11
6 files changed, 37 insertions, 25 deletions
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 6c7b5e43..1bab7ecb 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -500,6 +500,9 @@ set(META_SOURCES
)
set(API_SOURCES
+ modplatform/ModIndex.h
+ modplatform/ModIndex.cpp
+
modplatform/ModAPI.h
modplatform/flame/FlameAPI.h
diff --git a/launcher/modplatform/ModIndex.cpp b/launcher/modplatform/ModIndex.cpp
new file mode 100644
index 00000000..eb8be992
--- /dev/null
+++ b/launcher/modplatform/ModIndex.cpp
@@ -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
diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h
index ee623b78..bb5c7c9d 100644
--- a/launcher/modplatform/ModIndex.h
+++ b/launcher/modplatform/ModIndex.h
@@ -15,26 +15,8 @@ enum class Provider{
class ProviderCapabilities {
public:
- static QString hashType(Provider p)
- {
- 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 "";
- }
+ auto name(Provider) -> const char*;
+ auto hashType(Provider) -> QString;
};
struct ModpackAuthor {
diff --git a/launcher/modplatform/flame/FlameAPI.h b/launcher/modplatform/flame/FlameAPI.h
index 8bb33d47..e31cf0a1 100644
--- a/launcher/modplatform/flame/FlameAPI.h
+++ b/launcher/modplatform/flame/FlameAPI.h
@@ -1,5 +1,6 @@
#pragma once
+#include "modplatform/ModIndex.h"
#include "modplatform/helpers/NetworkModAPI.h"
class FlameAPI : public NetworkModAPI {
diff --git a/launcher/modplatform/modrinth/ModrinthAPI.h b/launcher/modplatform/modrinth/ModrinthAPI.h
index 79bc5175..f9d35fcd 100644
--- a/launcher/modplatform/modrinth/ModrinthAPI.h
+++ b/launcher/modplatform/modrinth/ModrinthAPI.h
@@ -20,6 +20,7 @@
#include "BuildConfig.h"
#include "modplatform/ModAPI.h"
+#include "modplatform/ModIndex.h"
#include "modplatform/helpers/NetworkModAPI.h"
#include <QDebug>
diff --git a/launcher/modplatform/packwiz/Packwiz.cpp b/launcher/modplatform/packwiz/Packwiz.cpp
index 978be462..872da9b1 100644
--- a/launcher/modplatform/packwiz/Packwiz.cpp
+++ b/launcher/modplatform/packwiz/Packwiz.cpp
@@ -19,6 +19,8 @@ static inline auto indexFileName(QString const& mod_name) -> QString
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
{
Mod mod;
@@ -27,7 +29,7 @@ auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, Mo
mod.filename = mod_version.fileName;
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.provider = mod_pack.provider;
@@ -92,7 +94,7 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
addToStream("hash", mod.hash);
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){
case(ModPlatform::Provider::FLAME):
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
- using ProviderCaps = ModPlatform::ProviderCapabilities;
using Provider = ModPlatform::Provider;
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;
- 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.file_id = intEntry(mod_provider_table, "file-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.mod_id() = stringEntry(mod_provider_table, "mod-id");
mod.version() = stringEntry(mod_provider_table, "version");