309
launcher/ui/widgets/JavaSettingsWidget.cpp
Normal file
309
launcher/ui/widgets/JavaSettingsWidget.cpp
Normal file
@@ -0,0 +1,309 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2024 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
*
|
||||
* Copyright 2013-2021 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "JavaSettingsWidget.h"
|
||||
#include <Application.h>
|
||||
#include <BuildConfig.h>
|
||||
#include <JavaCommon.h>
|
||||
#include <settings/Setting.h>
|
||||
#include <ui/java/InstallJavaDialog.h>
|
||||
|
||||
#include <FileSystem.h>
|
||||
#include <java/JavaInstallList.h>
|
||||
#include <java/JavaUtils.h>
|
||||
#include <sys.h>
|
||||
#include <ui/dialogs/CustomMessageBox.h>
|
||||
#include <ui/dialogs/VersionSelectDialog.h>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <memory>
|
||||
|
||||
#include "ui_JavaSettingsWidget.h"
|
||||
|
||||
JavaSettingsWidget::JavaSettingsWidget(InstancePtr instance, QWidget* parent)
|
||||
: QWidget(parent), m_instance(std::move(instance)), m_ui(new Ui::JavaSettingsWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (m_instance == nullptr) {
|
||||
m_ui->javaDownloadBtn->hide();
|
||||
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
|
||||
connect(m_ui->autodetectJavaCheckBox, &QCheckBox::stateChanged, this, [this](bool state) {
|
||||
m_ui->autodownloadJavaCheckBox->setEnabled(state);
|
||||
if (!state)
|
||||
m_ui->autodownloadJavaCheckBox->setChecked(false);
|
||||
});
|
||||
} else {
|
||||
m_ui->autodownloadJavaCheckBox->hide();
|
||||
}
|
||||
} else {
|
||||
m_ui->javaDownloadBtn->setVisible(BuildConfig.JAVA_DOWNLOADER_ENABLED);
|
||||
m_ui->skipWizardCheckBox->hide();
|
||||
m_ui->autodetectJavaCheckBox->hide();
|
||||
m_ui->autodownloadJavaCheckBox->hide();
|
||||
|
||||
m_ui->javaInstallationGroupBox->setCheckable(true);
|
||||
m_ui->memoryGroupBox->setCheckable(true);
|
||||
m_ui->javaArgumentsGroupBox->setCheckable(true);
|
||||
|
||||
SettingsObjectPtr settings = m_instance->settings();
|
||||
|
||||
connect(settings->getSetting("OverrideJavaLocation").get(), &Setting::SettingChanged, m_ui->javaInstallationGroupBox,
|
||||
[this, settings] { m_ui->javaInstallationGroupBox->setChecked(settings->get("OverrideJavaLocation").toBool()); });
|
||||
connect(settings->getSetting("JavaPath").get(), &Setting::SettingChanged, m_ui->javaInstallationGroupBox,
|
||||
[this, settings] { m_ui->javaPathTextBox->setText(settings->get("JavaPath").toString()); });
|
||||
|
||||
connect(m_ui->javaDownloadBtn, &QPushButton::clicked, this, [this] {
|
||||
auto javaDialog = new Java::InstallDialog({}, m_instance.get(), this);
|
||||
javaDialog->exec();
|
||||
});
|
||||
}
|
||||
|
||||
connect(m_ui->javaTestBtn, &QPushButton::clicked, this, &JavaSettingsWidget::onJavaTest);
|
||||
connect(m_ui->javaDetectBtn, &QPushButton::clicked, this, &JavaSettingsWidget::onJavaAutodetect);
|
||||
connect(m_ui->javaBrowseBtn, &QPushButton::clicked, this, &JavaSettingsWidget::onJavaBrowse);
|
||||
|
||||
connect(m_ui->maxMemSpinBox, &QSpinBox::valueChanged, this, &JavaSettingsWidget::updateThresholds);
|
||||
|
||||
loadSettings();
|
||||
updateThresholds();
|
||||
}
|
||||
|
||||
JavaSettingsWidget::~JavaSettingsWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void JavaSettingsWidget::loadSettings()
|
||||
{
|
||||
SettingsObjectPtr settings;
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings = m_instance->settings();
|
||||
else
|
||||
settings = APPLICATION->settings();
|
||||
|
||||
// Java Settings
|
||||
m_ui->javaInstallationGroupBox->setChecked(settings->get("OverrideJavaLocation").toBool());
|
||||
m_ui->javaPathTextBox->setText(settings->get("JavaPath").toString());
|
||||
|
||||
m_ui->skipCompatibilityCheckBox->setChecked(settings->get("IgnoreJavaCompatibility").toBool());
|
||||
|
||||
m_ui->javaArgumentsGroupBox->setChecked(m_instance == nullptr || settings->get("OverrideJavaArgs").toBool());
|
||||
m_ui->jvmArgsTextBox->setPlainText(settings->get("JvmArgs").toString());
|
||||
|
||||
if (m_instance == nullptr) {
|
||||
m_ui->skipWizardCheckBox->setChecked(settings->get("IgnoreJavaWizard").toBool());
|
||||
m_ui->autodetectJavaCheckBox->setChecked(settings->get("AutomaticJavaSwitch").toBool());
|
||||
m_ui->autodetectJavaCheckBox->stateChanged(m_ui->autodetectJavaCheckBox->isChecked());
|
||||
m_ui->autodownloadJavaCheckBox->setChecked(settings->get("AutomaticJavaDownload").toBool());
|
||||
}
|
||||
|
||||
// Memory
|
||||
m_ui->memoryGroupBox->setChecked(m_instance == nullptr || settings->get("OverrideMemory").toBool());
|
||||
int min = settings->get("MinMemAlloc").toInt();
|
||||
int max = settings->get("MaxMemAlloc").toInt();
|
||||
if (min < max) {
|
||||
m_ui->minMemSpinBox->setValue(min);
|
||||
m_ui->maxMemSpinBox->setValue(max);
|
||||
} else {
|
||||
m_ui->minMemSpinBox->setValue(max);
|
||||
m_ui->maxMemSpinBox->setValue(min);
|
||||
}
|
||||
m_ui->permGenSpinBox->setValue(settings->get("PermGen").toInt());
|
||||
|
||||
// Java arguments
|
||||
m_ui->javaArgumentsGroupBox->setChecked(m_instance == nullptr || settings->get("OverrideJavaArgs").toBool());
|
||||
m_ui->jvmArgsTextBox->setPlainText(settings->get("JvmArgs").toString());
|
||||
}
|
||||
|
||||
void JavaSettingsWidget::saveSettings()
|
||||
{
|
||||
SettingsObjectPtr settings;
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings = m_instance->settings();
|
||||
else
|
||||
settings = APPLICATION->settings();
|
||||
|
||||
SettingsObject::Lock lock(settings);
|
||||
|
||||
// Java Install Settings
|
||||
bool javaInstall = m_instance == nullptr || m_ui->javaInstallationGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideJavaLocation", javaInstall);
|
||||
|
||||
if (javaInstall) {
|
||||
settings->set("JavaPath", m_ui->javaPathTextBox->text());
|
||||
settings->set("IgnoreJavaCompatibility", m_ui->skipCompatibilityCheckBox->isChecked());
|
||||
} else {
|
||||
settings->reset("JavaPath");
|
||||
settings->reset("IgnoreJavaCompatibility");
|
||||
}
|
||||
|
||||
if (m_instance == nullptr) {
|
||||
settings->set("IgnoreJavaWizard", m_ui->skipWizardCheckBox->isChecked());
|
||||
settings->set("AutomaticJavaSwitch", m_ui->autodetectJavaCheckBox->isChecked());
|
||||
settings->set("AutomaticJavaDownload", m_ui->autodownloadJavaCheckBox->isChecked());
|
||||
}
|
||||
|
||||
// Memory
|
||||
bool memory = m_instance == nullptr || m_ui->memoryGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideMemory", memory);
|
||||
|
||||
if (memory) {
|
||||
int min = m_ui->minMemSpinBox->value();
|
||||
int max = m_ui->maxMemSpinBox->value();
|
||||
if (min < max) {
|
||||
settings->set("MinMemAlloc", min);
|
||||
settings->set("MaxMemAlloc", max);
|
||||
} else {
|
||||
settings->set("MinMemAlloc", max);
|
||||
settings->set("MaxMemAlloc", min);
|
||||
}
|
||||
settings->set("PermGen", m_ui->permGenSpinBox->value());
|
||||
} else {
|
||||
settings->reset("MinMemAlloc");
|
||||
settings->reset("MaxMemAlloc");
|
||||
settings->reset("PermGen");
|
||||
}
|
||||
|
||||
// Java arguments
|
||||
bool javaArgs = m_instance == nullptr || m_ui->javaArgumentsGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideJavaArgs", javaArgs);
|
||||
|
||||
if (javaArgs) {
|
||||
settings->set("JvmArgs", m_ui->jvmArgsTextBox->toPlainText().replace("\n", " "));
|
||||
} else {
|
||||
settings->reset("JvmArgs");
|
||||
}
|
||||
}
|
||||
|
||||
void JavaSettingsWidget::onJavaBrowse()
|
||||
{
|
||||
QString rawPath = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
|
||||
|
||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||
if (rawPath.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString cookedPath = FS::NormalizePath(rawPath);
|
||||
QFileInfo javaInfo(cookedPath);
|
||||
if (!javaInfo.exists() || !javaInfo.isExecutable()) {
|
||||
return;
|
||||
}
|
||||
m_ui->javaPathTextBox->setText(cookedPath);
|
||||
}
|
||||
|
||||
void JavaSettingsWidget::onJavaTest()
|
||||
{
|
||||
if (m_checker != nullptr)
|
||||
return;
|
||||
|
||||
QString jvmArgs;
|
||||
|
||||
if (m_instance == nullptr || m_ui->javaArgumentsGroupBox->isChecked())
|
||||
jvmArgs = m_ui->jvmArgsTextBox->toPlainText().replace("\n", " ");
|
||||
else
|
||||
jvmArgs = APPLICATION->settings()->get("JvmArgs").toString();
|
||||
|
||||
m_checker.reset(new JavaCommon::TestCheck(this, m_ui->javaPathTextBox->text(), jvmArgs, m_ui->minMemSpinBox->value(),
|
||||
m_ui->maxMemSpinBox->value(), m_ui->permGenSpinBox->value()));
|
||||
connect(m_checker.get(), &JavaCommon::TestCheck::finished, this, [this] { m_checker.reset(); });
|
||||
m_checker->run();
|
||||
}
|
||||
|
||||
void JavaSettingsWidget::onJavaAutodetect()
|
||||
{
|
||||
if (JavaUtils::getJavaCheckPath().isEmpty()) {
|
||||
JavaCommon::javaCheckNotFound(this);
|
||||
return;
|
||||
}
|
||||
|
||||
VersionSelectDialog versionDialog(APPLICATION->javalist().get(), tr("Select a Java version"), this, true);
|
||||
versionDialog.setResizeOn(2);
|
||||
versionDialog.exec();
|
||||
|
||||
if (versionDialog.result() == QDialog::Accepted && versionDialog.selectedVersion()) {
|
||||
JavaInstallPtr java = std::dynamic_pointer_cast<JavaInstall>(versionDialog.selectedVersion());
|
||||
m_ui->javaPathTextBox->setText(java->path);
|
||||
|
||||
if (!java->is_64bit && m_ui->maxMemSpinBox->value() > 2048) {
|
||||
CustomMessageBox::selectable(this, tr("Confirm Selection"),
|
||||
tr("You selected a 32-bit version of Java.\n"
|
||||
"This installation does not support more than 2048MiB of RAM.\n"
|
||||
"Please make sure that the maximum memory value is lower."),
|
||||
QMessageBox::Warning, QMessageBox::Ok, QMessageBox::Ok)
|
||||
->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
void JavaSettingsWidget::updateThresholds()
|
||||
{
|
||||
auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
|
||||
unsigned int maxMem = m_ui->maxMemSpinBox->value();
|
||||
unsigned int minMem = m_ui->minMemSpinBox->value();
|
||||
|
||||
QString iconName;
|
||||
|
||||
if (maxMem >= sysMiB) {
|
||||
iconName = "status-bad";
|
||||
m_ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity."));
|
||||
} else if (maxMem > (sysMiB * 0.9)) {
|
||||
iconName = "status-yellow";
|
||||
m_ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity."));
|
||||
} else if (maxMem < minMem) {
|
||||
iconName = "status-yellow";
|
||||
m_ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation is smaller than the minimum value"));
|
||||
} else {
|
||||
iconName = "status-good";
|
||||
m_ui->labelMaxMemIcon->setToolTip("");
|
||||
}
|
||||
|
||||
{
|
||||
auto height = m_ui->labelMaxMemIcon->fontInfo().pixelSize();
|
||||
QIcon icon = APPLICATION->getThemedIcon(iconName);
|
||||
QPixmap pix = icon.pixmap(height, height);
|
||||
m_ui->labelMaxMemIcon->setPixmap(pix);
|
||||
}
|
||||
}
|
||||
67
launcher/ui/widgets/JavaSettingsWidget.h
Normal file
67
launcher/ui/widgets/JavaSettingsWidget.h
Normal file
@@ -0,0 +1,67 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (C) 2024 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
*
|
||||
* Copyright 2013-2021 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <BaseInstance.h>
|
||||
#include <JavaCommon.h>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class JavaSettingsWidget;
|
||||
}
|
||||
|
||||
class JavaSettingsWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit JavaSettingsWidget(InstancePtr instance, QWidget* parent = nullptr);
|
||||
~JavaSettingsWidget() override;
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
private slots:
|
||||
void onJavaBrowse();
|
||||
void onJavaAutodetect();
|
||||
void onJavaTest();
|
||||
void updateThresholds();
|
||||
|
||||
private:
|
||||
InstancePtr m_instance;
|
||||
Ui::JavaSettingsWidget* m_ui;
|
||||
unique_qobject_ptr<JavaCommon::TestCheck> m_checker;
|
||||
};
|
||||
254
launcher/ui/widgets/JavaSettingsWidget.ui
Normal file
254
launcher/ui/widgets/JavaSettingsWidget.ui
Normal file
@@ -0,0 +1,254 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>JavaSettingsWidget</class>
|
||||
<widget class="QWidget" name="JavaSettingsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="javaInstallationGroupBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Java Insta&llation</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="autodetectJavaCheckBox">
|
||||
<property name="text">
|
||||
<string>Auto-&detect Java version</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="javaPathTextBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaBrowseBtn">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaDownloadBtn">
|
||||
<property name="text">
|
||||
<string>Download Java</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaDetectBtn">
|
||||
<property name="text">
|
||||
<string>Auto-detect...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="javaTestBtn">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="autodownloadJavaCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Automatically downloads and selects the Java build recommended by Mojang.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto-download &Mojang Java</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="skipWizardCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, the launcher won't prompt you to choose a Java version if one is not found on startup.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip Java setup prompt on startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="skipCompatibilityCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip Java compatibility checks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="memoryGroupBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Memor&y</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5" columnstretch="1,0,0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelPermGen">
|
||||
<property name="text">
|
||||
<string>PermGen (Java 7 and earlier):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelMinMem">
|
||||
<property name="text">
|
||||
<string>Minimum memory allocation:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="permGenSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>The amount of memory available to store loaded Java classes.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true"> MiB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>64</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelMaxMem">
|
||||
<property name="text">
|
||||
<string>Maximum memory allocation:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="labelMaxMemIcon">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>maxMemSpinBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="maxMemSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>The maximum amount of memory Minecraft is allowed to use.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true"> MiB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1048576</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>128</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1024</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="minMemSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>The amount of memory Minecraft is started with.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true"> MiB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1048576</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>128</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="javaArgumentsGroupBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Java Argumen&ts</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPlainTextEdit" name="jvmArgsTextBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -502,7 +502,7 @@ void JavaWizardWidget::retranslate()
|
||||
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
|
||||
m_autodownloadCheckBox->setText(tr("Auto-download Mojang Java"));
|
||||
}
|
||||
m_autodetectJavaCheckBox->setText(tr("Autodetect Java version"));
|
||||
m_autodetectJavaCheckBox->setText(tr("Auto-detect Java version"));
|
||||
m_autoJavaGroupBox->setTitle(tr("Autodetect Java"));
|
||||
}
|
||||
|
||||
|
||||
@@ -47,12 +47,20 @@ MinecraftSettingsWidget::MinecraftSettingsWidget(InstancePtr instance, QWidget*
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (m_instance == nullptr) {
|
||||
// Java
|
||||
m_ui->settingsTabs->removeTab(1);
|
||||
// Launch
|
||||
m_ui->settingsTabs->removeTab(2);
|
||||
for (int i = 0; i < m_ui->settingsTabs->count(); ++i) {
|
||||
const QString name = m_ui->settingsTabs->widget(i)->objectName();
|
||||
|
||||
if (name == "javaTab" || name == "launchTab") {
|
||||
m_ui->settingsTabs->removeTab(i);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
m_ui->openGlobalSettingsButton->setVisible(false);
|
||||
} else {
|
||||
m_javaSettings = new JavaSettingsWidget(m_instance, this);
|
||||
m_ui->javaScrollArea->setWidget(m_javaSettings);
|
||||
|
||||
m_ui->showGameTime->setText(tr("Show time &playing this instance"));
|
||||
m_ui->recordGameTime->setText(tr("&Record time playing this instance"));
|
||||
m_ui->showGlobalGameTime->hide();
|
||||
@@ -63,6 +71,14 @@ MinecraftSettingsWidget::MinecraftSettingsWidget(InstancePtr instance, QWidget*
|
||||
"not fully supported on this Minecraft version.</span>"));
|
||||
|
||||
connect(m_ui->openGlobalSettingsButton, &QCommandLinkButton::clicked, this, &MinecraftSettingsWidget::openGlobalSettings);
|
||||
|
||||
m_ui->miscellaneousSettingsBox->setCheckable(true);
|
||||
m_ui->consoleSettingsBox->setCheckable(true);
|
||||
m_ui->windowSizeGroupBox->setCheckable(true);
|
||||
m_ui->nativeWorkaroundsGroupBox->setCheckable(true);
|
||||
m_ui->perfomanceGroupBox->setCheckable(true);
|
||||
m_ui->gameTimeGroupBox->setCheckable(true);
|
||||
m_ui->legacySettingsGroupBox->setCheckable(true);
|
||||
}
|
||||
|
||||
m_ui->maximizedWarning->hide();
|
||||
@@ -84,29 +100,34 @@ MinecraftSettingsWidget::~MinecraftSettingsWidget()
|
||||
|
||||
void MinecraftSettingsWidget::loadSettings()
|
||||
{
|
||||
const SettingsObjectPtr settings = getSettings();
|
||||
SettingsObjectPtr settings;
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings = m_instance->settings();
|
||||
else
|
||||
settings = APPLICATION->settings();
|
||||
|
||||
// Miscellaneous
|
||||
m_ui->miscellaneousSettingsBox->setCheckable(m_instance != nullptr);
|
||||
m_ui->miscellaneousSettingsBox->setChecked(settings->get("OverrideMiscellaneous").toBool());
|
||||
m_ui->closeAfterLaunchCheck->setChecked(settings->get("CloseAfterLaunch").toBool());
|
||||
m_ui->quitAfterGameStopCheck->setChecked(settings->get("QuitAfterGameStop").toBool());
|
||||
|
||||
// Console
|
||||
m_ui->consoleSettingsBox->setCheckable(m_instance != nullptr);
|
||||
m_ui->consoleSettingsBox->setChecked(m_instance == nullptr || settings->get("OverrideConsole").toBool());
|
||||
m_ui->showConsoleCheck->setChecked(settings->get("ShowConsole").toBool());
|
||||
m_ui->autoCloseConsoleCheck->setChecked(settings->get("AutoCloseConsole").toBool());
|
||||
m_ui->showConsoleErrorCheck->setChecked(settings->get("ShowConsoleOnError").toBool());
|
||||
|
||||
// Window Size
|
||||
m_ui->windowSizeGroupBox->setCheckable(m_instance != nullptr);
|
||||
m_ui->windowSizeGroupBox->setChecked(m_instance == nullptr || settings->get("OverrideWindow").toBool());
|
||||
m_ui->windowSizeGroupBox->setChecked(settings->get("OverrideWindow").toBool());
|
||||
m_ui->maximizedCheckBox->setChecked(settings->get("LaunchMaximized").toBool());
|
||||
m_ui->windowWidthSpinBox->setValue(settings->get("MinecraftWinWidth").toInt());
|
||||
m_ui->windowHeightSpinBox->setValue(settings->get("MinecraftWinHeight").toInt());
|
||||
|
||||
if (m_javaSettings != nullptr)
|
||||
m_javaSettings->loadSettings();
|
||||
|
||||
// Custom commands
|
||||
m_ui->customCommands->initialize(m_instance != nullptr, m_instance == nullptr || settings->get("OverrideCommands").toBool(),
|
||||
settings->get("PreLaunchCommand").toString(), settings->get("WrapperCommand").toString(),
|
||||
@@ -117,7 +138,6 @@ void MinecraftSettingsWidget::loadSettings()
|
||||
settings->get("Env").toMap());
|
||||
|
||||
// Workarounds
|
||||
m_ui->nativeWorkaroundsGroupBox->setCheckable(m_instance != nullptr);
|
||||
m_ui->nativeWorkaroundsGroupBox->setChecked(m_instance == nullptr || settings->get("OverrideNativeWorkarounds").toBool());
|
||||
m_ui->useNativeGLFWCheck->setChecked(settings->get("UseNativeGLFW").toBool());
|
||||
m_ui->lineEditGLFWPath->setText(settings->get("CustomGLFWPath").toString());
|
||||
@@ -135,7 +155,6 @@ void MinecraftSettingsWidget::loadSettings()
|
||||
#endif
|
||||
|
||||
// Performance
|
||||
m_ui->perfomanceGroupBox->setCheckable(m_instance != nullptr);
|
||||
m_ui->perfomanceGroupBox->setChecked(m_instance == nullptr || settings->get("OverridePerformance").toBool());
|
||||
m_ui->enableFeralGamemodeCheck->setChecked(settings->get("EnableFeralGamemode").toBool());
|
||||
m_ui->enableMangoHud->setChecked(settings->get("EnableMangoHud").toBool());
|
||||
@@ -153,164 +172,170 @@ void MinecraftSettingsWidget::loadSettings()
|
||||
}
|
||||
|
||||
// Miscellanous
|
||||
m_ui->gameTimeGroupBox->setCheckable(m_instance != nullptr);
|
||||
m_ui->gameTimeGroupBox->setChecked(m_instance == nullptr || settings->get("OverrideGameTime").toBool());
|
||||
m_ui->showGameTime->setChecked(settings->get("ShowGameTime").toBool());
|
||||
m_ui->recordGameTime->setChecked(settings->get("RecordGameTime").toBool());
|
||||
m_ui->showGlobalGameTime->setChecked(m_instance != nullptr && settings->get("ShowGlobalGameTime").toBool());
|
||||
m_ui->showGameTimeWithoutDays->setChecked(m_instance != nullptr && settings->get("ShowGameTimeWithoutDays").toBool());
|
||||
m_ui->showGlobalGameTime->setChecked(m_instance == nullptr && settings->get("ShowGlobalGameTime").toBool());
|
||||
m_ui->showGameTimeWithoutDays->setChecked(m_instance == nullptr && settings->get("ShowGameTimeWithoutDays").toBool());
|
||||
|
||||
m_ui->legacySettingsGroupBox->setCheckable(m_instance != nullptr);
|
||||
m_ui->legacySettingsGroupBox->setChecked(m_instance == nullptr || settings->get("OverrideLegacySettings").toBool());
|
||||
m_ui->onlineFixes->setChecked(settings->get("OnlineFixes").toBool());
|
||||
}
|
||||
|
||||
void MinecraftSettingsWidget::saveSettings()
|
||||
{
|
||||
SettingsObjectPtr settings = getSettings();
|
||||
SettingsObject::Lock lock(settings);
|
||||
|
||||
// Miscellaneous
|
||||
bool miscellaneous = m_instance == nullptr || m_ui->miscellaneousSettingsBox->isChecked();
|
||||
SettingsObjectPtr settings;
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideMiscellaneous", miscellaneous);
|
||||
|
||||
if (miscellaneous) {
|
||||
settings->set("CloseAfterLaunch", m_ui->closeAfterLaunchCheck->isChecked());
|
||||
settings->set("QuitAfterGameStop", m_ui->quitAfterGameStopCheck->isChecked());
|
||||
} else {
|
||||
settings->reset("CloseAfterLaunch");
|
||||
settings->reset("QuitAfterGameStop");
|
||||
}
|
||||
|
||||
// Console
|
||||
bool console = m_instance == nullptr || m_ui->consoleSettingsBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideConsole", console);
|
||||
|
||||
if (console) {
|
||||
settings->set("ShowConsole", m_ui->showConsoleCheck->isChecked());
|
||||
settings->set("AutoCloseConsole", m_ui->autoCloseConsoleCheck->isChecked());
|
||||
settings->set("ShowConsoleOnError", m_ui->showConsoleErrorCheck->isChecked());
|
||||
} else {
|
||||
settings->reset("ShowConsole");
|
||||
settings->reset("AutoCloseConsole");
|
||||
settings->reset("ShowConsoleOnError");
|
||||
}
|
||||
|
||||
// Window Size
|
||||
bool window = m_instance == nullptr || m_ui->windowSizeGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideWindow", window);
|
||||
|
||||
if (window) {
|
||||
settings->set("LaunchMaximized", m_ui->maximizedCheckBox->isChecked());
|
||||
settings->set("MinecraftWinWidth", m_ui->windowWidthSpinBox->value());
|
||||
settings->set("MinecraftWinHeight", m_ui->windowHeightSpinBox->value());
|
||||
} else {
|
||||
settings->reset("LaunchMaximized");
|
||||
settings->reset("MinecraftWinWidth");
|
||||
settings->reset("MinecraftWinHeight");
|
||||
}
|
||||
|
||||
// Custom Commands
|
||||
bool custcmd = m_instance == nullptr || m_ui->customCommands->checked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideCommands", custcmd);
|
||||
|
||||
if (custcmd) {
|
||||
settings->set("PreLaunchCommand", m_ui->customCommands->prelaunchCommand());
|
||||
settings->set("WrapperCommand", m_ui->customCommands->wrapperCommand());
|
||||
settings->set("PostExitCommand", m_ui->customCommands->postexitCommand());
|
||||
} else {
|
||||
settings->reset("PreLaunchCommand");
|
||||
settings->reset("WrapperCommand");
|
||||
settings->reset("PostExitCommand");
|
||||
}
|
||||
|
||||
// Environment Variables
|
||||
auto env = m_instance == nullptr || m_ui->environmentVariables->override();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideEnv", env);
|
||||
|
||||
if (env)
|
||||
settings->set("Env", m_ui->environmentVariables->value());
|
||||
settings = m_instance->settings();
|
||||
else
|
||||
settings->reset("Env");
|
||||
settings = APPLICATION->settings();
|
||||
|
||||
// Workarounds
|
||||
bool workarounds = m_instance == nullptr || m_ui->nativeWorkaroundsGroupBox->isChecked();
|
||||
{
|
||||
SettingsObject::Lock lock(settings);
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideNativeWorkarounds", workarounds);
|
||||
// Miscellaneous
|
||||
bool miscellaneous = m_instance == nullptr || m_ui->miscellaneousSettingsBox->isChecked();
|
||||
|
||||
if (workarounds) {
|
||||
settings->set("UseNativeGLFW", m_ui->useNativeGLFWCheck->isChecked());
|
||||
settings->set("CustomGLFWPath", m_ui->lineEditGLFWPath->text());
|
||||
settings->set("UseNativeOpenAL", m_ui->useNativeOpenALCheck->isChecked());
|
||||
settings->set("CustomOpenALPath", m_ui->lineEditOpenALPath->text());
|
||||
} else {
|
||||
settings->reset("UseNativeGLFW");
|
||||
settings->reset("CustomGLFWPath");
|
||||
settings->reset("UseNativeOpenAL");
|
||||
settings->reset("CustomOpenALPath");
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideMiscellaneous", miscellaneous);
|
||||
|
||||
if (miscellaneous) {
|
||||
settings->set("CloseAfterLaunch", m_ui->closeAfterLaunchCheck->isChecked());
|
||||
settings->set("QuitAfterGameStop", m_ui->quitAfterGameStopCheck->isChecked());
|
||||
} else {
|
||||
settings->reset("CloseAfterLaunch");
|
||||
settings->reset("QuitAfterGameStop");
|
||||
}
|
||||
|
||||
// Console
|
||||
bool console = m_instance == nullptr || m_ui->consoleSettingsBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideConsole", console);
|
||||
|
||||
if (console) {
|
||||
settings->set("ShowConsole", m_ui->showConsoleCheck->isChecked());
|
||||
settings->set("AutoCloseConsole", m_ui->autoCloseConsoleCheck->isChecked());
|
||||
settings->set("ShowConsoleOnError", m_ui->showConsoleErrorCheck->isChecked());
|
||||
} else {
|
||||
settings->reset("ShowConsole");
|
||||
settings->reset("AutoCloseConsole");
|
||||
settings->reset("ShowConsoleOnError");
|
||||
}
|
||||
|
||||
// Window Size
|
||||
bool window = m_instance == nullptr || m_ui->windowSizeGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideWindow", window);
|
||||
|
||||
if (window) {
|
||||
settings->set("LaunchMaximized", m_ui->maximizedCheckBox->isChecked());
|
||||
settings->set("MinecraftWinWidth", m_ui->windowWidthSpinBox->value());
|
||||
settings->set("MinecraftWinHeight", m_ui->windowHeightSpinBox->value());
|
||||
} else {
|
||||
settings->reset("LaunchMaximized");
|
||||
settings->reset("MinecraftWinWidth");
|
||||
settings->reset("MinecraftWinHeight");
|
||||
}
|
||||
|
||||
// Custom Commands
|
||||
bool custcmd = m_instance == nullptr || m_ui->customCommands->checked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideCommands", custcmd);
|
||||
|
||||
if (custcmd) {
|
||||
settings->set("PreLaunchCommand", m_ui->customCommands->prelaunchCommand());
|
||||
settings->set("WrapperCommand", m_ui->customCommands->wrapperCommand());
|
||||
settings->set("PostExitCommand", m_ui->customCommands->postexitCommand());
|
||||
} else {
|
||||
settings->reset("PreLaunchCommand");
|
||||
settings->reset("WrapperCommand");
|
||||
settings->reset("PostExitCommand");
|
||||
}
|
||||
|
||||
// Environment Variables
|
||||
auto env = m_instance == nullptr || m_ui->environmentVariables->override();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideEnv", env);
|
||||
|
||||
if (env)
|
||||
settings->set("Env", m_ui->environmentVariables->value());
|
||||
else
|
||||
settings->reset("Env");
|
||||
|
||||
// Workarounds
|
||||
bool workarounds = m_instance == nullptr || m_ui->nativeWorkaroundsGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideNativeWorkarounds", workarounds);
|
||||
|
||||
if (workarounds) {
|
||||
settings->set("UseNativeGLFW", m_ui->useNativeGLFWCheck->isChecked());
|
||||
settings->set("CustomGLFWPath", m_ui->lineEditGLFWPath->text());
|
||||
settings->set("UseNativeOpenAL", m_ui->useNativeOpenALCheck->isChecked());
|
||||
settings->set("CustomOpenALPath", m_ui->lineEditOpenALPath->text());
|
||||
} else {
|
||||
settings->reset("UseNativeGLFW");
|
||||
settings->reset("CustomGLFWPath");
|
||||
settings->reset("UseNativeOpenAL");
|
||||
settings->reset("CustomOpenALPath");
|
||||
}
|
||||
|
||||
// Performance
|
||||
bool performance = m_instance == nullptr || m_ui->perfomanceGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverridePerformance", performance);
|
||||
|
||||
if (performance) {
|
||||
settings->set("EnableFeralGamemode", m_ui->enableFeralGamemodeCheck->isChecked());
|
||||
settings->set("EnableMangoHud", m_ui->enableMangoHud->isChecked());
|
||||
settings->set("UseDiscreteGpu", m_ui->useDiscreteGpuCheck->isChecked());
|
||||
settings->set("UseZink", m_ui->useZink->isChecked());
|
||||
} else {
|
||||
settings->reset("EnableFeralGamemode");
|
||||
settings->reset("EnableMangoHud");
|
||||
settings->reset("UseDiscreteGpu");
|
||||
settings->reset("UseZink");
|
||||
}
|
||||
|
||||
// Game time
|
||||
bool gameTime = m_instance == nullptr || m_ui->gameTimeGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideGameTime", gameTime);
|
||||
|
||||
if (gameTime) {
|
||||
settings->set("ShowGameTime", m_ui->showGameTime->isChecked());
|
||||
settings->set("RecordGameTime", m_ui->recordGameTime->isChecked());
|
||||
} else {
|
||||
settings->reset("ShowGameTime");
|
||||
settings->reset("RecordGameTime");
|
||||
}
|
||||
|
||||
if (m_instance == nullptr) {
|
||||
settings->set("ShowGlobalGameTime", m_ui->showGlobalGameTime->isChecked());
|
||||
settings->set("ShowGameTimeWithoutDays", m_ui->showGameTimeWithoutDays->isChecked());
|
||||
}
|
||||
|
||||
bool overrideLegacySettings = m_instance == nullptr || m_ui->legacySettingsGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideLegacySettings", overrideLegacySettings);
|
||||
|
||||
if (overrideLegacySettings) {
|
||||
settings->set("OnlineFixes", m_ui->onlineFixes->isChecked());
|
||||
} else {
|
||||
settings->reset("OnlineFixes");
|
||||
}
|
||||
}
|
||||
|
||||
// Performance
|
||||
bool performance = m_instance == nullptr || m_ui->perfomanceGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverridePerformance", performance);
|
||||
|
||||
if (performance) {
|
||||
settings->set("EnableFeralGamemode", m_ui->enableFeralGamemodeCheck->isChecked());
|
||||
settings->set("EnableMangoHud", m_ui->enableMangoHud->isChecked());
|
||||
settings->set("UseDiscreteGpu", m_ui->useDiscreteGpuCheck->isChecked());
|
||||
settings->set("UseZink", m_ui->useZink->isChecked());
|
||||
} else {
|
||||
settings->reset("EnableFeralGamemode");
|
||||
settings->reset("EnableMangoHud");
|
||||
settings->reset("UseDiscreteGpu");
|
||||
settings->reset("UseZink");
|
||||
}
|
||||
|
||||
// Game time
|
||||
bool gameTime = m_instance == nullptr || m_ui->gameTimeGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideGameTime", gameTime);
|
||||
|
||||
if (gameTime) {
|
||||
settings->set("ShowGameTime", m_ui->showGameTime->isChecked());
|
||||
settings->set("RecordGameTime", m_ui->recordGameTime->isChecked());
|
||||
} else {
|
||||
settings->reset("ShowGameTime");
|
||||
settings->reset("RecordGameTime");
|
||||
}
|
||||
|
||||
if (m_instance == nullptr) {
|
||||
settings->set("ShowGlobalGameTime", m_ui->showGlobalGameTime->isChecked());
|
||||
settings->set("ShowGameTimeWithoutDays", m_ui->showGameTimeWithoutDays->isChecked());
|
||||
}
|
||||
|
||||
bool overrideLegacySettings = m_instance == nullptr || m_ui->legacySettingsGroupBox->isChecked();
|
||||
|
||||
if (m_instance != nullptr)
|
||||
settings->set("OverrideLegacySettings", overrideLegacySettings);
|
||||
|
||||
if (overrideLegacySettings) {
|
||||
settings->set("OnlineFixes", m_ui->onlineFixes->isChecked());
|
||||
} else {
|
||||
settings->reset("OnlineFixes");
|
||||
}
|
||||
|
||||
if (m_instance != nullptr)
|
||||
m_instance->updateRuntimeContext();
|
||||
if (m_javaSettings != nullptr)
|
||||
m_javaSettings->saveSettings();
|
||||
}
|
||||
|
||||
void MinecraftSettingsWidget::openGlobalSettings()
|
||||
@@ -322,11 +347,3 @@ void MinecraftSettingsWidget::openGlobalSettings()
|
||||
else // TODO select tab
|
||||
APPLICATION->ShowGlobalSettings(this, "minecraft-settings");
|
||||
}
|
||||
|
||||
SettingsObjectPtr MinecraftSettingsWidget::getSettings() const
|
||||
{
|
||||
if (m_instance != nullptr)
|
||||
return m_instance->settings();
|
||||
|
||||
return APPLICATION->settings();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <minecraft/MinecraftInstance.h>
|
||||
#include <QWidget>
|
||||
#include "JavaSettingsWidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class MinecraftSettingsWidget;
|
||||
@@ -54,8 +55,7 @@ class MinecraftSettingsWidget : public QWidget {
|
||||
void openGlobalSettings();
|
||||
|
||||
private:
|
||||
SettingsObjectPtr getSettings() const;
|
||||
|
||||
InstancePtr m_instance;
|
||||
Ui::MinecraftSettingsWidget* m_ui;
|
||||
JavaSettingsWidget* m_javaSettings = nullptr;
|
||||
};
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>607</height>
|
||||
<height>550</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
@@ -282,6 +282,30 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="javaTab">
|
||||
<attribute name="title">
|
||||
<string>Java</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="javaScrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>624</width>
|
||||
<height>297</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tweaksPage">
|
||||
<attribute name="title">
|
||||
<string>Tweaks</string>
|
||||
@@ -301,7 +325,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>439</height>
|
||||
<height>398</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
@@ -489,7 +513,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>624</width>
|
||||
<height>291</height>
|
||||
<height>297</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||
|
||||
Reference in New Issue
Block a user