summaryrefslogtreecommitdiffstats
path: root/libmultimc/src
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-07-27 11:41:45 +0200
committerPetr Mrázek <peterix@gmail.com>2013-07-27 11:41:45 +0200
commita7a84d4dbb58565f108cb0886da6cb786e34d10d (patch)
tree1337bc6c5f428fe1bc8c1c7bac209cb10fa7a0ab /libmultimc/src
parent97cf08f964ceebf4cb98b46f473bf952007a8a21 (diff)
downloadMultiMC-a7a84d4dbb58565f108cb0886da6cb786e34d10d.tar
MultiMC-a7a84d4dbb58565f108cb0886da6cb786e34d10d.tar.gz
MultiMC-a7a84d4dbb58565f108cb0886da6cb786e34d10d.tar.lz
MultiMC-a7a84d4dbb58565f108cb0886da6cb786e34d10d.tar.xz
MultiMC-a7a84d4dbb58565f108cb0886da6cb786e34d10d.zip
Parsing the version files, part III
Diffstat (limited to 'libmultimc/src')
-rw-r--r--libmultimc/src/fullversion.cpp1
-rw-r--r--libmultimc/src/fullversionfactory.cpp104
-rw-r--r--libmultimc/src/gameupdatetask.cpp2
-rw-r--r--libmultimc/src/instance.cpp1
-rw-r--r--libmultimc/src/library.cpp2
5 files changed, 66 insertions, 44 deletions
diff --git a/libmultimc/src/fullversion.cpp b/libmultimc/src/fullversion.cpp
index 6f4662b4..53664c2a 100644
--- a/libmultimc/src/fullversion.cpp
+++ b/libmultimc/src/fullversion.cpp
@@ -1,4 +1,5 @@
#include <QtCore>
#include "fullversion.h"
+#include <library.h>
// ECHO, echo, echo, .... \ No newline at end of file
diff --git a/libmultimc/src/fullversionfactory.cpp b/libmultimc/src/fullversionfactory.cpp
index 9b4ae266..bb55b4a9 100644
--- a/libmultimc/src/fullversionfactory.cpp
+++ b/libmultimc/src/fullversionfactory.cpp
@@ -2,6 +2,61 @@
#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();
@@ -48,7 +103,6 @@ QSharedPointer<FullVersion> FullVersionFactory::parse4(QJsonObject root, QShared
QJsonArray libList = root.value("libraries").toArray();
for (auto libVal : libList)
{
- QSharedPointer<Library> library(new Library());
if (!libVal.isObject())
{
continue;
@@ -60,7 +114,7 @@ QSharedPointer<FullVersion> FullVersionFactory::parse4(QJsonObject root, QShared
auto nameVal = libObj.value("name");
if(!nameVal.isString())
continue;
- library->name = nameVal.toString();
+ QSharedPointer<Library> library(new Library(nameVal.toString()));
// Extract excludes (if any)
auto extractVal = libObj.value("extract");
@@ -84,6 +138,7 @@ QSharedPointer<FullVersion> FullVersionFactory::parse4(QJsonObject root, QShared
auto nativesVal = libObj.value("natives");
if(nativesVal.isObject())
{
+ library->setIsNative();
auto nativesObj = nativesVal.toObject();
auto iter = nativesObj.begin();
while(iter != nativesObj.end())
@@ -93,50 +148,13 @@ QSharedPointer<FullVersion> FullVersionFactory::parse4(QJsonObject root, QShared
continue;
if(!iter.value().isString())
continue;
- library->natives[osType] = iter.value().toString();
+ library->addNative(osType, iter.value().toString());
iter++;
}
}
-
- // Library rules (if any)
- auto rulesVal = libObj.value("rules");
- if(rulesVal.isArray())
- {
- QList<QSharedPointer<Rule> > rules;
-
- 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())
- {
- rule.reset(new ImplicitRule(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();
- rule.reset(new OsRule(action, requiredOs, versionRegex));
- }
- rules.append(rule);
- }
- library->rules = rules;
- }
+ library->setRules(parse4rules(libObj));
+ library->finalize();
+ fullVersion->libraries.append(library);
}
return fullVersion;
}
diff --git a/libmultimc/src/gameupdatetask.cpp b/libmultimc/src/gameupdatetask.cpp
index 61880118..bae85c17 100644
--- a/libmultimc/src/gameupdatetask.cpp
+++ b/libmultimc/src/gameupdatetask.cpp
@@ -141,6 +141,7 @@ void GameUpdateTask::jarlibFinished()
{
m_inst->setCurrentVersion(targetVersion->descriptor());
m_inst->setShouldUpdate(false);
+ m_inst->setIsForNewLauncher(true);
exit(1);
}
@@ -195,6 +196,7 @@ void GameUpdateTask::legacyJarFinished()
{
setState(StateFinished);
emit gameUpdateComplete(m_response);
+ m_inst->setIsForNewLauncher(true);
exit(1);
}
diff --git a/libmultimc/src/instance.cpp b/libmultimc/src/instance.cpp
index c1506a02..5fdb5064 100644
--- a/libmultimc/src/instance.cpp
+++ b/libmultimc/src/instance.cpp
@@ -34,6 +34,7 @@ Instance::Instance(const QString &rootDir, QObject *parent) :
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"));
diff --git a/libmultimc/src/library.cpp b/libmultimc/src/library.cpp
index 0fb4f9d3..9d4cc6e3 100644
--- a/libmultimc/src/library.cpp
+++ b/libmultimc/src/library.cpp
@@ -34,4 +34,4 @@ OpSys OpSys_fromString(QString name)
return Os_OSX;
return Os_Other;
}
-// default url for lib: https://s3.amazonaws.com/Minecraft.Download/libraries/
+// default url for lib: