summaryrefslogtreecommitdiffstats
path: root/src/common/settings_common.h
diff options
context:
space:
mode:
authorlat9nq <22451773+lat9nq@users.noreply.github.com>2023-06-12 23:05:30 +0200
committerlat9nq <22451773+lat9nq@users.noreply.github.com>2023-07-21 16:56:54 +0200
commit11e7e1b8cec5a665bdc6c9e702f83ad6ea35dd6b (patch)
treec308cfcddc0ffd20561114559329411242e31bb5 /src/common/settings_common.h
parentsettings_setting: Fix errors (diff)
downloadyuzu-11e7e1b8cec5a665bdc6c9e702f83ad6ea35dd6b.tar
yuzu-11e7e1b8cec5a665bdc6c9e702f83ad6ea35dd6b.tar.gz
yuzu-11e7e1b8cec5a665bdc6c9e702f83ad6ea35dd6b.tar.bz2
yuzu-11e7e1b8cec5a665bdc6c9e702f83ad6ea35dd6b.tar.lz
yuzu-11e7e1b8cec5a665bdc6c9e702f83ad6ea35dd6b.tar.xz
yuzu-11e7e1b8cec5a665bdc6c9e702f83ad6ea35dd6b.tar.zst
yuzu-11e7e1b8cec5a665bdc6c9e702f83ad6ea35dd6b.zip
Diffstat (limited to 'src/common/settings_common.h')
-rw-r--r--src/common/settings_common.h96
1 files changed, 71 insertions, 25 deletions
diff --git a/src/common/settings_common.h b/src/common/settings_common.h
index 93fddeba6..81d59115d 100644
--- a/src/common/settings_common.h
+++ b/src/common/settings_common.h
@@ -1,3 +1,6 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
#pragma once
#include <forward_list>
@@ -40,31 +43,7 @@ enum class Category : u32 {
MaxEnum,
};
-class BasicSetting {
-protected:
- explicit BasicSetting() = default;
-
-public:
- virtual ~BasicSetting() = default;
-
- virtual Category Category() const = 0;
- virtual constexpr bool Switchable() const = 0;
- virtual std::string ToString() const = 0;
- virtual std::string ToStringGlobal() const;
- virtual void LoadString(const std::string& load) = 0;
- virtual std::string Canonicalize() const = 0;
- virtual const std::string& GetLabel() const = 0;
- virtual std::string DefaultToString() const = 0;
- virtual bool Save() const = 0;
- virtual std::type_index TypeId() const = 0;
- virtual constexpr bool IsEnum() const = 0;
- virtual bool RuntimeModfiable() const = 0;
- virtual void SetGlobal(bool global) {}
- virtual constexpr u32 Id() const = 0;
- virtual std::string MinVal() const = 0;
- virtual std::string MaxVal() const = 0;
- virtual bool UsingGlobal() const;
-};
+class BasicSetting;
class Linkage {
public:
@@ -75,4 +54,71 @@ public:
u32 count;
};
+class BasicSetting {
+protected:
+ explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_,
+ bool save_, bool runtime_modifiable_);
+
+public:
+ virtual ~BasicSetting();
+
+ /* Data retrieval */
+
+ [[nodiscard]] virtual std::string ToString() const = 0;
+ [[nodiscard]] virtual std::string ToStringGlobal() const;
+ [[nodiscard]] virtual std::string DefaultToString() const = 0;
+ [[nodiscard]] virtual std::string MinVal() const = 0;
+ [[nodiscard]] virtual std::string MaxVal() const = 0;
+ virtual void LoadString(const std::string& load) = 0;
+ [[nodiscard]] virtual std::string Canonicalize() const = 0;
+
+ /* Identification */
+
+ [[nodiscard]] virtual std::type_index TypeId() const = 0;
+ [[nodiscard]] virtual constexpr bool IsEnum() const = 0;
+ /**
+ * Returns whether the current setting is Switchable.
+ *
+ * @returns If the setting is a SwitchableSetting
+ */
+ [[nodiscard]] virtual constexpr bool Switchable() const {
+ return false;
+ }
+ /**
+ * Returns the save preference of the setting i.e. when saving or reading the setting from a
+ * frontend, whether this setting should be skipped.
+ *
+ * @returns The save preference
+ */
+ [[nodiscard]] bool Save() const;
+ [[nodiscard]] bool RuntimeModfiable() const;
+ [[nodiscard]] constexpr u32 Id() const {
+ return id;
+ }
+ /**
+ * Returns the setting's category AKA INI group.
+ *
+ * @returns The setting's category
+ */
+ [[nodiscard]] Category Category() const;
+ /**
+ * Returns the label this setting was created with.
+ *
+ * @returns A reference to the label
+ */
+ [[nodiscard]] const std::string& GetLabel() const;
+
+ /* Switchable settings */
+
+ virtual void SetGlobal(bool global);
+ [[nodiscard]] virtual bool UsingGlobal() const;
+
+private:
+ const std::string label; ///< The setting's label
+ const enum Category category; ///< The setting's category AKA INI group
+ const u32 id;
+ const bool save;
+ const bool runtime_modifiable;
+};
+
} // namespace Settings