From a5f56cb7cb36a0657f9906b2a0a01261d5132eb1 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:18:59 +0300 Subject: [PATCH] a bit of docs on modsettingsmanager --- loader/src/loader/ModSettingsManager.cpp | 2 ++ loader/src/loader/ModSettingsManager.hpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/loader/src/loader/ModSettingsManager.cpp b/loader/src/loader/ModSettingsManager.cpp index 6c68b12a..6d43ca58 100644 --- a/loader/src/loader/ModSettingsManager.cpp +++ b/loader/src/loader/ModSettingsManager.cpp @@ -30,6 +30,8 @@ ModSettingsManager::ModSettingsManager(ModMetadata const& metadata) } ModSettingsManager::~ModSettingsManager() {} +ModSettingsManager::ModSettingsManager(ModSettingsManager&&) = default; + Result<> ModSettingsManager::registerCustomSetting(std::string_view key, std::shared_ptr ptr) { if (!ptr) { return Err("Custom settings must not be null!"); diff --git a/loader/src/loader/ModSettingsManager.hpp b/loader/src/loader/ModSettingsManager.hpp index 5f78c340..a1593f91 100644 --- a/loader/src/loader/ModSettingsManager.hpp +++ b/loader/src/loader/ModSettingsManager.hpp @@ -14,10 +14,28 @@ public: ModSettingsManager(ModMetadata const& metadata); ~ModSettingsManager(); + ModSettingsManager(ModSettingsManager&&); + ModSettingsManager(ModSettingsManager const&) = delete; + + /** + * Load setting values from savedata. + * The format of the savedata should be an object with the keys being + * setting IDs and then the values the values of the saved settings + * @returns Ok if no horrible errors happened. Note that a setting value + * missing is not considered a horrible error, but will instead just log a + * warning into the console! + */ Result<> load(matjson::Value const& json); + /** + * Save setting values to savedata. + * The format of the savedata will be an object with the keys being + * setting IDs and then the values the values of the saved settings + * @note If saving a setting fails, it will log a warning to the console + */ void save(matjson::Value& json); Result<> registerCustomSetting(std::string_view key, std::shared_ptr ptr); + // remove in v4 Result<> registerLegacyCustomSetting(std::string_view key, std::unique_ptr&& ptr); std::shared_ptr get(std::string_view key);