summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-08-25 22:48:41 +0200
committerPetr Mrázek <peterix@gmail.com>2013-08-25 22:48:41 +0200
commitf0990fae4bc6e54837764c0ded1461b9f1770401 (patch)
tree619dd1c5007d902e2d349bb42e3f66454596713a /logic
parentd884f849d60db44f05a6a6b22f4ffcf520900389 (diff)
downloadMultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.tar
MultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.tar.gz
MultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.tar.lz
MultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.tar.xz
MultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.zip
Many improvements
PermGen can be tweaked from the settings menu Groups are saved on change/exit Install target is no longer completely broken All the deplibs are now static Added notes dialog Fixed ini file format support (can save strings with newlines, tabs. UTF-8 is explicitly used!) Rename button now uses line breaks so it doesn't grow ever wider (Added a custom tool button subclass) There is now a CAT button. Meow.
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.cpp11
-rw-r--r--logic/BaseInstance.h10
-rw-r--r--logic/LegacyInstance.cpp1
-rw-r--r--logic/OneSixInstance.cpp1
-rw-r--r--logic/lists/InstanceList.cpp72
-rw-r--r--logic/lists/InstanceList.h7
6 files changed, 94 insertions, 8 deletions
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index bd2aad8a..6593e715 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.cpp
@@ -71,6 +71,7 @@ BaseInstance::BaseInstance( BaseInstancePrivate* d_in,
settings().registerSetting(new Setting("OverrideMemory", false));
settings().registerSetting(new OverrideSetting("MinMemAlloc", globalSettings->getSetting("MinMemAlloc")));
settings().registerSetting(new OverrideSetting("MaxMemAlloc", globalSettings->getSetting("MaxMemAlloc")));
+ settings().registerSetting(new OverrideSetting("PermGen", globalSettings->getSetting("PermGen")));
// Auto login
settings().registerSetting(new Setting("OverrideLogin", false));
@@ -187,12 +188,20 @@ void BaseInstance::setLastLaunch ( qint64 val )
emit propertiesChanged ( this );
}
-void BaseInstance::setGroup ( QString val )
+void BaseInstance::setGroupInitial ( QString val )
{
I_D(BaseInstance);
d->m_group = val;
emit propertiesChanged ( this );
}
+
+void BaseInstance::setGroupPost ( QString val )
+{
+ setGroupInitial(val);
+ emit groupChanged();
+}
+
+
QString BaseInstance::group() const
{
I_D(BaseInstance);
diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h
index 13ed169f..a1e6075a 100644
--- a/logic/BaseInstance.h
+++ b/logic/BaseInstance.h
@@ -70,7 +70,9 @@ public:
void setNotes(QString val);
QString group() const;
- void setGroup(QString val);
+ void setGroupInitial(QString val);
+ void setGroupPost(QString val);
+
virtual QString intendedVersionId() const = 0;
virtual bool setIntendedVersionId(QString version) = 0;
@@ -157,12 +159,16 @@ public:
/// FIXME: this really should be elsewhere...
virtual QString instanceConfigFolder() const = 0;
+
signals:
/*!
* \brief Signal emitted when properties relevant to the instance view change
*/
void propertiesChanged(BaseInstance * inst);
-
+ /*!
+ * \brief Signal emitted when groups are affected in any way
+ */
+ void groupChanged();
protected:
QSharedPointer<BaseInstancePrivate> inst_d;
};
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index dce1d2f3..3aa3e683 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -68,6 +68,7 @@ MinecraftProcess* LegacyInstance::prepareForLaunch(QString user, QString session
// launcher arguments
args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt());
args << QString("-Xmx%1m").arg(settings().get("MaxMemAlloc").toInt());
+ args << QString("-XX:MaxPermSize=%1m").arg(settings().get("PermGen").toInt());
args << "-jar" << LAUNCHER_FILE;
args << user;
args << session;
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index 4cbf17b2..61002320 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -113,6 +113,7 @@ MinecraftProcess* OneSixInstance::prepareForLaunch ( QString user, QString sessi
args.append(Util::Commandline::splitArgs(settings().get("JvmArgs").toString()));
args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt());
args << QString("-Xmx%1m").arg(settings().get("MaxMemAlloc").toInt());
+ args << QString("-XX:MaxPermSize=%1m").arg(settings().get("PermGen").toInt());
QDir natives_dir(natives_dir_raw);
args << QString("-Djava.library.path=%1").arg( natives_dir.absolutePath() );
QString classPath;
diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp
index 39f55f7b..b2c9ec6d 100644
--- a/logic/lists/InstanceList.cpp
+++ b/logic/lists/InstanceList.cpp
@@ -14,6 +14,7 @@
*/
#include <QDir>
+#include <QSet>
#include <QFile>
#include <QDirIterator>
#include <QThread>
@@ -36,6 +37,73 @@ InstanceList::InstanceList(const QString &instDir, QObject *parent) :
}
+InstanceList::~InstanceList()
+{
+ saveGroupList();
+}
+
+
+void InstanceList::groupChanged()
+{
+ // save the groups. save all of them.
+ saveGroupList();
+}
+
+void InstanceList::saveGroupList()
+{
+ QString groupFileName = m_instDir + "/instgroups.json";
+ QFile groupFile(groupFileName);
+
+ // if you can't open the file, fail
+ if (!groupFile.open(QIODevice::WriteOnly| QIODevice::Truncate))
+ {
+ // An error occurred. Ignore it.
+ qDebug("Failed to read instance group file.");
+ return;
+ }
+ QTextStream out(&groupFile);
+ QMap<QString, QSet<QString> > groupMap;
+ for(auto instance: m_instances)
+ {
+ QString id = instance->id();
+ QString group = instance->group();
+ if(group.isEmpty())
+ continue;
+ if(!groupMap.count(group))
+ {
+ QSet<QString> set;
+ set.insert(id);
+ groupMap[group] = set;
+ }
+ else
+ {
+ QSet<QString> &set = groupMap[group];
+ set.insert(id);
+ }
+ }
+ QJsonObject toplevel;
+ toplevel.insert("formatVersion",QJsonValue(QString("1")));
+ QJsonObject groupsArr;
+ for(auto iter = groupMap.begin(); iter != groupMap.end(); iter++)
+ {
+ auto list = iter.value();
+ auto name = iter.key();
+ QJsonObject groupObj;
+ QJsonArray instanceArr;
+ groupObj.insert("hidden",QJsonValue(QString("false")));
+ for(auto item: list)
+ {
+ instanceArr.append(QJsonValue(item));
+ }
+ groupObj.insert("instances",instanceArr);
+ groupsArr.insert(name,groupObj);
+ }
+ toplevel.insert("groups",groupsArr);
+ QJsonDocument doc(toplevel);
+ groupFile.write(doc.toJson(QJsonDocument::Indented));
+ groupFile.close();
+}
+
void InstanceList::loadGroupList(QMap<QString, QString> & groupMap)
{
QString groupFileName = m_instDir + "/instgroups.json";
@@ -176,12 +244,13 @@ InstanceList::InstListError InstanceList::loadList()
auto iter = groupMap.find(inst->id());
if(iter != groupMap.end())
{
- inst->setGroup((*iter));
+ inst->setGroupInitial((*iter));
}
qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8());
inst->setParent(this);
m_instances.append(inst);
connect(instPtr, SIGNAL(propertiesChanged(BaseInstance*)),this, SLOT(propertiesChanged(BaseInstance*)));
+ connect(instPtr, SIGNAL(groupChanged()),this, SLOT(groupChanged()));
}
}
emit invalidated();
@@ -191,6 +260,7 @@ InstanceList::InstListError InstanceList::loadList()
/// Clear all instances. Triggers notifications.
void InstanceList::clear()
{
+ saveGroupList();
m_instances.clear();
emit invalidated();
};
diff --git a/logic/lists/InstanceList.h b/logic/lists/InstanceList.h
index 82ef0ea4..50ba56f3 100644
--- a/logic/lists/InstanceList.h
+++ b/logic/lists/InstanceList.h
@@ -26,13 +26,12 @@ class InstanceList : public QObject
{
Q_OBJECT
private:
- /*!
- * \brief Get the instance groups
- */
void loadGroupList(QMap<QString, QString> & groupList);
+ void saveGroupList();
public:
explicit InstanceList(const QString &instDir, QObject *parent = 0);
+ virtual ~InstanceList();
/*!
* \brief Error codes returned by functions in the InstanceList class.
@@ -84,7 +83,7 @@ signals:
private slots:
void propertiesChanged(BaseInstance * inst);
-
+ void groupChanged();
protected:
QString m_instDir;
QList< InstancePtr > m_instances;