From 171325d42784a69ac3cadc6ab330603e258eec02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 9 Jun 2014 01:29:18 +0200 Subject: Instance settings moved to a page. --- gui/dialogs/InstanceSettings.cpp | 244 ----------------------- gui/dialogs/InstanceSettings.h | 60 ------ gui/dialogs/InstanceSettings.ui | 419 --------------------------------------- 3 files changed, 723 deletions(-) delete mode 100644 gui/dialogs/InstanceSettings.cpp delete mode 100644 gui/dialogs/InstanceSettings.h delete mode 100644 gui/dialogs/InstanceSettings.ui (limited to 'gui/dialogs') diff --git a/gui/dialogs/InstanceSettings.cpp b/gui/dialogs/InstanceSettings.cpp deleted file mode 100644 index 9f0cae3b..00000000 --- a/gui/dialogs/InstanceSettings.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Authors: Andrew Okin - * Peterix - * Orochimarufan - * - * 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 "MultiMC.h" -#include "InstanceSettings.h" -#include "ui_InstanceSettings.h" -#include "gui/Platform.h" -#include "gui/dialogs/VersionSelectDialog.h" - -#include "logic/NagUtils.h" - -#include "logic/java/JavaUtils.h" -#include "logic/java/JavaVersionList.h" -#include "logic/java/JavaChecker.h" - -#include -#include - -InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent) - : QDialog(parent), ui(new Ui::InstanceSettings), m_obj(obj) -{ - MultiMCPlatform::fixWM_CLASS(this); - ui->setupUi(this); - - restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("SettingsGeometry").toByteArray())); - - loadSettings(); -} - -InstanceSettings::~InstanceSettings() -{ - delete ui; -} - -void InstanceSettings::showEvent(QShowEvent *ev) -{ - QDialog::showEvent(ev); -} - -void InstanceSettings::closeEvent(QCloseEvent *ev) -{ - MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64()); - - QDialog::closeEvent(ev); -} - -void InstanceSettings::on_customCommandsGroupBox_toggled(bool state) -{ - ui->labelCustomCmdsDescription->setEnabled(state); -} - -void InstanceSettings::on_buttonBox_accepted() -{ - MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64()); - - applySettings(); - accept(); -} - -void InstanceSettings::on_buttonBox_rejected() -{ - MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64()); - - reject(); -} - -void InstanceSettings::applySettings() -{ - // Console - bool console = ui->consoleSettingsBox->isChecked(); - m_obj->set("OverrideConsole", console); - if (console) - { - m_obj->set("ShowConsole", ui->showConsoleCheck->isChecked()); - m_obj->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); - } - else - { - m_obj->reset("ShowConsole"); - m_obj->reset("AutoCloseConsole"); - } - - // Window Size - bool window = ui->windowSizeGroupBox->isChecked(); - m_obj->set("OverrideWindow", window); - if (window) - { - m_obj->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); - m_obj->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); - m_obj->set("MinecraftWinHeight", ui->windowHeightSpinBox->value()); - } - else - { - m_obj->reset("LaunchMaximized"); - m_obj->reset("MinecraftWinWidth"); - m_obj->reset("MinecraftWinHeight"); - } - - // Memory - bool memory = ui->memoryGroupBox->isChecked(); - m_obj->set("OverrideMemory", memory); - if (memory) - { - m_obj->set("MinMemAlloc", ui->minMemSpinBox->value()); - m_obj->set("MaxMemAlloc", ui->maxMemSpinBox->value()); - m_obj->set("PermGen", ui->permGenSpinBox->value()); - } - else - { - m_obj->reset("MinMemAlloc"); - m_obj->reset("MaxMemAlloc"); - m_obj->reset("PermGen"); - } - - // Java Settings - bool java = ui->javaSettingsGroupBox->isChecked(); - m_obj->set("OverrideJava", java); - if (java) - { - m_obj->set("JavaPath", ui->javaPathTextBox->text()); - m_obj->set("JvmArgs", ui->jvmArgsTextBox->text()); - - NagUtils::checkJVMArgs(m_obj->get("JvmArgs").toString(), this->parentWidget()); - } - else - { - m_obj->reset("JavaPath"); - m_obj->reset("JvmArgs"); - } - - // Custom Commands - bool custcmd = ui->customCommandsGroupBox->isChecked(); - m_obj->set("OverrideCommands", custcmd); - if (custcmd) - { - m_obj->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); - m_obj->set("PostExitCommand", ui->postExitCmdTextBox->text()); - } - else - { - m_obj->reset("PreLaunchCommand"); - m_obj->reset("PostExitCommand"); - } -} - -void InstanceSettings::loadSettings() -{ - // Console - ui->consoleSettingsBox->setChecked(m_obj->get("OverrideConsole").toBool()); - ui->showConsoleCheck->setChecked(m_obj->get("ShowConsole").toBool()); - ui->autoCloseConsoleCheck->setChecked(m_obj->get("AutoCloseConsole").toBool()); - - // Window Size - ui->windowSizeGroupBox->setChecked(m_obj->get("OverrideWindow").toBool()); - ui->maximizedCheckBox->setChecked(m_obj->get("LaunchMaximized").toBool()); - ui->windowWidthSpinBox->setValue(m_obj->get("MinecraftWinWidth").toInt()); - ui->windowHeightSpinBox->setValue(m_obj->get("MinecraftWinHeight").toInt()); - - // Memory - ui->memoryGroupBox->setChecked(m_obj->get("OverrideMemory").toBool()); - ui->minMemSpinBox->setValue(m_obj->get("MinMemAlloc").toInt()); - ui->maxMemSpinBox->setValue(m_obj->get("MaxMemAlloc").toInt()); - ui->permGenSpinBox->setValue(m_obj->get("PermGen").toInt()); - - // Java Settings - ui->javaSettingsGroupBox->setChecked(m_obj->get("OverrideJava").toBool()); - ui->javaPathTextBox->setText(m_obj->get("JavaPath").toString()); - ui->jvmArgsTextBox->setText(m_obj->get("JvmArgs").toString()); - - // Custom Commands - ui->customCommandsGroupBox->setChecked(m_obj->get("OverrideCommands").toBool()); - ui->preLaunchCmdTextBox->setText(m_obj->get("PreLaunchCommand").toString()); - ui->postExitCmdTextBox->setText(m_obj->get("PostExitCommand").toString()); -} - -void InstanceSettings::on_javaDetectBtn_clicked() -{ - JavaVersionPtr java; - - VersionSelectDialog vselect(MMC->javalist().get(), tr("Select a Java version"), this, true); - vselect.setResizeOn(2); - vselect.exec(); - - if (vselect.result() == QDialog::Accepted && vselect.selectedVersion()) - { - java = std::dynamic_pointer_cast(vselect.selectedVersion()); - ui->javaPathTextBox->setText(java->path); - } -} - -void InstanceSettings::on_javaBrowseBtn_clicked() -{ - QString dir = QFileDialog::getOpenFileName(this, tr("Find Java executable")); - if (!dir.isNull()) - { - ui->javaPathTextBox->setText(dir); - } -} - -void InstanceSettings::on_javaTestBtn_clicked() -{ - checker.reset(new JavaChecker()); - connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this, - SLOT(checkFinished(JavaCheckResult))); - checker->path = ui->javaPathTextBox->text(); - checker->performCheck(); -} - -void InstanceSettings::checkFinished(JavaCheckResult result) -{ - if (result.valid) - { - QString text; - text += "Java test succeeded!\n"; - if (result.is_64bit) - text += "Using 64bit java.\n"; - text += "\n"; - text += "Platform reported: " + result.realPlatform; - QMessageBox::information(this, tr("Java test success"), text); - } - else - { - QMessageBox::warning( - this, tr("Java test failure"), - tr("The specified java binary didn't work. You should use the auto-detect feature, " - "or set the path to the java executable.")); - } -} diff --git a/gui/dialogs/InstanceSettings.h b/gui/dialogs/InstanceSettings.h deleted file mode 100644 index 6895589f..00000000 --- a/gui/dialogs/InstanceSettings.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2013 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 -#include "settingsobject.h" -#include "logic/java/JavaChecker.h" - -namespace Ui -{ -class InstanceSettings; -} - -class InstanceSettings : public QDialog -{ - Q_OBJECT - -public: - explicit InstanceSettings(SettingsObject *s, QWidget *parent = 0); - ~InstanceSettings(); - - void updateCheckboxStuff(); - - void applySettings(); - void loadSettings(); - -protected: - virtual void showEvent(QShowEvent *); - virtual void closeEvent(QCloseEvent *); -private -slots: - void on_customCommandsGroupBox_toggled(bool arg1); - void on_buttonBox_accepted(); - void on_buttonBox_rejected(); - - void on_javaDetectBtn_clicked(); - - void on_javaTestBtn_clicked(); - - void on_javaBrowseBtn_clicked(); - - void checkFinished(JavaCheckResult result); -private: - Ui::InstanceSettings *ui; - SettingsObject *m_obj; - std::shared_ptr checker; -}; diff --git a/gui/dialogs/InstanceSettings.ui b/gui/dialogs/InstanceSettings.ui deleted file mode 100644 index 9c7e1757..00000000 --- a/gui/dialogs/InstanceSettings.ui +++ /dev/null @@ -1,419 +0,0 @@ - - - InstanceSettings - - - - 0 - 0 - 526 - 637 - - - - Instance Settings - - - - - - QTabWidget::Rounded - - - 0 - - - - Minecraft - - - - - - true - - - Window Size - - - true - - - false - - - - - - Start Minecraft maximized? - - - - - - - - - Window height: - - - - - - - Window width: - - - - - - - 854 - - - 65536 - - - 1 - - - 854 - - - - - - - 480 - - - 65536 - - - 480 - - - - - - - - - - - - true - - - Console Settings - - - true - - - false - - - - - - Show console while the game is running? - - - - - - - Automatically close console when the game quits? - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Java - - - - - - true - - - Memory - - - true - - - false - - - - - - The maximum amount of memory Minecraft is allowed to use. - - - MB - - - 512 - - - 65536 - - - 128 - - - 1024 - - - - - - - Minimum memory allocation: - - - - - - - Maximum memory allocation: - - - - - - - The amount of memory Minecraft is started with. - - - MB - - - 256 - - - 65536 - - - 128 - - - 256 - - - - - - - The amount of memory available to store loaded Java classes. - - - MB - - - 64 - - - 999999999 - - - 8 - - - 64 - - - - - - - PermGen: - - - - - - - - - - true - - - Java Settings - - - true - - - false - - - - - - Test - - - - - - - Java path: - - - - - - - JVM arguments: - - - - - - - - - - - - - Browse... - - - - - - - Auto-detect... - - - - - - - - - - true - - - Custom Commands - - - true - - - false - - - - - - - - - Post-exit command: - - - - - - - Pre-launch command: - - - - - - - - - - - - - false - - - - 0 - 0 - - - - Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working directory with INST_ID, INST_DIR, and INST_NAME as environment variables. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - settingsTabs - buttonBox - windowSizeGroupBox - maximizedCheckBox - windowWidthSpinBox - windowHeightSpinBox - consoleSettingsBox - showConsoleCheck - autoCloseConsoleCheck - memoryGroupBox - minMemSpinBox - maxMemSpinBox - permGenSpinBox - javaSettingsGroupBox - jvmArgsTextBox - customCommandsGroupBox - preLaunchCmdTextBox - postExitCmdTextBox - - - - -- cgit v1.2.3