mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
Generalise resource metadata
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@ -5,6 +5,8 @@
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
#include "MetadataHandler.h"
|
||||
#include "ModDetails.h"
|
||||
#include "QObjectPtr.h"
|
||||
|
||||
enum class ResourceType {
|
||||
@ -15,6 +17,13 @@ enum class ResourceType {
|
||||
LITEMOD, //!< The resource is a litemod
|
||||
};
|
||||
|
||||
enum class ResourceStatus {
|
||||
INSTALLED, // Both JAR and Metadata are present
|
||||
NOT_INSTALLED, // Only the Metadata is present
|
||||
NO_METADATA, // Only the JAR is present
|
||||
UNKNOWN, // Default status
|
||||
};
|
||||
|
||||
enum class SortType { NAME, DATE, VERSION, ENABLED, PACK_FORMAT, PROVIDER };
|
||||
|
||||
enum class EnableAction { ENABLE, DISABLE, TOGGLE };
|
||||
@ -46,9 +55,18 @@ class Resource : public QObject {
|
||||
[[nodiscard]] auto type() const -> ResourceType { return m_type; }
|
||||
[[nodiscard]] bool enabled() const { return m_enabled; }
|
||||
|
||||
[[nodiscard]] virtual auto name() const -> QString { return m_name; }
|
||||
[[nodiscard]] virtual auto name() const -> QString;
|
||||
[[nodiscard]] virtual bool valid() const { return m_type != ResourceType::UNKNOWN; }
|
||||
|
||||
[[nodiscard]] auto status() const -> ResourceStatus { return m_status; };
|
||||
[[nodiscard]] auto metadata() -> std::shared_ptr<Metadata::ModStruct> { return m_metadata; }
|
||||
[[nodiscard]] auto metadata() const -> std::shared_ptr<const Metadata::ModStruct> { return m_metadata; }
|
||||
[[nodiscard]] auto provider() const -> QString;
|
||||
|
||||
void setStatus(ResourceStatus status) { m_status = status; }
|
||||
void setMetadata(std::shared_ptr<Metadata::ModStruct>&& metadata);
|
||||
void setMetadata(const Metadata::ModStruct& metadata) { setMetadata(std::make_shared<Metadata::ModStruct>(metadata)); }
|
||||
|
||||
/** Compares two Resources, for sorting purposes, considering a ascending order, returning:
|
||||
* > 0: 'this' comes after 'other'
|
||||
* = 0: 'this' is equal to 'other'
|
||||
@ -81,7 +99,8 @@ class Resource : public QObject {
|
||||
}
|
||||
|
||||
// Delete all files of this resource.
|
||||
bool destroy(bool attemptTrash = true);
|
||||
auto destroy(bool attemptTrash = true) -> bool;
|
||||
auto destroy(QDir& index_dir, bool preserve_metadata = false, bool attempt_trash = true) -> bool;
|
||||
|
||||
[[nodiscard]] auto isSymLink() const -> bool { return m_file_info.isSymLink(); }
|
||||
|
||||
@ -110,6 +129,11 @@ class Resource : public QObject {
|
||||
/* The type of file we're dealing with. */
|
||||
ResourceType m_type = ResourceType::UNKNOWN;
|
||||
|
||||
/* Installation status of the resource. */
|
||||
ResourceStatus m_status = ResourceStatus::UNKNOWN;
|
||||
|
||||
std::shared_ptr<Metadata::ModStruct> m_metadata = nullptr;
|
||||
|
||||
/* Whether the resource is enabled (e.g. shows up in the game) or not. */
|
||||
bool m_enabled = true;
|
||||
|
||||
|
Reference in New Issue
Block a user