2013-07-15 01:31:30 +05:30
|
|
|
/* Copyright 2013 MultiMC Contributors
|
|
|
|
*
|
|
|
|
* Authors: Andrew Okin
|
|
|
|
* Peterix
|
|
|
|
* Orochimarufan <orochimarufan.x3@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2013-07-14 23:56:53 +05:30
|
|
|
#include "instancesettings.h"
|
|
|
|
#include "ui_instancesettings.h"
|
|
|
|
|
2013-07-16 04:00:32 +05:30
|
|
|
InstanceSettings::InstanceSettings( SettingsObject * obj, QWidget *parent) :
|
|
|
|
m_obj(obj),
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::InstanceSettings)
|
2013-07-14 23:56:53 +05:30
|
|
|
{
|
2013-07-16 04:00:32 +05:30
|
|
|
ui->setupUi(this);
|
|
|
|
loadSettings();
|
2013-07-14 23:56:53 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
InstanceSettings::~InstanceSettings()
|
|
|
|
{
|
2013-07-16 04:00:32 +05:30
|
|
|
delete ui;
|
2013-07-14 23:56:53 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceSettings::on_customCommandsGroupBox_toggled(bool state)
|
|
|
|
{
|
2013-07-16 04:00:32 +05:30
|
|
|
ui->labelCustomCmdsDescription->setEnabled(state);
|
2013-07-14 23:56:53 +05:30
|
|
|
}
|
|
|
|
|
2013-07-16 04:00:32 +05:30
|
|
|
void InstanceSettings::on_buttonBox_accepted()
|
2013-07-14 23:56:53 +05:30
|
|
|
{
|
2013-07-16 04:00:32 +05:30
|
|
|
applySettings();
|
|
|
|
accept();
|
|
|
|
}
|
2013-07-14 23:56:53 +05:30
|
|
|
|
2013-07-16 04:00:32 +05:30
|
|
|
void InstanceSettings::on_buttonBox_rejected()
|
|
|
|
{
|
|
|
|
reject();
|
2013-07-14 23:56:53 +05:30
|
|
|
}
|
|
|
|
|
2013-07-16 04:00:32 +05:30
|
|
|
|
|
|
|
void InstanceSettings::applySettings()
|
2013-07-14 23:56:53 +05:30
|
|
|
{
|
2013-07-16 04:00:32 +05:30
|
|
|
// 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("LaunchCompatMode", ui->compatModeCheckBox->isChecked());
|
|
|
|
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("LaunchCompatMode");
|
|
|
|
m_obj->reset("LaunchMaximized");
|
|
|
|
m_obj->reset("MinecraftWinWidth");
|
|
|
|
m_obj->reset("MinecraftWinHeight");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Auto Login
|
|
|
|
bool login = ui->accountSettingsGroupBox->isChecked();
|
|
|
|
m_obj->set("OverrideLogin", login);
|
|
|
|
if(login)
|
|
|
|
{
|
|
|
|
m_obj->set("AutoLogin", ui->autoLoginChecBox->isChecked());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_obj->reset("AutoLogin");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_obj->reset("MinMemAlloc");
|
|
|
|
m_obj->reset("MaxMemAlloc");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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());
|
|
|
|
}
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-07-15 01:31:30 +05:30
|
|
|
|
2013-07-16 04:00:32 +05:30
|
|
|
void InstanceSettings::loadSettings()
|
|
|
|
{
|
|
|
|
// Console
|
|
|
|
ui->showConsoleCheck->setChecked(m_obj->get("ShowConsole").toBool());
|
|
|
|
ui->autoCloseConsoleCheck->setChecked(m_obj->get("AutoCloseConsole").toBool());
|
|
|
|
ui->consoleSettingsBox->setChecked(m_obj->get("OverrideConsole").toBool());
|
|
|
|
|
|
|
|
// Window Size
|
|
|
|
ui->compatModeCheckBox->setChecked(m_obj->get("LaunchCompatMode").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());
|
|
|
|
ui->windowSizeGroupBox->setChecked(m_obj->get("OverrideWindow").toBool());
|
|
|
|
|
|
|
|
// Auto Login
|
|
|
|
ui->autoLoginChecBox->setChecked(m_obj->get("AutoLogin").toBool());
|
|
|
|
ui->accountSettingsGroupBox->setChecked(m_obj->get("OverrideLogin").toBool());
|
|
|
|
|
|
|
|
// Memory
|
|
|
|
ui->minMemSpinBox->setValue(m_obj->get("MinMemAlloc").toInt());
|
|
|
|
ui->maxMemSpinBox->setValue(m_obj->get("MaxMemAlloc").toInt());
|
|
|
|
ui->memoryGroupBox->setChecked(m_obj->get("OverrideMemory").toBool());
|
|
|
|
|
|
|
|
// Java Settings
|
|
|
|
ui->javaPathTextBox->setText(m_obj->get("JavaPath").toString());
|
|
|
|
ui->jvmArgsTextBox->setText(m_obj->get("JvmArgs").toString());
|
|
|
|
ui->javaSettingsGroupBox->setChecked(m_obj->get("OverrideJava").toBool());
|
|
|
|
|
|
|
|
// Custom Commands
|
|
|
|
ui->preLaunchCmdTextBox->setText(m_obj->get("PreLaunchCommand").toString());
|
|
|
|
ui->postExitCmdTextBox->setText(m_obj->get("PostExitCommand").toString());
|
|
|
|
ui->customCommandsGroupBox->setChecked(m_obj->get("OverrideCommands").toBool());
|
2013-07-14 23:56:53 +05:30
|
|
|
}
|