aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/mod/Resource.h
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/minecraft/mod/Resource.h')
-rw-r--r--launcher/minecraft/mod/Resource.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/launcher/minecraft/mod/Resource.h b/launcher/minecraft/mod/Resource.h
index e76bc49e..cee1f172 100644
--- a/launcher/minecraft/mod/Resource.h
+++ b/launcher/minecraft/mod/Resource.h
@@ -22,6 +22,12 @@ enum class SortType {
ENABLED,
};
+enum class EnableAction {
+ ENABLE,
+ DISABLE,
+ TOGGLE
+};
+
/** General class for managed resources. It mirrors a file in disk, with some more info
* for display and house-keeping purposes.
*
@@ -47,6 +53,7 @@ class Resource : public QObject {
[[nodiscard]] auto dateTimeChanged() const -> QDateTime { return m_changed_date_time; }
[[nodiscard]] auto internal_id() const -> QString { return m_internal_id; }
[[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 bool valid() const { return m_type != ResourceType::UNKNOWN; }
@@ -65,6 +72,12 @@ class Resource : public QObject {
*/
[[nodiscard]] virtual bool applyFilter(QRegularExpression filter) const;
+ /** Changes the enabled property, according to 'action'.
+ *
+ * Returns whether a change was applied to the Resource's properties.
+ */
+ bool enable(EnableAction action);
+
[[nodiscard]] auto shouldResolve() const -> bool { return !m_is_resolving && !m_is_resolved; }
[[nodiscard]] auto isResolving() const -> bool { return m_is_resolving; }
[[nodiscard]] auto resolutionTicket() const -> int { return m_resolution_ticket; }
@@ -92,6 +105,9 @@ class Resource : public QObject {
/* The type of file we're dealing with. */
ResourceType m_type = ResourceType::UNKNOWN;
+ /* Whether the resource is enabled (e.g. shows up in the game) or not. */
+ bool m_enabled = true;
+
/* Used to keep trach of pending / concluded actions on the resource. */
bool m_is_resolving = false;
bool m_is_resolved = false;