Make Minecraft resource URL override consistent with other overrides (#4860)
This commit is contained in:
@@ -872,13 +872,13 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
m_settings->reset("MetaURLOverride");
|
||||
|
||||
// Resource URL
|
||||
m_settings->registerSetting("ResourceURL", BuildConfig.DEFAULT_RESOURCE_BASE);
|
||||
m_settings->registerSetting({ "ResourceURLOverride", "ResourceURL" }, "");
|
||||
|
||||
QUrl resourceUrl(m_settings->get("ResourceURL").toString());
|
||||
QUrl resourceUrl(m_settings->get("ResourceURLOverride").toString());
|
||||
|
||||
// get rid of invalid resource urls
|
||||
if (!resourceUrl.isValid() || (resourceUrl.scheme() != "http" && resourceUrl.scheme() != "https"))
|
||||
m_settings->reset("ResourceURL");
|
||||
m_settings->reset("ResourceURLOverride");
|
||||
}
|
||||
|
||||
m_settings->registerSetting("CloseAfterLaunch", false);
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
#include "net/NetRequest.h"
|
||||
#include "update/AssetUpdateTask.h"
|
||||
|
||||
namespace {
|
||||
QSet<QString> collectPathsFromDir(QString dirPath)
|
||||
@@ -298,7 +299,7 @@ QString AssetObject::getLocalPath()
|
||||
|
||||
QUrl AssetObject::getUrl()
|
||||
{
|
||||
auto resourceURL = APPLICATION->settings()->get("ResourceURL").toString();
|
||||
auto resourceURL = AssetUpdateTask::resourceUrl();
|
||||
return resourceURL + getRelPath();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ void AssetUpdateTask::assetIndexFinished()
|
||||
|
||||
auto job = index.getDownloadJob();
|
||||
if (job) {
|
||||
QString resourceURL = APPLICATION->settings()->get("ResourceURL").toString();
|
||||
QString resourceURL = resourceUrl();
|
||||
QString source = tr("Mojang");
|
||||
if (resourceURL != BuildConfig.DEFAULT_RESOURCE_BASE) {
|
||||
source = QUrl(resourceURL).host();
|
||||
@@ -111,3 +111,12 @@ bool AssetUpdateTask::abort()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString AssetUpdateTask::resourceUrl()
|
||||
{
|
||||
if (const QString urlOverride = APPLICATION->settings()->get("ResourceURLOverride").toString(); !urlOverride.isEmpty()) {
|
||||
return urlOverride;
|
||||
}
|
||||
|
||||
return BuildConfig.DEFAULT_RESOURCE_BASE;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ class AssetUpdateTask : public Task {
|
||||
|
||||
bool canAbort() const override;
|
||||
|
||||
public:
|
||||
static QString resourceUrl();
|
||||
|
||||
private slots:
|
||||
void assetIndexFinished();
|
||||
void assetIndexFailed(QString reason);
|
||||
|
||||
@@ -80,6 +80,7 @@ APIPage::APIPage(QWidget* parent) : QWidget(parent), ui(new Ui::APIPage)
|
||||
ui->msaClientID->setValidator(new QRegularExpressionValidator(s_validMSAClientID, ui->msaClientID));
|
||||
|
||||
ui->metaURL->setPlaceholderText(BuildConfig.META_URL);
|
||||
ui->resourceURL->setPlaceholderText(BuildConfig.DEFAULT_RESOURCE_BASE);
|
||||
ui->userAgentLineEdit->setPlaceholderText(BuildConfig.USER_AGENT);
|
||||
|
||||
loadSettings();
|
||||
@@ -136,7 +137,7 @@ void APIPage::loadSettings()
|
||||
ui->msaClientID->setText(msaClientID);
|
||||
QString metaURL = s->get("MetaURLOverride").toString();
|
||||
ui->metaURL->setText(metaURL);
|
||||
QString resourceURL = s->get("ResourceURL").toString();
|
||||
QString resourceURL = s->get("ResourceURLOverride").toString();
|
||||
ui->resourceURL->setText(resourceURL);
|
||||
QString flameKey = s->get("FlameKeyOverride").toString();
|
||||
ui->flameKey->setText(flameKey);
|
||||
@@ -185,7 +186,7 @@ void APIPage::applySettings()
|
||||
}
|
||||
|
||||
s->set("MetaURLOverride", metaURL.toString());
|
||||
s->set("ResourceURL", resourceURL.toString());
|
||||
s->set("ResourceURLOverride", resourceURL.toString());
|
||||
QString flameKey = ui->flameKey->text();
|
||||
s->set("FlameKeyOverride", flameKey);
|
||||
QString modrinthToken = ui->modrinthToken->text();
|
||||
|
||||
Reference in New Issue
Block a user