diff options
author | TheKodeToad <TheKodeToad@proton.me> | 2023-08-16 20:46:16 +0100 |
---|---|---|
committer | TheKodeToad <TheKodeToad@proton.me> | 2023-08-16 22:23:38 +0100 |
commit | 3e2733d840d24ce4f46b49bca0b8656d4d6e3d87 (patch) | |
tree | 386113207514b8071b0122b318c10439259ca83c /launcher/BaseInstance.h | |
parent | 57430fd189aed592a170d597de61b3acabaaa43d (diff) | |
parent | c88088c91a92a371a9bc2b7384c2897157772b7e (diff) | |
download | PrismLauncher-3e2733d840d24ce4f46b49bca0b8656d4d6e3d87.tar.gz PrismLauncher-3e2733d840d24ce4f46b49bca0b8656d4d6e3d87.tar.bz2 PrismLauncher-3e2733d840d24ce4f46b49bca0b8656d4d6e3d87.zip |
Merge branch 'develop' into better-launch
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher/BaseInstance.h')
-rw-r--r-- | launcher/BaseInstance.h | 87 |
1 files changed, 31 insertions, 56 deletions
diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h index 7da4e20b..47fff595 100644 --- a/launcher/BaseInstance.h +++ b/launcher/BaseInstance.h @@ -47,16 +47,16 @@ #include "settings/SettingsObject.h" -#include "settings/INIFile.h" #include "BaseVersionList.h" -#include "minecraft/auth/MinecraftAccount.h" #include "MessageLevel.h" +#include "minecraft/auth/MinecraftAccount.h" #include "pathmatcher/IPathMatcher.h" +#include "settings/INIFile.h" #include "net/Mode.h" -#include "minecraft/launch/MinecraftServerTarget.h" #include "RuntimeContext.h" +#include "minecraft/launch/MinecraftServerTarget.h" class QDir; class Task; @@ -74,23 +74,21 @@ typedef std::shared_ptr<BaseInstance> InstancePtr; * To create a new instance type, create a new class inheriting from this class * and implement the pure virtual functions. */ -class BaseInstance : public QObject, public std::enable_shared_from_this<BaseInstance> -{ +class BaseInstance : public QObject, public std::enable_shared_from_this<BaseInstance> { Q_OBJECT -protected: + protected: /// no-touchy! - BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir); + BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir); -public: /* types */ - enum class Status - { + public: /* types */ + enum class Status { Present, - Gone // either nuked or invalidated + Gone // either nuked or invalidated }; -public: + public: /// virtual destructor to make sure the destruction is COMPLETE - virtual ~BaseInstance() {}; + virtual ~BaseInstance() {} virtual void saveNow() = 0; @@ -119,10 +117,7 @@ public: QString instanceRoot() const; /// Path to the instance's game root directory. - virtual QString gameRoot() const - { - return instanceRoot(); - } + virtual QString gameRoot() const { return instanceRoot(); } /// Path to the instance's mods directory. virtual QString modsRoot() const = 0; @@ -153,15 +148,12 @@ public: void copyManagedPack(BaseInstance& other); /// guess log level from a line of game log - virtual MessageLevel::Enum guessLevel([[maybe_unused]] const QString &line, MessageLevel::Enum level) - { - return level; - }; + virtual MessageLevel::Enum guessLevel([[maybe_unused]] const QString& line, MessageLevel::Enum level) { return level; } virtual QStringList extraArguments(); /// Traits. Normally inside the version, depends on instance implementation. - virtual QSet <QString> traits() const = 0; + virtual QSet<QString> traits() const = 0; /** * Gets the time that the instance was last launched. @@ -191,8 +183,7 @@ public: virtual Task::Ptr createUpdateTask(Net::Mode mode) = 0; /// returns a valid launcher (task container) - virtual shared_qobject_ptr<LaunchTask> createLaunchTask( - AuthSessionPtr account, MinecraftServerTargetPtr serverToJoin) = 0; + virtual shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account, MinecraftServerTargetPtr serverToJoin) = 0; /// returns the current launch task (if any) shared_qobject_ptr<LaunchTask> getLaunchTask(); @@ -224,45 +215,30 @@ public: virtual QString typeName() const = 0; void updateRuntimeContext(); - RuntimeContext runtimeContext() const - { - return m_runtimeContext; - } + RuntimeContext runtimeContext() const { return m_runtimeContext; } - bool hasVersionBroken() const - { - return m_hasBrokenVersion; - } + bool hasVersionBroken() const { return m_hasBrokenVersion; } void setVersionBroken(bool value) { - if(m_hasBrokenVersion != value) - { + if (m_hasBrokenVersion != value) { m_hasBrokenVersion = value; emit propertiesChanged(this); } } - bool hasUpdateAvailable() const - { - return m_hasUpdate; - } + bool hasUpdateAvailable() const { return m_hasUpdate; } void setUpdateAvailable(bool value) { - if(m_hasUpdate != value) - { + if (m_hasUpdate != value) { m_hasUpdate = value; emit propertiesChanged(this); } } - bool hasCrashed() const - { - return m_crashed; - } + bool hasCrashed() const { return m_crashed; } void setCrashed(bool value) { - if(m_crashed != value) - { + if (m_crashed != value) { m_crashed = value; emit propertiesChanged(this); } @@ -292,19 +268,19 @@ public: bool removeLinkedInstanceId(const QString& id); bool isLinkedToInstanceId(const QString& id) const; -protected: + protected: void changeStatus(Status newStatus); - SettingsObjectPtr globalSettings() const { return m_global_settings.lock(); }; + SettingsObjectPtr globalSettings() const { return m_global_settings.lock(); } bool isSpecificSettingsLoaded() const { return m_specific_settings_loaded; } void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; } -signals: + signals: /*! * \brief Signal emitted when properties relevant to the instance view change */ - void propertiesChanged(BaseInstance *inst); + void propertiesChanged(BaseInstance* inst); void launchTaskChanged(shared_qobject_ptr<LaunchTask>); @@ -314,10 +290,10 @@ signals: void statusChanged(Status from, Status to); -protected slots: + protected slots: void iconUpdated(QString key); -protected: /* data */ + protected: /* data */ QString m_rootDir; SettingsObjectPtr m_settings; // InstanceFlags m_flags; @@ -326,7 +302,7 @@ protected: /* data */ QDateTime m_timeStarted; RuntimeContext m_runtimeContext; -private: /* data */ + private: /* data */ Status m_status = Status::Present; bool m_crashed = false; bool m_hasUpdate = false; @@ -334,9 +310,8 @@ private: /* data */ SettingsObjectWeakPtr m_global_settings; bool m_specific_settings_loaded = false; - }; Q_DECLARE_METATYPE(shared_qobject_ptr<BaseInstance>) -//Q_DECLARE_METATYPE(BaseInstance::InstanceFlag) -//Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags) +// Q_DECLARE_METATYPE(BaseInstance::InstanceFlag) +// Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags) |