2016-10-02 23:55:54 +01:00
|
|
|
#include "InstanceCreationTask.h"
|
|
|
|
#include "settings/INISettingsObject.h"
|
|
|
|
#include "FileSystem.h"
|
|
|
|
|
|
|
|
//FIXME: remove this
|
2017-07-24 08:01:37 +01:00
|
|
|
#include "minecraft/MinecraftInstance.h"
|
2020-06-27 11:02:31 +01:00
|
|
|
#include "minecraft/PackProfile.h"
|
2016-10-02 23:55:54 +01:00
|
|
|
|
2018-03-19 01:36:12 +00:00
|
|
|
InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version)
|
2016-10-02 23:55:54 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
m_version = version;
|
2022-04-05 00:30:27 +01:00
|
|
|
m_usingLoader = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loaderVersion)
|
|
|
|
{
|
|
|
|
m_version = version;
|
|
|
|
m_usingLoader = true;
|
|
|
|
m_loader = loader;
|
|
|
|
m_loaderVersion = loaderVersion;
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceCreationTask::executeTask()
|
|
|
|
{
|
2018-07-15 13:51:05 +01: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();
|
|
|
|
MinecraftInstance inst(m_globalSettings, instanceSettings, m_stagingPath);
|
2020-06-27 11:02:31 +01:00
|
|
|
auto components = inst.getPackProfile();
|
2018-07-15 13:51:05 +01:00
|
|
|
components->buildingFromScratch();
|
|
|
|
components->setComponentVersion("net.minecraft", m_version->descriptor(), true);
|
2022-04-05 00:30:27 +01:00
|
|
|
if(m_usingLoader)
|
|
|
|
components->setComponentVersion(m_loader, m_loaderVersion->descriptor(), true);
|
2018-07-15 13:51:05 +01:00
|
|
|
inst.setName(m_instName);
|
|
|
|
inst.setIconKey(m_instIcon);
|
|
|
|
instanceSettings->resumeSave();
|
|
|
|
}
|
|
|
|
emitSucceeded();
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|