// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CommonActivatableWidget.h" #include "Containers/Array.h" #include "CoreTypes.h" #include "GameSettingRegistry.h" #include "GameSettingRegistryChangeTracker.h" #include "Misc/AssertionMacros.h" #include "UObject/NameTypes.h" #include "UObject/UObjectGlobals.h" #include "GameSettingScreen.generated.h" class UGameSetting; class UGameSettingCollection; class UGameSettingPanel; class UObject; class UWidget; struct FFrame; enum class EGameSettingChangeReason : uint8; /** * */ UCLASS(Abstract, meta = (Category = "Settings", DisableNativeTick)) class GAMESETTINGS_API UGameSettingScreen : public UCommonActivatableWidget { GENERATED_BODY() public: protected: virtual void NativeOnInitialized() override; virtual void NativeOnActivated() override; virtual void NativeOnDeactivated() override; virtual UWidget* NativeGetDesiredFocusTarget() const override; UFUNCTION(BlueprintCallable) void NavigateToSetting(FName SettingDevName); UFUNCTION(BlueprintCallable) void NavigateToSettings(const TArray& SettingDevNames); UFUNCTION(BlueprintNativeEvent) void OnSettingsDirtyStateChanged(bool bSettingsDirty); virtual void OnSettingsDirtyStateChanged_Implementation(bool bSettingsDirty) { } UFUNCTION(BlueprintCallable) bool AttemptToPopNavigation(); UFUNCTION(BlueprintCallable) UGameSettingCollection* GetSettingCollection(FName SettingDevName, bool& HasAnySettings); protected: virtual UGameSettingRegistry* CreateRegistry() PURE_VIRTUAL(, return nullptr;); template GameSettingRegistryT* GetRegistry() const { return Cast(const_cast(this)->GetOrCreateRegistry()); } UFUNCTION(BlueprintCallable) virtual void CancelChanges(); UFUNCTION(BlueprintCallable) virtual void ApplyChanges(); UFUNCTION(BlueprintCallable) bool HaveSettingsBeenChanged() const { return ChangeTracker.HaveSettingsBeenChanged(); } void ClearDirtyState(); void HandleSettingChanged(UGameSetting* Setting, EGameSettingChangeReason Reason); FGameSettingRegistryChangeTracker ChangeTracker; private: UGameSettingRegistry* GetOrCreateRegistry(); private: // Bound Widgets UPROPERTY(BlueprintReadOnly, meta = (BindWidget, BlueprintProtected = true, AllowPrivateAccess = true)) TObjectPtr Settings_Panel; UPROPERTY(Transient) mutable TObjectPtr Registry; };