Copying of FTB instances working again
This commit is contained in:
parent
f54705e1c5
commit
4883d15262
@ -25,6 +25,7 @@
|
||||
#include "logic/auth/MojangAccount.h"
|
||||
|
||||
class QDialog;
|
||||
class QDir;
|
||||
class Task;
|
||||
class MinecraftProcess;
|
||||
class OneSixUpdate;
|
||||
@ -52,6 +53,7 @@ public:
|
||||
virtual ~BaseInstance() {};
|
||||
|
||||
virtual void init() {}
|
||||
virtual void copy(const QDir &newDir) {}
|
||||
|
||||
/// nuke thoroughly - deletes the instance contents, notifies the list/model which is
|
||||
/// responsible of cleaning up the husk
|
||||
|
@ -184,6 +184,8 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
|
||||
if(inst_type == "LegacyFTB")
|
||||
m_settings->set("InstanceType", "Legacy");
|
||||
|
||||
oldInstance->copy(instDir);
|
||||
|
||||
auto error = loadInstance(newInstance, instDir);
|
||||
|
||||
switch (error)
|
||||
|
@ -6,7 +6,9 @@
|
||||
#include "ForgeInstaller.h"
|
||||
#include "lists/ForgeVersionList.h"
|
||||
#include "OneSixInstance_p.h"
|
||||
#include "OneSixVersionBuilder.h"
|
||||
#include "MultiMC.h"
|
||||
#include "pathutils.h"
|
||||
|
||||
class OneSixFTBInstanceForge : public Task
|
||||
{
|
||||
@ -88,6 +90,70 @@ void OneSixFTBInstance::init()
|
||||
reloadVersion();
|
||||
}
|
||||
|
||||
void OneSixFTBInstance::copy(const QDir &newDir)
|
||||
{
|
||||
QStringList libraryNames;
|
||||
// create patch file
|
||||
{
|
||||
QLOG_DEBUG() << "Creating patch file for FTB instance...";
|
||||
QFile f(minecraftRoot() + "/pack.json");
|
||||
if (!f.open(QFile::ReadOnly))
|
||||
{
|
||||
QLOG_ERROR() << "Couldn't open" << f.fileName() << ":" << f.errorString();
|
||||
return;
|
||||
}
|
||||
QJsonObject root = QJsonDocument::fromJson(f.readAll()).object();
|
||||
QJsonArray libs = root.value("libraries").toArray();
|
||||
QJsonArray outLibs;
|
||||
for (auto lib : libs)
|
||||
{
|
||||
QJsonObject libObj = lib.toObject();
|
||||
libObj.insert("MMC-hint", QString("local"));
|
||||
libObj.insert("insert", QString("prepend"));
|
||||
libraryNames.append(libObj.value("name").toString());
|
||||
outLibs.append(libObj);
|
||||
}
|
||||
root.remove("libraries");
|
||||
root.remove("id");
|
||||
root.insert("+libraries", outLibs);
|
||||
root.insert("order", 1);
|
||||
root.insert("fileId", QString("org.multimc.ftb.pack.json"));
|
||||
root.insert("name", name());
|
||||
root.insert("mcVersion", intendedVersionId());
|
||||
root.insert("version", intendedVersionId());
|
||||
ensureFilePathExists(newDir.absoluteFilePath("patches/ftb.json"));
|
||||
QFile out(newDir.absoluteFilePath("patches/ftb.json"));
|
||||
if (!out.open(QFile::WriteOnly | QFile::Truncate))
|
||||
{
|
||||
QLOG_ERROR() << "Couldn't open" << out.fileName() << ":" << out.errorString();
|
||||
return;
|
||||
}
|
||||
out.write(QJsonDocument(root).toJson());
|
||||
}
|
||||
// copy libraries
|
||||
{
|
||||
QLOG_DEBUG() << "Copying FTB libraries";
|
||||
for (auto library : libraryNames)
|
||||
{
|
||||
OneSixLibrary *lib = new OneSixLibrary(library);
|
||||
lib->finalize();
|
||||
const QString out = QDir::current().absoluteFilePath("libraries/" + lib->storagePath());
|
||||
if (QFile::exists(out))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!ensureFilePathExists(out))
|
||||
{
|
||||
QLOG_ERROR() << "Couldn't create folder structure for" << out;
|
||||
}
|
||||
if (!QFile::copy(librariesPath().absoluteFilePath(lib->storagePath()), out))
|
||||
{
|
||||
QLOG_ERROR() << "Couldn't copy" << lib->rawName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString OneSixFTBInstance::id() const
|
||||
{
|
||||
return "FTB/" + BaseInstance::id();
|
||||
@ -109,6 +175,11 @@ QStringList OneSixFTBInstance::externalPatches() const
|
||||
<< minecraftRoot() + "/pack.json";
|
||||
}
|
||||
|
||||
bool OneSixFTBInstance::providesVersionFile() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QString OneSixFTBInstance::getStatusbarDescription()
|
||||
{
|
||||
return "OneSix FTB: " + intendedVersionId();
|
||||
|
@ -12,6 +12,7 @@ public:
|
||||
QObject *parent = 0);
|
||||
|
||||
void init() override;
|
||||
void copy(const QDir &newDir) override;
|
||||
|
||||
virtual QString getStatusbarDescription();
|
||||
virtual bool menuActionEnabled(QString action_name) const;
|
||||
@ -23,6 +24,7 @@ public:
|
||||
QDir librariesPath() const override;
|
||||
QDir versionsPath() const override;
|
||||
QStringList externalPatches() const override;
|
||||
bool providesVersionFile() const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<OneSixLibrary> m_forge;
|
||||
|
@ -391,6 +391,11 @@ QStringList OneSixInstance::externalPatches() const
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
bool OneSixInstance::providesVersionFile() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString OneSixInstance::loaderModsDir() const
|
||||
{
|
||||
return PathCombine(minecraftRoot(), "mods");
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
virtual QDir librariesPath() const;
|
||||
virtual QDir versionsPath() const;
|
||||
virtual QStringList externalPatches() const;
|
||||
virtual bool providesVersionFile() const;
|
||||
|
||||
signals:
|
||||
void versionReloaded();
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "pathutils.h"
|
||||
#include <JlCompress.h>
|
||||
|
||||
OneSixUpdate::OneSixUpdate(BaseInstance *inst, QObject *parent)
|
||||
OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent)
|
||||
: Task(parent), m_inst(inst)
|
||||
{
|
||||
}
|
||||
@ -73,6 +73,11 @@ void OneSixUpdate::executeTask()
|
||||
|
||||
void OneSixUpdate::versionFileStart()
|
||||
{
|
||||
if (m_inst->providesVersionFile())
|
||||
{
|
||||
jarlibStart();
|
||||
return;
|
||||
}
|
||||
QLOG_INFO() << m_inst->name() << ": getting version file.";
|
||||
setStatus(tr("Getting the version files from Mojang..."));
|
||||
|
||||
|
@ -23,13 +23,13 @@
|
||||
#include "logic/tasks/Task.h"
|
||||
|
||||
class MinecraftVersion;
|
||||
class BaseInstance;
|
||||
class OneSixInstance;
|
||||
|
||||
class OneSixUpdate : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OneSixUpdate(BaseInstance *inst, QObject *parent = 0);
|
||||
explicit OneSixUpdate(OneSixInstance *inst, QObject *parent = 0);
|
||||
virtual void executeTask();
|
||||
|
||||
private
|
||||
@ -55,5 +55,5 @@ private:
|
||||
|
||||
// target version, determined during this task
|
||||
std::shared_ptr<MinecraftVersion> targetVersion;
|
||||
BaseInstance *m_inst = nullptr;
|
||||
OneSixInstance *m_inst = nullptr;
|
||||
};
|
||||
|
@ -104,7 +104,6 @@ QList<std::shared_ptr<OneSixLibrary> > OneSixVersion::getActiveNormalLibs()
|
||||
QList<std::shared_ptr<OneSixLibrary> > output;
|
||||
for (auto lib : libraries)
|
||||
{
|
||||
qDebug() << "Checking" << lib->rawName() << lib->isActive() << !lib->isNative();
|
||||
if (lib->isActive() && !lib->isNative())
|
||||
{
|
||||
output.append(lib);
|
||||
|
Loading…
Reference in New Issue
Block a user