mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-08-04 03:47:57 -04:00
add setting to update minecraft instance setting to the latest available version
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
078de50951
commit
db429d1de1
@ -317,4 +317,21 @@ Version::Ptr VersionList::getLatestForParent(const QString& uid, const QString&
|
|||||||
return latestCompat;
|
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
|
} // namespace Meta
|
||||||
|
@ -45,6 +45,7 @@ class VersionList : public BaseVersionList, public BaseEntity {
|
|||||||
BaseVersion::Ptr getRecommended() const override;
|
BaseVersion::Ptr getRecommended() const override;
|
||||||
Version::Ptr getRecommendedForParent(const QString& uid, const QString& version);
|
Version::Ptr getRecommendedForParent(const QString& uid, const QString& version);
|
||||||
Version::Ptr getLatestForParent(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;
|
QVariant data(const QModelIndex& index, int role) const override;
|
||||||
RoleList providesRoles() const override;
|
RoleList providesRoles() const override;
|
||||||
|
@ -181,6 +181,7 @@ void MinecraftInstance::loadSpecificSettings()
|
|||||||
auto locationOverride = m_settings->registerSetting("OverrideJavaLocation", false);
|
auto locationOverride = m_settings->registerSetting("OverrideJavaLocation", false);
|
||||||
auto argsOverride = m_settings->registerSetting("OverrideJavaArgs", false);
|
auto argsOverride = m_settings->registerSetting("OverrideJavaArgs", false);
|
||||||
m_settings->registerSetting("AutomaticJava", false);
|
m_settings->registerSetting("AutomaticJava", false);
|
||||||
|
m_settings->registerSetting("UseLatestMinecraftVersion", false);
|
||||||
|
|
||||||
if (auto global_settings = globalSettings()) {
|
if (auto global_settings = globalSettings()) {
|
||||||
m_settings->registerOverride(global_settings->getSetting("JavaPath"), locationOverride);
|
m_settings->registerOverride(global_settings->getSetting("JavaPath"), locationOverride);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "MinecraftLoadAndCheck.h"
|
#include "MinecraftLoadAndCheck.h"
|
||||||
|
#include "Application.h"
|
||||||
#include "MinecraftInstance.h"
|
#include "MinecraftInstance.h"
|
||||||
#include "PackProfile.h"
|
#include "PackProfile.h"
|
||||||
|
|
||||||
@ -8,6 +9,14 @@ void MinecraftLoadAndCheck::executeTask()
|
|||||||
{
|
{
|
||||||
// add offline metadata load task
|
// add offline metadata load task
|
||||||
auto components = m_inst->getPackProfile();
|
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) {
|
if (auto result = components->reload(m_netmode); !result) {
|
||||||
emitFailed(result.error);
|
emitFailed(result.error);
|
||||||
return;
|
return;
|
||||||
|
@ -1061,3 +1061,20 @@ QList<ModPlatform::ModLoaderType> PackProfile::getModLoadersList()
|
|||||||
}
|
}
|
||||||
return result;
|
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
|
/// apply the component patches. Catches all the errors and returns true/false for success/failure
|
||||||
void invalidateLaunchProfile();
|
void invalidateLaunchProfile();
|
||||||
|
|
||||||
|
void updateLatestMinecraft();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void scheduleSave();
|
void scheduleSave();
|
||||||
bool saveIsScheduled() const;
|
bool saveIsScheduled() const;
|
||||||
|
@ -60,6 +60,7 @@ MinecraftSettingsWidget::MinecraftSettingsWidget(MinecraftInstancePtr instance,
|
|||||||
m_ui->serverJoinGroupBox->hide();
|
m_ui->serverJoinGroupBox->hide();
|
||||||
m_ui->globalDataPacksGroupBox->hide();
|
m_ui->globalDataPacksGroupBox->hide();
|
||||||
m_ui->loaderGroup->hide();
|
m_ui->loaderGroup->hide();
|
||||||
|
m_ui->latestMCVersionCheckBox->hide();
|
||||||
} else {
|
} else {
|
||||||
m_javaSettings = new JavaSettingsWidget(m_instance, this);
|
m_javaSettings = new JavaSettingsWidget(m_instance, this);
|
||||||
m_ui->javaScrollArea->setWidget(m_javaSettings);
|
m_ui->javaScrollArea->setWidget(m_javaSettings);
|
||||||
@ -281,6 +282,8 @@ void MinecraftSettingsWidget::loadSettings()
|
|||||||
m_ui->fabric->blockSignals(false);
|
m_ui->fabric->blockSignals(false);
|
||||||
m_ui->quilt->blockSignals(false);
|
m_ui->quilt->blockSignals(false);
|
||||||
m_ui->liteLoader->blockSignals(false);
|
m_ui->liteLoader->blockSignals(false);
|
||||||
|
|
||||||
|
m_ui->latestMCVersionCheckBox->setChecked(settings->get("UseLatestMinecraftVersion").toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->legacySettingsGroupBox->setChecked(settings->get("OverrideLegacySettings").toBool());
|
m_ui->legacySettingsGroupBox->setChecked(settings->get("OverrideLegacySettings").toBool());
|
||||||
@ -457,6 +460,8 @@ void MinecraftSettingsWidget::saveSettings()
|
|||||||
} else {
|
} else {
|
||||||
settings->reset("InstanceAccountId");
|
settings->reset("InstanceAccountId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings->set("UseLatestMinecraftVersion", m_ui->latestMCVersionCheckBox->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool overrideLegacySettings = m_instance == nullptr || m_ui->legacySettingsGroupBox->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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="latestMCVersionCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Allways use the latest minecraft version</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_2">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user