From 586092cf9901dde873882c76cb3944cd0addbd2a Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 9 Jan 2013 12:58:33 -0600 Subject: Added readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..6578b53e --- /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.

-- cgit v1.2.3 From fce0f5df045f1d956cabeda41406001a037c9ab7 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 14 Jan 2013 17:42:38 -0600 Subject: Added stuff. --- MultiMC.pro | 8 ++++- MultiMC.pro.user | 2 +- data/appsettings.cpp | 22 ++++++++++++++ data/appsettings.h | 27 +++++++++++++++++ data/inifile.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++ data/inifile.h | 36 ++++++++++++++++++++++ data/instancebase.cpp | 22 ++++++++------ data/instancebase.h | 13 ++++---- data/instancelist.cpp | 52 ++++++++++++++++++++++++++++++++ data/instancelist.h | 38 +++++++++++++++++++++++ data/settingsbase.cpp | 22 ++++++++++++++ data/settingsbase.h | 33 ++++++++++++++++++++ data/settingsmacros.h | 35 ++++++++++++++++++++++ data/settingsmacrosundef.h | 26 ++++++++++++++++ data/stdinstance.cpp | 22 ++++++++++++++ data/stdinstance.h | 28 +++++++++++++++++ gui/mainwindow.cpp | 6 +++- gui/mainwindow.h | 6 ++++ stdinstance.cpp | 0 stdinstance.h | 0 util/pathutils.cpp | 5 ++++ util/pathutils.h | 1 + 22 files changed, 461 insertions(+), 18 deletions(-) create mode 100644 data/appsettings.cpp create mode 100644 data/appsettings.h create mode 100644 data/inifile.cpp create mode 100644 data/inifile.h create mode 100644 data/instancelist.cpp create mode 100644 data/instancelist.h create mode 100644 data/settingsbase.cpp create mode 100644 data/settingsbase.h create mode 100644 data/settingsmacros.h create mode 100644 data/settingsmacrosundef.h create mode 100644 data/stdinstance.cpp create mode 100644 data/stdinstance.h create mode 100644 stdinstance.cpp create mode 100644 stdinstance.h diff --git a/MultiMC.pro b/MultiMC.pro index 6115627c..81d72aee 100644 --- a/MultiMC.pro +++ b/MultiMC.pro @@ -15,11 +15,17 @@ 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 HEADERS += gui/mainwindow.h \ data/instancebase.h \ util/pathutils.h \ + data/instancelist.h \ + data/stdinstance.h \ + data/inifile.h FORMS += gui/mainwindow.ui diff --git a/MultiMC.pro.user b/MultiMC.pro.user index c72c06aa..f23af787 100644 --- a/MultiMC.pro.user +++ b/MultiMC.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/data/appsettings.cpp b/data/appsettings.cpp new file mode 100644 index 00000000..525def6e --- /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 00000000..f8c7ff73 --- /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 00000000..df94e43e --- /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 00000000..75783859 --- /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 2e0a65df..15dc54f4 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 df23b1b0..8c61aee0 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 00000000..7385ba86 --- /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 00000000..83ea48e2 --- /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 00000000..66195603 --- /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 00000000..8a7e7e77 --- /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 00000000..94e52155 --- /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 00000000..85b13bac --- /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 00000000..8bb74097 --- /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 dir) : + InstanceBase(dir) +{ + +} diff --git a/data/stdinstance.h b/data/stdinstance.h new file mode 100644 index 00000000..0bb8a0c3 --- /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: + StdInstance(QString dir); +}; + +#endif // STDINSTANCE_H diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 875cc256..ff9d0461 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -24,6 +24,10 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow) { ui->setupUi(this); + instList.loadInstances("instances"); + + model.setInstanceList(&instList); + ui->instListView->setModel(&model); } MainWindow::~MainWindow() @@ -43,7 +47,7 @@ void MainWindow::on_actionViewInstanceFolder_triggered() void MainWindow::on_actionRefresh_triggered() { - + instList.loadInstances("instances"); } void MainWindow::on_actionViewCentralModsFolder_triggered() diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 6d9a0216..a735d78e 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -18,6 +18,9 @@ #include +#include "../data/instancelist.h" +#include "../data/instancelistmodel.h" + namespace Ui { class MainWindow; } @@ -51,6 +54,9 @@ private slots: private: Ui::MainWindow *ui; + + InstanceList instList; + InstanceListModel model; }; #endif // MAINWINDOW_H diff --git a/stdinstance.cpp b/stdinstance.cpp new file mode 100644 index 00000000..e69de29b diff --git a/stdinstance.h b/stdinstance.h new file mode 100644 index 00000000..e69de29b diff --git a/util/pathutils.cpp b/util/pathutils.cpp index 809dd6f2..8610b80d 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 bfd11bea..1922e3a0 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); -- cgit v1.2.3 From f7e9a7523fdd8c9e2aaaf59f36fc4a702690b760 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 15 Jan 2013 18:46:27 -0600 Subject: Added settings dialog. --- MultiMC.pro | 9 +- MultiMC.pro.user | 2 +- data/stdinstance.cpp | 4 +- data/stdinstance.h | 2 +- gui/mainwindow.cpp | 8 +- gui/mainwindow.h | 5 +- gui/settingsdialog.cpp | 77 +++++++ gui/settingsdialog.h | 50 +++++ gui/settingsdialog.ui | 541 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 684 insertions(+), 14 deletions(-) create mode 100644 gui/settingsdialog.cpp create mode 100644 gui/settingsdialog.h create mode 100644 gui/settingsdialog.ui diff --git a/MultiMC.pro b/MultiMC.pro index 81d72aee..34d297c0 100644 --- a/MultiMC.pro +++ b/MultiMC.pro @@ -18,16 +18,19 @@ SOURCES += main.cpp\ util/pathutils.cpp \ data/instancelist.cpp \ data/stdinstance.cpp \ - data/inifile.cpp + data/inifile.cpp \ + gui/settingsdialog.cpp HEADERS += gui/mainwindow.h \ data/instancebase.h \ util/pathutils.h \ data/instancelist.h \ data/stdinstance.h \ - data/inifile.h + data/inifile.h \ + gui/settingsdialog.h -FORMS += gui/mainwindow.ui +FORMS += gui/mainwindow.ui \ + gui/settingsdialog.ui RESOURCES += \ multimc.qrc diff --git a/MultiMC.pro.user b/MultiMC.pro.user index f23af787..84f78217 100644 --- a/MultiMC.pro.user +++ b/MultiMC.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/data/stdinstance.cpp b/data/stdinstance.cpp index 8bb74097..1324b510 100644 --- a/data/stdinstance.cpp +++ b/data/stdinstance.cpp @@ -15,8 +15,8 @@ #include "stdinstance.h" -StdInstance::StdInstance(QString dir) : - InstanceBase(dir) +StdInstance::StdInstance(QString rootDir) : + InstanceBase(rootDir) { } diff --git a/data/stdinstance.h b/data/stdinstance.h index 0bb8a0c3..59b1c8ab 100644 --- a/data/stdinstance.h +++ b/data/stdinstance.h @@ -22,7 +22,7 @@ class StdInstance : public InstanceBase { public: - StdInstance(QString dir); + explicit StdInstance(QString rootDir); }; #endif // STDINSTANCE_H diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index ff9d0461..8f7372c8 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -19,15 +19,14 @@ #include #include +#include "../gui/settingsdialog.h" + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); instList.loadInstances("instances"); - - model.setInstanceList(&instList); - ui->instListView->setModel(&model); } MainWindow::~MainWindow() @@ -62,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 a735d78e..09cd0817 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -19,9 +19,9 @@ #include #include "../data/instancelist.h" -#include "../data/instancelistmodel.h" -namespace Ui { +namespace Ui +{ class MainWindow; } @@ -56,7 +56,6 @@ private: Ui::MainWindow *ui; InstanceList instList; - InstanceListModel model; }; #endif // MAINWINDOW_H diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp new file mode 100644 index 00000000..46569340 --- /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 00000000..3e9d9e0f --- /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 00000000..315686ca --- /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 + + + + + -- cgit v1.2.3 From b371ee1de22be6d846aa53ae5574555ca012f1c3 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 15 Jan 2013 19:04:10 -0600 Subject: Added mod edit window. --- MultiMC.pro | 9 +- MultiMC.pro.user | 2 +- gui/modeditwindow.cpp | 29 ++++++ gui/modeditwindow.h | 37 ++++++++ gui/modeditwindow.ui | 241 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 314 insertions(+), 4 deletions(-) create mode 100644 gui/modeditwindow.cpp create mode 100644 gui/modeditwindow.h create mode 100644 gui/modeditwindow.ui diff --git a/MultiMC.pro b/MultiMC.pro index 34d297c0..0ca6daee 100644 --- a/MultiMC.pro +++ b/MultiMC.pro @@ -19,7 +19,8 @@ SOURCES += main.cpp\ data/instancelist.cpp \ data/stdinstance.cpp \ data/inifile.cpp \ - gui/settingsdialog.cpp + gui/settingsdialog.cpp \ + gui/modeditwindow.cpp HEADERS += gui/mainwindow.h \ data/instancebase.h \ @@ -27,10 +28,12 @@ HEADERS += gui/mainwindow.h \ data/instancelist.h \ data/stdinstance.h \ data/inifile.h \ - gui/settingsdialog.h + gui/settingsdialog.h \ + gui/modeditwindow.h FORMS += gui/mainwindow.ui \ - gui/settingsdialog.ui + gui/settingsdialog.ui \ + gui/modeditwindow.ui RESOURCES += \ multimc.qrc diff --git a/MultiMC.pro.user b/MultiMC.pro.user index 84f78217..21852a10 100644 --- a/MultiMC.pro.user +++ b/MultiMC.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/gui/modeditwindow.cpp b/gui/modeditwindow.cpp new file mode 100644 index 00000000..e457252a --- /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 00000000..c669e0b1 --- /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 00000000..c35c35d1 --- /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 + + + + + + + + -- cgit v1.2.3