From ce253ded0e0d2ae90a971c2e074d561f5e7baeb2 Mon Sep 17 00:00:00 2001 From: Stiepen Date: Sun, 14 Jul 2013 20:26:53 +0200 Subject: Added Per-Instance settings --- MultiMC.pro | 9 +- gui/instancesettings.cpp | 89 +++++++++++ gui/instancesettings.h | 32 ++++ gui/instancesettings.ui | 386 +++++++++++++++++++++++++++++++++++++++++++++++ gui/mainwindow.cpp | 16 ++ 5 files changed, 529 insertions(+), 3 deletions(-) create mode 100644 gui/instancesettings.cpp create mode 100644 gui/instancesettings.h create mode 100644 gui/instancesettings.ui diff --git a/MultiMC.pro b/MultiMC.pro index 3f480529..6af1ec0d 100644 --- a/MultiMC.pro +++ b/MultiMC.pro @@ -21,7 +21,8 @@ SOURCES += main.cpp\ data/inifile.cpp \ gui/settingsdialog.cpp \ gui/modeditwindow.cpp \ - util/appsettings.cpp + util/appsettings.cpp \ + gui/instancesettings.cpp HEADERS += gui/mainwindow.h \ data/instancebase.h \ @@ -32,11 +33,13 @@ HEADERS += gui/mainwindow.h \ gui/settingsdialog.h \ gui/modeditwindow.h \ util/apputils.h \ - util/appsettings.h + util/appsettings.h \ + gui/instancesettings.h FORMS += gui/mainwindow.ui \ gui/settingsdialog.ui \ - gui/modeditwindow.ui + gui/modeditwindow.ui \ + gui/instancesettings.ui RESOURCES += \ multimc.qrc diff --git a/gui/instancesettings.cpp b/gui/instancesettings.cpp new file mode 100644 index 00000000..7e82e1d6 --- /dev/null +++ b/gui/instancesettings.cpp @@ -0,0 +1,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()); +} diff --git a/gui/instancesettings.h b/gui/instancesettings.h new file mode 100644 index 00000000..af75a0f1 --- /dev/null +++ b/gui/instancesettings.h @@ -0,0 +1,32 @@ +#ifndef INSTANCESETTINGS_H +#define INSTANCESETTINGS_H + +#include + +namespace Ui { +class InstanceSettings; +} + +class InstanceSettings : public QDialog +{ + Q_OBJECT + +public: + explicit InstanceSettings(QWidget *parent = 0); + ~InstanceSettings(); + + void updateCheckboxStuff(); + + void applySettings(SettingsObject *s); + void loadSettings(SettingsObject* s); + +private slots: + void on_overrideGlobalMcCheck_clicked(bool checked); + + void on_customCommandsGroupBox_toggled(bool arg1); + +private: + Ui::InstanceSettings *ui; +}; + +#endif // INSTANCESETTINGS_H diff --git a/gui/instancesettings.ui b/gui/instancesettings.ui new file mode 100644 index 00000000..1fb8b023 --- /dev/null +++ b/gui/instancesettings.ui @@ -0,0 +1,386 @@ + + + InstanceSettings + + + + 0 + 0 + 453 + 563 + + + + Dialog + + + + + 9 + 9 + 435 + 516 + + + + QTabWidget::Rounded + + + 0 + + + + Minecraft + + + + + + true + + + Window Size + + + true + + + false + + + + + + Compatibility mode? + + + + + + + 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? + + + + + + + + + + true + + + Account Settings + + + true + + + false + + + + + + false + + + Login automatically when an instance icon is double clicked? + + + false + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Java + + + + + + true + + + Memory + + + true + + + false + + + + + + 512 + + + 65536 + + + 128 + + + 1024 + + + + + + + Minimum memory allocation: + + + + + + + Maximum memory allocation: + + + + + + + 256 + + + 65536 + + + 128 + + + 256 + + + + + + + + + + true + + + Java Settings + + + true + + + false + + + + + + Java path: + + + + + + + + + + JVM arguments: + + + + + + + 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 + + + + + + + + + + 270 + 530 + 166 + 23 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 8ba988c5..0b592cf0 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -553,3 +553,19 @@ void MainWindow::on_actionChangeInstLWJGLVersion_triggered() } } + +void MainWindow::on_actionInstanceSettings_triggered() +{ + if (view->selectionModel()->selectedIndexes().count() < 1) + return; + + Instance *inst = selectedInstance(); + SettingsObject *s; + s = &inst->settings(); + InstanceSettings *settings = new InstanceSettings (this); + settings->loadSettings(s); + if (settings->exec()) { + settings->applySettings(s); + } + delete settings; +} -- cgit v1.2.3