diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2014-02-21 19:15:59 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2014-02-21 19:15:59 +0100 |
commit | 4883d1526222f9804f304f4cc189d6e44cb22b97 (patch) | |
tree | 3337cb34d9fdf4947c30b6e36f7747782cb212d4 /logic/OneSixFTBInstance.cpp | |
parent | f54705e1c5311e023b2e1ebd5d4db226a7c7149e (diff) | |
download | MultiMC-4883d1526222f9804f304f4cc189d6e44cb22b97.tar MultiMC-4883d1526222f9804f304f4cc189d6e44cb22b97.tar.gz MultiMC-4883d1526222f9804f304f4cc189d6e44cb22b97.tar.lz MultiMC-4883d1526222f9804f304f4cc189d6e44cb22b97.tar.xz MultiMC-4883d1526222f9804f304f4cc189d6e44cb22b97.zip |
Copying of FTB instances working again
Diffstat (limited to 'logic/OneSixFTBInstance.cpp')
-rw-r--r-- | logic/OneSixFTBInstance.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/logic/OneSixFTBInstance.cpp b/logic/OneSixFTBInstance.cpp index 4bd30b1d..307ddb7c 100644 --- a/logic/OneSixFTBInstance.cpp +++ b/logic/OneSixFTBInstance.cpp @@ -6,7 +6,9 @@ #include "ForgeInstaller.h" #include "lists/ForgeVersionList.h" #include "OneSixInstance_p.h" +#include "OneSixVersionBuilder.h" #include "MultiMC.h" +#include "pathutils.h" class OneSixFTBInstanceForge : public Task { @@ -88,6 +90,70 @@ void OneSixFTBInstance::init() reloadVersion(); } +void OneSixFTBInstance::copy(const QDir &newDir) +{ + QStringList libraryNames; + // create patch file + { + QLOG_DEBUG() << "Creating patch file for FTB instance..."; + QFile f(minecraftRoot() + "/pack.json"); + if (!f.open(QFile::ReadOnly)) + { + QLOG_ERROR() << "Couldn't open" << f.fileName() << ":" << f.errorString(); + return; + } + QJsonObject root = QJsonDocument::fromJson(f.readAll()).object(); + QJsonArray libs = root.value("libraries").toArray(); + QJsonArray outLibs; + for (auto lib : libs) + { + QJsonObject libObj = lib.toObject(); + libObj.insert("MMC-hint", QString("local")); + libObj.insert("insert", QString("prepend")); + libraryNames.append(libObj.value("name").toString()); + outLibs.append(libObj); + } + root.remove("libraries"); + root.remove("id"); + root.insert("+libraries", outLibs); + root.insert("order", 1); + root.insert("fileId", QString("org.multimc.ftb.pack.json")); + root.insert("name", name()); + root.insert("mcVersion", intendedVersionId()); + root.insert("version", intendedVersionId()); + ensureFilePathExists(newDir.absoluteFilePath("patches/ftb.json")); + QFile out(newDir.absoluteFilePath("patches/ftb.json")); + if (!out.open(QFile::WriteOnly | QFile::Truncate)) + { + QLOG_ERROR() << "Couldn't open" << out.fileName() << ":" << out.errorString(); + return; + } + out.write(QJsonDocument(root).toJson()); + } + // copy libraries + { + QLOG_DEBUG() << "Copying FTB libraries"; + for (auto library : libraryNames) + { + OneSixLibrary *lib = new OneSixLibrary(library); + lib->finalize(); + const QString out = QDir::current().absoluteFilePath("libraries/" + lib->storagePath()); + if (QFile::exists(out)) + { + continue; + } + if (!ensureFilePathExists(out)) + { + QLOG_ERROR() << "Couldn't create folder structure for" << out; + } + if (!QFile::copy(librariesPath().absoluteFilePath(lib->storagePath()), out)) + { + QLOG_ERROR() << "Couldn't copy" << lib->rawName(); + } + } + } +} + QString OneSixFTBInstance::id() const { return "FTB/" + BaseInstance::id(); @@ -109,6 +175,11 @@ QStringList OneSixFTBInstance::externalPatches() const << minecraftRoot() + "/pack.json"; } +bool OneSixFTBInstance::providesVersionFile() const +{ + return true; +} + QString OneSixFTBInstance::getStatusbarDescription() { return "OneSix FTB: " + intendedVersionId(); |