fix: implement PR suggestions
Some stylistic changes, and get hashes from the mod providers when building the metadata.
This commit is contained in:
parent
96e36f0604
commit
e17b6804a7
@ -644,7 +644,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
m_settings->registerSetting("MCLaunchMethod", "LauncherPart");
|
m_settings->registerSetting("MCLaunchMethod", "LauncherPart");
|
||||||
|
|
||||||
// Minecraft mods
|
// Minecraft mods
|
||||||
m_settings->registerSetting("DontUseModMetadata", false);
|
m_settings->registerSetting("ModMetadataDisabled", false);
|
||||||
|
|
||||||
// Minecraft offline player name
|
// Minecraft offline player name
|
||||||
m_settings->registerSetting("LastOfflinePlayerName", "");
|
m_settings->registerSetting("LastOfflinePlayerName", "");
|
||||||
|
@ -10,7 +10,7 @@ ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir)
|
|||||||
|
|
||||||
void ModFolderLoadTask::run()
|
void ModFolderLoadTask::run()
|
||||||
{
|
{
|
||||||
if (!APPLICATION->settings()->get("DontUseModMetadata").toBool()) {
|
if (!APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
|
||||||
// Read metadata first
|
// Read metadata first
|
||||||
getFromMetadata();
|
getFromMetadata();
|
||||||
}
|
}
|
||||||
@ -34,14 +34,9 @@ void ModFolderLoadTask::run()
|
|||||||
void ModFolderLoadTask::getFromMetadata()
|
void ModFolderLoadTask::getFromMetadata()
|
||||||
{
|
{
|
||||||
m_index_dir.refresh();
|
m_index_dir.refresh();
|
||||||
for (auto entry : m_index_dir.entryList()) {
|
for (auto entry : m_index_dir.entryList(QDir::Files)) {
|
||||||
// QDir::Filter::NoDotAndDotDot seems to exclude all files for some reason...
|
|
||||||
if (entry == "." || entry == "..")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto metadata = Metadata::get(m_index_dir, entry);
|
auto metadata = Metadata::get(m_index_dir, entry);
|
||||||
// TODO: Don't simply return. Instead, show to the user that the metadata is there, but
|
|
||||||
// it's not currently 'installed' (i.e. there's no JAR file yet).
|
|
||||||
if(!metadata.isValid()){
|
if(!metadata.isValid()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace ModPlatform {
|
namespace ModPlatform {
|
||||||
|
|
||||||
enum class Provider{
|
enum class Provider {
|
||||||
MODRINTH,
|
MODRINTH,
|
||||||
FLAME
|
FLAME
|
||||||
};
|
};
|
||||||
@ -33,6 +33,7 @@ struct IndexedVersion {
|
|||||||
QString date;
|
QString date;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
QVector<QString> loaders = {};
|
QVector<QString> loaders = {};
|
||||||
|
QString hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IndexedPack {
|
struct IndexedPack {
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include "modplatform/flame/FlameAPI.h"
|
#include "modplatform/flame/FlameAPI.h"
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
|
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||||
|
|
||||||
void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
||||||
{
|
{
|
||||||
pack.addonId = Json::requireInteger(obj, "id");
|
pack.addonId = Json::requireInteger(obj, "id");
|
||||||
@ -60,6 +62,12 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
|||||||
file.downloadUrl = Json::requireString(obj, "downloadUrl");
|
file.downloadUrl = Json::requireString(obj, "downloadUrl");
|
||||||
file.fileName = Json::requireString(obj, "fileName");
|
file.fileName = Json::requireString(obj, "fileName");
|
||||||
|
|
||||||
|
auto hash_list = Json::ensureArray(obj, "hashes");
|
||||||
|
if(!hash_list.isEmpty()){
|
||||||
|
if(hash_list.contains(ProviderCaps.hashType(ModPlatform::Provider::FLAME)))
|
||||||
|
file.hash = Json::requireString(hash_list, "value");
|
||||||
|
}
|
||||||
|
|
||||||
unsortedVersions.append(file);
|
unsortedVersions.append(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
static ModrinthAPI api;
|
static ModrinthAPI api;
|
||||||
|
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||||
|
|
||||||
void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
||||||
{
|
{
|
||||||
@ -95,6 +96,9 @@ void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
|||||||
if (parent.contains("url")) {
|
if (parent.contains("url")) {
|
||||||
file.downloadUrl = Json::requireString(parent, "url");
|
file.downloadUrl = Json::requireString(parent, "url");
|
||||||
file.fileName = Json::requireString(parent, "filename");
|
file.fileName = Json::requireString(parent, "filename");
|
||||||
|
auto hash_list = Json::requireObject(parent, "hashes");
|
||||||
|
if(hash_list.contains(ProviderCaps.hashType(ModPlatform::Provider::MODRINTH)))
|
||||||
|
file.hash = Json::requireString(hash_list, ProviderCaps.hashType(ModPlatform::Provider::MODRINTH));
|
||||||
|
|
||||||
unsortedVersions.append(file);
|
unsortedVersions.append(file);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, Mo
|
|||||||
|
|
||||||
mod.url = mod_version.downloadUrl;
|
mod.url = mod_version.downloadUrl;
|
||||||
mod.hash_format = ProviderCaps.hashType(mod_pack.provider);
|
mod.hash_format = ProviderCaps.hashType(mod_pack.provider);
|
||||||
mod.hash = ""; // FIXME
|
mod.hash = mod_version.hash;
|
||||||
|
|
||||||
mod.provider = mod_pack.provider;
|
mod.provider = mod_pack.provider;
|
||||||
mod.file_id = mod_pack.addonId;
|
mod.file_id = mod_pack.addonId;
|
||||||
|
@ -345,7 +345,7 @@ void LauncherPage::applySettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mods
|
// Mods
|
||||||
s->set("DontUseModMetadata", ui->metadataDisableBtn->isChecked());
|
s->set("ModMetadataDisabled", ui->metadataDisableBtn->isChecked());
|
||||||
}
|
}
|
||||||
void LauncherPage::loadSettings()
|
void LauncherPage::loadSettings()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user