2016-02-27 18:58:40 +00:00
|
|
|
#include "FTBProfileStrategy.h"
|
|
|
|
#include "OneSixFTBInstance.h"
|
|
|
|
|
2015-10-05 00:47:27 +01:00
|
|
|
#include <FileSystem.h>
|
2015-04-03 10:55:16 +01:00
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QUuid>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonArray>
|
|
|
|
|
|
|
|
FTBProfileStrategy::FTBProfileStrategy(OneSixFTBInstance* instance) : OneSixProfileStrategy(instance)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
|
|
|
{
|
2016-02-21 04:51:36 +00:00
|
|
|
// FIXME: this should be here, but it needs us to be able to deal with multiple libraries paths
|
|
|
|
// OneSixProfileStrategy::loadDefaultBuiltinPatches();
|
2015-04-03 10:55:16 +01:00
|
|
|
auto mcVersion = m_instance->intendedVersionId();
|
2016-03-13 01:28:55 +00:00
|
|
|
auto nativeInstance = dynamic_cast<OneSixFTBInstance *>(m_instance);
|
2015-04-03 10:55:16 +01:00
|
|
|
|
|
|
|
ProfilePatchPtr minecraftPatch;
|
|
|
|
{
|
2017-04-23 01:31:13 +01:00
|
|
|
std::shared_ptr< VersionFile > file;
|
2015-04-03 10:55:16 +01:00
|
|
|
auto mcJson = m_instance->versionsPath().absoluteFilePath(mcVersion + "/" + mcVersion + ".json");
|
|
|
|
// load up the base minecraft patch
|
|
|
|
if(QFile::exists(mcJson))
|
|
|
|
{
|
2017-04-23 01:31:13 +01:00
|
|
|
file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
|
2016-03-13 01:28:55 +00:00
|
|
|
for(auto addLib: file->libraries)
|
|
|
|
{
|
|
|
|
addLib->setHint("local");
|
|
|
|
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
|
|
|
}
|
2015-04-03 10:55:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-23 01:31:13 +01:00
|
|
|
file = std::make_shared<VersionFile>();
|
|
|
|
file->addProblem(ProblemSeverity::Error, QObject::tr("Minecraft version is missing in the FTB data."));
|
|
|
|
}
|
|
|
|
file->uid = "net.minecraft";
|
|
|
|
file->name = QObject::tr("Minecraft (tracked)");
|
|
|
|
if(file->version.isEmpty())
|
|
|
|
{
|
|
|
|
file->version = mcVersion;
|
2015-04-03 10:55:16 +01:00
|
|
|
}
|
2017-04-23 01:31:13 +01:00
|
|
|
minecraftPatch = std::make_shared<ProfilePatch>(file);
|
|
|
|
minecraftPatch->setVanilla(true);
|
2015-04-03 10:55:16 +01:00
|
|
|
minecraftPatch->setOrder(-2);
|
|
|
|
}
|
|
|
|
profile->appendPatch(minecraftPatch);
|
|
|
|
|
|
|
|
ProfilePatchPtr packPatch;
|
|
|
|
{
|
2017-04-23 01:31:13 +01:00
|
|
|
std::shared_ptr< VersionFile > file;
|
2015-04-03 10:55:16 +01:00
|
|
|
auto mcJson = m_instance->minecraftRoot() + "/pack.json";
|
2017-04-23 01:31:13 +01:00
|
|
|
// load up the base minecraft patch, if it's there...
|
2015-04-03 10:55:16 +01:00
|
|
|
if(QFile::exists(mcJson))
|
|
|
|
{
|
2017-04-23 01:31:13 +01:00
|
|
|
file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
|
2015-04-04 01:01:52 +01:00
|
|
|
// adapt the loaded file - the FTB patch file format is different than ours.
|
2016-03-26 15:56:57 +00:00
|
|
|
file->minecraftVersion.clear();
|
2017-04-14 11:33:54 +01:00
|
|
|
file->mainJar = nullptr;
|
2016-03-13 01:28:55 +00:00
|
|
|
for(auto addLib: file->libraries)
|
2015-04-04 01:01:52 +01:00
|
|
|
{
|
2016-03-07 01:01:28 +00:00
|
|
|
addLib->setHint("local");
|
2015-05-27 00:30:18 +01:00
|
|
|
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
2015-04-04 01:01:52 +01:00
|
|
|
}
|
2017-04-23 01:31:13 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
file = std::make_shared<VersionFile>();
|
|
|
|
file->addProblem(ProblemSeverity::Error, QObject::tr("Modpack version file is missing."));
|
|
|
|
}
|
|
|
|
file->uid = "org.multimc.ftb.pack";
|
|
|
|
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())
|
2015-04-03 10:55:16 +01:00
|
|
|
{
|
2017-04-23 01:31:13 +01:00
|
|
|
if(versionFile.open(QIODevice::ReadOnly))
|
2015-04-04 01:01:52 +01:00
|
|
|
{
|
2017-04-23 01:31:13 +01:00
|
|
|
// FIXME: just guessing the encoding/charset here.
|
|
|
|
auto version = QString::fromUtf8(versionFile.readAll());
|
|
|
|
file->version = version;
|
2015-04-04 01:01:52 +01:00
|
|
|
}
|
2015-04-03 10:55:16 +01:00
|
|
|
}
|
|
|
|
}
|
2017-04-23 01:31:13 +01:00
|
|
|
packPatch = std::make_shared<ProfilePatch>(file);
|
|
|
|
packPatch->setVanilla(true);
|
2016-02-21 04:51:36 +00:00
|
|
|
packPatch->setOrder(1);
|
2015-04-03 10:55:16 +01:00
|
|
|
}
|
2016-02-21 04:51:36 +00:00
|
|
|
profile->appendPatch(packPatch);
|
2015-04-03 10:55:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FTBProfileStrategy::load()
|
|
|
|
{
|
|
|
|
profile->clearPatches();
|
|
|
|
|
|
|
|
loadDefaultBuiltinPatches();
|
|
|
|
loadUserPatches();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FTBProfileStrategy::saveOrder(ProfileUtils::PatchOrder order)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FTBProfileStrategy::resetOrder()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-17 22:38:28 +01:00
|
|
|
bool FTBProfileStrategy::installJarMods(QStringList filepaths)
|
2015-04-03 10:55:16 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-08-06 23:46:29 +01:00
|
|
|
bool FTBProfileStrategy::installCustomJar(QString filepath)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-17 22:38:28 +01:00
|
|
|
bool FTBProfileStrategy::customizePatch(ProfilePatchPtr patch)
|
2015-04-03 10:55:16 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-17 22:38:28 +01:00
|
|
|
bool FTBProfileStrategy::revertPatch(ProfilePatchPtr patch)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|