2016-10-02 23:55:54 +01:00
|
|
|
#include "InstanceCreationTask.h"
|
|
|
|
#include "BaseInstanceProvider.h"
|
|
|
|
#include "settings/INISettingsObject.h"
|
|
|
|
#include "FileSystem.h"
|
|
|
|
|
|
|
|
//FIXME: remove this
|
|
|
|
#include "minecraft/onesix/OneSixInstance.h"
|
|
|
|
|
2017-09-05 22:38:17 +01:00
|
|
|
InstanceCreationTask::InstanceCreationTask(SettingsObjectPtr settings, const QString & stagingPath, BaseVersionPtr version,
|
2016-10-02 23:55:54 +01:00
|
|
|
const QString& instName, const QString& instIcon, const QString& instGroup)
|
|
|
|
{
|
|
|
|
m_globalSettings = settings;
|
2017-09-05 22:38:17 +01:00
|
|
|
m_stagingPath = stagingPath;
|
2016-10-02 23:55:54 +01:00
|
|
|
m_instName = instName;
|
|
|
|
m_instIcon = instIcon;
|
|
|
|
m_instGroup = instGroup;
|
|
|
|
m_version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceCreationTask::executeTask()
|
|
|
|
{
|
2017-05-03 22:11:52 +01:00
|
|
|
setStatus(tr("Creating instance from version %1").arg(m_version->name()));
|
2017-09-05 22:38:17 +01:00
|
|
|
{
|
|
|
|
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
|
|
|
|
instanceSettings->suspendSave();
|
|
|
|
instanceSettings->registerSetting("InstanceType", "Legacy");
|
|
|
|
instanceSettings->set("InstanceType", "OneSix");
|
|
|
|
OneSixInstance inst(m_globalSettings, instanceSettings, m_stagingPath);
|
|
|
|
inst.setIntendedVersionId(m_version->descriptor());
|
|
|
|
inst.setName(m_instName);
|
|
|
|
inst.setIconKey(m_instIcon);
|
|
|
|
inst.init();
|
|
|
|
instanceSettings->resumeSave();
|
|
|
|
}
|
2016-10-02 23:55:54 +01:00
|
|
|
emitSucceeded();
|
|
|
|
}
|