aboutsummaryrefslogtreecommitdiff
path: root/libmultimc/src
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-07-29 00:59:35 +0200
committerPetr Mrázek <peterix@gmail.com>2013-07-29 00:59:35 +0200
commit2e0cbf393a5320dbf5448ca44a9b5905314b0be8 (patch)
tree4baac9cf015ca7b15d83de33c705e0d8d4497d30 /libmultimc/src
parent8808a8b108b82916eaf30f9aca50cd3ab16af230 (diff)
downloadPrismLauncher-2e0cbf393a5320dbf5448ca44a9b5905314b0be8.tar.gz
PrismLauncher-2e0cbf393a5320dbf5448ca44a9b5905314b0be8.tar.bz2
PrismLauncher-2e0cbf393a5320dbf5448ca44a9b5905314b0be8.zip
Massive renaming in the backend folder, all around restructure in the same.
Diffstat (limited to 'libmultimc/src')
-rw-r--r--libmultimc/src/appsettings.cpp69
-rw-r--r--libmultimc/src/fullversion.cpp29
-rw-r--r--libmultimc/src/fullversionfactory.cpp206
-rw-r--r--libmultimc/src/gameupdatetask.cpp283
-rw-r--r--libmultimc/src/instance.cpp205
-rw-r--r--libmultimc/src/instancelist.cpp233
-rw-r--r--libmultimc/src/instanceloader.cpp61
-rw-r--r--libmultimc/src/instversion.cpp67
-rw-r--r--libmultimc/src/instversionlist.cpp129
-rw-r--r--libmultimc/src/library.cpp81
-rw-r--r--libmultimc/src/loginresponse.cpp69
-rw-r--r--libmultimc/src/logintask.cpp121
-rw-r--r--libmultimc/src/lwjglversionlist.cpp204
-rw-r--r--libmultimc/src/minecraftprocess.cpp269
-rw-r--r--libmultimc/src/minecraftversion.cpp105
-rw-r--r--libmultimc/src/minecraftversionlist.cpp528
-rw-r--r--libmultimc/src/task.cpp83
-rw-r--r--libmultimc/src/userinfo.cpp49
-rw-r--r--libmultimc/src/version.cpp46
19 files changed, 0 insertions, 2837 deletions
diff --git a/libmultimc/src/appsettings.cpp b/libmultimc/src/appsettings.cpp
deleted file mode 100644
index 7c886fdb..00000000
--- a/libmultimc/src/appsettings.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/* 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"
-
-#include <setting.h>
-
-#include <QPoint>
-#include <QApplication>
-//#include <QColor>
-
-AppSettings::AppSettings(QObject *parent) :
- INISettingsObject(QApplication::applicationDirPath() + "/multimc.cfg",parent)
-{
- // Updates
- registerSetting(new Setting("UseDevBuilds", false));
- registerSetting(new Setting("AutoUpdate", true));
-
- // Folders
- registerSetting(new Setting("InstanceDir", "instances"));
- registerSetting(new Setting("CentralModsDir", "mods"));
- registerSetting(new Setting("LWJGLDir", "lwjgl"));
-
- // Console
- registerSetting(new Setting("ShowConsole", true));
- registerSetting(new Setting("AutoCloseConsole", true));
-
- // Toolbar settings
- registerSetting(new Setting("InstanceToolbarVisible", true));
- registerSetting(new Setting("InstanceToolbarPosition", QPoint()));
-
- // Console Colors
-// registerSetting(new Setting("SysMessageColor", QColor(Qt::blue)));
-// registerSetting(new Setting("StdOutColor", QColor(Qt::black)));
-// registerSetting(new Setting("StdErrColor", QColor(Qt::red)));
-
- // Window Size
- registerSetting(new Setting("LaunchCompatMode", false));
- registerSetting(new Setting("LaunchMaximized", false));
- registerSetting(new Setting("MinecraftWinWidth", 854));
- registerSetting(new Setting("MinecraftWinHeight", 480));
-
- // Auto login
- registerSetting(new Setting("AutoLogin", false));
-
- // Memory
- registerSetting(new Setting("MinMemAlloc", 512));
- registerSetting(new Setting("MaxMemAlloc", 1024));
-
- // Java Settings
- registerSetting(new Setting("JavaPath", "java"));
- registerSetting(new Setting("JvmArgs", ""));
-
- // Custom Commands
- registerSetting(new Setting("PreLaunchCommand", ""));
- registerSetting(new Setting("PostExitCommand", ""));
-}
diff --git a/libmultimc/src/fullversion.cpp b/libmultimc/src/fullversion.cpp
deleted file mode 100644
index 24047c9f..00000000
--- a/libmultimc/src/fullversion.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <QtCore>
-#include "fullversion.h"
-#include <library.h>
-
-QList<QSharedPointer<Library> > FullVersion::getActiveNormalLibs()
-{
- QList<QSharedPointer<Library> > output;
- for ( auto lib: libraries )
- {
- if (lib->getIsActive() && !lib->getIsNative())
- {
- output.append(lib);
- }
- }
- return output;
-}
-
-QList<QSharedPointer<Library> > FullVersion::getActiveNativeLibs()
-{
- QList<QSharedPointer<Library> > output;
- for ( auto lib: libraries )
- {
- if (lib->getIsActive() && lib->getIsNative())
- {
- output.append(lib);
- }
- }
- return output;
-}
diff --git a/libmultimc/src/fullversionfactory.cpp b/libmultimc/src/fullversionfactory.cpp
deleted file mode 100644
index bb55b4a9..00000000
--- a/libmultimc/src/fullversionfactory.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-#include "fullversionfactory.h"
-#include "fullversion.h"
-#include <library.h>
-
-class LibraryFinalizer
-{
-public:
- LibraryFinalizer(QSharedPointer<Library> library)
- {
- m_library = library;
- }
-
- QSharedPointer<Library> m_library;
-};
-
-// Library rules (if any)
-QList<QSharedPointer<Rule> > FullVersionFactory::parse4rules(QJsonObject & baseObj)
-{
- QList<QSharedPointer<Rule> > rules;
- auto rulesVal = baseObj.value("rules");
- if(rulesVal.isArray())
- {
- QJsonArray ruleList = rulesVal.toArray();
- for(auto ruleVal : ruleList)
- {
- QSharedPointer<Rule> rule;
- if(!ruleVal.isObject())
- continue;
- auto ruleObj = ruleVal.toObject();
- auto actionVal = ruleObj.value("action");
- if(!actionVal.isString())
- continue;
- auto action = RuleAction_fromString(actionVal.toString());
- if(action == Defer)
- continue;
-
- auto osVal = ruleObj.value("os");
- if(!osVal.isObject())
- {
- // add a new implicit action rule
- rules.append(ImplicitRule::create(action));
- }
- else
- {
- auto osObj = osVal.toObject();
- auto osNameVal = osObj.value("name");
- if(!osNameVal.isString())
- continue;
- OpSys requiredOs = OpSys_fromString(osNameVal.toString());
- QString versionRegex = osObj.value("version").toString();
- // add a new OS rule
- rules.append(OsRule::create(action, requiredOs, versionRegex));
- }
- }
- }
- return rules;
-}
-
-
-QSharedPointer<FullVersion> FullVersionFactory::parse4(QJsonObject root, QSharedPointer<FullVersion> fullVersion)
-{
- fullVersion->id = root.value("id").toString();
-
- // if it's on our legacy list, it's legacy
- if(legacyWhitelist.contains(fullVersion->id))
- fullVersion->isLegacy = true;
-
- fullVersion->mainClass = root.value("mainClass").toString();
- auto procArgsValue = root.value("processArguments");
- if(procArgsValue.isString())
- {
- fullVersion->processArguments = procArgsValue.toString();
- QString toCompare = fullVersion->processArguments.toLower();
- if(toCompare == "legacy")
- {
- fullVersion->minecraftArguments = " ${auth_player_name} ${auth_session}";
- fullVersion->isLegacy = true;
- }
- else if(toCompare == "username_session")
- {
- fullVersion->minecraftArguments = "--username ${auth_player_name} --session ${auth_session}";
- }
- else if(toCompare == "username_session_version")
- {
- fullVersion->minecraftArguments = "--username ${auth_player_name} --session ${auth_session} --version ${profile_name}";
- }
- }
-
- auto minecraftArgsValue = root.value("minecraftArguments");
- if(minecraftArgsValue.isString())
- {
- fullVersion->minecraftArguments = minecraftArgsValue.toString();
- }
-
- fullVersion->releaseTime = root.value("releaseTime").toString();
- fullVersion->time = root.value("time").toString();
-
- // Iterate through the list, if it's a list.
- auto librariesValue = root.value("libraries");
- if(!librariesValue.isArray())
- return fullVersion;
-
- QJsonArray libList = root.value("libraries").toArray();
- for (auto libVal : libList)
- {
- if (!libVal.isObject())
- {
- continue;
- }
-
- QJsonObject libObj = libVal.toObject();
-
- // Library name
- auto nameVal = libObj.value("name");
- if(!nameVal.isString())
- continue;
- QSharedPointer<Library> library(new Library(nameVal.toString()));
-
- // Extract excludes (if any)
- auto extractVal = libObj.value("extract");
- if(extractVal.isObject())
- {
- QStringList excludes;
- auto extractObj = extractVal.toObject();
- auto excludesVal = extractObj.value("exclude");
- if(!excludesVal.isArray())
- goto SKIP_EXTRACTS;
- auto excludesList = excludesVal.toArray();
- for(auto excludeVal : excludesList)
- {
- if(excludeVal.isString())
- excludes.append(excludeVal.toString());
- }
- library->extract_excludes = excludes;
- }
- SKIP_EXTRACTS:
-
- auto nativesVal = libObj.value("natives");
- if(nativesVal.isObject())
- {
- library->setIsNative();
- auto nativesObj = nativesVal.toObject();
- auto iter = nativesObj.begin();
- while(iter != nativesObj.end())
- {
- auto osType = OpSys_fromString(iter.key());
- if(osType == Os_Other)
- continue;
- if(!iter.value().isString())
- continue;
- library->addNative(osType, iter.value().toString());
- iter++;
- }
- }
- library->setRules(parse4rules(libObj));
- library->finalize();
- fullVersion->libraries.append(library);
- }
- return fullVersion;
-}
-
-QSharedPointer<FullVersion> FullVersionFactory::parse(QByteArray data)
-{
- QSharedPointer<FullVersion> readVersion(new FullVersion());
-
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
-
- if (jsonError.error != QJsonParseError::NoError)
- {
- error_string = QString( "Error reading version file :") + " " + jsonError.errorString();
- m_error = FullVersionFactory::ParseError;
- return QSharedPointer<FullVersion>();
- }
-
- if(!jsonDoc.isObject())
- {
- error_string = "Error reading version file.";
- m_error = FullVersionFactory::ParseError;
- return QSharedPointer<FullVersion>();
- }
- QJsonObject root = jsonDoc.object();
-
- readVersion->minimumLauncherVersion = root.value("minimumLauncherVersion").toDouble();
- switch(readVersion->minimumLauncherVersion)
- {
- case 1:
- case 2:
- case 3:
- case 4:
- return parse4(root, readVersion);
- // ADD MORE HERE :D
- default:
- error_string = "Version file was for an unrecognized launcher version. RIP";
- m_error = FullVersionFactory::UnsupportedVersion;
- return QSharedPointer<FullVersion>();
- }
-}
-
-
-FullVersionFactory::FullVersionFactory()
-{
- m_error = FullVersionFactory::AllOK;
- legacyWhitelist.append("1.5.1");
- legacyWhitelist.append("1.5.2");
-}
diff --git a/libmultimc/src/gameupdatetask.cpp b/libmultimc/src/gameupdatetask.cpp
deleted file mode 100644
index bae85c17..00000000
--- a/libmultimc/src/gameupdatetask.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/* 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 "gameupdatetask.h"
-
-#include <QtNetwork>
-
-#include <QFile>
-#include <QFileInfo>
-#include <QTextStream>
-#include <QDataStream>
-
-#include <QDebug>
-
-#include "minecraftversionlist.h"
-#include "fullversionfactory.h"
-#include <fullversion.h>
-
-#include "pathutils.h"
-
-
-GameUpdateTask::GameUpdateTask(const LoginResponse &response, Instance *inst, QObject *parent) :
- Task(parent), m_response(response)
-{
- m_inst = inst;
- m_updateState = StateInit;
-}
-
-void GameUpdateTask::executeTask()
-{
- updateStatus();
-
- // Get a pointer to the version object that corresponds to the instance's version.
- targetVersion = (MinecraftVersion *)MinecraftVersionList::getMainList().
- findVersion(m_inst->intendedVersion());
- if(targetVersion == NULL)
- {
- //Q_ASSERT_X(targetVersion != NULL, "game update", "instance's intended version is not an actual version");
- setState(StateFinished);
- emit gameUpdateComplete(m_response);
- return;
- }
-
- /////////////////////////
- // BUILD DOWNLOAD LIST //
- /////////////////////////
- // Build a list of URLs that will need to be downloaded.
-
- setState(StateDetermineURLs);
-
- if (targetVersion->launcherVersion() == MinecraftVersion::Launcher16)
- {
- determineNewVersion();
- }
- else
- {
- getLegacyJar();
- }
- QEventLoop loop;
- loop.exec();
-}
-
-void GameUpdateTask::determineNewVersion()
-{
- QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
- urlstr += targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".json";
- auto dljob = DownloadJob::create(QUrl(urlstr));
- specificVersionDownloadJob.reset(new JobList());
- specificVersionDownloadJob->add(dljob);
- connect(specificVersionDownloadJob.data(), SIGNAL(finished()), SLOT(versionFileFinished()));
- connect(specificVersionDownloadJob.data(), SIGNAL(failed()), SLOT(versionFileFailed()));
- connect(specificVersionDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64)));
- download_queue.enqueue(specificVersionDownloadJob);
-}
-
-void GameUpdateTask::versionFileFinished()
-{
- JobPtr firstJob = specificVersionDownloadJob->getFirstJob();
- auto DlJob = firstJob.dynamicCast<DownloadJob>();
- FullVersionFactory parser;
- auto version = parser.parse(DlJob->m_data);
-
- if(!version)
- {
- error(parser.error_string);
- exit(0);
- }
-
- if(version->isLegacy)
- {
- getLegacyJar();
- return;
- }
-
- // save the version file in $instanceId/version.json and versions/$version/$version.json
- QString version_id = targetVersion->descriptor();
- QString mc_dir = m_inst->minecraftDir();
- QString inst_dir = m_inst->rootDir();
- QString version1 = PathCombine(inst_dir, "/version.json");
- QString version2 = QString("versions/") + version_id + "/" + version_id + ".json";
- DownloadJob::ensurePathExists(version1);
- DownloadJob::ensurePathExists(version2);
- QFile vfile1 (version1);
- QFile vfile2 (version2);
- vfile1.open(QIODevice::Truncate | QIODevice::WriteOnly );
- vfile2.open(QIODevice::Truncate | QIODevice::WriteOnly );
- vfile1.write(DlJob->m_data);
- vfile2.write(DlJob->m_data);
- vfile1.close();
- vfile2.close();
-
- // download the right jar, save it in versions/$version/$version.jar
- QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
- urlstr += targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".jar";
- QString targetstr ("versions/");
- targetstr += targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".jar";
- auto dljob = DownloadJob::create(QUrl(urlstr), targetstr);
-
- jarlibDownloadJob.reset(new JobList());
- jarlibDownloadJob->add(dljob);
- connect(jarlibDownloadJob.data(), SIGNAL(finished()), SLOT(jarlibFinished()));
- connect(jarlibDownloadJob.data(), SIGNAL(failed()), SLOT(jarlibFailed()));
- connect(jarlibDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64)));
- // determine and download all the libraries, save them in libraries/whatever...
- download_queue.enqueue(jarlibDownloadJob);
-}
-
-void GameUpdateTask::jarlibFinished()
-{
- m_inst->setCurrentVersion(targetVersion->descriptor());
- m_inst->setShouldUpdate(false);
- m_inst->setIsForNewLauncher(true);
- exit(1);
-}
-
-void GameUpdateTask::jarlibFailed()
-{
- error("Failed to download the binary garbage. Try again. Maybe. IF YOU DARE");
- exit(0);
-}
-
-void GameUpdateTask::versionFileFailed()
-{
- error("Failed to download the version description. Try again.");
- exit(0);
-}
-
-
-// this is legacy minecraft...
-void GameUpdateTask::getLegacyJar()
-{
- // Make directories
- QDir binDir(m_inst->binDir());
- if (!binDir.exists() && !binDir.mkpath("."))
- {
- error("Failed to create bin folder.");
- return;
- }
-
- // Add the URL for minecraft.jar
- // This will be either 'minecraft' or the version number, depending on where
- // we're downloading from.
- QString jarFilename = "minecraft";
- if (targetVersion->launcherVersion() == MinecraftVersion::Launcher16)
- {
- jarFilename = targetVersion->descriptor();
- }
-
- QUrl mcJarURL = targetVersion->downloadURL() + jarFilename + ".jar";
- qDebug() << mcJarURL.toString();
- auto dljob = DownloadJob::create(mcJarURL, PathCombine(m_inst->minecraftDir(), "bin/minecraft.jar"));
-
- legacyDownloadJob.reset(new JobList());
- legacyDownloadJob->add(dljob);
- connect(legacyDownloadJob.data(), SIGNAL(finished()), SLOT(legacyJarFinished()));
- connect(legacyDownloadJob.data(), SIGNAL(failed()), SLOT(legacyJarFailed()));
- connect(legacyDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64)));
-
- download_queue.enqueue(legacyDownloadJob);
-}
-
-
-void GameUpdateTask::legacyJarFinished()
-{
- setState(StateFinished);
- emit gameUpdateComplete(m_response);
- m_inst->setIsForNewLauncher(true);
- exit(1);
-}
-
-void GameUpdateTask::legacyJarFailed()
-{
- emit gameUpdateError("failed to download the minecraft.jar");
- exit(0);
-}
-
-int GameUpdateTask::state() const
-{
- return m_updateState;
-}
-
-void GameUpdateTask::setState(int state, bool resetSubStatus)
-{
- m_updateState = state;
- if (resetSubStatus)
- setSubStatus("");
- else // We only need to update if we're not resetting substatus becasue setSubStatus updates status for us.
- updateStatus();
-}
-
-QString GameUpdateTask::subStatus() const
-{
- return m_subStatusMsg;
-}
-
-void GameUpdateTask::setSubStatus(const QString &msg)
-{
- m_subStatusMsg = msg;
- updateStatus();
-}
-
-QString GameUpdateTask::getStateMessage(int state)
-{
- switch (state)
- {
- case StateInit:
- return "Initializing";
-
- case StateDetermineURLs:
- return "Determining files to download";
-
- case StateDownloadFiles:
- return "Downloading files";
-
- case StateInstall:
- return "Installing";
-
- case StateFinished:
- return "Finished";
-
- default:
- return "Downloading instance files";
- }
-}
-
-void GameUpdateTask::updateStatus()
-{
- QString newStatus;
-
- newStatus = getStateMessage(state());
- if (!subStatus().isEmpty())
- newStatus += ": " + subStatus();
- else
- newStatus += "...";
-
- setStatus(newStatus);
-}
-
-
-void GameUpdateTask::error(const QString &msg)
-{
- emit gameUpdateError(msg);
-}
-
-void GameUpdateTask::updateDownloadProgress(qint64 current, qint64 total)
-{
- // The progress on the current file is current / total
- float currentDLProgress = (float) current / (float) total;
- setProgress((int)(currentDLProgress * 100)); // convert to percentage
-}
-
diff --git a/libmultimc/src/instance.cpp b/libmultimc/src/instance.cpp
deleted file mode 100644
index 5fdb5064..00000000
--- a/libmultimc/src/instance.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/* 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 "include/instance.h"
-
-#include <QFileInfo>
-
-#include "inisettingsobject.h"
-#include "setting.h"
-#include "overridesetting.h"
-
-#include "pathutils.h"
-#include <minecraftversionlist.h>
-
-Instance::Instance(const QString &rootDir, QObject *parent) :
- QObject(parent)
-{
- m_rootDir = rootDir;
- m_settings = new INISettingsObject(configFile(), this);
-
- settings().registerSetting(new Setting("name", "Unnamed Instance"));
- settings().registerSetting(new Setting("iconKey", "default"));
- settings().registerSetting(new Setting("notes", ""));
- settings().registerSetting(new Setting("NeedsRebuild", true));
- settings().registerSetting(new Setting("IsForNewLauncher", false));
- settings().registerSetting(new Setting("ShouldUpdate", false));
- settings().registerSetting(new Setting("JarVersion", "Unknown"));
- settings().registerSetting(new Setting("LwjglVersion", "2.9.0"));
- settings().registerSetting(new Setting("IntendedJarVersion", ""));
- settings().registerSetting(new Setting("lastLaunchTime", 0));
-
- // Java Settings
- settings().registerSetting(new OverrideSetting("JavaPath", globalSettings->getSetting("JavaPath")));
- settings().registerSetting(new OverrideSetting("JvmArgs", globalSettings->getSetting("JvmArgs")));
-
- // Custom Commands
- settings().registerSetting(new OverrideSetting("PreLaunchCommand",
- globalSettings->getSetting("PreLaunchCommand")));
- settings().registerSetting(new OverrideSetting("PostExitCommand",
- globalSettings->getSetting("PostExitCommand")));
-
- // Window Size
- settings().registerSetting(new OverrideSetting("LaunchCompatMode", globalSettings->getSetting("LaunchCompatMode")));
- settings().registerSetting(new OverrideSetting("LaunchMaximized", globalSettings->getSetting("LaunchMaximized")));
- settings().registerSetting(new OverrideSetting("MinecraftWinWidth", globalSettings->getSetting("MinecraftWinWidth")));
- settings().registerSetting(new OverrideSetting("MinecraftWinHeight", globalSettings->getSetting("MinecraftWinHeight")));
-
- // Memory
- settings().registerSetting(new OverrideSetting("MinMemAlloc", globalSettings->getSetting("MinMemAlloc")));
- settings().registerSetting(new OverrideSetting("MaxMemAlloc", globalSettings->getSetting("MaxMemAlloc")));
-
- // Auto login
- settings().registerSetting(new OverrideSetting("AutoLogin", globalSettings->getSetting("AutoLogin")));
-
- // Console
- settings().registerSetting(new OverrideSetting("ShowConsole", globalSettings->getSetting("ShowConsole")));
- settings().registerSetting(new OverrideSetting("AutoCloseConsole", globalSettings->getSetting("AutoCloseConsole")));
-
- // Overrides
- settings().registerSetting(new Setting("OverrideConsole", false));
- settings().registerSetting(new Setting("OverrideWindow", false));
- settings().registerSetting(new Setting("OverrideLogin", false));
- settings().registerSetting(new Setting("OverrideMemory", false));
- settings().registerSetting(new Setting("OverrideJava", false));
- settings().registerSetting(new Setting("OverrideCommands", false));
-}
-
-QString Instance::id() const
-{
- return QFileInfo(rootDir()).fileName();
-}
-
-QString Instance::rootDir() const
-{
- return m_rootDir;
-}
-
-InstanceList *Instance::instList() const
-{
- if (parent()->inherits("InstanceList"))
- return (InstanceList *)parent();
- else
- return NULL;
-}
-
-QString Instance::minecraftDir() const
-{
- QFileInfo mcDir(PathCombine(rootDir(), "minecraft"));
- QFileInfo dotMCDir(PathCombine(rootDir(), ".minecraft"));
-
- if (dotMCDir.exists() && !mcDir.exists())
- return dotMCDir.filePath();
- else
- return mcDir.filePath();
-}
-
-QString Instance::instModsDir() const
-{
- return PathCombine(rootDir(), "instMods");
-}
-
-QString Instance::binDir() const
-{
- return PathCombine(minecraftDir(), "bin");
-}
-
-QString Instance::savesDir() const
-{
- return PathCombine(minecraftDir(), "saves");
-}
-
-QString Instance::mlModsDir() const
-{
- return PathCombine(minecraftDir(), "mods");
-}
-
-QString Instance::coreModsDir() const
-{
- return PathCombine(minecraftDir(), "coremods");
-}
-
-QString Instance::resourceDir() const
-{
- return PathCombine(minecraftDir(), "resources");
-}
-
-QString Instance::screenshotsDir() const
-{
- return PathCombine(minecraftDir(), "screenshots");
-}
-
-QString Instance::texturePacksDir() const
-{
- return PathCombine(minecraftDir(), "texturepacks");
-}
-
-QString Instance::mcJar() const
-{
- return PathCombine(binDir(), "minecraft.jar");
-}
-
-QString Instance::mcBackup() const
-{
- return PathCombine(binDir(), "mcbackup.jar");
-}
-
-QString Instance::configFile() const
-{
- return PathCombine(rootDir(), "instance.cfg");
-}
-
-QString Instance::modListFile() const
-{
- return PathCombine(rootDir(), "modlist");
-}
-
-InstVersionList *Instance::versionList() const
-{
- return &MinecraftVersionList::getMainList();
-}
-
-bool Instance::shouldUpdateCurrentVersion() const
-{
- QFileInfo jar(mcJar());
- return jar.lastModified().toUTC().toMSecsSinceEpoch() != lastCurrentVersionUpdate();
-}
-
-void Instance::updateCurrentVersion(bool keepCurrent)
-{
- QFileInfo jar(mcJar());
-
- if(!jar.exists())
- {
- setLastCurrentVersionUpdate(0);
- setCurrentVersion("Unknown");
- return;
- }
-
- qint64 time = jar.lastModified().toUTC().toMSecsSinceEpoch();
-
- setLastCurrentVersionUpdate(time);
- if (!keepCurrent)
- {
- // TODO: Implement GetMinecraftJarVersion function.
- QString newVersion = "Unknown";//javautils::GetMinecraftJarVersion(jar.absoluteFilePath());
- setCurrentVersion(newVersion);
- }
-}
-
-SettingsObject &Instance::settings() const
-{
- return *m_settings;
-}
diff --git a/libmultimc/src/instancelist.cpp b/libmultimc/src/instancelist.cpp
deleted file mode 100644
index 1a7dc10d..00000000
--- a/libmultimc/src/instancelist.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/* 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 "include/instancelist.h"
-
-#include <QDir>
-#include <QFile>
-#include <QDirIterator>
-#include <QThread>
-#include <QTextStream>
-#include <QJsonDocument>
-#include <QJsonObject>
-#include <QJsonArray>
-
-#include "include/instance.h"
-#include "include/instanceloader.h"
-
-#include "pathutils.h"
-
-const static int GROUP_FILE_FORMAT_VERSION = 1;
-
-InstanceList::InstanceList(const QString &instDir, QObject *parent) :
- QObject(parent), m_instDir("instances")
-{
-
-}
-
-void InstanceList::loadGroupList(QMap<QString, QString> & groupMap)
-{
- QString groupFileName = m_instDir + "/instgroups.json";
-
- // if there's no group file, fail
- if(!QFileInfo(groupFileName).exists())
- return;
-
- QFile groupFile(groupFileName);
-
- // if you can't open the file, fail
- if (!groupFile.open(QIODevice::ReadOnly))
- {
- // An error occurred. Ignore it.
- qDebug("Failed to read instance group file.");
- return;
- }
-
- QTextStream in(&groupFile);
- QString jsonStr = in.readAll();
- groupFile.close();
-
- QJsonParseError error;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonStr.toUtf8(), &error);
-
- // if the json was bad, fail
- if (error.error != QJsonParseError::NoError)
- {
- qWarning(QString("Failed to parse instance group file: %1 at offset %2").
- arg(error.errorString(), QString::number(error.offset)).toUtf8());
- return;
- }
-
- // if the root of the json wasn't an object, fail
- if (!jsonDoc.isObject())
- {
- qWarning("Invalid group file. Root entry should be an object.");
- return;
- }
-
- QJsonObject rootObj = jsonDoc.object();
-
- // Make sure the format version matches, otherwise fail.
- if (rootObj.value("formatVersion").toVariant().toInt() != GROUP_FILE_FORMAT_VERSION)
- return;
-
- // Get the groups. if it's not an object, fail
- if (!rootObj.value("groups").isObject())
- {
- qWarning("Invalid group list JSON: 'groups' should be an object.");
- return;
- }
-
- // Iterate through all the groups.
- QJsonObject groupMapping = rootObj.value("groups").toObject();
- for (QJsonObject::iterator iter = groupMapping.begin(); iter != groupMapping.end(); iter++)
- {
- QString groupName = iter.key();
-
- // If not an object, complain and skip to the next one.
- if (!iter.value().isObject())
- {
- qWarning(QString("Group '%1' in the group list should "
- "be an object.").arg(groupName).toUtf8());
- continue;
- }
-
- QJsonObject groupObj = iter.value().toObject();
- if (!groupObj.value("instances").isArray())
- {
- qWarning(QString("Group '%1' in the group list is invalid. "
- "It should contain an array "
- "called 'instances'.").arg(groupName).toUtf8());
- continue;
- }
-
- // Iterate through the list of instances in the group.
- QJsonArray instancesArray = groupObj.value("instances").toArray();
-
- for (QJsonArray::iterator iter2 = instancesArray.begin();
- iter2 != instancesArray.end(); iter2++)
- {
- groupMap[(*iter2).toString()] = groupName;
- }
- }
-}
-
-InstanceList::InstListError InstanceList::loadList()
-{
- // load the instance groups
- QMap<QString, QString> groupMap;
- loadGroupList(groupMap);
-
- m_instances.clear();
- QDir dir(m_instDir);
- QDirIterator iter(dir);
- while (iter.hasNext())
- {
- QString subDir = iter.next();
- if (!QFileInfo(PathCombine(subDir, "instance.cfg")).exists())
- co