// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "GameSetting.h" #include "Templates/Casts.h" #include "GameSettingRegistry.generated.h" #define UE_API GAMESETTINGS_API struct FGameplayTag; //-------------------------------------- // UGameSettingRegistry //-------------------------------------- class ULocalPlayer; struct FGameSettingFilterState; enum class EGameSettingChangeReason : uint8; /** * */ UCLASS(MinimalAPI, Abstract, BlueprintType) class UGameSettingRegistry : public UObject { GENERATED_BODY() public: DECLARE_EVENT_TwoParams(UGameSettingRegistry, FOnSettingChanged, UGameSetting*, EGameSettingChangeReason); DECLARE_EVENT_OneParam(UGameSettingRegistry, FOnSettingEditConditionChanged, UGameSetting*); FOnSettingChanged OnSettingChangedEvent; FOnSettingEditConditionChanged OnSettingEditConditionChangedEvent; DECLARE_EVENT_TwoParams(UGameSettingRegistry, FOnSettingNamedActionEvent, UGameSetting* /*Setting*/, FGameplayTag /*GameSettings_Action_Tag*/); FOnSettingNamedActionEvent OnSettingNamedActionEvent; /** Navigate to the child settings of the provided setting. */ DECLARE_EVENT_OneParam(UGameSettingRegistry, FOnExecuteNavigation, UGameSetting* /*Setting*/); FOnExecuteNavigation OnExecuteNavigationEvent; public: UE_API UGameSettingRegistry(); UE_API void Initialize(ULocalPlayer* InLocalPlayer); UE_API virtual void Regenerate(); UE_API virtual bool IsFinishedInitializing() const; UE_API virtual void SaveChanges(); UE_API void GetSettingsForFilter(const FGameSettingFilterState& FilterState, TArray& InOutSettings); UE_API UGameSetting* FindSettingByDevName(const FName& SettingDevName); template T* FindSettingByDevNameChecked(const FName& SettingDevName) { T* Setting = Cast(FindSettingByDevName(SettingDevName)); check(Setting); return Setting; } protected: UE_API virtual void OnInitialize(ULocalPlayer* InLocalPlayer) PURE_VIRTUAL(, ) virtual void OnSettingApplied(UGameSetting* Setting) { } UE_API void RegisterSetting(UGameSetting* InSetting); UE_API void RegisterInnerSettings(UGameSetting* InSetting); // Internal event handlers. UE_API void HandleSettingChanged(UGameSetting* Setting, EGameSettingChangeReason Reason); UE_API void HandleSettingApplied(UGameSetting* Setting); UE_API void HandleSettingEditConditionsChanged(UGameSetting* Setting); UE_API void HandleSettingNamedAction(UGameSetting* Setting, FGameplayTag GameSettings_Action_Tag); UE_API void HandleSettingNavigation(UGameSetting* Setting); UPROPERTY(Transient) TArray> TopLevelSettings; UPROPERTY(Transient) TArray> RegisteredSettings; UPROPERTY(Transient) TObjectPtr OwningLocalPlayer; }; #undef UE_API