2017-11-11 06:08:31 +05:30
|
|
|
#include "MinecraftLoadAndCheck.h"
|
|
|
|
#include "MinecraftInstance.h"
|
2020-06-27 15:32:31 +05:30
|
|
|
#include "PackProfile.h"
|
2017-11-11 06:08:31 +05:30
|
|
|
|
|
|
|
MinecraftLoadAndCheck::MinecraftLoadAndCheck(MinecraftInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MinecraftLoadAndCheck::executeTask()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
// add offline metadata load task
|
2020-06-27 15:32:31 +05:30
|
|
|
auto components = m_inst->getPackProfile();
|
2018-07-15 18:21:05 +05:30
|
|
|
components->reload(Net::Mode::Offline);
|
|
|
|
m_task = components->getCurrentTask();
|
2017-11-11 06:08:31 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
if(!m_task)
|
|
|
|
{
|
|
|
|
emitSucceeded();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
connect(m_task.get(), &Task::succeeded, this, &MinecraftLoadAndCheck::subtaskSucceeded);
|
|
|
|
connect(m_task.get(), &Task::failed, this, &MinecraftLoadAndCheck::subtaskFailed);
|
|
|
|
connect(m_task.get(), &Task::progress, this, &MinecraftLoadAndCheck::progress);
|
|
|
|
connect(m_task.get(), &Task::status, this, &MinecraftLoadAndCheck::setStatus);
|
2017-11-11 06:08:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void MinecraftLoadAndCheck::subtaskSucceeded()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
if(isFinished())
|
|
|
|
{
|
2018-11-12 04:25:50 +05:30
|
|
|
qCritical() << "MinecraftUpdate: Subtask" << sender() << "succeeded, but work was already done!";
|
2018-07-15 18:21:05 +05:30
|
|
|
return;
|
|
|
|
}
|
|
|
|
emitSucceeded();
|
2017-11-11 06:08:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void MinecraftLoadAndCheck::subtaskFailed(QString error)
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
if(isFinished())
|
|
|
|
{
|
2018-11-12 04:25:50 +05:30
|
|
|
qCritical() << "MinecraftUpdate: Subtask" << sender() << "failed, but work was already done!";
|
2018-07-15 18:21:05 +05:30
|
|
|
return;
|
|
|
|
}
|
|
|
|
emitFailed(error);
|
2017-11-11 06:08:31 +05:30
|
|
|
}
|