2022-05-23 18:41:30 +00:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-09-13 07:18:28 +00:00
|
|
|
#include "Containers/UnrealString.h"
|
|
|
|
#include "GameSettingFilterState.h"
|
2022-05-23 18:41:30 +00:00
|
|
|
#include "GameSettingValue.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
#include "Internationalization/Text.h"
|
|
|
|
#include "Math/Range.h"
|
|
|
|
#include "Math/UnrealMathSSE.h"
|
|
|
|
#include "Misc/AssertionMacros.h"
|
|
|
|
#include "Misc/Optional.h"
|
|
|
|
#include "UObject/UObjectGlobals.h"
|
2022-05-23 18:41:30 +00:00
|
|
|
|
|
|
|
#include "GameSettingValueScalar.generated.h"
|
|
|
|
|
2022-09-13 07:18:28 +00:00
|
|
|
class UObject;
|
|
|
|
|
2022-05-23 18:41:30 +00:00
|
|
|
UCLASS(abstract)
|
|
|
|
class GAMESETTINGS_API UGameSettingValueScalar : public UGameSettingValue
|
|
|
|
{
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
public:
|
|
|
|
UGameSettingValueScalar();
|
|
|
|
|
|
|
|
void SetValueNormalized(double NormalizedValue);
|
|
|
|
double GetValueNormalized() const;
|
|
|
|
|
|
|
|
TOptional<double> GetDefaultValueNormalized() const
|
|
|
|
{
|
|
|
|
TOptional<double> DefaultValue = GetDefaultValue();
|
|
|
|
if (DefaultValue.IsSet())
|
|
|
|
{
|
|
|
|
return FMath::GetMappedRangeValueClamped(GetSourceRange(), TRange<double>(0, 1), DefaultValue.GetValue());
|
|
|
|
}
|
|
|
|
return TOptional<double>();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual TOptional<double> GetDefaultValue() const PURE_VIRTUAL(, return TOptional<double>(););
|
|
|
|
virtual void SetValue(double Value, EGameSettingChangeReason Reason = EGameSettingChangeReason::Change) PURE_VIRTUAL(, );
|
|
|
|
virtual double GetValue() const PURE_VIRTUAL(, return 0;);
|
|
|
|
virtual TRange<double> GetSourceRange() const PURE_VIRTUAL(, return TRange<double>(););
|
|
|
|
virtual double GetSourceStep() const PURE_VIRTUAL(, return 0.01;);
|
|
|
|
double GetNormalizedStepSize() const
|
|
|
|
{
|
|
|
|
TRange<double> 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:
|
|
|
|
};
|