// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "UObject/ObjectMacros.h" #include "GameSettingValue.h" #include "GameSettingValueScalar.generated.h" UCLASS(abstract) class GAMESETTINGS_API UGameSettingValueScalar : public UGameSettingValue { GENERATED_BODY() public: UGameSettingValueScalar(); void SetValueNormalized(double NormalizedValue); double GetValueNormalized() const; TOptional GetDefaultValueNormalized() const { TOptional DefaultValue = GetDefaultValue(); if (DefaultValue.IsSet()) { return FMath::GetMappedRangeValueClamped(GetSourceRange(), TRange(0, 1), DefaultValue.GetValue()); } return TOptional(); } virtual TOptional GetDefaultValue() const PURE_VIRTUAL(, return TOptional();); virtual void SetValue(double Value, EGameSettingChangeReason Reason = EGameSettingChangeReason::Change) PURE_VIRTUAL(, ); virtual double GetValue() const PURE_VIRTUAL(, return 0;); virtual TRange GetSourceRange() const PURE_VIRTUAL(, return TRange();); virtual double GetSourceStep() const PURE_VIRTUAL(, return 0.01;); double GetNormalizedStepSize() const { TRange SourceRange = GetSourceRange(); return GetSourceStep() / FMath::Abs(SourceRange.GetUpperBoundValue() - SourceRange.GetLowerBoundValue()); } virtual FText GetFormattedText() const PURE_VIRTUAL(, return FText::GetEmpty();); virtual FString GetAnalyticsValue() const override { return LexToString(GetValue()); } protected: };