diff options
author | flow <flowlnlnln@gmail.com> | 2022-07-07 20:31:24 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-09-20 18:32:36 -0300 |
commit | 941d75824af8d8e3deb1dfc0597c9493911f0cf0 (patch) | |
tree | 12578af364c0c44bf7a6addf9d855d75d22c6449 /launcher/InstanceCreationTask.cpp | |
parent | ec9ddc4f225c89ea3ccbf24c9a3be36848aa3172 (diff) | |
download | PrismLauncher-941d75824af8d8e3deb1dfc0597c9493911f0cf0.tar.gz PrismLauncher-941d75824af8d8e3deb1dfc0597c9493911f0cf0.tar.bz2 PrismLauncher-941d75824af8d8e3deb1dfc0597c9493911f0cf0.zip |
refactor: add instance creation abstraction and move vanilla
This is so that 1. Code is more cleanly separated, and 2. Allows to more
easily add instance updating :)
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/InstanceCreationTask.cpp')
-rw-r--r-- | launcher/InstanceCreationTask.cpp | 42 |
1 files changed, 10 insertions, 32 deletions
diff --git a/launcher/InstanceCreationTask.cpp b/launcher/InstanceCreationTask.cpp index e01bf306..c8c91997 100644 --- a/launcher/InstanceCreationTask.cpp +++ b/launcher/InstanceCreationTask.cpp @@ -1,40 +1,18 @@ #include "InstanceCreationTask.h" -#include "settings/INISettingsObject.h" -#include "FileSystem.h" -//FIXME: remove this -#include "minecraft/MinecraftInstance.h" -#include "minecraft/PackProfile.h" +#include <QDebug> -InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version) -{ - m_version = version; - m_usingLoader = false; -} - -InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loaderVersion) -{ - m_version = version; - m_usingLoader = true; - m_loader = loader; - m_loaderVersion = loaderVersion; -} +InstanceCreationTask::InstanceCreationTask() {} 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(); - MinecraftInstance inst(m_globalSettings, instanceSettings, m_stagingPath); - auto components = inst.getPackProfile(); - components->buildingFromScratch(); - components->setComponentVersion("net.minecraft", m_version->descriptor(), true); - if(m_usingLoader) - components->setComponentVersion(m_loader, m_loaderVersion->descriptor()); - inst.setName(m_instName); - inst.setIconKey(m_instIcon); - instanceSettings->resumeSave(); + if (updateInstance() || createInstance()) { + emitSucceeded(); + return; } - emitSucceeded(); + + qWarning() << "Instance creation failed!"; + if (!m_error_message.isEmpty()) + qWarning() << "Reason: " << m_error_message; + emitFailed(tr("Error while creating new instance.")); } |