This commit is contained in:
Petr Mrázek 2013-01-20 00:26:50 +01:00
commit 3e0ba1ffd3
29 changed files with 1452 additions and 21 deletions

View File

@ -15,13 +15,25 @@ TEMPLATE = app
SOURCES += main.cpp\ SOURCES += main.cpp\
gui/mainwindow.cpp \ gui/mainwindow.cpp \
data/instancebase.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 \ HEADERS += gui/mainwindow.h \
data/instancebase.h \ data/instancebase.h \
util/pathutils.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 += \ RESOURCES += \
multimc.qrc multimc.qrc

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.6.1, 2013-01-09T12:15:16. --> <!-- Written by Qt Creator 2.6.1, 2013-01-15T19:01:37. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>

8
README.md Normal file
View File

@ -0,0 +1,8 @@
![MultiMC](http://i.imgur.com/QJXbz.png)
<h1>MultiMC 5</h1>
<p>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.</p>
<h3>License</h3>
<p>Copyright &copy; 2013 MultiMC Contributors</p>
<p>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 <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>.</p>
<p>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.</p>

22
data/appsettings.cpp Normal file
View File

@ -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)
{
}

27
data/appsettings.h Normal file
View File

@ -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

75
data/inifile.cpp Normal file
View File

@ -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 <QFile>
#include <QTextStream>
#include <QStringList>
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;
}

36
data/inifile.h Normal file
View File

@ -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 <QMap>
#include <QString>
#include <QVariant>
// Sectionless INI parser (for instance config files)
class INIFile : public QMap<QString, QVariant>
{
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

View File

@ -15,31 +15,35 @@
#include "instancebase.h" #include "instancebase.h"
#include <QFileInfo>
#include "../util/pathutils.h" #include "../util/pathutils.h"
InstanceBase::InstanceBase(QString rootDir, QObject *parent) : InstanceBase::InstanceBase(QString dir, QObject *parent) :
QObject(parent), QObject(parent),
m_rootDir(rootDir), rootDir(dir)
m_config(PathCombine(rootDir, "instance.cfg"), QSettings::IniFormat)
{ {
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 ///////////// ///////////// Config Values /////////////
// Name // 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);
} }

View File

@ -18,7 +18,8 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QSettings>
#include "../data/inifile.h"
class InstanceBase : public QObject class InstanceBase : public QObject
{ {
@ -26,18 +27,18 @@ class InstanceBase : public QObject
public: public:
explicit InstanceBase(QString rootDir, QObject *parent = 0); explicit InstanceBase(QString rootDir, QObject *parent = 0);
QString GetRootDir() const; QString getRootDir() const;
QString GetInstName() const; QString getInstName() const;
void SetInstName(QString name); void setInstName(QString name);
protected: protected:
private: private:
QString m_rootDir; QString rootDir;
QSettings m_config; INIFile config;
}; };
#endif // INSTANCEBASE_H #endif // INSTANCEBASE_H

52
data/instancelist.cpp Normal file
View File

@ -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 <QDir>
#include <QDirIterator>
#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);
}
}
}

38
data/instancelist.h Normal file
View File

@ -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 <QList>
#include "instancebase.h"
class InstanceList : public QList<InstanceBase*>
{
public:
explicit InstanceList();
void addInstance(InstanceBase *inst);
void loadInstances(QString dir);
signals:
public slots:
};
#endif // INSTANCELIST_H

22
data/settingsbase.cpp Normal file
View File

@ -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)
{
}

33
data/settingsbase.h Normal file
View File

@ -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 <QSettings>
#include "../util/settingsmacros.h"
class SettingsBase : public QSettings
{
public:
SettingsBase(QString fileName);
};
#include "../util/settingsmacrosundef.h"
#endif // SETTINGSBASE_H

35
data/settingsmacros.h Normal file
View File

@ -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

View File

@ -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

22
data/stdinstance.cpp Normal file
View File

@ -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)
{
}

28
data/stdinstance.h Normal file
View File

@ -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

View File

@ -19,11 +19,14 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QUrl> #include <QUrl>
#include "../gui/settingsdialog.h"
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::MainWindow) ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
instList.loadInstances("instances");
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -43,7 +46,7 @@ void MainWindow::on_actionViewInstanceFolder_triggered()
void MainWindow::on_actionRefresh_triggered() void MainWindow::on_actionRefresh_triggered()
{ {
instList.loadInstances("instances");
} }
void MainWindow::on_actionViewCentralModsFolder_triggered() void MainWindow::on_actionViewCentralModsFolder_triggered()
@ -58,7 +61,8 @@ void MainWindow::on_actionCheckUpdate_triggered()
void MainWindow::on_actionSettings_triggered() void MainWindow::on_actionSettings_triggered()
{ {
SettingsDialog dialog(this);
dialog.exec();
} }
void MainWindow::on_actionReportBug_triggered() void MainWindow::on_actionReportBug_triggered()

View File

@ -18,7 +18,10 @@
#include <QMainWindow> #include <QMainWindow>
namespace Ui { #include "../data/instancelist.h"
namespace Ui
{
class MainWindow; class MainWindow;
} }
@ -51,6 +54,8 @@ private slots:
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
InstanceList instList;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

29
gui/modeditwindow.cpp Normal file
View File

@ -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;
}

37
gui/modeditwindow.h Normal file
View File

@ -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 <QDialog>
namespace Ui {
class ModEditWindow;
}
class ModEditWindow : public QDialog
{
Q_OBJECT
public:
explicit ModEditWindow(QWidget *parent = 0);
~ModEditWindow();
private:
Ui::ModEditWindow *ui;
};
#endif // MODEDITWINDOW_H

241
gui/modeditwindow.ui Normal file
View File

@ -0,0 +1,241 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ModEditWindow</class>
<widget class="QDialog" name="ModEditWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>540</width>
<height>420</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="jarModsTab">
<attribute name="title">
<string>Jar Mods</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListView" name="jarModsListView"/>
</item>
<item>
<layout class="QVBoxLayout" name="jarModsButtonBox">
<item>
<widget class="QPushButton" name="addJarModButton">
<property name="text">
<string>&amp;Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="delJarModButton">
<property name="text">
<string>&amp;Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mcforgeButton">
<property name="text">
<string>MCForge</string>
</property>
</widget>
</item>
<item>
<spacer name="jarModsButtonSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="jarModMoveUpButton">
<property name="text">
<string>Move &amp;Up</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="jarModMoveDownButton">
<property name="text">
<string>Move &amp;Down</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="mlModsTab">
<attribute name="title">
<string>Mods</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QListView" name="mlModListView"/>
</item>
<item>
<layout class="QVBoxLayout" name="mlModsButtonBox">
<item>
<widget class="QPushButton" name="addMlModButton">
<property name="text">
<string>&amp;Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="delMlModButton">
<property name="text">
<string>&amp;Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="mlModsButtonSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="viewMlModFolderButton">
<property name="text">
<string>&amp;View Folder</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="coreModsTab">
<attribute name="title">
<string>Core Mods</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QListView" name="coreModsListView"/>
</item>
<item>
<layout class="QVBoxLayout" name="coreModsButtonBox">
<item>
<widget class="QPushButton" name="addCoreModButton">
<property name="text">
<string>&amp;Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="delCoreModButton">
<property name="text">
<string>&amp;Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="coreModsButtonSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="viewCoreModFolderButton">
<property name="text">
<string>&amp;View Folder</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="texturePacksTab">
<attribute name="title">
<string>Texture Packs</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QListView" name="texturePackListView"/>
</item>
<item>
<layout class="QVBoxLayout" name="texturePacksButtonBox">
<item>
<widget class="QPushButton" name="addTPackButton">
<property name="text">
<string>&amp;Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="delTPackButton">
<property name="text">
<string>&amp;Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="texturePacksButtonSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="viewTPackFolderButton">
<property name="text">
<string>&amp;View Folder</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

77
gui/settingsdialog.cpp Normal file
View File

@ -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 <QFileDialog>
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();
}

50
gui/settingsdialog.h Normal file
View File

@ -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 <QDialog>
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

541
gui/settingsdialog.ui Normal file
View File

@ -0,0 +1,541 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>420</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<property name="windowIcon">
<iconset resource="../multimc.qrc">
<normaloff>:/icons/toolbar/settings</normaloff>:/icons/toolbar/settings</iconset>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="mainLayout">
<item>
<widget class="QTabWidget" name="settingsTabs">
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="generalTab">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="generalTabLayout">
<item>
<widget class="QGroupBox" name="sortingModeBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Sorting Mode</string>
</property>
<layout class="QHBoxLayout" name="sortingModeBoxLayout">
<item>
<widget class="QRadioButton" name="sortLastLaunchedBtn">
<property name="text">
<string>By last launched</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="sortByNameBtn">
<property name="text">
<string>By name</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="updateSettingsBox">
<property name="title">
<string>Update Settings</string>
</property>
<layout class="QVBoxLayout" name="updateSettingsBoxLayout">
<item>
<widget class="QCheckBox" name="devBuildsCheckBox">
<property name="text">
<string>Use development builds?</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="autoUpdateCheckBox">
<property name="text">
<string>Check for updates when MultiMC starts?</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="foldersBox">
<property name="title">
<string>Folders</string>
</property>
<layout class="QGridLayout" name="foldersBoxLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelInstDir">
<property name="text">
<string>Instances:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="instDirTextBox"/>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="instDirBrowseBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelModsDir">
<property name="text">
<string>Mods:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="modsDirTextBox"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="modsDirBrowseBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelLWJGLDir">
<property name="text">
<string>LWJGL:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lwjglDirTextBox"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="lwjglDirBrowseBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="generalTabSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="consoleTab">
<attribute name="title">
<string>Console</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="consoleSettingsBox">
<property name="title">
<string>Console Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="showConsoleCheck">
<property name="text">
<string>Show console while the game is running?</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="autoCloseConsoleCheck">
<property name="text">
<string>Automatically close console when the game quits?</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="consoleColorsBox">
<property name="title">
<string>Instance Console Colors</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelSysMessageColor">
<property name="text">
<string>System message color:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="sysMsgColorTextBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelOutputMsgColor">
<property name="text">
<string>Output message color:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="outMsgColorTextBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelErrorMessageColor">
<property name="text">
<string>Error message color:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="errMsgColorTextBox"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="consoleVerticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="minecraftTab">
<attribute name="title">
<string>Minecraft</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="windowSizeGroupBox">
<property name="title">
<string>Window Size</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="compatModeCheckBox">
<property name="text">
<string>Compatibility mode?</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="maximizedCheckBox">
<property name="text">
<string>Start Minecraft maximized?</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayoutWindowSize">
<item row="1" column="0">
<widget class="QLabel" name="labelWindowHeight">
<property name="text">
<string>Window height:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelWindowWidth">
<property name="text">
<string>Window width:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="windowWidthSpinBox">
<property name="minimum">
<number>854</number>
</property>
<property name="maximum">
<number>65536</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>854</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="windowHeightSpinBox">
<property name="minimum">
<number>480</number>
</property>
<property name="maximum">
<number>65536</number>
</property>
<property name="value">
<number>480</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="autoLoginCheckBox">
<property name="text">
<string>Login automatically when an instance launches?</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacerMinecraft">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="javaTab">
<attribute name="title">
<string>Java</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="memoryGroupBox">
<property name="title">
<string>Memory</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="1">
<widget class="QSpinBox" name="maxMemSpinBox">
<property name="minimum">
<number>512</number>
</property>
<property name="maximum">
<number>65536</number>
</property>
<property name="singleStep">
<number>128</number>
</property>
<property name="value">
<number>1024</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelMinMem">
<property name="text">
<string>Minimum memory allocation:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelMaxMem">
<property name="text">
<string>Maximum memory allocation:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="minMemSpinBox">
<property name="minimum">
<number>256</number>
</property>
<property name="maximum">
<number>65536</number>
</property>
<property name="singleStep">
<number>128</number>
</property>
<property name="value">
<number>256</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="javaSettingsGroupBox">
<property name="title">
<string>Java Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="labelJavaPath">
<property name="text">
<string>Java path:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="javaPathTextBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelJVMArgs">
<property name="text">
<string>JVM arguments:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Auto-detect</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="jvmArgsTextBox"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="customCommandsGroupBox">
<property name="title">
<string>Custom Commands</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QLabel" name="labelPostExitCmd">
<property name="text">
<string>Post-exit command:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelPreLaunchCmd">
<property name="text">
<string>Pre-launch command:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="preLaunchCmdTextBox"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="postExitCmdTextBox"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="labelCustomCmdsDescription">
<property name="text">
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacerJava">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../multimc.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>257</x>
<y>410</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>325</x>
<y>410</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0
stdinstance.cpp Normal file
View File

0
stdinstance.h Normal file
View File

View File

@ -26,6 +26,11 @@ QString PathCombine(QString path1, QString path2)
return path1.append(path2); return path1.append(path2);
} }
QString PathCombine(QString path1, QString path2, QString path3)
{
return PathCombine(PathCombine(path1, path2), path3);
}
QString AbsolutePath(QString path) QString AbsolutePath(QString path)
{ {
return QFileInfo(path).absolutePath(); return QFileInfo(path).absolutePath();

View File

@ -19,6 +19,7 @@
#include <QString> #include <QString>
QString PathCombine(QString path1, QString path2); QString PathCombine(QString path1, QString path2);
QString PathCombine(QString path1, QString path2, QString path3);
QString AbsolutePath(QString path); QString AbsolutePath(QString path);