summaryrefslogtreecommitdiffstats
path: root/api/logic/InstanceCreationTask.cpp
blob: 978d4687b1b7a380b4b472353b005bf19dc446b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "InstanceCreationTask.h"
#include "settings/INISettingsObject.h"
#include "FileSystem.h"

//FIXME: remove this
#include "minecraft/MinecraftInstance.h"
#include "minecraft/ComponentList.h"

InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version)
{
    m_version = version;
}

void InstanceCreationTask::executeTask()
{
    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.getComponentList();
        components->buildingFromScratch();
        components->setComponentVersion("net.minecraft", m_version->descriptor(), true);
        inst.setName(m_instName);
        inst.setIconKey(m_instIcon);
        instanceSettings->resumeSave();
    }
    emitSucceeded();
}