diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-04-10 15:53:05 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-05-01 00:00:14 +0200 |
commit | b6d455a02bd338e9dc0faa09d4d8177ecd8d569a (patch) | |
tree | 41982bca1ede50049f2f8c7109dd18edeefde6d0 /api/logic/minecraft/ftb/FTBProfileStrategy.cpp | |
parent | 47e37635f50c09b4f9a9ee7699e3120bab3e4088 (diff) | |
download | MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.gz MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.lz MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.xz MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.zip |
NOISSUE reorganize and document libraries
Diffstat (limited to 'api/logic/minecraft/ftb/FTBProfileStrategy.cpp')
-rw-r--r-- | api/logic/minecraft/ftb/FTBProfileStrategy.cpp | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp new file mode 100644 index 00000000..f5faacae --- /dev/null +++ b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp @@ -0,0 +1,128 @@ +#include "FTBProfileStrategy.h" +#include "OneSixFTBInstance.h" + +#include "minecraft/VersionBuildError.h" +#include "minecraft/MinecraftVersionList.h" +#include <FileSystem.h> + +#include <QDir> +#include <QUuid> +#include <QJsonDocument> +#include <QJsonArray> + +FTBProfileStrategy::FTBProfileStrategy(OneSixFTBInstance* instance) : OneSixProfileStrategy(instance) +{ +} + +void FTBProfileStrategy::loadDefaultBuiltinPatches() +{ + // FIXME: this should be here, but it needs us to be able to deal with multiple libraries paths + // OneSixProfileStrategy::loadDefaultBuiltinPatches(); + auto mcVersion = m_instance->intendedVersionId(); + auto nativeInstance = dynamic_cast<OneSixFTBInstance *>(m_instance); + + ProfilePatchPtr minecraftPatch; + { + auto mcJson = m_instance->versionsPath().absoluteFilePath(mcVersion + "/" + mcVersion + ".json"); + // load up the base minecraft patch + if(QFile::exists(mcJson)) + { + auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); + file->fileId = "net.minecraft"; + file->name = QObject::tr("Minecraft (tracked)"); + file->setVanilla(true); + if(file->version.isEmpty()) + { + file->version = mcVersion; + } + for(auto addLib: file->libraries) + { + addLib->setHint("local"); + addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath()); + } + minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(file); + } + else + { + throw VersionIncomplete("net.minecraft"); + } + minecraftPatch->setOrder(-2); + } + profile->appendPatch(minecraftPatch); + + ProfilePatchPtr packPatch; + { + auto mcJson = m_instance->minecraftRoot() + "/pack.json"; + // load up the base minecraft patch + if(QFile::exists(mcJson)) + { + auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); + + // adapt the loaded file - the FTB patch file format is different than ours. + file->minecraftVersion.clear(); + for(auto addLib: file->libraries) + { + addLib->setHint("local"); + addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath()); + } + file->fileId = "org.multimc.ftb.pack"; + file->setVanilla(true); + file->name = QObject::tr("%1 (FTB pack)").arg(m_instance->name()); + if(file->version.isEmpty()) + { + file->version = QObject::tr("Unknown"); + QFile versionFile (FS::PathCombine(m_instance->instanceRoot(), "version")); + if(versionFile.exists()) + { + if(versionFile.open(QIODevice::ReadOnly)) + { + // FIXME: just guessing the encoding/charset here. + auto version = QString::fromUtf8(versionFile.readAll()); + file->version = version; + } + } + } + packPatch = std::dynamic_pointer_cast<ProfilePatch>(file); + } + else + { + throw VersionIncomplete("org.multimc.ftb.pack"); + } + packPatch->setOrder(1); + } + profile->appendPatch(packPatch); + +} + +void FTBProfileStrategy::load() +{ + profile->clearPatches(); + + loadDefaultBuiltinPatches(); + loadUserPatches(); +} + +bool FTBProfileStrategy::saveOrder(ProfileUtils::PatchOrder order) +{ + return false; +} + +bool FTBProfileStrategy::resetOrder() +{ + return false; +} + +bool FTBProfileStrategy::installJarMods(QStringList filepaths) +{ + return false; +} + +bool FTBProfileStrategy::customizePatch(ProfilePatchPtr patch) +{ + return false; +} + +bool FTBProfileStrategy::revertPatch(ProfilePatchPtr patch) +{ + return false; +} |