mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-08-03 19:37:45 -04:00
Merge 4273af1d4bab2bb14ae1988634801503fed1adaa into 79b7e277f1f06f6b315e293b029423fe35e57431
This commit is contained in:
commit
04424a3834
@ -317,4 +317,21 @@ Version::Ptr VersionList::getLatestForParent(const QString& uid, const QString&
|
||||
return latestCompat;
|
||||
}
|
||||
|
||||
static const Meta::Version::Ptr& getLatestVersion(const Meta::Version::Ptr& a, const Meta::Version::Ptr& b)
|
||||
{
|
||||
if (!a)
|
||||
return b;
|
||||
if (!b)
|
||||
return a;
|
||||
return (a->rawTime() > b->rawTime() ? a : b);
|
||||
}
|
||||
|
||||
Version::Ptr VersionList::getLatest()
|
||||
{
|
||||
Version::Ptr latestCompat = nullptr;
|
||||
for (auto ver : m_versions) {
|
||||
latestCompat = getLatestVersion(latestCompat, ver);
|
||||
}
|
||||
return latestCompat;
|
||||
}
|
||||
} // namespace Meta
|
||||
|
@ -45,6 +45,7 @@ class VersionList : public BaseVersionList, public BaseEntity {
|
||||
BaseVersion::Ptr getRecommended() const override;
|
||||
Version::Ptr getRecommendedForParent(const QString& uid, const QString& version);
|
||||
Version::Ptr getLatestForParent(const QString& uid, const QString& version);
|
||||
Version::Ptr getLatest();
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
RoleList providesRoles() const override;
|
||||
|
@ -181,6 +181,7 @@ void MinecraftInstance::loadSpecificSettings()
|
||||
auto locationOverride = m_settings->registerSetting("OverrideJavaLocation", false);
|
||||
auto argsOverride = m_settings->registerSetting("OverrideJavaArgs", false);
|
||||
m_settings->registerSetting("AutomaticJava", false);
|
||||
m_settings->registerSetting("UseLatestMinecraftVersion", false);
|
||||
|
||||
if (auto global_settings = globalSettings()) {
|
||||
m_settings->registerOverride(global_settings->getSetting("JavaPath"), locationOverride);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "MinecraftLoadAndCheck.h"
|
||||
#include "Application.h"
|
||||
#include "MinecraftInstance.h"
|
||||
#include "PackProfile.h"
|
||||
|
||||
@ -8,6 +9,14 @@ void MinecraftLoadAndCheck::executeTask()
|
||||
{
|
||||
// add offline metadata load task
|
||||
auto components = m_inst->getPackProfile();
|
||||
if (m_inst->settings()->get("UseLatestMinecraftVersion").toBool()) {
|
||||
if (APPLICATION->settings()->get("AutomaticJavaSwitch").toBool() && m_inst->settings()->get("AutomaticJava").toBool() &&
|
||||
m_inst->settings()->get("OverrideJavaLocation").toBool()) {
|
||||
m_inst->settings()->set("OverrideJavaLocation", false);
|
||||
m_inst->settings()->set("JavaPath", "");
|
||||
}
|
||||
components->updateLatestMinecraft();
|
||||
}
|
||||
if (auto result = components->reload(m_netmode); !result) {
|
||||
emitFailed(result.error);
|
||||
return;
|
||||
|
@ -1061,3 +1061,20 @@ QList<ModPlatform::ModLoaderType> PackProfile::getModLoadersList()
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void PackProfile::updateLatestMinecraft()
|
||||
{
|
||||
const QString uid = "net.minecraft";
|
||||
auto patch = getComponent(uid);
|
||||
patch->waitLoadMeta(); // make sure we have latest versions
|
||||
auto list = patch->getVersionList();
|
||||
if (!list) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto latest = list->getLatest();
|
||||
|
||||
qDebug() << "Change" << uid << "to" << latest.get();
|
||||
setComponentVersion(uid, latest->descriptor(), true);
|
||||
resolve(Net::Mode::Online);
|
||||
}
|
@ -164,6 +164,8 @@ class PackProfile : public QAbstractListModel {
|
||||
/// apply the component patches. Catches all the errors and returns true/false for success/failure
|
||||
void invalidateLaunchProfile();
|
||||
|
||||
void updateLatestMinecraft();
|
||||
|
||||
private:
|
||||
void scheduleSave();
|
||||
bool saveIsScheduled() const;
|
||||
|
@ -60,6 +60,7 @@ MinecraftSettingsWidget::MinecraftSettingsWidget(MinecraftInstancePtr instance,
|
||||
m_ui->serverJoinGroupBox->hide();
|
||||
m_ui->globalDataPacksGroupBox->hide();
|
||||
m_ui->loaderGroup->hide();
|
||||
m_ui->latestMCVersionCheckBox->hide();
|
||||
} else {
|
||||
m_javaSettings = new JavaSettingsWidget(m_instance, this);
|
||||
m_ui->javaScrollArea->setWidget(m_javaSettings);
|
||||
@ -281,6 +282,8 @@ void MinecraftSettingsWidget::loadSettings()
|
||||
m_ui->fabric->blockSignals(false);
|
||||
m_ui->quilt->blockSignals(false);
|
||||
m_ui->liteLoader->blockSignals(false);
|
||||
|
||||
m_ui->latestMCVersionCheckBox->setChecked(settings->get("UseLatestMinecraftVersion").toBool());
|
||||
}
|
||||
|
||||
m_ui->legacySettingsGroupBox->setChecked(settings->get("OverrideLegacySettings").toBool());
|
||||
@ -457,6 +460,8 @@ void MinecraftSettingsWidget::saveSettings()
|
||||
} else {
|
||||
settings->reset("InstanceAccountId");
|
||||
}
|
||||
|
||||
settings->set("UseLatestMinecraftVersion", m_ui->latestMCVersionCheckBox->isChecked());
|
||||
}
|
||||
|
||||
bool overrideLegacySettings = m_instance == nullptr || m_ui->legacySettingsGroupBox->isChecked();
|
||||
|
@ -519,6 +519,13 @@ It is most likely you will need to change the path - please refer to the mod's w
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="latestMCVersionCheckBox">
|
||||
<property name="text">
|
||||
<string>Always use the latest minecraft version</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
Loading…
x
Reference in New Issue
Block a user