a bit of docs on modsettingsmanager

This commit is contained in:
HJfod 2024-08-20 13:18:59 +03:00
parent 71eb4a2041
commit a5f56cb7cb
2 changed files with 20 additions and 0 deletions

View file

@ -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<SettingV3> ptr) {
if (!ptr) {
return Err("Custom settings must not be null!");

View file

@ -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<SettingV3> ptr);
// remove in v4
Result<> registerLegacyCustomSetting(std::string_view key, std::unique_ptr<SettingValue>&& ptr);
std::shared_ptr<SettingV3> get(std::string_view key);