summaryrefslogtreecommitdiffstats
path: root/logic/ForgeInstaller.cpp
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-01-23 21:31:41 +0100
committerJan Dalheimer <jan@dalheimer.de>2014-01-23 21:31:41 +0100
commit156bc8f27656c115bf1b023cd4ebc5f629df3887 (patch)
tree79e7ff327148f0841d7184a3882d8c2e6938ef4a /logic/ForgeInstaller.cpp
parentc39d26f4453166603749826eee1a732c815047d0 (diff)
downloadMultiMC-156bc8f27656c115bf1b023cd4ebc5f629df3887.tar
MultiMC-156bc8f27656c115bf1b023cd4ebc5f629df3887.tar.gz
MultiMC-156bc8f27656c115bf1b023cd4ebc5f629df3887.tar.lz
MultiMC-156bc8f27656c115bf1b023cd4ebc5f629df3887.tar.xz
MultiMC-156bc8f27656c115bf1b023cd4ebc5f629df3887.zip
Forge works now too, and so does forge+liteloader
Diffstat (limited to 'logic/ForgeInstaller.cpp')
-rw-r--r--logic/ForgeInstaller.cpp48
1 files changed, 37 insertions, 11 deletions
diff --git a/logic/ForgeInstaller.cpp b/logic/ForgeInstaller.cpp
index 29735a7d..35663ddd 100644
--- a/logic/ForgeInstaller.cpp
+++ b/logic/ForgeInstaller.cpp
@@ -22,13 +22,13 @@
#include <pathutils.h>
#include <QStringList>
#include "MultiMC.h"
+#include "DerpInstance.h"
#include <QJsonDocument>
+#include <QJsonArray>
#include <QSaveFile>
#include <QCryptographicHash>
-// DERPFIX
-
ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
{
std::shared_ptr<DerpVersion> newVersion;
@@ -64,7 +64,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
// read the forge version info
{
- // DERPFIX newVersion = DerpVersion::fromJson(versionInfoVal.toObject());
+ newVersion = DerpVersion::fromJson(versionInfoVal.toObject());
if (!newVersion)
return;
}
@@ -109,12 +109,22 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
}
-bool ForgeInstaller::apply(std::shared_ptr<DerpVersion> to)
+bool ForgeInstaller::add(DerpInstance *to)
{
+ if (!BaseInstaller::add(to))
+ {
+ return false;
+ }
+
+ QJsonObject obj;
+ obj.insert("order", 5);
+
if (!m_forge_version)
return false;
int sliding_insert_window = 0;
{
+ QJsonArray librariesPlus;
+
// for each library in the version we are adding (except for the blacklisted)
QSet<QString> blacklist{"lwjgl", "lwjgl_util", "lwjgl-platform"};
for (auto lib : m_forge_version->libraries)
@@ -133,27 +143,43 @@ bool ForgeInstaller::apply(std::shared_ptr<DerpVersion> to)
if (blacklist.contains(libName))
continue;
- // find an entry that matches this one
+ QJsonObject libObj = lib->toJson();
+
bool found = false;
- for (auto tolib : to->libraries)
+ // find an entry that matches this one
+ for (auto tolib : to->getFullVersion()->libraries)
{
if (tolib->name() != libName)
continue;
found = true;
// replace lib
- tolib = lib;
+ libObj.insert("insert", QString("apply"));
break;
}
if (!found)
{
// add lib
- to->libraries.insert(sliding_insert_window, lib);
+ QJsonObject insertObj;
+ insertObj.insert("before", to->getFullVersion()->libraries.at(sliding_insert_window)->rawName());
+ libObj.insert("insert", insertObj);
sliding_insert_window++;
}
+ librariesPlus.append(libObj);
}
- to->mainClass = m_forge_version->mainClass;
- to->minecraftArguments = m_forge_version->minecraftArguments;
- to->processArguments = m_forge_version->processArguments;
+ obj.insert("+libraries", librariesPlus);
+ obj.insert("mainClass", m_forge_version->mainClass);
+ obj.insert("minecraftArguments", m_forge_version->minecraftArguments);
+ obj.insert("processArguments", m_forge_version->processArguments);
+ }
+
+ QFile file(filename(to->instanceRoot()));
+ if (!file.open(QFile::WriteOnly))
+ {
+ QLOG_ERROR() << "Error opening" << file.fileName() << "for reading:" << file.errorString();
+ return false;
}
+ file.write(QJsonDocument(obj).toJson());
+ file.close();
+
return true;
}