diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-01-27 22:31:07 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-04-02 00:14:06 +0200 |
commit | 791221e923586bb717396ecf18bd13e57034df99 (patch) | |
tree | 9f608af07375b38626c8964671620477158341ba /logic/ftb | |
parent | 593111b14463e9d5d08256061b981b5ab1cfb710 (diff) | |
download | MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar.gz MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar.lz MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar.xz MultiMC-791221e923586bb717396ecf18bd13e57034df99.zip |
NOISSUE Refactors and moving of things
Diffstat (limited to 'logic/ftb')
-rw-r--r-- | logic/ftb/FTBVersion.h | 32 | ||||
-rw-r--r-- | logic/ftb/LegacyFTBInstance.cpp | 20 | ||||
-rw-r--r-- | logic/ftb/LegacyFTBInstance.h | 13 | ||||
-rw-r--r-- | logic/ftb/OneSixFTBInstance.cpp | 139 | ||||
-rw-r--r-- | logic/ftb/OneSixFTBInstance.h | 29 |
5 files changed, 233 insertions, 0 deletions
diff --git a/logic/ftb/FTBVersion.h b/logic/ftb/FTBVersion.h new file mode 100644 index 00000000..dbd9c29e --- /dev/null +++ b/logic/ftb/FTBVersion.h @@ -0,0 +1,32 @@ +#pragma once +#include <logic/minecraft/MinecraftVersion.h> + +class FTBVersion : public BaseVersion +{ +public: + FTBVersion(MinecraftVersionPtr parent) : m_version(parent){}; + +public: + virtual QString descriptor() override + { + return m_version->descriptor(); + } + + virtual QString name() override + { + return m_version->name(); + } + + virtual QString typeString() const override + { + return m_version->typeString(); + } + + MinecraftVersionPtr getMinecraftVersion() + { + return m_version; + } + +private: + MinecraftVersionPtr m_version; +}; diff --git a/logic/ftb/LegacyFTBInstance.cpp b/logic/ftb/LegacyFTBInstance.cpp new file mode 100644 index 00000000..06bef948 --- /dev/null +++ b/logic/ftb/LegacyFTBInstance.cpp @@ -0,0 +1,20 @@ +#include "LegacyFTBInstance.h" + +LegacyFTBInstance::LegacyFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) : + LegacyInstance(rootDir, settings, parent) +{ +} + +QString LegacyFTBInstance::getStatusbarDescription() +{ + if (flags() & VersionBrokenFlag) + { + return "Legacy FTB: " + intendedVersionId() + " (broken)"; + } + return "Legacy FTB: " + intendedVersionId(); +} + +QString LegacyFTBInstance::id() const +{ + return "FTB/" + BaseInstance::id(); +} diff --git a/logic/ftb/LegacyFTBInstance.h b/logic/ftb/LegacyFTBInstance.h new file mode 100644 index 00000000..7ae7a97c --- /dev/null +++ b/logic/ftb/LegacyFTBInstance.h @@ -0,0 +1,13 @@ +#pragma once + +#include "logic/LegacyInstance.h" + +class LegacyFTBInstance : public LegacyInstance +{ + Q_OBJECT +public: + explicit LegacyFTBInstance(const QString &rootDir, SettingsObject *settings, + QObject *parent = 0); + virtual QString getStatusbarDescription(); + virtual QString id() const; +}; diff --git a/logic/ftb/OneSixFTBInstance.cpp b/logic/ftb/OneSixFTBInstance.cpp new file mode 100644 index 00000000..d55b1ea9 --- /dev/null +++ b/logic/ftb/OneSixFTBInstance.cpp @@ -0,0 +1,139 @@ +#include "OneSixFTBInstance.h" + +#include "logic/minecraft/MinecraftProfile.h" +#include "logic/minecraft/OneSixLibrary.h" +#include "logic/minecraft/VersionBuilder.h" +#include "logic/tasks/SequentialTask.h" +#include "logic/forge/ForgeInstaller.h" +#include "logic/forge/ForgeVersionList.h" +#include "MultiMC.h" +#include "pathutils.h" + +OneSixFTBInstance::OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) : + OneSixInstance(rootDir, settings, parent) +{ +} + +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"); + + // HACK HACK HACK HACK + // A workaround for a problem in MultiMC, triggered by a historical problem in FTB, + // triggered by Mojang getting their library versions wrong in 1.7.10 + if(intendedVersionId() == "1.7.10") + { + auto insert = [&outLibs, &libraryNames](QString name) + { + QJsonObject libObj; + libObj.insert("insert", QString("replace")); + libObj.insert("name", name); + libraryNames.push_back(name); + outLibs.prepend(libObj); + }; + insert("com.google.guava:guava:16.0"); + insert("org.apache.commons:commons-lang3:3.2.1"); + } + 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); + 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(); +} + +QDir OneSixFTBInstance::librariesPath() const +{ + return QDir(MMC->settings()->get("FTBRoot").toString() + "/libraries"); +} + +QDir OneSixFTBInstance::versionsPath() const +{ + return QDir(MMC->settings()->get("FTBRoot").toString() + "/versions"); +} + +/* +QStringList OneSixFTBInstance::externalPatches() const +{ + return QStringList() << versionsPath().absoluteFilePath(intendedVersionId() + "/" + intendedVersionId() + ".json") + << minecraftRoot() + "/pack.json"; +} +*/ + +bool OneSixFTBInstance::providesVersionFile() const +{ + return true; +} + +QString OneSixFTBInstance::getStatusbarDescription() +{ + if (flags() & VersionBrokenFlag) + { + return "OneSix FTB: " + intendedVersionId() + " (broken)"; + } + return "OneSix FTB: " + intendedVersionId(); +} + +std::shared_ptr<Task> OneSixFTBInstance::doUpdate() +{ + return OneSixInstance::doUpdate(); +} + +#include "OneSixFTBInstance.moc" diff --git a/logic/ftb/OneSixFTBInstance.h b/logic/ftb/OneSixFTBInstance.h new file mode 100644 index 00000000..3419e94c --- /dev/null +++ b/logic/ftb/OneSixFTBInstance.h @@ -0,0 +1,29 @@ +#pragma once + +#include "logic/OneSixInstance.h" + +class OneSixLibrary; + +class OneSixFTBInstance : public OneSixInstance +{ + Q_OBJECT +public: + explicit OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, + QObject *parent = 0); + virtual ~OneSixFTBInstance(){}; + + void copy(const QDir &newDir) override; + + virtual QString getStatusbarDescription(); + + virtual std::shared_ptr<Task> doUpdate() override; + + virtual QString id() const; + + QDir librariesPath() const override; + QDir versionsPath() const override; + bool providesVersionFile() const override; + +private: + std::shared_ptr<OneSixLibrary> m_forge; +}; |