summaryrefslogtreecommitdiffstats
path: root/gui/instancesettings.cpp
blob: 7e82e1d626b49a26cf65878085792fcbfae04e3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "instancesettings.h"
#include "ui_instancesettings.h"

InstanceSettings::InstanceSettings(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::InstanceSettings)
{
    ui->setupUi(this);
}

InstanceSettings::~InstanceSettings()
{
    delete ui;
}

void InstanceSettings::on_customCommandsGroupBox_toggled(bool state)
{
    ui->labelCustomCmdsDescription->setEnabled(state);
}


void InstanceSettings::applySettings(SettingsObject *s)
{

    // Console
    s->set("ShowConsole", ui->showConsoleCheck->isChecked());
    s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked());
    s->set("OverrideConsole", ui->consoleSettingsBox->isChecked());

    // Window Size
    s->set("LaunchCompatMode", ui->compatModeCheckBox->isChecked());
    s->set("LaunchMaximized", ui->maximizedCheckBox->isChecked());
    s->set("MinecraftWinWidth", ui->windowWidthSpinBox->value());
    s->set("MinecraftWinHeight", ui->windowHeightSpinBox->value());
    s->set("OverrideWindow", ui->windowSizeGroupBox->isChecked());

    // Auto Login
    s->set("AutoLogin", ui->autoLoginCheckBox->isChecked());
    s->set("OverrideLogin", ui->accountSettingsGroupBox->isChecked());

    // Memory
    s->set("MinMemAlloc", ui->minMemSpinBox->value());
    s->set("MaxMemAlloc", ui->maxMemSpinBox->value());
    s->set("OverrideMemory", ui->memoryGroupBox->isChecked());

    // Java Settings
    s->set("JavaPath", ui->javaPathTextBox->text());
    s->set("JvmArgs", ui->jvmArgsTextBox->text());
    s->set("OverrideJava", ui->javaSettingsGroupBox->isChecked());

    // Custom Commands
    s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text());
    s->set("PostExitCommand", ui->postExitCmdTextBox->text());
    s->set("OverrideCommands", ui->customCommandsGroupBox->isChecked());
}

void InstanceSettings::loadSettings(SettingsObject *s)
{
    // Console
    ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
    ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool());
    ui->consoleSettingsBox->setChecked(s->get("OverrideConsole").toBool());

    // Window Size
    ui->compatModeCheckBox->setChecked(s->get("LaunchCompatMode").toBool());
    ui->maximizedCheckBox->setChecked(s->get("LaunchMaximized").toBool());
    ui->windowWidthSpinBox->setValue(s->get("MinecraftWinWidth").toInt());
    ui->windowHeightSpinBox->setValue(s->get("MinecraftWinHeight").toInt());
    ui->windowSizeGroupBox->setChecked(s->get("OverrideWindow").toBool());

    // Auto Login
    ui->autoLoginCheckBox->setChecked(s->get("AutoLogin").toBool());
    ui->accountSettingsGroupBox->setChecked(s->get("OverrideLogin").toBool());

    // Memory
    ui->minMemSpinBox->setValue(s->get("MinMemAlloc").toInt());
    ui->maxMemSpinBox->setValue(s->get("MaxMemAlloc").toInt());
    ui->memoryGroupBox->setChecked(s->get("OverrideMemory").toBool());

    // Java Settings
    ui->javaPathTextBox->setText(s->get("JavaPath").toString());
    ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString());
    ui->javaSettingsGroupBox->setChecked(s->get("OverrideJava").toBool());

    // Custom Commands
    ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString());
    ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString());
    ui->customCommandsGroupBox->setChecked(s->get("OverrideCommands").toBool());
}