MultiMC5/launcher/InstanceCreationTask.cpp

32 lines
1.1 KiB
C++
Raw Normal View History

2016-10-02 22:55:54 +00:00
#include "InstanceCreationTask.h"
#include "settings/INISettingsObject.h"
#include "FileSystem.h"
//FIXME: remove this
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
2016-10-02 22:55:54 +00:00
2018-03-19 01:36:12 +00:00
InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version)
2016-10-02 22:55:54 +00:00
{
2018-07-15 12:51:05 +00:00
m_version = version;
2016-10-02 22:55:54 +00:00
}
void InstanceCreationTask::executeTask()
{
2018-07-15 12:51:05 +00:00
setStatus(tr("Creating instance from version %1").arg(m_version->name()));
{
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
instanceSettings->suspendSave();
instanceSettings->registerSetting("InstanceType", "Legacy");
instanceSettings->set("InstanceType", "OneSix");
MinecraftInstance inst(m_globalSettings, instanceSettings, m_stagingPath);
auto components = inst.getPackProfile();
2018-07-15 12:51:05 +00:00
components->buildingFromScratch();
components->setComponentVersion("net.minecraft", m_version->descriptor(), true);
inst.setName(m_instName);
inst.setIconKey(m_instIcon);
instanceSettings->resumeSave();
}
emitSucceeded();
2016-10-02 22:55:54 +00:00
}