Skip to content

Commit

Permalink
update class specification
Browse files Browse the repository at this point in the history
  • Loading branch information
SpontanCombust committed Sep 7, 2023
1 parent ce8bb3f commit d9cec6a
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions doc/class_specification.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
# Class specification


## [ISettingsGroup](../modSettingsFramework/content/scripts/local/settings_group.ws)
Abstract base class which is an analogue to settings groups in XML. Child classes generated by the parser store settings variables.
## [`CSettingsMasterRegistry`](../modSettingsFramework/content/scripts/local/settings_master_registry.ws)
Class that contains all settings master objects and updates them when necessary.

### Public member constants
- `id: name` - value of the id attribute for the group in the XML.
- `defaultPresetIndex: int` - value of the default preset used by the given group. By default it's 0. To see how to instruct the parser deduce default presets refer to [XML specification](./xml_specification.md).
- `FRAMEWORK_VERSION: name` - version of the framework

### Public member functions
- `Init(parent_: ISettingsMaster) : void` - used internally.
- `ValidateSettings() : void` - checks all fields and corrects their values so they adhere to the limits set in the XML, e.g. if the value of a variable corresponding to a slider config is within the correct range.
- `ReadSettings(optional config: CInGameConfigWrapper) : void` - reads the data from game's configuration.
- `WriteSettings(shouldSave: bool, optional config: CInGameConfigWrapper) : void` - writes the data into game's configuration. If 'shouldSave' is true saved the data to disk.
- `ResetSettings(presetIndex: int, shouldSave: bool, optional config: CInGameConfigWrapper) : void` - applies a preset with given id. Automatically updates settings class to reflect this. If 'shouldSave' is true saved the data to disk.
- `ResetSettingsToDefault() : void` - calls Reset() with defaultPresetIndex.
- `EnumValueMappingConfigToUnified(vId: name, val: int) : int` - returns integer value of the unified enum type for options var index in user config. If the config value is not valid for given option, should return -1. More about unified enums in [details](./details.md).
- `EnumValueMappingUnifiedToConfig(vId: name, val: int) : int` - returns the options var index in user config for integer value of unified enum. If the unified value is not valid for given option, should return -1. More about unified enums in [details](./details.md).
- `EnumValueMappingValidateUnified(vId: name, val: int) : int` - If integer value for given enum variable is correct returns said value. Otherwise returns the smallest valid value. More about unified enums in [details](./details.md).
- `AddSettings(settingsMaster : ISettingsMaster, id : name): void` - adds a settings master object to the registry and initialises it. The 'id' parameter is used to identify said object later.
- `GetSettings(id : name) : ISettingsMaster` - returns stored settings master object or NULL if it can't find any with this id.
- `RemoveSettings(id : name) : void` - removes settings master object from the registry.
- `ReadAllSettings() : void` - reads settings values from user config into stored settings master objects.


## [`ISettingsMaster`](../modSettingsFramework/content/scripts/local/settings_master.ws)
Expand All @@ -37,3 +30,22 @@ Abstract base class for the settings class generated by the parser. The child cl
- `ReadSettingValue(config: CInGameConfigWrapper, groupId: name, varId: name) : string` - method used by ReadSettings to retrieve values from game config. By default it used CInGameConfigWrapper directly.
- `WriteSettingValue(config: CInGameConfigWrapper, groupId: name, varId: name, value: string) : void` - method used by WriteSettings to write values into game config. By default it used CInGameConfigWrapper directly.
- `ResetSettingValues(config: CInGameConfigWrapper, groupId: name, presetIndex: int) : void` - method used by ISettingsGroup's Reset method to apply a preset. By default it used CInGameConfigWrapper directly.


## [ISettingsGroup](../modSettingsFramework/content/scripts/local/settings_group.ws)
Abstract base class which is an analogue to settings groups in XML. Child classes generated by the parser store settings variables.

### Public member constants
- `id: name` - value of the id attribute for the group in the XML.
- `defaultPresetIndex: int` - value of the default preset used by the given group. By default it's 0. To see how to instruct the parser deduce default presets refer to [XML specification](./xml_specification.md).

### Public member functions
- `Init(parent_: ISettingsMaster) : void` - used internally.
- `ValidateSettings() : void` - checks all fields and corrects their values so they adhere to the limits set in the XML, e.g. if the value of a variable corresponding to a slider config is within the correct range.
- `ReadSettings(optional config: CInGameConfigWrapper) : void` - reads the data from game's configuration.
- `WriteSettings(shouldSave: bool, optional config: CInGameConfigWrapper) : void` - writes the data into game's configuration. If 'shouldSave' is true saved the data to disk.
- `ResetSettings(presetIndex: int, shouldSave: bool, optional config: CInGameConfigWrapper) : void` - applies a preset with given id. Automatically updates settings class to reflect this. If 'shouldSave' is true saved the data to disk.
- `ResetSettingsToDefault() : void` - calls Reset() with defaultPresetIndex.
- `EnumValueMappingConfigToUnified(vId: name, val: int) : int` - returns integer value of the unified enum type for options var index in user config. If the config value is not valid for given option, should return -1. More about unified enums in [details](./details.md).
- `EnumValueMappingUnifiedToConfig(vId: name, val: int) : int` - returns the options var index in user config for integer value of unified enum. If the unified value is not valid for given option, should return -1. More about unified enums in [details](./details.md).
- `EnumValueMappingValidateUnified(vId: name, val: int) : int` - If integer value for given enum variable is correct returns said value. Otherwise returns the smallest valid value. More about unified enums in [details](./details.md).

0 comments on commit d9cec6a

Please sign in to comment.