From 17ad1e64f824fba6d8f153191effdb2af7d387c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 27 Feb 2016 19:58:40 +0100 Subject: NOISSUE move files into paths that make more sense --- logic/minecraft/ftb/FTBProfileStrategy.cpp | 128 +++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 logic/minecraft/ftb/FTBProfileStrategy.cpp (limited to 'logic/minecraft/ftb/FTBProfileStrategy.cpp') diff --git a/logic/minecraft/ftb/FTBProfileStrategy.cpp b/logic/minecraft/ftb/FTBProfileStrategy.cpp new file mode 100644 index 00000000..c4bfa27b --- /dev/null +++ b/logic/minecraft/ftb/FTBProfileStrategy.cpp @@ -0,0 +1,128 @@ +#include "FTBProfileStrategy.h" +#include "OneSixFTBInstance.h" + +#include "minecraft/VersionBuildError.h" +#include "minecraft/MinecraftVersionList.h" +#include + +#include +#include +#include +#include + +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(); + + 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; + } + minecraftPatch = std::dynamic_pointer_cast(file); + } + else + { + throw VersionIncomplete("net.minecraft"); + } + minecraftPatch->setOrder(-2); + } + profile->appendPatch(minecraftPatch); + + auto nativeInstance = dynamic_cast(m_instance); + 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->addLibs = file->overwriteLibs; + file->overwriteLibs.clear(); + file->shouldOverwriteLibs = false; + file->id.clear(); + for(auto addLib: file->addLibs) + { + addLib->m_hint = "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(file); + } + else + { + throw VersionIncomplete("org.multimc.ftb.pack"); + } + packPatch->setOrder(1); + } + profile->appendPatch(packPatch); + +} + +void FTBProfileStrategy::load() +{ + profile->clearPatches(); + + loadDefaultBuiltinPatches(); + loadUserPatches(); + + profile->finalize(); +} + +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; +} -- cgit v1.2.3