Class USFSettingsSubsystem
ClassList > USFSettingsSubsystem
The subsystem that manages all settings data and logic at runtime. More...
#include "SFSettingsSubsystem.h"
Inherits the following classes: UGameInstanceSubsystem
Public Attributes
| Type | Name |
|---|---|
| FOnSFSettingChanged | OnSettingValueChanged |
| FOnSFSettingSaved | OnSettingValueSaved |
| FOnSFSettingsInitialized | OnSettingsInitialized |
Public Functions
| Type | Name |
|---|---|
| bool | AreAnySettingsDirty () const |
| class USFSettingValue * | GetDefaultSettingValue (const FGameplayTag SettingTag) const |
| class USFSettingOptionSource * | GetDynamicOptionSource (const FGameplayTag & SettingTag) const |
| FGameplayTag | GetKeybindingCollision (const struct FKey Key, const FGameplayTagContainer CollisionChannels, const FGameplayTag SettingTagToIgnore) const |
| TArray< USFSettingCategory * > | GetRootCategories () const |
| class USFSettingValue * | GetSavedSettingValue (const FGameplayTag SettingTag) const |
| class USFSettingDefinition * | GetSettingDefinition (const FGameplayTag & SettingTag) const |
| class USFSettingValue * | GetSettingValue (const FGameplayTag SettingTag) const |
| bool | IsInitialized () const |
| bool | IsSettingDirty (const FGameplayTag SettingTag) const |
| bool | IsSettingEditable (const FGameplayTag & SettingTag) const |
| bool | IsSettingVisible (const FGameplayTag & SettingTag) const |
| void | ResetSettingToDefault (const FGameplayTag SettingTag) |
| void | ResetSettingsToDefault () |
| void | RevertSetting (const FGameplayTag SettingTag) |
| void | RevertSettings () |
| void | SaveSettings () |
| void | SetSettingValue (const FGameplayTag SettingTag, const class USFSettingValue * NewValue) |
| bool | UpdateKeybinding (const FGameplayTag SettingTag, struct FSFKeybindValueData & NewValue, const enum ESFKeybindCollisionResolution ResolutionPolicy) |
Protected Attributes
| Type | Name |
|---|---|
| TMap< FGameplayTag, TObjectPtr< class USFSettingValue > > | CurrentValues |
| TMap< FGameplayTag, TObjectPtr< class USFSettingOptionSource > > | DynamicOptionSources |
| TMap< FGameplayTag, TObjectPtr< class USFSettingDefinition > > | RegisteredSettings |
| TMap< FGameplayTag, TObjectPtr< class USFSettingValue > > | SavedValues |
| TObjectPtr< class USFSettingsRegistry > | SettingsRegistry |
Protected Functions
| Type | Name |
|---|---|
| void | LoadSettingsFromSaveGame () |
| bool | ResolveKeybindingCollision (const FGameplayTag & SettingBeingUpdated, const struct FKey & NewKey, const struct FKey & OldKey, const FGameplayTagContainer & CollisionChannels, const enum ESFKeybindCollisionResolution & ResolutionPolicy) |
| void | SaveSettingsToSaveGame () |
Detailed Description
This subsystem is responsible for managing all settings data and logic at runtime. This includes tasks such as:
- Asynchronously loads setting definitions and categories from the settings registry on initialization
- Manages current and saved setting values
- Checks conditions for settings' visibility and editability
- Handles saving and loading settings to disk.
- Among other things.
Note:
BlueprintType
Public Attributes Documentation
variable OnSettingValueChanged
FOnSFSettingChanged USFSettingsSubsystem::OnSettingValueChanged;
Event fired when a setting's current active value is changed.
Note:
BlueprintAssignable
variable OnSettingValueSaved
FOnSFSettingSaved USFSettingsSubsystem::OnSettingValueSaved;
Event fired when a setting's current active value is saved to disk.
Note:
BlueprintAssignable
variable OnSettingsInitialized
FOnSFSettingsInitialized USFSettingsSubsystem::OnSettingsInitialized;
Event fired when the settings registry has finished loading and saved setting values have been loaded from disk, indicating that the subsystem is ready to be used.
Public Functions Documentation
function AreAnySettingsDirty
bool USFSettingsSubsystem::AreAnySettingsDirty () const
Check if any setting has its current active value different from its saved value.
Returns:
true if there is at least one setting that is dirty, false if all settings are clean or if there are no registered settings.
Note:
BlueprintPure
function GetDefaultSettingValue
class USFSettingValue * USFSettingsSubsystem::GetDefaultSettingValue (
const FGameplayTag SettingTag
) const
Get the default value of a setting associated with the given setting Gameplay Tag.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Returns:
The default value of the setting associated with the given setting Gameplay Tag. Returns nullptr if the tag is not found or if the value is invalid.
Note:
BlueprintPure
function GetDynamicOptionSource
class USFSettingOptionSource * USFSettingsSubsystem::GetDynamicOptionSource (
const FGameplayTag & SettingTag
) const
Get the dynamic option source object associated with the given setting Gameplay Tag if it is a discrete setting with dynamic options.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Returns:
The setting option source object associated with the given setting Gameplay Tag. Returns nullptr if invalid.
Note:
BlueprintPure
function GetKeybindingCollision
FGameplayTag USFSettingsSubsystem::GetKeybindingCollision (
const struct FKey Key,
const FGameplayTagContainer CollisionChannels,
const FGameplayTag SettingTagToIgnore
) const
Check for keybinding collisions with a given input key and collision channels, excluding a specific setting.
Parameters:
KeyThe input key to check for collisions.CollisionChannelsThe Gameplay Tag container of collision channels to check against. Only settings that have at least one of these tags in their collision channels will be checked for collision.SettingTagToIgnoreThe Gameplay Tag of the setting to ignore during collision check. This is useful when updating a keybinding for a specific setting and you want to ignore collision with its current keybinding.
Returns:
The Gameplay Tag of the setting that has a colliding keybinding, or an empty tag if there are no collisions.
Note:
BlueprintPure
function GetRootCategories
TArray< USFSettingCategory * > USFSettingsSubsystem::GetRootCategories () const
Get the collection of root categories.
Returns:
An array of root categories.
Note:
BlueprintPure
function GetSavedSettingValue
class USFSettingValue * USFSettingsSubsystem::GetSavedSettingValue (
const FGameplayTag SettingTag
) const
Get the saved value of a setting associated with the given setting Gameplay Tag.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Returns:
The saved value of the setting associated with the given setting Gameplay Tag. Returns the default setting if no saved value is found. Returns nullptr if the tag is not found or if the value is invalid.
Note:
BlueprintPure
function GetSettingDefinition
class USFSettingDefinition * USFSettingsSubsystem::GetSettingDefinition (
const FGameplayTag & SettingTag
) const
Get the setting definition associated with the given setting Gameplay Tag
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Returns:
The setting definition Data Asset associated with the given setting Gameplay Tag. Returns nullptr if the tag is not found or if the associated asset failed to load.
Note:
BlueprintPure
function GetSettingValue
class USFSettingValue * USFSettingsSubsystem::GetSettingValue (
const FGameplayTag SettingTag
) const
Get the current active value of a setting associated with the given setting Gameplay Tag.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Returns:
The current active value of the setting associated with the given setting Gameplay Tag. Returns the default setting if no current value is found. Returns nullptr if the tag is not found or if the value is invalid.
Note:
BlueprintPure
function IsInitialized
inline bool USFSettingsSubsystem::IsInitialized () const
Checks if the settings registry has finished loading and saved setting values have been loaded from disk.
Returns:
true if the subsystem is ready to be used, false if the settings registry is still loading or if there was an error during initialization.
Note:
BlueprintPure
function IsSettingDirty
bool USFSettingsSubsystem::IsSettingDirty (
const FGameplayTag SettingTag
) const
Check if the current active value of the setting associated with the given setting Gameplay Tag is different from its saved value.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Returns:
true if they are different or if one of them is invalid, false if they are the same or if they are both invalid.
Note:
BlueprintPure
function IsSettingEditable
bool USFSettingsSubsystem::IsSettingEditable (
const FGameplayTag & SettingTag
) const
Check if a setting associated with the given setting Gameplay Tag should be editable/enabled based on its editability conditions defined in its setting definition.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Returns:
true if the setting should be editable/enabled, false if it should be disabled or if the tag's setting is not found.
Note:
BlueprintPure
function IsSettingVisible
bool USFSettingsSubsystem::IsSettingVisible (
const FGameplayTag & SettingTag
) const
Check if a setting associated with the given setting Gameplay Tag should be visible based on its visibility conditions defined in its setting definition.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Returns:
true if the setting should be visible, false if it should be hidden or if the tag's setting is not found.
Note:
BlueprintPure
function ResetSettingToDefault
void USFSettingsSubsystem::ResetSettingToDefault (
const FGameplayTag SettingTag
)
Discard current active value and reset to default value for the setting associated with the given setting Gameplay Tag. Does not change saved value. Fires OnSettingValueChanged if the value was reset.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Note:
BlueprintCallable
function ResetSettingsToDefault
void USFSettingsSubsystem::ResetSettingsToDefault ()
Discard the current active value and reset to default value for all settings. Does not change saved values.
Note:
BlueprintCallable
function RevertSetting
void USFSettingsSubsystem::RevertSetting (
const FGameplayTag SettingTag
)
Discard current active value and revert to saved value for the setting associated with the given setting Gameplay Tag. Does not change saved value. Fires OnSettingValueChanged if the value was reverted.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Note:
BlueprintCallable
function RevertSettings
void USFSettingsSubsystem::RevertSettings ()
Discard the current active value and revert to saved value for all settings that have unsaved changes. Does not change saved values.
Note:
BlueprintCallable
function SaveSettings
void USFSettingsSubsystem::SaveSettings ()
Save and serialize all current active setting values to disk, overwriting previous saved values.
Note:
BlueprintCallable
function SetSettingValue
void USFSettingsSubsystem::SetSettingValue (
const FGameplayTag SettingTag,
const class USFSettingValue * NewValue
)
Update the current active value of a setting associated with the given setting Gameplay Tag. Does not save value to disk.
Parameters:
SettingTagThe Gameplay Tag associated with the setting.
Note:
BlueprintCallable
function UpdateKeybinding
bool USFSettingsSubsystem::UpdateKeybinding (
const FGameplayTag SettingTag,
struct FSFKeybindValueData & NewValue,
const enum ESFKeybindCollisionResolution ResolutionPolicy
)
Update a keybinding for a setting with specific collision handling. If the new keybinding collides with existing keybindings based on the given collision channels, the collision will be resolved according to the specified resolution policy.
Parameters:
SettingTagThe Gameplay Tag of the setting to update the keybinding for.NewValueThe new keybinding value data to apply to the setting.ResolutionPolicyThe policy to use for resolving keybinding collisions if the new keybinding collides with existing keybindings. AllowDuplicate means the new keybinding will be applied even if there is a collision. Overwrite means the existing conflicting keybind will be removed. Swap means the existing conflicting keybind will be changed to the new keybinding's old value.
Returns:
true if the keybinding was updated successfully, false if there was an error such as the setting tag not being found, the new value being invalid, or if collision resolution failed.
Note:
BlueprintCallable
Protected Attributes Documentation
variable CurrentValues
TMap<FGameplayTag, TObjectPtr<class USFSettingValue> > USFSettingsSubsystem::CurrentValues;
The map of setting GameplayTag to current active value for registered settings. Used for managing current setting values at runtime.
Note:
Transient
variable DynamicOptionSources
TMap<FGameplayTag, TObjectPtr<class USFSettingOptionSource> > USFSettingsSubsystem::DynamicOptionSources;
The map of setting GameplayTag to setting setting option source object for registered discrete settings wtih dynamic options.
Note:
Transient
variable RegisteredSettings
TMap<FGameplayTag, TObjectPtr<class USFSettingDefinition> > USFSettingsSubsystem::RegisteredSettings;
The map of setting GameplayTag to setting definition Data Asset for registered settings. Used for quick lookup of setting definitions at runtime.
Note:
Transient
variable SavedValues
TMap<FGameplayTag, TObjectPtr<class USFSettingValue> > USFSettingsSubsystem::SavedValues;
The map of setting GameplayTag to saved value for registered settings. Used for managing saved setting values at runtime and for saving/loading settings to disk.
Note:
Transient
variable SettingsRegistry
TObjectPtr<class USFSettingsRegistry> USFSettingsSubsystem::SettingsRegistry;
Transient pointer to the loaded settings registry asset.
Note:
Transient
Protected Functions Documentation
function LoadSettingsFromSaveGame
void USFSettingsSubsystem::LoadSettingsFromSaveGame ()
Load saved setting values from disk and update CurrentValues and SavedValues maps accordingly. Called during initialization after settings registry is loaded.
function ResolveKeybindingCollision
bool USFSettingsSubsystem::ResolveKeybindingCollision (
const FGameplayTag & SettingBeingUpdated,
const struct FKey & NewKey,
const struct FKey & OldKey,
const FGameplayTagContainer & CollisionChannels,
const enum ESFKeybindCollisionResolution & ResolutionPolicy
)
Check for keybinding collisions with a given new keybinding for a specific setting and resolve them according to the specified resolution policy.
Parameters:
SettingBeingUpdatedThe Gameplay Tag of the setting that is being updated with the new keybinding.NewKeyThe new keybinding value that is being applied to the setting.OldKeyThe old keybinding value that is being replaced by the new keybinding for the setting.CollisionChannelsThe Gameplay Tag container of collision channels to check against. Only settings that have at least one of these tags in their collision channels will be checked for collision.ResolutionPolicyThe policy to use for resolving keybinding collisions if the new keybinding collides with existing keybindings. AllowDuplicate means the new keybinding will be applied even if there is a collision. Overwrite means the existing conflicting keybind will be removed. Swap means the existing conflicting keybind will be changed to the new keybinding's old value.
Returns:
true if the collision was resolved successfully, false if resolution failed.
function SaveSettingsToSaveGame
void USFSettingsSubsystem::SaveSettingsToSaveGame ()
Save current active setting values to disk and update SavedValues map accordingly. Called when SaveSettings is called.
The documentation for this class was generated from the following file Source/SettingsFramework/Public/SFSettingsSubsystem.h