// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "GameSettingValueScalar.h" #include "GameSettingValueScalarDynamic.generated.h" #define UE_API GAMESETTINGS_API struct FNumberFormattingOptions; class FGameSettingDataSource; class UObject; ////////////////////////////////////////////////////////////////////////// // UGameSettingValueScalarDynamic ////////////////////////////////////////////////////////////////////////// typedef TFunction FSettingScalarFormatFunction; UCLASS(MinimalAPI) class UGameSettingValueScalarDynamic : public UGameSettingValueScalar { GENERATED_BODY() public: static UE_API FSettingScalarFormatFunction Raw; static UE_API FSettingScalarFormatFunction RawOneDecimal; static UE_API FSettingScalarFormatFunction RawTwoDecimals; static UE_API FSettingScalarFormatFunction ZeroToOnePercent; static UE_API FSettingScalarFormatFunction ZeroToOnePercent_OneDecimal; static UE_API FSettingScalarFormatFunction SourceAsPercent1; static UE_API FSettingScalarFormatFunction SourceAsPercent100; static UE_API FSettingScalarFormatFunction SourceAsInteger; private: static const FNumberFormattingOptions& GetOneDecimalFormattingOptions(); public: UE_API UGameSettingValueScalarDynamic(); /** UGameSettingValue */ UE_API virtual void Startup() override; UE_API virtual void StoreInitial() override; UE_API virtual void ResetToDefault() override; UE_API virtual void RestoreToInitial() override; /** UGameSettingValueScalar */ UE_API virtual TOptional GetDefaultValue() const override; UE_API virtual void SetValue(double Value, EGameSettingChangeReason Reason = EGameSettingChangeReason::Change) override; UE_API virtual double GetValue() const override; UE_API virtual TRange GetSourceRange() const override; UE_API virtual double GetSourceStep() const override; UE_API virtual FText GetFormattedText() const override; /** UGameSettingValueDiscreteDynamic */ UE_API void SetDynamicGetter(const TSharedRef& InGetter); UE_API void SetDynamicSetter(const TSharedRef& InSetter); UE_API void SetDefaultValue(double InValue); /** */ UE_API void SetDisplayFormat(FSettingScalarFormatFunction InDisplayFormat); /** */ UE_API void SetSourceRangeAndStep(const TRange& InRange, double InSourceStep); /** * The SetSourceRangeAndStep defines the actual range the numbers could move in, but often * the true minimum for the user is greater than the minimum source range, so for example, the range * of some slider might be 0..100, but you want to restrict the slider so that while it shows * a bar that travels from 0 to 100, the user can't set anything lower than some minimum, e.g. 1. * That is the Minimum Limit. */ UE_API void SetMinimumLimit(const TOptional& InMinimum); /** * The SetSourceRangeAndStep defines the actual range the numbers could move in, but rarely * the true maximum for the user is less than the maximum source range, so for example, the range * of some slider might be 0..100, but you want to restrict the slider so that while it shows * a bar that travels from 0 to 100, the user can't set anything lower than some maximum, e.g. 95. * That is the Maximum Limit. */ UE_API void SetMaximumLimit(const TOptional& InMaximum); protected: /** UGameSettingValue */ UE_API virtual void OnInitialized() override; UE_API void OnDataSourcesReady(); protected: TSharedPtr Getter; TSharedPtr Setter; TOptional DefaultValue; double InitialValue = 0; TRange SourceRange = TRange(0, 1); double SourceStep = 0.01; TOptional Minimum; TOptional Maximum; FSettingScalarFormatFunction DisplayFormat; }; #undef UE_API