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
|
|
|
|
2023-08-02 17:35:35 +01:00
|
|
|
MinecraftLoadAndCheck::MinecraftLoadAndCheck(MinecraftInstance* inst, QObject* parent) : Task(parent), m_inst(inst) {}
|
2017-11-11 00:38:31 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
2023-08-02 17:35:35 +01:00
|
|
|
if (!m_task) {
|
2017-11-11 00:38:31 +00:00
|
|
|
emitSucceeded();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
connect(m_task.get(), &Task::succeeded, this, &MinecraftLoadAndCheck::subtaskSucceeded);
|
|
|
|
connect(m_task.get(), &Task::failed, this, &MinecraftLoadAndCheck::subtaskFailed);
|
2023-08-02 17:35:35 +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-26 21:20:30 +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()
|
|
|
|
{
|
2023-08-02 17:35:35 +01:00
|
|
|
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)
|
|
|
|
{
|
2023-08-02 17:35:35 +01:00
|
|
|
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);
|
|
|
|
}
|