diff --git a/MultiMC.pro b/MultiMC.pro index 6115627cf..0ca6daee6 100644 --- a/MultiMC.pro +++ b/MultiMC.pro @@ -15,13 +15,25 @@ TEMPLATE = app SOURCES += main.cpp\ gui/mainwindow.cpp \ data/instancebase.cpp \ - util/pathutils.cpp + util/pathutils.cpp \ + data/instancelist.cpp \ + data/stdinstance.cpp \ + data/inifile.cpp \ + gui/settingsdialog.cpp \ + gui/modeditwindow.cpp HEADERS += gui/mainwindow.h \ data/instancebase.h \ util/pathutils.h \ + data/instancelist.h \ + data/stdinstance.h \ + data/inifile.h \ + gui/settingsdialog.h \ + gui/modeditwindow.h -FORMS += gui/mainwindow.ui +FORMS += gui/mainwindow.ui \ + gui/settingsdialog.ui \ + gui/modeditwindow.ui RESOURCES += \ multimc.qrc diff --git a/MultiMC.pro.user b/MultiMC.pro.user index c72c06aab..21852a101 100644 --- a/MultiMC.pro.user +++ b/MultiMC.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/README.md b/README.md new file mode 100644 index 000000000..6578b53ee --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +![MultiMC](http://i.imgur.com/QJXbz.png) +

MultiMC 5

+

MultiMC is a custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once. It also allows you to easily install and remove mods by simply dragging and dropping.

+ +

License

+

Copyright © 2013 MultiMC Contributors

+

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this program 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.

diff --git a/data/appsettings.cpp b/data/appsettings.cpp new file mode 100644 index 000000000..525def6e3 --- /dev/null +++ b/data/appsettings.cpp @@ -0,0 +1,22 @@ +/* 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. + */ + +#include "appsettings.h" + +AppSettings::AppSettings(QString fileName) : + SettingsBase(fileName) +{ + +} diff --git a/data/appsettings.h b/data/appsettings.h new file mode 100644 index 000000000..f8c7ff733 --- /dev/null +++ b/data/appsettings.h @@ -0,0 +1,27 @@ +/* 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. + */ + +#ifndef APPSETTINGS_H +#define APPSETTINGS_H + +#include "settingsbase.h" + +class AppSettings : public SettingsBase +{ +public: + AppSettings(QString fileName); +}; + +#endif // APPSETTINGS_H diff --git a/data/inifile.cpp b/data/inifile.cpp new file mode 100644 index 000000000..df94e43e6 --- /dev/null +++ b/data/inifile.cpp @@ -0,0 +1,75 @@ +/* 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. + */ + +#include "inifile.h" + +#include +#include +#include + +INIFile::INIFile() +{ + +} + +bool INIFile::saveFile(QString fileName) +{ + // TODO Handle errors. + QFile file(fileName); + file.open(QIODevice::WriteOnly); + QTextStream out(&file); + + for (Iterator iter = begin(); iter != end(); iter++) + { + out << iter.key() << "=" << iter.value().toString() << "\n"; + } + + return true; +} + +bool INIFile::loadFile(QString fileName) +{ + // TODO Handle errors. + QFile file(fileName); + file.open(QIODevice::ReadOnly); + QTextStream in(&file); + + QStringList lines = in.readAll().split('\n'); + for (int i = 0; i < lines.count(); i++) + { + // Ignore comments. + QString line = lines[i].left('#').trimmed(); + + QString key = line.section('=', 0).trimmed(); + QVariant value(line.section('=', 1).trimmed()); + + this->operator [](key) = value; + } + + return true; +} + +QVariant INIFile::get(QString key, QVariant def) const +{ + if (!this->contains(key)) + return def; + else + return this->operator [](key); +} + +void INIFile::set(QString key, QVariant val) +{ + this->operator [](key) = val; +} diff --git a/data/inifile.h b/data/inifile.h new file mode 100644 index 000000000..757838598 --- /dev/null +++ b/data/inifile.h @@ -0,0 +1,36 @@ +/* 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. + */ + +#ifndef INIFILE_H +#define INIFILE_H + +#include +#include +#include + +// Sectionless INI parser (for instance config files) +class INIFile : public QMap +{ +public: + explicit INIFile(); + + bool loadFile(QString fileName); + bool saveFile(QString fileName); + + QVariant get(QString key, QVariant def) const; + void set(QString key, QVariant val); +}; + +#endif // INIFILE_H diff --git a/data/instancebase.cpp b/data/instancebase.cpp index 2e0a65df2..15dc54f49 100644 --- a/data/instancebase.cpp +++ b/data/instancebase.cpp @@ -15,31 +15,35 @@ #include "instancebase.h" +#include + #include "../util/pathutils.h" -InstanceBase::InstanceBase(QString rootDir, QObject *parent) : +InstanceBase::InstanceBase(QString dir, QObject *parent) : QObject(parent), - m_rootDir(rootDir), - m_config(PathCombine(rootDir, "instance.cfg"), QSettings::IniFormat) + rootDir(dir) { + QFileInfo cfgFile; + if (cfgFile.exists()) + config.loadFile(PathCombine(rootDir, "instance.cfg")); } -QString InstanceBase::GetRootDir() const +QString InstanceBase::getRootDir() const { - return m_rootDir; + return rootDir; } ///////////// Config Values ///////////// // Name -QString InstanceBase::GetInstName() const +QString InstanceBase::getInstName() const { - return m_config.value("name", "Unnamed").toString(); + return config.get("name", "Unnamed").toString(); } -void InstanceBase::SetInstName(QString name) +void InstanceBase::setInstName(QString name) { - m_config.setValue("name", name); + config.set("name", name); } diff --git a/data/instancebase.h b/data/instancebase.h index df23b1b0f..8c61aee00 100644 --- a/data/instancebase.h +++ b/data/instancebase.h @@ -18,7 +18,8 @@ #include #include -#include + +#include "../data/inifile.h" class InstanceBase : public QObject { @@ -26,18 +27,18 @@ class InstanceBase : public QObject public: explicit InstanceBase(QString rootDir, QObject *parent = 0); - QString GetRootDir() const; + QString getRootDir() const; - QString GetInstName() const; - void SetInstName(QString name); + QString getInstName() const; + void setInstName(QString name); protected: private: - QString m_rootDir; + QString rootDir; - QSettings m_config; + INIFile config; }; #endif // INSTANCEBASE_H diff --git a/data/instancelist.cpp b/data/instancelist.cpp new file mode 100644 index 000000000..7385ba86a --- /dev/null +++ b/data/instancelist.cpp @@ -0,0 +1,52 @@ +/* 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. + */ + +#include "instancelist.h" + +#include +#include + +#include "stdinstance.h" + +#include "../util/pathutils.h" + +InstanceList::InstanceList() : + QList() +{ + +} + +void InstanceList::addInstance(InstanceBase *inst) +{ + append(inst); +} + +void InstanceList::loadInstances(QString dir) +{ + qDebug("Loading instances"); + QDir instDir(dir); + QDirIterator iter(instDir); + + while (iter.hasNext()) + { + QString subDir = iter.next(); + if (QFileInfo(PathCombine(subDir, "instance.cfg")).exists()) + { + // TODO Differentiate between different instance types. + InstanceBase* inst = new StdInstance(subDir); + addInstance(inst); + } + } +} diff --git a/data/instancelist.h b/data/instancelist.h new file mode 100644 index 000000000..83ea48e27 --- /dev/null +++ b/data/instancelist.h @@ -0,0 +1,38 @@ +/* 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. + */ + +#ifndef INSTANCELIST_H +#define INSTANCELIST_H + +#include + +#include "instancebase.h" + +class InstanceList : public QList +{ +public: + explicit InstanceList(); + + void addInstance(InstanceBase *inst); + + void loadInstances(QString dir); + +signals: + +public slots: + +}; + +#endif // INSTANCELIST_H diff --git a/data/settingsbase.cpp b/data/settingsbase.cpp new file mode 100644 index 000000000..66195603e --- /dev/null +++ b/data/settingsbase.cpp @@ -0,0 +1,22 @@ +/* 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. + */ + +#include "settingsbase.h" + +SettingsBase::SettingsBase(QString fileName) : + QSettings(fileName, QSettings::IniFormat) +{ + +} diff --git a/data/settingsbase.h b/data/settingsbase.h new file mode 100644 index 000000000..8a7e7e774 --- /dev/null +++ b/data/settingsbase.h @@ -0,0 +1,33 @@ +/* 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. + */ + +#ifndef SETTINGSBASE_H +#define SETTINGSBASE_H + +#include + +#include "../util/settingsmacros.h" + +class SettingsBase : public QSettings +{ +public: + SettingsBase(QString fileName); + + +}; + +#include "../util/settingsmacrosundef.h" + +#endif // SETTINGSBASE_H diff --git a/data/settingsmacros.h b/data/settingsmacros.h new file mode 100644 index 000000000..94e521558 --- /dev/null +++ b/data/settingsmacros.h @@ -0,0 +1,35 @@ +/* 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. + */ + +#ifndef SETTINGSMACROS_H +#define SETTINGSMACROS_H + +#define STR_VAL(val) # val + +#define DEFINE_SETTING(funcName, name, defVal, typeName, toFunc) \ + virtual typeName Get ## funcName() const { return value(name). ## toFunc(); } \ + virtual void Set ## funcName(typeName value) { setValue(name, value); } \ + virtual void Reset ## funcName() { + +#define DEFINE_SETTING_STR(name, defVal) \ + DEFINE_SETTING(name, STR_VAL(name), defVal, QString, toString) + +#define DEFINE_SETTING_BOOL(name, defVal) \ + DEFINE_SETTING(name, STR_VAL(name), defVal, bool, toBool) + +#define DEFINE_SETTING_INT(name, defVal) \ + DEFINE_SETTING(name, STR_VAL(name), defVal, int, toInt) + +#endif // SETTINGSMACROS_H diff --git a/data/settingsmacrosundef.h b/data/settingsmacrosundef.h new file mode 100644 index 000000000..85b13bacb --- /dev/null +++ b/data/settingsmacrosundef.h @@ -0,0 +1,26 @@ +/* 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. + */ + +#ifndef SETTINGSMACROSUNDEF_H +#define SETTINGSMACROSUNDEF_H + +#undef DEFINE_SETTING +#undef DEFINE_SETTING_STR +#undef DEFINE_SETTING_BOOL +#undef DEFINE_SETTING_INT + +#undef STR_VAL + +#endif // SETTINGSMACROSUNDEF_H diff --git a/data/stdinstance.cpp b/data/stdinstance.cpp new file mode 100644 index 000000000..1324b510f --- /dev/null +++ b/data/stdinstance.cpp @@ -0,0 +1,22 @@ +/* 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. + */ + +#include "stdinstance.h" + +StdInstance::StdInstance(QString rootDir) : + InstanceBase(rootDir) +{ + +} diff --git a/data/stdinstance.h b/data/stdinstance.h new file mode 100644 index 000000000..59b1c8ab3 --- /dev/null +++ b/data/stdinstance.h @@ -0,0 +1,28 @@ +/* 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. + */ + +#ifndef STDINSTANCE_H +#define STDINSTANCE_H + +#include "instancebase.h" + +// Standard client instance. +class StdInstance : public InstanceBase +{ +public: + explicit StdInstance(QString rootDir); +}; + +#endif // STDINSTANCE_H diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 875cc2563..8f7372c8e 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -19,11 +19,14 @@ #include #include +#include "../gui/settingsdialog.h" + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); + instList.loadInstances("instances"); } MainWindow::~MainWindow() @@ -43,7 +46,7 @@ void MainWindow::on_actionViewInstanceFolder_triggered() void MainWindow::on_actionRefresh_triggered() { - + instList.loadInstances("instances"); } void MainWindow::on_actionViewCentralModsFolder_triggered() @@ -58,7 +61,8 @@ void MainWindow::on_actionCheckUpdate_triggered() void MainWindow::on_actionSettings_triggered() { - + SettingsDialog dialog(this); + dialog.exec(); } void MainWindow::on_actionReportBug_triggered() diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 6d9a0216d..09cd08179 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -18,7 +18,10 @@ #include -namespace Ui { +#include "../data/instancelist.h" + +namespace Ui +{ class MainWindow; } @@ -51,6 +54,8 @@ private slots: private: Ui::MainWindow *ui; + + InstanceList instList; }; #endif // MAINWINDOW_H diff --git a/gui/modeditwindow.cpp b/gui/modeditwindow.cpp new file mode 100644 index 000000000..e457252a3 --- /dev/null +++ b/gui/modeditwindow.cpp @@ -0,0 +1,29 @@ +/* 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. + */ + +#include "modeditwindow.h" +#include "ui_modeditwindow.h" + +ModEditWindow::ModEditWindow(QWidget *parent) : + QDialog(parent), + ui(new Ui::ModEditWindow) +{ + ui->setupUi(this); +} + +ModEditWindow::~ModEditWindow() +{ + delete ui; +} diff --git a/gui/modeditwindow.h b/gui/modeditwindow.h new file mode 100644 index 000000000..c669e0b1b --- /dev/null +++ b/gui/modeditwindow.h @@ -0,0 +1,37 @@ +/* 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. + */ + +#ifndef MODEDITWINDOW_H +#define MODEDITWINDOW_H + +#include + +namespace Ui { +class ModEditWindow; +} + +class ModEditWindow : public QDialog +{ + Q_OBJECT + +public: + explicit ModEditWindow(QWidget *parent = 0); + ~ModEditWindow(); + +private: + Ui::ModEditWindow *ui; +}; + +#endif // MODEDITWINDOW_H diff --git a/gui/modeditwindow.ui b/gui/modeditwindow.ui new file mode 100644 index 000000000..c35c35d1e --- /dev/null +++ b/gui/modeditwindow.ui @@ -0,0 +1,241 @@ + + + ModEditWindow + + + + 0 + 0 + 540 + 420 + + + + Dialog + + + + + + 0 + + + + Jar Mods + + + + + + + + + + + &Add + + + + + + + &Remove + + + + + + + MCForge + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Move &Up + + + + + + + Move &Down + + + + + + + + + + Mods + + + + + + + + + + + &Add + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + + + Core Mods + + + + + + + + + + + &Add + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + + + Texture Packs + + + + + + + + + + + &Add + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + + + + + + QDialogButtonBox::Close + + + + + + + + diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp new file mode 100644 index 000000000..465693400 --- /dev/null +++ b/gui/settingsdialog.cpp @@ -0,0 +1,77 @@ +/* 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. + */ + +#include "settingsdialog.h" +#include "ui_settingsdialog.h" + +#include + +SettingsDialog::SettingsDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::SettingsDialog) +{ + ui->setupUi(this); +} + +SettingsDialog::~SettingsDialog() +{ + delete ui; +} + +void SettingsDialog::updateCheckboxStuff() +{ + ui->minMemSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() || + ui->maximizedCheckBox->isChecked())); + ui->maxMemSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() || + ui->maximizedCheckBox->isChecked())); + + ui->maximizedCheckBox->setEnabled(!ui->compatModeCheckBox->isChecked()); +} + +void SettingsDialog::on_instDirBrowseBtn_clicked() +{ + QString dir = QFileDialog::getExistingDirectory(this, "Instance Directory", + ui->instDirTextBox->text()); + if (!dir.isEmpty()) + ui->instDirTextBox->setText(dir); +} + +void SettingsDialog::on_modsDirBrowseBtn_clicked() +{ + QString dir = QFileDialog::getExistingDirectory(this, "Mods Directory", + ui->modsDirTextBox->text()); + if (!dir.isEmpty()) + ui->modsDirTextBox->setText(dir); +} + +void SettingsDialog::on_lwjglDirBrowseBtn_clicked() +{ + QString dir = QFileDialog::getExistingDirectory(this, "LWJGL Directory", + ui->lwjglDirTextBox->text()); + if (!dir.isEmpty()) + ui->lwjglDirTextBox->setText(dir); +} + +void SettingsDialog::on_compatModeCheckBox_clicked(bool checked) +{ + Q_UNUSED(checked); + updateCheckboxStuff(); +} + +void SettingsDialog::on_maximizedCheckBox_clicked(bool checked) +{ + Q_UNUSED(checked); + updateCheckboxStuff(); +} diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h new file mode 100644 index 000000000..3e9d9e0f1 --- /dev/null +++ b/gui/settingsdialog.h @@ -0,0 +1,50 @@ +/* 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. + */ + +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include + +namespace Ui { +class SettingsDialog; +} + +class SettingsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit SettingsDialog(QWidget *parent = 0); + ~SettingsDialog(); + + void updateCheckboxStuff(); + +private slots: + void on_instDirBrowseBtn_clicked(); + + void on_modsDirBrowseBtn_clicked(); + + void on_lwjglDirBrowseBtn_clicked(); + + void on_compatModeCheckBox_clicked(bool checked); + + void on_maximizedCheckBox_clicked(bool checked); + +private: + Ui::SettingsDialog *ui; +}; + +#endif // SETTINGSDIALOG_H diff --git a/gui/settingsdialog.ui b/gui/settingsdialog.ui new file mode 100644 index 000000000..315686ca5 --- /dev/null +++ b/gui/settingsdialog.ui @@ -0,0 +1,541 @@ + + + SettingsDialog + + + + 0 + 0 + 400 + 420 + + + + Settings + + + + :/icons/toolbar/settings:/icons/toolbar/settings + + + true + + + + + + QTabWidget::Rounded + + + 0 + + + + General + + + + + + true + + + Sorting Mode + + + + + + By last launched + + + + + + + By name + + + + + + + + + + Update Settings + + + + + + Use development builds? + + + + + + + Check for updates when MultiMC starts? + + + + + + + + + + Folders + + + + + + Instances: + + + + + + + + + + ... + + + + + + + Mods: + + + + + + + + + + ... + + + + + + + LWJGL: + + + + + + + + + + ... + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Console + + + + + + Console Settings + + + + + + Show console while the game is running? + + + + + + + Automatically close console when the game quits? + + + + + + + + + + Instance Console Colors + + + + + + System message color: + + + + + + + + + + Output message color: + + + + + + + + + + Error message color: + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Minecraft + + + + + + Window Size + + + + + + Compatibility mode? + + + + + + + Start Minecraft maximized? + + + + + + + + + Window height: + + + + + + + Window width: + + + + + + + 854 + + + 65536 + + + 1 + + + 854 + + + + + + + 480 + + + 65536 + + + 480 + + + + + + + + + + + + Login automatically when an instance launches? + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Java + + + + + + Memory + + + + + + 512 + + + 65536 + + + 128 + + + 1024 + + + + + + + Minimum memory allocation: + + + + + + + Maximum memory allocation: + + + + + + + 256 + + + 65536 + + + 128 + + + 256 + + + + + + + + + + Java Settings + + + + + + Java path: + + + + + + + + + + JVM arguments: + + + + + + + Auto-detect + + + + + + + + + + + + + Custom Commands + + + + + + Post-exit command: + + + + + + + Pre-launch command: + + + + + + + + + + + + + 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. + + + true + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + SettingsDialog + accept() + + + 257 + 410 + + + 157 + 274 + + + + + buttonBox + rejected() + SettingsDialog + reject() + + + 325 + 410 + + + 286 + 274 + + + + + diff --git a/stdinstance.cpp b/stdinstance.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/stdinstance.h b/stdinstance.h new file mode 100644 index 000000000..e69de29bb diff --git a/util/pathutils.cpp b/util/pathutils.cpp index 809dd6f26..8610b80d9 100644 --- a/util/pathutils.cpp +++ b/util/pathutils.cpp @@ -26,6 +26,11 @@ QString PathCombine(QString path1, QString path2) return path1.append(path2); } +QString PathCombine(QString path1, QString path2, QString path3) +{ + return PathCombine(PathCombine(path1, path2), path3); +} + QString AbsolutePath(QString path) { return QFileInfo(path).absolutePath(); diff --git a/util/pathutils.h b/util/pathutils.h index bfd11bea4..1922e3a08 100644 --- a/util/pathutils.h +++ b/util/pathutils.h @@ -19,6 +19,7 @@ #include QString PathCombine(QString path1, QString path2); +QString PathCombine(QString path1, QString path2, QString path3); QString AbsolutePath(QString path);