resolve problems

Signed-off-by: clague <93119153+clague@users.noreply.github.com>
This commit is contained in:
clague 2025-06-16 21:56:23 +08:00
parent 4bf6e59f3b
commit 09ec3eb621
No known key found for this signature in database
GPG key ID: B81A7CB54D1C02EA
4 changed files with 12 additions and 18 deletions

View file

@ -866,13 +866,13 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_settings->reset("MetaURLOverride");
// Resource URL
m_settings->registerSetting("ResourceURLOverride", "");
m_settings->registerSetting("ResourceURL", BuildConfig.DEFAULT_RESOURCE_BASE);
QUrl resourceUrl(m_settings->get("ResourceURLOverride").toString());
QUrl resourceUrl(m_settings->get("ResourceURL").toString());
// get rid of invalid resource urls
if (!resourceUrl.isValid() || (resourceUrl.scheme() != "http" && resourceUrl.scheme() != "https"))
m_settings->reset("ResourceURLOverride");
m_settings->reset("ResourceURL");
}
m_settings->registerSetting("CloseAfterLaunch", false);

View file

@ -298,11 +298,7 @@ QString AssetObject::getLocalPath()
QUrl AssetObject::getUrl()
{
auto s = APPLICATION->settings();
auto resourceURL = s->get("ResourceURLOverride").toString();
if (resourceURL.isEmpty()) {
return BuildConfig.DEFAULT_RESOURCE_BASE + getRelPath();
}
auto resourceURL = APPLICATION->settings()->get("ResourceURL").toString();
return resourceURL + getRelPath();
}

View file

@ -1,5 +1,6 @@
#include "AssetUpdateTask.h"
#include "BuildConfig.h"
#include "launch/LaunchStep.h"
#include "minecraft/AssetsUtils.h"
#include "minecraft/MinecraftInstance.h"
@ -71,15 +72,12 @@ void AssetUpdateTask::assetIndexFinished()
auto job = index.getDownloadJob();
if (job) {
QString resourceURLRaw;
auto statusText = tr("Getting the assets files from Mojang...");
resourceURLRaw = APPLICATION->settings()->get("ResourceURLOverride").toString();
// FIXME: Need translation
if (!resourceURLRaw.isEmpty()) {
QUrl resourceURL = QUrl(resourceURLRaw);
statusText.replace("Mojang", resourceURL.host());
QString resourceURL = APPLICATION->settings()->get("ResourceURL").toString();
QString source = tr("Mojang");
if (resourceURL != BuildConfig.DEFAULT_RESOURCE_BASE) {
source = QUrl(resourceURL).host();
}
setStatus(statusText);
setStatus(tr("Getting the assets files from %1...").arg(source));
downloadJob = job;
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);

View file

@ -138,7 +138,7 @@ void APIPage::loadSettings()
ui->msaClientID->setText(msaClientID);
QString metaURL = s->get("MetaURLOverride").toString();
ui->metaURL->setText(metaURL);
QString resourceURL = s->get("ResourceURLOverride").toString();
QString resourceURL = s->get("ResourceURL").toString();
ui->resourceURL->setText(resourceURL);
QString flameKey = s->get("FlameKeyOverride").toString();
ui->flameKey->setText(flameKey);
@ -183,7 +183,7 @@ void APIPage::applySettings()
}
s->set("MetaURLOverride", metaURL.toString());
s->set("ResourceURLOverride", resourceURL.toString());
s->set("ResourceURL", resourceURL.toString());
QString flameKey = ui->flameKey->text();
s->set("FlameKeyOverride", flameKey);
QString modrinthToken = ui->modrinthToken->text();