2017-11-11 00:38:31 +00:00
|
|
|
#include "MinecraftLoadAndCheck.h"
|
|
|
|
#include "MinecraftInstance.h"
|
2020-06-27 11:02:31 +01:00
|
|
|
#include "PackProfile.h"
|
2017-11-11 00:38:31 +00:00
|
|
|
|
|
|
|
MinecraftLoadAndCheck::MinecraftLoadAndCheck(MinecraftInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MinecraftLoadAndCheck::executeTask()
|
|
|
|
{
|
|
|
|
// add offline metadata load task
|
2020-06-27 11:02:31 +01:00
|
|
|
auto components = m_inst->getPackProfile();
|
2017-11-11 00:38:31 +00:00
|
|
|
components->reload(Net::Mode::Offline);
|
|
|
|
m_task = components->getCurrentTask();
|
|
|
|
|
|
|
|
if(!m_task)
|
|
|
|
{
|
|
|
|
emitSucceeded();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
connect(m_task.get(), &Task::succeeded, this, &MinecraftLoadAndCheck::subtaskSucceeded);
|
|
|
|
connect(m_task.get(), &Task::failed, this, &MinecraftLoadAndCheck::subtaskFailed);
|
2022-06-22 23:56:24 +01:00
|
|
|
connect(m_task.get(), &Task::aborted, this, [this]{ subtaskFailed(tr("Aborted")); });
|
2017-11-11 00:38:31 +00:00
|
|
|
connect(m_task.get(), &Task::progress, this, &MinecraftLoadAndCheck::progress);
|
2023-07-01 07:50:13 +01:00
|
|
|
connect(m_task.get(), &Task::stepProgress, this, &MinecraftLoadAndCheck::propagateStepProgress);
|
2017-11-11 00:38:31 +00:00
|
|
|
connect(m_task.get(), &Task::status, this, &MinecraftLoadAndCheck::setStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MinecraftLoadAndCheck::subtaskSucceeded()
|
|
|
|
{
|
|
|
|
if(isFinished())
|
|
|
|
{
|
2018-11-11 22:55:50 +00:00
|
|
|
qCritical() << "MinecraftUpdate: Subtask" << sender() << "succeeded, but work was already done!";
|
2017-11-11 00:38:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
emitSucceeded();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MinecraftLoadAndCheck::subtaskFailed(QString error)
|
|
|
|
{
|
|
|
|
if(isFinished())
|
|
|
|
{
|
2018-11-11 22:55:50 +00:00
|
|
|
qCritical() << "MinecraftUpdate: Subtask" << sender() << "failed, but work was already done!";
|
2017-11-11 00:38:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
emitFailed(error);
|
|
|
|
}
|