mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
feat+fix: Rework modrinth fallback for blocked mods a bit (#4499)
This commit is contained in:
commit
5dd90996b9
4 changed files with 34 additions and 24 deletions
|
|
@ -886,6 +886,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||
m_settings->set("FlameKeyOverride", flameKey);
|
||||
m_settings->reset("CFKeyOverride");
|
||||
}
|
||||
m_settings->registerSetting("FallbackMRBlockedMods", true);
|
||||
m_settings->registerSetting("ModrinthToken", "");
|
||||
m_settings->registerSetting("UserAgentOverride", "");
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#include "net/NetJob.h"
|
||||
#include "tasks/Task.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
static const FlameAPI flameAPI;
|
||||
static ModrinthAPI modrinthAPI;
|
||||
|
||||
|
|
@ -169,34 +171,30 @@ void Flame::FileResolvingTask::netJobFinished(QByteArray* response)
|
|||
|
||||
getFlameProjects();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (APPLICATION->settings()->get("FallbackMRBlockedMods").toBool()){
|
||||
try {
|
||||
auto entries = Json::requireObject(doc);
|
||||
for (auto& out : m_manifest.files) {
|
||||
auto url = QUrl(out.version.downloadUrl, QUrl::TolerantMode);
|
||||
if (!url.isValid() && "sha1" == out.version.hash_type && !out.version.hash.isEmpty()) {
|
||||
try {
|
||||
auto entry = Json::requireObject(entries, out.version.hash);
|
||||
|
||||
try {
|
||||
auto entries = Json::requireObject(doc);
|
||||
for (auto& out : m_manifest.files) {
|
||||
auto url = QUrl(out.version.downloadUrl, QUrl::TolerantMode);
|
||||
if (!url.isValid() && "sha1" == out.version.hash_type && !out.version.hash.isEmpty()) {
|
||||
try {
|
||||
auto entry = Json::requireObject(entries, out.version.hash);
|
||||
auto file = Modrinth::loadIndexedPackVersion(entry);
|
||||
|
||||
auto file = Modrinth::loadIndexedPackVersion(entry);
|
||||
|
||||
// If there's more than one mod loader for this version, we can't know for sure
|
||||
// which file is relative to each loader, so it's best to not use any one and
|
||||
// let the user download it manually.
|
||||
if (!file.loaders || hasSingleModLoaderSelected(file.loaders)) {
|
||||
out.version.downloadUrl = file.downloadUrl;
|
||||
qDebug() << "Found alternative on modrinth" << out.version.fileName;
|
||||
} catch (Json::JsonException& e) {
|
||||
qDebug() << e.cause();
|
||||
qDebug() << entries;
|
||||
}
|
||||
} catch (Json::JsonException& e) {
|
||||
qDebug() << e.cause();
|
||||
qDebug() << entries;
|
||||
}
|
||||
}
|
||||
} catch (Json::JsonException& e) {
|
||||
qDebug() << e.cause();
|
||||
qDebug() << doc;
|
||||
}
|
||||
} catch (Json::JsonException& e) {
|
||||
qDebug() << e.cause();
|
||||
qDebug() << doc;
|
||||
}
|
||||
getFlameProjects();
|
||||
});
|
||||
|
|
@ -215,7 +213,6 @@ void Flame::FileResolvingTask::netJobFinished(QByteArray* response)
|
|||
step_progress->status = status;
|
||||
stepProgress(*step_progress);
|
||||
});
|
||||
|
||||
m_task->start();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,6 +135,10 @@ void APIPage::loadSettings()
|
|||
|
||||
ui->pasteTypeComboBox->setCurrentIndex(pasteTypeIndex);
|
||||
|
||||
if (bool fallbackMRBlockedMods = s->get("FallbackMRBlockedMods").toBool()) {
|
||||
ui->FallbackMRBlockedMods->setChecked(fallbackMRBlockedMods);
|
||||
}
|
||||
|
||||
QString msaClientID = s->get("MSAClientIDOverride").toString();
|
||||
ui->msaClientID->setText(msaClientID);
|
||||
QString metaURL = s->get("MetaURLOverride").toString();
|
||||
|
|
@ -188,6 +192,7 @@ void APIPage::applySettings()
|
|||
upgradeToHTTPS(resourceURL);
|
||||
upgradeToHTTPS(fmlLibsURL);
|
||||
|
||||
s->set("FallbackMRBlockedMods", ui->FallbackMRBlockedMods->checkState());
|
||||
s->set("MetaURLOverride", metaURL.toString());
|
||||
s->set("ResourceURLOverride", resourceURL.toString());
|
||||
s->set("LegacyFMLLibsURLOverride", fmlLibsURL.toString());
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-216</y>
|
||||
<width>816</width>
|
||||
<height>832</height>
|
||||
<y>-262</y>
|
||||
<width>820</width>
|
||||
<height>908</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
|
|
@ -379,6 +379,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="FallbackMRBlockedMods">
|
||||
<property name="text">
|
||||
<string>Enable fallback to Modrinth for blocked mods</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue