PrismLauncher/launcher/InstanceCreationTask.h
Trial97 92a1403c09
refactor VanillaCreationTask
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
2026-05-24 22:07:05 +03:00

46 lines
1.3 KiB
C++

#pragma once
#include "InstanceTask.h"
#include "minecraft/MinecraftInstance.h"
class InstanceCreationTask : public InstanceTask {
Q_OBJECT
public:
InstanceCreationTask() = default;
~InstanceCreationTask() override = default;
bool abort() override;
protected:
void executeTask() final;
/**
* Tries to update an already existing instance.
*
* This can be implemented by subclasses to provide a way of updating an already existing
* instance, according to that implementation's concept of 'identity' (i.e. instances that
* are updates / downgrades of one another).
*
* If this returns true, createInstance() will not run, so you should do all update steps in here.
* Otherwise, createInstance() is run as normal.
*/
virtual bool updateInstance() { return false; };
/**
* Creates a new instance.
*
* Returns the instance if it was created or nullptr otherwise.
*/
virtual std::unique_ptr<MinecraftInstance> createInstance() { return nullptr; }
QString getError() const { return m_error_message; }
protected:
void setError(const QString& message) { m_error_message = message; };
protected:
bool m_abort = false;
private:
QString m_error_message;
};