Don't assume forge for FTB instances. Fix FTB related stuff.
This commit is contained in:
parent
43881b9cdb
commit
f54705e1c5
@ -51,6 +51,8 @@ public:
|
|||||||
/// virtual destructor to make sure the destruction is COMPLETE
|
/// virtual destructor to make sure the destruction is COMPLETE
|
||||||
virtual ~BaseInstance() {};
|
virtual ~BaseInstance() {};
|
||||||
|
|
||||||
|
virtual void init() {}
|
||||||
|
|
||||||
/// nuke thoroughly - deletes the instance contents, notifies the list/model which is
|
/// nuke thoroughly - deletes the instance contents, notifies the list/model which is
|
||||||
/// responsible of cleaning up the husk
|
/// responsible of cleaning up the husk
|
||||||
void nuke();
|
void nuke();
|
||||||
|
@ -75,6 +75,7 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
|
|||||||
{
|
{
|
||||||
return InstanceFactory::UnknownLoadError;
|
return InstanceFactory::UnknownLoadError;
|
||||||
}
|
}
|
||||||
|
inst->init();
|
||||||
return NoLoadError;
|
return NoLoadError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,6 +157,8 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
|
|||||||
return InstanceFactory::NoSuchVersion;
|
return InstanceFactory::NoSuchVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inst->init();
|
||||||
|
|
||||||
// FIXME: really, how do you even know?
|
// FIXME: really, how do you even know?
|
||||||
return InstanceFactory::NoCreateError;
|
return InstanceFactory::NoCreateError;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "tasks/SequentialTask.h"
|
#include "tasks/SequentialTask.h"
|
||||||
#include "ForgeInstaller.h"
|
#include "ForgeInstaller.h"
|
||||||
#include "lists/ForgeVersionList.h"
|
#include "lists/ForgeVersionList.h"
|
||||||
|
#include "OneSixInstance_p.h"
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
|
||||||
class OneSixFTBInstanceForge : public Task
|
class OneSixFTBInstanceForge : public Task
|
||||||
@ -80,14 +81,11 @@ private:
|
|||||||
OneSixFTBInstance::OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) :
|
OneSixFTBInstance::OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) :
|
||||||
OneSixInstance(rootDir, settings, parent)
|
OneSixInstance(rootDir, settings, parent)
|
||||||
{
|
{
|
||||||
QFile f(QDir(minecraftRoot()).absoluteFilePath("pack.json"));
|
}
|
||||||
if (f.open(QFile::ReadOnly))
|
|
||||||
{
|
void OneSixFTBInstance::init()
|
||||||
QString data = QString::fromUtf8(f.readAll());
|
{
|
||||||
QRegularExpressionMatch match = QRegularExpression("net.minecraftforge:minecraftforge:[\\.\\d]*").match(data);
|
reloadVersion();
|
||||||
m_forge.reset(new OneSixLibrary(match.captured()));
|
|
||||||
m_forge->finalize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OneSixFTBInstance::id() const
|
QString OneSixFTBInstance::id() const
|
||||||
@ -104,6 +102,13 @@ QDir OneSixFTBInstance::versionsPath() const
|
|||||||
return QDir(MMC->settings()->get("FTBRoot").toString() + "/versions");
|
return QDir(MMC->settings()->get("FTBRoot").toString() + "/versions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList OneSixFTBInstance::externalPatches() const
|
||||||
|
{
|
||||||
|
I_D(OneSixInstance);
|
||||||
|
return QStringList() << versionsPath().absoluteFilePath(intendedVersionId() + "/" + intendedVersionId() + ".json")
|
||||||
|
<< minecraftRoot() + "/pack.json";
|
||||||
|
}
|
||||||
|
|
||||||
QString OneSixFTBInstance::getStatusbarDescription()
|
QString OneSixFTBInstance::getStatusbarDescription()
|
||||||
{
|
{
|
||||||
return "OneSix FTB: " + intendedVersionId();
|
return "OneSix FTB: " + intendedVersionId();
|
||||||
@ -115,18 +120,7 @@ bool OneSixFTBInstance::menuActionEnabled(QString action_name) const
|
|||||||
|
|
||||||
std::shared_ptr<Task> OneSixFTBInstance::doUpdate()
|
std::shared_ptr<Task> OneSixFTBInstance::doUpdate()
|
||||||
{
|
{
|
||||||
std::shared_ptr<SequentialTask> task;
|
return OneSixInstance::doUpdate();
|
||||||
task.reset(new SequentialTask(this));
|
|
||||||
if (!MMC->forgelist()->isLoaded())
|
|
||||||
{
|
|
||||||
task->addTask(std::shared_ptr<Task>(MMC->forgelist()->getLoadTask()));
|
|
||||||
}
|
|
||||||
task->addTask(OneSixInstance::doUpdate());
|
|
||||||
task->addTask(std::shared_ptr<Task>(new OneSixFTBInstanceForge(m_forge->version(), this, this)));
|
|
||||||
//FIXME: yes. this may appear dumb. but the previous step can change the list, so we do it all again.
|
|
||||||
//TODO: Add a graph task. Construct graphs of tasks so we may capture the logic properly.
|
|
||||||
task->addTask(OneSixInstance::doUpdate());
|
|
||||||
return task;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "OneSixFTBInstance.moc"
|
#include "OneSixFTBInstance.moc"
|
||||||
|
@ -10,6 +10,9 @@ class OneSixFTBInstance : public OneSixInstance
|
|||||||
public:
|
public:
|
||||||
explicit OneSixFTBInstance(const QString &rootDir, SettingsObject *settings,
|
explicit OneSixFTBInstance(const QString &rootDir, SettingsObject *settings,
|
||||||
QObject *parent = 0);
|
QObject *parent = 0);
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
|
||||||
virtual QString getStatusbarDescription();
|
virtual QString getStatusbarDescription();
|
||||||
virtual bool menuActionEnabled(QString action_name) const;
|
virtual bool menuActionEnabled(QString action_name) const;
|
||||||
|
|
||||||
@ -17,8 +20,9 @@ public:
|
|||||||
|
|
||||||
virtual QString id() const;
|
virtual QString id() const;
|
||||||
|
|
||||||
virtual QDir librariesPath() const override;
|
QDir librariesPath() const override;
|
||||||
virtual QDir versionsPath() const override;
|
QDir versionsPath() const override;
|
||||||
|
QStringList externalPatches() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<OneSixLibrary> m_forge;
|
std::shared_ptr<OneSixLibrary> m_forge;
|
||||||
|
@ -36,6 +36,10 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings,
|
|||||||
d->m_settings->registerSetting("ShouldUpdate", false);
|
d->m_settings->registerSetting("ShouldUpdate", false);
|
||||||
d->version.reset(new OneSixVersion(this, this));
|
d->version.reset(new OneSixVersion(this, this));
|
||||||
d->vanillaVersion.reset(new OneSixVersion(this, this));
|
d->vanillaVersion.reset(new OneSixVersion(this, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneSixInstance::init()
|
||||||
|
{
|
||||||
if (QDir(instanceRoot()).exists("version.json"))
|
if (QDir(instanceRoot()).exists("version.json"))
|
||||||
{
|
{
|
||||||
reloadVersion();
|
reloadVersion();
|
||||||
@ -316,11 +320,12 @@ bool OneSixInstance::reloadVersion(QWidget *widgetParent)
|
|||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
|
|
||||||
bool ret = d->version->reload(widgetParent);
|
bool ret = d->version->reload(widgetParent, false, externalPatches());
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
ret = d->vanillaVersion->reload(widgetParent, true);
|
ret = d->vanillaVersion->reload(widgetParent, true, externalPatches());
|
||||||
}
|
}
|
||||||
|
|
||||||
emit versionReloaded();
|
emit versionReloaded();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -381,6 +386,11 @@ QDir OneSixInstance::versionsPath() const
|
|||||||
return QDir::current().absoluteFilePath("versions");
|
return QDir::current().absoluteFilePath("versions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList OneSixInstance::externalPatches() const
|
||||||
|
{
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
QString OneSixInstance::loaderModsDir() const
|
QString OneSixInstance::loaderModsDir() const
|
||||||
{
|
{
|
||||||
return PathCombine(minecraftRoot(), "mods");
|
return PathCombine(minecraftRoot(), "mods");
|
||||||
|
@ -27,6 +27,8 @@ public:
|
|||||||
explicit OneSixInstance(const QString &rootDir, SettingsObject *settings,
|
explicit OneSixInstance(const QString &rootDir, SettingsObject *settings,
|
||||||
QObject *parent = 0);
|
QObject *parent = 0);
|
||||||
|
|
||||||
|
virtual void init() override;
|
||||||
|
|
||||||
////// Mod Lists //////
|
////// Mod Lists //////
|
||||||
std::shared_ptr<ModList> loaderModList();
|
std::shared_ptr<ModList> loaderModList();
|
||||||
std::shared_ptr<ModList> resourcePackList();
|
std::shared_ptr<ModList> resourcePackList();
|
||||||
@ -70,6 +72,7 @@ public:
|
|||||||
|
|
||||||
virtual QDir librariesPath() const;
|
virtual QDir librariesPath() const;
|
||||||
virtual QDir versionsPath() const;
|
virtual QDir versionsPath() const;
|
||||||
|
virtual QStringList externalPatches() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void versionReloaded();
|
void versionReloaded();
|
||||||
|
@ -26,10 +26,10 @@ OneSixVersion::OneSixVersion(OneSixInstance *instance, QObject *parent)
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersion::reload(QWidget *widgetParent, const bool onlyVanilla)
|
bool OneSixVersion::reload(QWidget *widgetParent, const bool onlyVanilla, const QStringList &external)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
bool ret = OneSixVersionBuilder::build(this, m_instance, widgetParent, onlyVanilla);
|
bool ret = OneSixVersionBuilder::build(this, m_instance, widgetParent, onlyVanilla, external);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -104,6 +104,7 @@ QList<std::shared_ptr<OneSixLibrary> > OneSixVersion::getActiveNormalLibs()
|
|||||||
QList<std::shared_ptr<OneSixLibrary> > output;
|
QList<std::shared_ptr<OneSixLibrary> > output;
|
||||||
for (auto lib : libraries)
|
for (auto lib : libraries)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Checking" << lib->rawName() << lib->isActive() << !lib->isNative();
|
||||||
if (lib->isActive() && !lib->isNative())
|
if (lib->isActive() && !lib->isNative())
|
||||||
{
|
{
|
||||||
output.append(lib);
|
output.append(lib);
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
virtual int columnCount(const QModelIndex &parent) const;
|
virtual int columnCount(const QModelIndex &parent) const;
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
bool reload(QWidget *widgetParent, const bool onlyVanilla = false);
|
bool reload(QWidget *widgetParent, const bool onlyVanilla = false, const QStringList &external = QStringList());
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
@ -192,7 +192,7 @@ struct VersionFile
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
static VersionFile fromJson(const QJsonDocument &doc, const QString &filename,
|
static VersionFile fromJson(const QJsonDocument &doc, const QString &filename,
|
||||||
const bool requireOrder, bool &isError)
|
const bool requireOrder, bool &isError, const OneSixVersionBuilder::ParseFlags flags = OneSixVersionBuilder::NoFlags)
|
||||||
{
|
{
|
||||||
VersionFile out;
|
VersionFile out;
|
||||||
isError = true;
|
isError = true;
|
||||||
@ -251,7 +251,10 @@ struct VersionFile
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
readString("id", out.id);
|
if (!(flags & OneSixVersionBuilder::IsFTBPackJson))
|
||||||
|
{
|
||||||
|
readString("id", out.id);
|
||||||
|
}
|
||||||
readString("mainClass", out.mainClass);
|
readString("mainClass", out.mainClass);
|
||||||
readString("processArguments", out.processArguments);
|
readString("processArguments", out.processArguments);
|
||||||
readString("minecraftArguments", out.overwriteMinecraftArguments);
|
readString("minecraftArguments", out.overwriteMinecraftArguments);
|
||||||
@ -343,7 +346,7 @@ struct VersionFile
|
|||||||
|
|
||||||
if (root.contains("libraries"))
|
if (root.contains("libraries"))
|
||||||
{
|
{
|
||||||
out.shouldOverwriteLibs = true;
|
out.shouldOverwriteLibs = !(flags & OneSixVersionBuilder::IsFTBPackJson);
|
||||||
QJsonValue librariesVal = root.value("libraries");
|
QJsonValue librariesVal = root.value("libraries");
|
||||||
if (!librariesVal.isArray())
|
if (!librariesVal.isArray())
|
||||||
{
|
{
|
||||||
@ -367,7 +370,16 @@ struct VersionFile
|
|||||||
QLOG_ERROR() << "Error while reading a library entry in" << filename;
|
QLOG_ERROR() << "Error while reading a library entry in" << filename;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out.overwriteLibs.append(lib);
|
if (flags & OneSixVersionBuilder::IsFTBPackJson)
|
||||||
|
{
|
||||||
|
lib.hint = "local";
|
||||||
|
lib.insertType = Library::Prepend;
|
||||||
|
out.addLibs.prepend(lib);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out.overwriteLibs.append(lib);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (root.contains("+libraries"))
|
if (root.contains("+libraries"))
|
||||||
@ -775,13 +787,13 @@ OneSixVersionBuilder::OneSixVersionBuilder()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersionBuilder::build(OneSixVersion *version, OneSixInstance *instance,
|
bool OneSixVersionBuilder::build(OneSixVersion *version, OneSixInstance *instance,
|
||||||
QWidget *widgetParent, const bool onlyVanilla)
|
QWidget *widgetParent, const bool onlyVanilla, const QStringList &external)
|
||||||
{
|
{
|
||||||
OneSixVersionBuilder builder;
|
OneSixVersionBuilder builder;
|
||||||
builder.m_version = version;
|
builder.m_version = version;
|
||||||
builder.m_instance = instance;
|
builder.m_instance = instance;
|
||||||
builder.m_widgetParent = widgetParent;
|
builder.m_widgetParent = widgetParent;
|
||||||
return builder.build(onlyVanilla);
|
return builder.build(onlyVanilla, external);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersionBuilder::read(OneSixVersion *version, const QJsonObject &obj)
|
bool OneSixVersionBuilder::read(OneSixVersion *version, const QJsonObject &obj)
|
||||||
@ -793,140 +805,171 @@ bool OneSixVersionBuilder::read(OneSixVersion *version, const QJsonObject &obj)
|
|||||||
return builder.read(obj);
|
return builder.read(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersionBuilder::build(const bool onlyVanilla)
|
bool OneSixVersionBuilder::build(const bool onlyVanilla, const QStringList &external)
|
||||||
{
|
{
|
||||||
m_version->clear();
|
m_version->clear();
|
||||||
|
|
||||||
QDir root(m_instance->instanceRoot());
|
QDir root(m_instance->instanceRoot());
|
||||||
QDir patches(root.absoluteFilePath("patches/"));
|
QDir patches(root.absoluteFilePath("patches/"));
|
||||||
|
|
||||||
if (QFile::exists(root.absoluteFilePath("custom.json")))
|
if (external.isEmpty())
|
||||||
{
|
{
|
||||||
QLOG_INFO() << "Reading custom.json";
|
if (QFile::exists(root.absoluteFilePath("custom.json")))
|
||||||
VersionFile file;
|
|
||||||
if (!read(QFileInfo(root.absoluteFilePath("custom.json")), false, &file))
|
|
||||||
{
|
{
|
||||||
return false;
|
QLOG_INFO() << "Reading custom.json";
|
||||||
}
|
|
||||||
file.name = "custom.json";
|
|
||||||
file.filename = "custom.json";
|
|
||||||
file.fileId = "org.multimc.custom.json";
|
|
||||||
file.version = QString();
|
|
||||||
bool isError = false;
|
|
||||||
file.applyTo(m_version, isError);
|
|
||||||
if (isError)
|
|
||||||
{
|
|
||||||
QMessageBox::critical(
|
|
||||||
m_widgetParent, QObject::tr("Error"),
|
|
||||||
QObject::tr(
|
|
||||||
"Error while applying %1. Please check MultiMC-0.log for more info.")
|
|
||||||
.arg(root.absoluteFilePath("custom.json")));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// version.json -> patches/*.json -> user.json
|
|
||||||
|
|
||||||
// version.json
|
|
||||||
{
|
|
||||||
QLOG_INFO() << "Reading version.json";
|
|
||||||
VersionFile file;
|
VersionFile file;
|
||||||
if (!read(QFileInfo(root.absoluteFilePath("version.json")), false, &file))
|
if (!read(QFileInfo(root.absoluteFilePath("custom.json")), false, &file))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
file.name = "version.json";
|
file.name = "custom.json";
|
||||||
file.fileId = "org.multimc.version.json";
|
file.filename = "custom.json";
|
||||||
file.version = m_instance->intendedVersionId();
|
file.fileId = "org.multimc.custom.json";
|
||||||
file.mcVersion = m_instance->intendedVersionId();
|
file.version = QString();
|
||||||
bool isError = false;
|
bool isError = false;
|
||||||
file.applyTo(m_version, isError);
|
file.applyTo(m_version, isError);
|
||||||
if (isError)
|
if (isError)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
m_widgetParent, QObject::tr("Error"),
|
m_widgetParent, QObject::tr("Error"),
|
||||||
QObject::tr(
|
QObject::tr(
|
||||||
"Error while applying %1. Please check MultiMC-0.log for more info.")
|
"Error while applying %1. Please check MultiMC-0.log for more info.")
|
||||||
.arg(root.absoluteFilePath("version.json")));
|
.arg(root.absoluteFilePath("custom.json")));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!onlyVanilla)
|
|
||||||
{
|
{
|
||||||
|
// version.json -> patches/*.json -> user.json
|
||||||
|
|
||||||
// patches/
|
// version.json
|
||||||
{
|
{
|
||||||
// load all, put into map for ordering, apply in the right order
|
QLOG_INFO() << "Reading version.json";
|
||||||
QMap<QString, int> overrideOrder = readOverrideOrders(m_instance);
|
VersionFile file;
|
||||||
|
if (!read(QFileInfo(root.absoluteFilePath("version.json")), false, &file))
|
||||||
QMap<int, QPair<QString, VersionFile>> files;
|
|
||||||
for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
|
|
||||||
{
|
{
|
||||||
QLOG_INFO() << "Reading" << info.fileName();
|
return false;
|
||||||
VersionFile file;
|
|
||||||
if (!read(info, true, &file))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (overrideOrder.contains(file.fileId))
|
|
||||||
{
|
|
||||||
file.order = overrideOrder.value(file.fileId);
|
|
||||||
}
|
|
||||||
if (files.contains(file.order))
|
|
||||||
{
|
|
||||||
QLOG_ERROR() << file.fileId << "has the same order as" << files[file.order].second.fileId;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
files.insert(file.order, qMakePair(info.fileName(), file));
|
|
||||||
}
|
}
|
||||||
for (auto order : files.keys())
|
file.name = "version.json";
|
||||||
|
file.fileId = "org.multimc.version.json";
|
||||||
|
file.version = m_instance->intendedVersionId();
|
||||||
|
file.mcVersion = m_instance->intendedVersionId();
|
||||||
|
bool isError = false;
|
||||||
|
file.applyTo(m_version, isError);
|
||||||
|
if (isError)
|
||||||
{
|
{
|
||||||
QLOG_DEBUG() << "Applying file with order" << order;
|
QMessageBox::critical(
|
||||||
auto filePair = files[order];
|
m_widgetParent, QObject::tr("Error"),
|
||||||
bool isError = false;
|
QObject::tr(
|
||||||
filePair.second.applyTo(m_version, isError);
|
"Error while applying %1. Please check MultiMC-0.log for more info.")
|
||||||
if (isError)
|
.arg(root.absoluteFilePath("version.json")));
|
||||||
{
|
return false;
|
||||||
QMessageBox::critical(
|
|
||||||
m_widgetParent, QObject::tr("Error"),
|
|
||||||
QObject::tr("Error while applying %1. Please check MultiMC-0.log "
|
|
||||||
"for more info.").arg(filePair.first));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!onlyVanilla)
|
||||||
|
{
|
||||||
|
|
||||||
|
// patches/
|
||||||
|
{
|
||||||
|
// load all, put into map for ordering, apply in the right order
|
||||||
|
QMap<QString, int> overrideOrder = readOverrideOrders(m_instance);
|
||||||
|
|
||||||
|
QMap<int, QPair<QString, VersionFile>> files;
|
||||||
|
for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "Reading" << info.fileName();
|
||||||
|
VersionFile file;
|
||||||
|
if (!read(info, true, &file))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (overrideOrder.contains(file.fileId))
|
||||||
|
{
|
||||||
|
file.order = overrideOrder.value(file.fileId);
|
||||||
|
}
|
||||||
|
if (files.contains(file.order))
|
||||||
|
{
|
||||||
|
QLOG_ERROR() << file.fileId << "has the same order as" << files[file.order].second.fileId;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
files.insert(file.order, qMakePair(info.fileName(), file));
|
||||||
|
}
|
||||||
|
for (auto order : files.keys())
|
||||||
|
{
|
||||||
|
QLOG_DEBUG() << "Applying file with order" << order;
|
||||||
|
auto filePair = files[order];
|
||||||
|
bool isError = false;
|
||||||
|
filePair.second.applyTo(m_version, isError);
|
||||||
|
if (isError)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(
|
||||||
|
m_widgetParent, QObject::tr("Error"),
|
||||||
|
QObject::tr("Error while applying %1. Please check MultiMC-0.log "
|
||||||
|
"for more info.").arg(filePair.first));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// user.json
|
// user.json
|
||||||
{
|
|
||||||
if (QFile::exists(root.absoluteFilePath("user.json")))
|
|
||||||
{
|
{
|
||||||
QLOG_INFO() << "Reading user.json";
|
if (QFile::exists(root.absoluteFilePath("user.json")))
|
||||||
VersionFile file;
|
|
||||||
if (!read(QFileInfo(root.absoluteFilePath("user.json")), false, &file))
|
|
||||||
{
|
{
|
||||||
return false;
|
QLOG_INFO() << "Reading user.json";
|
||||||
}
|
VersionFile file;
|
||||||
file.name = "user.json";
|
if (!read(QFileInfo(root.absoluteFilePath("user.json")), false, &file))
|
||||||
file.fileId = "org.multimc.user.json";
|
{
|
||||||
file.version = QString();
|
return false;
|
||||||
file.mcVersion = QString();
|
}
|
||||||
bool isError = false;
|
file.name = "user.json";
|
||||||
file.applyTo(m_version, isError);
|
file.fileId = "org.multimc.user.json";
|
||||||
if (isError)
|
file.version = QString();
|
||||||
{
|
file.mcVersion = QString();
|
||||||
QMessageBox::critical(
|
bool isError = false;
|
||||||
m_widgetParent, QObject::tr("Error"),
|
file.applyTo(m_version, isError);
|
||||||
QObject::tr(
|
if (isError)
|
||||||
"Error while applying %1. Please check MultiMC-0.log for more info.")
|
{
|
||||||
.arg(root.absoluteFilePath("user.json")));
|
QMessageBox::critical(
|
||||||
return false;
|
m_widgetParent, QObject::tr("Error"),
|
||||||
|
QObject::tr(
|
||||||
|
"Error while applying %1. Please check MultiMC-0.log for more info.")
|
||||||
|
.arg(root.absoluteFilePath("user.json")));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto fileName : external)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "Reading" << fileName;
|
||||||
|
VersionFile file;
|
||||||
|
ParseFlags flags = fileName.endsWith("pack.json") ? IsFTBPackJson : NoFlags;
|
||||||
|
if (!read(QFileInfo(fileName), false, &file, flags))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
file.name = QFileInfo(fileName).fileName();
|
||||||
|
file.fileId = "org.multimc.external." + file.name;
|
||||||
|
file.version = QString();
|
||||||
|
file.mcVersion = QString();
|
||||||
|
bool isError = false;
|
||||||
|
file.applyTo(m_version, isError);
|
||||||
|
if (isError)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(
|
||||||
|
m_widgetParent, QObject::tr("Error"),
|
||||||
|
QObject::tr(
|
||||||
|
"Error while applying %1. Please check MultiMC-0.log for more info.")
|
||||||
|
.arg(fileName));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -986,7 +1029,7 @@ bool OneSixVersionBuilder::read(const QJsonObject &obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersionBuilder::read(const QFileInfo &fileInfo, const bool requireOrder,
|
bool OneSixVersionBuilder::read(const QFileInfo &fileInfo, const bool requireOrder,
|
||||||
VersionFile *out)
|
VersionFile *out, const ParseFlags flags)
|
||||||
{
|
{
|
||||||
QFile file(fileInfo.absoluteFilePath());
|
QFile file(fileInfo.absoluteFilePath());
|
||||||
if (!file.open(QFile::ReadOnly))
|
if (!file.open(QFile::ReadOnly))
|
||||||
@ -1007,7 +1050,7 @@ bool OneSixVersionBuilder::read(const QFileInfo &fileInfo, const bool requireOrd
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool isError = false;
|
bool isError = false;
|
||||||
*out = VersionFile::fromJson(doc, file.fileName(), requireOrder, isError);
|
*out = VersionFile::fromJson(doc, file.fileName(), requireOrder, isError, flags);
|
||||||
if (isError)
|
if (isError)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
|
@ -29,19 +29,27 @@ class OneSixVersionBuilder
|
|||||||
{
|
{
|
||||||
OneSixVersionBuilder();
|
OneSixVersionBuilder();
|
||||||
public:
|
public:
|
||||||
static bool build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent, const bool onlyVanilla);
|
static bool build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent, const bool onlyVanilla, const QStringList &external);
|
||||||
static bool read(OneSixVersion *version, const QJsonObject &obj);
|
static bool read(OneSixVersion *version, const QJsonObject &obj);
|
||||||
static QMap<QString, int> readOverrideOrders(OneSixInstance *instance);
|
static QMap<QString, int> readOverrideOrders(OneSixInstance *instance);
|
||||||
static bool writeOverrideOrders(const QMap<QString, int> &order, OneSixInstance *instance);
|
static bool writeOverrideOrders(const QMap<QString, int> &order, OneSixInstance *instance);
|
||||||
|
|
||||||
|
enum ParseFlag
|
||||||
|
{
|
||||||
|
NoFlags = 0x0,
|
||||||
|
IsFTBPackJson = 0x1
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(ParseFlags, ParseFlag)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OneSixVersion *m_version;
|
OneSixVersion *m_version;
|
||||||
OneSixInstance *m_instance;
|
OneSixInstance *m_instance;
|
||||||
QWidget *m_widgetParent;
|
QWidget *m_widgetParent;
|
||||||
|
|
||||||
bool build(const bool onlyVanilla);
|
bool build(const bool onlyVanilla, const QStringList &external);
|
||||||
bool read(const QJsonObject &obj);
|
bool read(const QJsonObject &obj);
|
||||||
|
|
||||||
bool read(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out);
|
bool read(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out, const ParseFlags flags = NoFlags);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(OneSixVersionBuilder::ParseFlags)
|
||||||
|
@ -336,8 +336,6 @@ QList<FTBRecord> InstanceList::discoverFTBInstances()
|
|||||||
if (!test.exists())
|
if (!test.exists())
|
||||||
continue;
|
continue;
|
||||||
record.name = attrs.value("name").toString();
|
record.name = attrs.value("name").toString();
|
||||||
if(record.name.contains("voxel", Qt::CaseInsensitive))
|
|
||||||
continue;
|
|
||||||
record.logo = attrs.value("logo").toString();
|
record.logo = attrs.value("logo").toString();
|
||||||
record.mcVersion = attrs.value("mcVersion").toString();
|
record.mcVersion = attrs.value("mcVersion").toString();
|
||||||
record.description = attrs.value("description").toString();
|
record.description = attrs.value("description").toString();
|
||||||
|
Loading…
Reference in New Issue
Block a user