2016-02-28 00:28:40 +05:30
|
|
|
#include "FTBProfileStrategy.h"
|
|
|
|
#include "OneSixFTBInstance.h"
|
|
|
|
|
2015-02-09 06:21:14 +05:30
|
|
|
#include "minecraft/VersionBuildError.h"
|
2015-10-05 05:17:27 +05:30
|
|
|
#include <FileSystem.h>
|
2015-04-03 15:25:16 +05:30
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QUuid>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonArray>
|
|
|
|
|
|
|
|
FTBProfileStrategy::FTBProfileStrategy(OneSixFTBInstance* instance) : OneSixProfileStrategy(instance)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
|
|
|
{
|
2016-02-21 10:21:36 +05:30
|
|
|
// FIXME: this should be here, but it needs us to be able to deal with multiple libraries paths
|
|
|
|
// OneSixProfileStrategy::loadDefaultBuiltinPatches();
|
2015-04-03 15:25:16 +05:30
|
|
|
auto mcVersion = m_instance->intendedVersionId();
|
2016-03-13 06:58:55 +05:30
|
|
|
auto nativeInstance = dynamic_cast<OneSixFTBInstance *>(m_instance);
|
2015-04-03 15:25:16 +05:30
|
|
|
|
|
|
|
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);
|
2017-03-20 04:28:54 +05:30
|
|
|
file->uid = "net.minecraft";
|
2015-04-04 05:31:52 +05:30
|
|
|
file->name = QObject::tr("Minecraft (tracked)");
|
2015-04-03 15:25:16 +05:30
|
|
|
if(file->version.isEmpty())
|
|
|
|
{
|
|
|
|
file->version = mcVersion;
|
|
|
|
}
|
2016-03-13 06:58:55 +05:30
|
|
|
for(auto addLib: file->libraries)
|
|
|
|
{
|
|
|
|
addLib->setHint("local");
|
|
|
|
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
|
|
|
}
|
2017-03-27 07:04:39 +05:30
|
|
|
minecraftPatch = std::make_shared<ProfilePatch>(file);
|
|
|
|
minecraftPatch->setVanilla(true);
|
2015-04-03 15:25:16 +05:30
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-17 09:10:07 +05:30
|
|
|
throw VersionIncomplete("net.minecraft : " + mcJson);
|
2015-04-03 15:25:16 +05:30
|
|
|
}
|
|
|
|
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))
|
|
|
|
{
|
2015-04-04 05:31:52 +05:30
|
|
|
auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
|
|
|
|
|
|
|
|
// adapt the loaded file - the FTB patch file format is different than ours.
|
2016-03-26 21:26:57 +05:30
|
|
|
file->minecraftVersion.clear();
|
2017-04-14 16:03:54 +05:30
|
|
|
file->mainJar = nullptr;
|
2016-03-13 06:58:55 +05:30
|
|
|
for(auto addLib: file->libraries)
|
2015-04-04 05:31:52 +05:30
|
|
|
{
|
2016-03-07 06:31:28 +05:30
|
|
|
addLib->setHint("local");
|
2015-05-27 05:00:18 +05:30
|
|
|
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
2015-04-04 05:31:52 +05:30
|
|
|
}
|
2017-03-20 04:28:54 +05:30
|
|
|
file->uid = "org.multimc.ftb.pack";
|
2015-04-04 05:31:52 +05:30
|
|
|
file->name = QObject::tr("%1 (FTB pack)").arg(m_instance->name());
|
2015-04-03 15:25:16 +05:30
|
|
|
if(file->version.isEmpty())
|
|
|
|
{
|
2015-04-04 05:31:52 +05:30
|
|
|
file->version = QObject::tr("Unknown");
|
2015-10-05 05:17:27 +05:30
|
|
|
QFile versionFile (FS::PathCombine(m_instance->instanceRoot(), "version"));
|
2015-04-04 05:31:52 +05:30
|
|
|
if(versionFile.exists())
|
|
|
|
{
|
|
|
|
if(versionFile.open(QIODevice::ReadOnly))
|
|
|
|
{
|
|
|
|
// FIXME: just guessing the encoding/charset here.
|
|
|
|
auto version = QString::fromUtf8(versionFile.readAll());
|
|
|
|
file->version = version;
|
|
|
|
}
|
|
|
|
}
|
2015-04-03 15:25:16 +05:30
|
|
|
}
|
2017-03-27 07:04:39 +05:30
|
|
|
packPatch = std::make_shared<ProfilePatch>(file);
|
|
|
|
packPatch->setVanilla(true);
|
2015-04-03 15:25:16 +05:30
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-17 09:10:07 +05:30
|
|
|
throw VersionIncomplete("org.multimc.ftb.pack : " + mcJson);
|
2015-04-03 15:25:16 +05:30
|
|
|
}
|
2016-02-21 10:21:36 +05:30
|
|
|
packPatch->setOrder(1);
|
2015-04-03 15:25:16 +05:30
|
|
|
}
|
2016-02-21 10:21:36 +05:30
|
|
|
profile->appendPatch(packPatch);
|
2015-04-03 15:25:16 +05:30
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FTBProfileStrategy::load()
|
|
|
|
{
|
|
|
|
profile->clearPatches();
|
|
|
|
|
|
|
|
loadDefaultBuiltinPatches();
|
|
|
|
loadUserPatches();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FTBProfileStrategy::saveOrder(ProfileUtils::PatchOrder order)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FTBProfileStrategy::resetOrder()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-18 03:08:28 +05:30
|
|
|
bool FTBProfileStrategy::installJarMods(QStringList filepaths)
|
2015-04-03 15:25:16 +05:30
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-18 03:08:28 +05:30
|
|
|
bool FTBProfileStrategy::customizePatch(ProfilePatchPtr patch)
|
2015-04-03 15:25:16 +05:30
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-18 03:08:28 +05:30
|
|
|
bool FTBProfileStrategy::revertPatch(ProfilePatchPtr patch)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|