aboutsummaryrefslogtreecommitdiff
path: root/launcher/InstanceCreationTask.h
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-07-07 20:31:24 -0300
committerflow <flowlnlnln@gmail.com>2022-09-20 18:32:36 -0300
commit941d75824af8d8e3deb1dfc0597c9493911f0cf0 (patch)
tree12578af364c0c44bf7a6addf9d855d75d22c6449 /launcher/InstanceCreationTask.h
parentec9ddc4f225c89ea3ccbf24c9a3be36848aa3172 (diff)
downloadPrismLauncher-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.h')
-rw-r--r--launcher/InstanceCreationTask.h47
1 files changed, 30 insertions, 17 deletions
diff --git a/launcher/InstanceCreationTask.h b/launcher/InstanceCreationTask.h
index 23367c3f..af854713 100644
--- a/launcher/InstanceCreationTask.h
+++ b/launcher/InstanceCreationTask.h
@@ -1,26 +1,39 @@
#pragma once
-#include "tasks/Task.h"
-#include "net/NetJob.h"
-#include <QUrl>
-#include "settings/SettingsObject.h"
#include "BaseVersion.h"
#include "InstanceTask.h"
-class InstanceCreationTask : public InstanceTask
-{
+class InstanceCreationTask : public InstanceTask {
Q_OBJECT
-public:
- explicit InstanceCreationTask(BaseVersionPtr version);
- explicit InstanceCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loaderVersion);
+ public:
+ InstanceCreationTask();
+ virtual ~InstanceCreationTask() = default;
-protected:
- //! Entry point for tasks.
- virtual void executeTask() override;
+ protected:
+ void executeTask() final override;
-private: /* data */
- BaseVersionPtr m_version;
- bool m_usingLoader;
- QString m_loader;
- BaseVersionPtr m_loaderVersion;
+ /**
+ * 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 whether the instance creation was successful (true) or not (false).
+ */
+ virtual bool createInstance() { return false; };
+
+ protected:
+ void setError(QString message) { m_error_message = message; };
+
+ private:
+ QString m_error_message;
};