2014-03-14 14:13:41 -04:00
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
2014-04-23 20:18:55 -04:00
# include "EnvironmentQueryEditorPrivatePCH.h"
2014-03-14 14:13:41 -04:00
# include "EnvQueryTestDetails.h"
2014-05-29 17:06:50 -04:00
# include "EnvironmentQuery/EnvQueryTypes.h"
# include "EnvironmentQuery/EnvQueryTest.h"
2014-03-14 14:13:41 -04:00
# define LOCTEXT_NAMESPACE "EnvQueryTestDetails"
TSharedRef < IDetailCustomization > FEnvQueryTestDetails : : MakeInstance ( )
{
return MakeShareable ( new FEnvQueryTestDetails ) ;
}
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void FEnvQueryTestDetails : : CustomizeDetails ( IDetailLayoutBuilder & DetailLayout )
{
2014-05-16 21:50:28 -04:00
AllowWriting = false ;
2014-03-14 14:13:41 -04:00
TArray < TWeakObjectPtr < UObject > > EditedObjects ;
DetailLayout . GetObjectsBeingCustomized ( EditedObjects ) ;
for ( int32 i = 0 ; i < EditedObjects . Num ( ) ; i + + )
{
2014-05-16 21:50:28 -04:00
const UEnvQueryTest * EditedTest = Cast < const UEnvQueryTest > ( EditedObjects [ i ] . Get ( ) ) ;
2014-03-14 14:13:41 -04:00
if ( EditedTest )
{
MyTest = EditedTest ;
break ;
}
}
2014-05-16 21:50:28 -04:00
// Initialize all handles
2014-03-14 14:13:41 -04:00
ConditionHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , Condition ) ) ;
2014-05-16 21:50:28 -04:00
FilterTypeHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , FilterType ) ) ;
ScoreEquationHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , ScoringEquation ) ) ;
TestPurposeHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , TestPurpose ) ) ;
2014-06-10 16:45:28 -04:00
ScoreHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , Weight ) ) ;
2014-05-16 21:50:28 -04:00
ClampMinTypeHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , ClampMinType ) ) ;
ClampMaxTypeHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , ClampMaxType ) ) ;
ScoreClampingMinHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , ScoreClampingMin ) ) ;
FloatFilterMinHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , FloatFilterMin ) ) ;
ScoreClampingMaxHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , ScoreClampingMax ) ) ;
FloatFilterMaxHandle = DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , FloatFilterMax ) ) ;
// Build combo box data values
BuildConditionValues ( ) ;
BuildFilterTestValues ( ) ;
BuildScoreEquationValues ( ) ;
BuildScoreClampingTypeValues ( true , ClampMinTypeValues ) ;
BuildScoreClampingTypeValues ( false , ClampMaxTypeValues ) ;
2014-03-14 14:13:41 -04:00
2014-06-26 17:26:58 -04:00
// // dynamic Condition combo
// IDetailCategoryBuilder& DeprecatedFilterCategory = DetailLayout.EditCategory("Deprecated Filter and Score");
// IDetailPropertyRow& ConditionRow = DeprecatedFilterCategory.AddProperty(ConditionHandle);
// ConditionRow.CustomWidget()
// .NameContent()
// [
// ConditionHandle->CreatePropertyNameWidget()
// ]
// .ValueContent()
// [
// SNew(SComboButton)
// .OnGetMenuContent(this, &FEnvQueryTestDetails::OnGetConditionContent)
// .ContentPadding(FMargin( 2.0f, 2.0f ))
// .ButtonContent()
// [
// SNew(STextBlock)
// .Text(this, &FEnvQueryTestDetails::GetCurrentConditionDesc)
// .Font(IDetailLayoutBuilder::GetDetailFont())
// ]
// ];
// ConditionRow.EditCondition(TAttribute<bool>(this, &FEnvQueryTestDetails::AllowWritingToFiltersFromScore), NULL);
//
// // TODO: Remove!
// IDetailPropertyRow& DiscardFailedRow = DeprecatedFilterCategory.AddProperty(DetailLayout.GetProperty(GET_MEMBER_NAME_CHECKED(UEnvQueryTest, bDiscardFailedItems)));
// DiscardFailedRow.EditCondition(TAttribute<bool>(this, &FEnvQueryTestDetails::AllowWritingToFiltersFromScore), NULL);
//
// // DEPRECATED! Remove as soon as testing is complete!
// IDetailPropertyRow& FloatFilterRow = DeprecatedFilterCategory.AddProperty(DetailLayout.GetProperty(GET_MEMBER_NAME_CHECKED(UEnvQueryTest, FloatFilter)));
// FloatFilterRow.Visibility(TAttribute<EVisibility>::Create(TAttribute<EVisibility>::FGetter::CreateSP(this, &FEnvQueryTestDetails::GetFloatFilterVisibility)));
// FloatFilterRow.EditCondition(TAttribute<bool>(this, &FEnvQueryTestDetails::AllowWritingToFiltersFromScore), NULL);
//
// IDetailPropertyRow& WeightModiferRow = DeprecatedFilterCategory.AddProperty(DetailLayout.GetProperty(GET_MEMBER_NAME_CHECKED(UEnvQueryTest, WeightModifier)));
// WeightModiferRow.EditCondition(TAttribute<bool>(this, &FEnvQueryTestDetails::AllowWritingToFiltersFromScore), NULL);
2014-05-16 21:50:28 -04:00
IDetailCategoryBuilder & TestCategory = DetailLayout . EditCategory ( " Test " ) ;
IDetailPropertyRow & TestPurposeRow = TestCategory . AddProperty ( TestPurposeHandle ) ;
IDetailCategoryBuilder & FilterCategory = DetailLayout . EditCategory ( " Filter " ) ;
IDetailPropertyRow & FilterTypeRow = FilterCategory . AddProperty ( FilterTypeHandle ) ;
FilterTypeRow . CustomWidget ( )
. NameContent ( )
[
FilterTypeHandle - > CreatePropertyNameWidget ( )
]
. ValueContent ( )
[
SNew ( SComboButton )
. OnGetMenuContent ( this , & FEnvQueryTestDetails : : OnGetFilterTestContent )
. ContentPadding ( FMargin ( 2.0f , 2.0f ) )
. ButtonContent ( )
[
SNew ( STextBlock )
. Text ( this , & FEnvQueryTestDetails : : GetCurrentFilterTestDesc )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
] ;
FilterTypeRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetFloatFilterVisibility ) ) ) ;
2014-03-14 14:13:41 -04:00
// filters
2014-05-16 21:50:28 -04:00
IDetailPropertyRow & FloatFilterMinRow = FilterCategory . AddProperty ( DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , FloatFilterMin ) ) ) ;
FloatFilterMinRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetVisibilityOfFloatFilterMin ) ) ) ;
2014-03-14 14:13:41 -04:00
2014-05-16 21:50:28 -04:00
IDetailPropertyRow & FloatFilterMaxRow = FilterCategory . AddProperty ( DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , FloatFilterMax ) ) ) ;
FloatFilterMaxRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetVisibilityOfFloatFilterMax ) ) ) ;
IDetailPropertyRow & BoolFilterRow = FilterCategory . AddProperty ( DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , BoolFilter ) ) ) ;
2014-03-14 14:13:41 -04:00
BoolFilterRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetBoolFilterVisibility ) ) ) ;
2014-05-16 21:50:28 -04:00
IDetailGroup & HackToEnsureFilterCategoryIsVisible = FilterCategory . AddGroup ( " HackForVisibility " , FString ( TEXT ( " " ) ) ) ;
2014-04-23 19:29:53 -04:00
2014-05-16 21:50:28 -04:00
// Scoring
IDetailCategoryBuilder & ScoreCategory = DetailLayout . EditCategory ( " Score " ) ;
2014-03-14 14:13:41 -04:00
2014-05-16 21:50:28 -04:00
//----------------------------
// BEGIN Scoring: Clamping
IDetailGroup & ClampingGroup = ScoreCategory . AddGroup ( " Clamping " , FString ( TEXT ( " Clamping " ) ) ) ;
// Drop-downs for setting type of lower and upper bound normalization
IDetailPropertyRow & ClampMinTypeRow = ClampingGroup . AddPropertyRow ( ClampMinTypeHandle . ToSharedRef ( ) ) ;
ClampMinTypeRow . CustomWidget ( )
. NameContent ( )
[
ClampMinTypeHandle - > CreatePropertyNameWidget ( )
]
. ValueContent ( )
[
SNew ( SComboButton )
. OnGetMenuContent ( this , & FEnvQueryTestDetails : : OnGetClampMinTypeContent )
. ContentPadding ( FMargin ( 2.0f , 2.0f ) )
. ButtonContent ( )
[
SNew ( STextBlock )
. Text ( this , & FEnvQueryTestDetails : : GetClampMinTypeDesc )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
] ;
ClampMinTypeRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetFloatScoreVisibility ) ) ) ;
2014-06-26 17:26:58 -04:00
// Lower Bound for normalization of score if specified independently of filtering.
IDetailPropertyRow & ScoreClampingMinRow = ClampingGroup . AddPropertyRow ( ScoreClampingMinHandle . ToSharedRef ( ) ) ;
ScoreClampingMinRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetVisibilityOfScoreClampingMinimum ) ) ) ;
// Lower Bound for scoring when tied to filter minimum.
IDetailPropertyRow & FloatFilterMinForClampingRow = ClampingGroup . AddPropertyRow ( FloatFilterMinHandle . ToSharedRef ( ) ) ;
FloatFilterMinForClampingRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetVisibilityOfFilterMinForScoreClamping ) ) ) ;
FloatFilterMinForClampingRow . ToolTip ( TEXT ( " See Filter Thresholds under the Filter tab. Values lower than this (before clamping) cause the item to be thrown out as invalid. Values are normalized with this value as the minimum, so items with this value will have a normalized score of 0. " ) ) ;
FloatFilterMinForClampingRow . EditCondition ( TAttribute < bool > ( this , & FEnvQueryTestDetails : : AllowWritingToFiltersFromScore ) , NULL ) ;
2014-05-16 21:50:28 -04:00
IDetailPropertyRow & ClampMaxTypeRow = ClampingGroup . AddPropertyRow ( ClampMaxTypeHandle . ToSharedRef ( ) ) ;
ClampMaxTypeRow . CustomWidget ( )
. NameContent ( )
[
ClampMaxTypeHandle - > CreatePropertyNameWidget ( )
]
. ValueContent ( )
[
SNew ( SComboButton )
. OnGetMenuContent ( this , & FEnvQueryTestDetails : : OnGetClampMaxTypeContent )
. ContentPadding ( FMargin ( 2.0f , 2.0f ) )
. ButtonContent ( )
[
SNew ( STextBlock )
. Text ( this , & FEnvQueryTestDetails : : GetClampMaxTypeDesc )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
] ;
ClampMaxTypeRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetFloatScoreVisibility ) ) ) ;
// Upper Bound for normalization of score if specified independently of filtering.
IDetailPropertyRow & ScoreClampingMaxRow = ClampingGroup . AddPropertyRow ( ScoreClampingMaxHandle . ToSharedRef ( ) ) ;
ScoreClampingMaxRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetVisibilityOfScoreClampingMaximum ) ) ) ;
// Upper Bound for scoring when tied to filter maximum.
IDetailPropertyRow & FloatFilterMaxForClampingRow = ClampingGroup . AddPropertyRow ( FloatFilterMaxHandle . ToSharedRef ( ) ) ;
FloatFilterMaxForClampingRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetVisibilityOfFilterMaxForScoreClamping ) ) ) ;
FloatFilterMaxForClampingRow . ToolTip ( TEXT ( " See Filter Thresholds under the Filter tab. Values higher than this (before normalization) cause the item to be thrown out as invalid. Values are normalized with this value as the maximum, so items with this value will have a normalized score of 1. " ) ) ;
FloatFilterMaxForClampingRow . EditCondition ( TAttribute < bool > ( this , & FEnvQueryTestDetails : : AllowWritingToFiltersFromScore ) , NULL ) ;
// END Scoring: Clamping, continue Scoring
//----------------------------
2014-06-26 17:26:58 -04:00
IDetailPropertyRow & BoolScoreTestRow = ScoreCategory . AddProperty ( DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , BoolFilter ) ) ) ;
2014-05-16 21:50:28 -04:00
BoolScoreTestRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetBoolFilterVisibilityForScoring ) ) ) ;
2014-06-26 17:26:58 -04:00
BoolScoreTestRow . DisplayName ( TEXT ( " Bool Match " ) ) ;
BoolScoreTestRow . ToolTip ( TEXT ( " Boolean value to match in order to grant score of 'Weight'. Not matching this value will not change score. " ) ) ;
2014-05-16 21:50:28 -04:00
// IDetailPropertyRow& ScoreMirrorNormalizedScoreRow = ScoreCategory.AddProperty(DetailLayout.GetProperty(GET_MEMBER_NAME_CHECKED(UEnvQueryTest, bMirrorNormalizedScore)));
// ScoreMirrorNormalizedScoreRow.Visibility(TAttribute<EVisibility>::Create(TAttribute<EVisibility>::FGetter::CreateSP(this, &FEnvQueryTestDetails::GetFloatScoreVisibility)));
IDetailPropertyRow & ScoreEquationTypeRow = ScoreCategory . AddProperty ( ScoreEquationHandle ) ;
ScoreEquationTypeRow . CustomWidget ( )
2014-03-14 14:13:41 -04:00
. NameContent ( )
. VAlign ( VAlign_Top )
[
2014-05-16 21:50:28 -04:00
ScoreEquationHandle - > CreatePropertyNameWidget ( )
2014-03-14 14:13:41 -04:00
]
. ValueContent ( ) . MaxDesiredWidth ( 600 )
[
SNew ( SVerticalBox )
+ SVerticalBox : : Slot ( )
. AutoHeight ( )
. HAlign ( HAlign_Left )
[
2014-05-16 21:50:28 -04:00
SNew ( SComboButton )
. OnGetMenuContent ( this , & FEnvQueryTestDetails : : OnGetEquationValuesContent )
. ContentPadding ( FMargin ( 2.0f , 2.0f ) )
. ButtonContent ( )
[
SNew ( STextBlock )
. Text ( this , & FEnvQueryTestDetails : : GetEquationValuesDesc )
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
2014-03-14 14:13:41 -04:00
]
+ SVerticalBox : : Slot ( )
. Padding ( 0 , 2 , 0 , 0 )
. AutoHeight ( )
[
SNew ( STextBlock )
. IsEnabled ( false )
2014-05-16 21:50:28 -04:00
. Text ( this , & FEnvQueryTestDetails : : GetScoreEquationInfo )
2014-03-14 14:13:41 -04:00
. Font ( IDetailLayoutBuilder : : GetDetailFont ( ) )
]
] ;
2014-06-26 17:26:58 -04:00
ScoreEquationTypeRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetFloatScoreVisibility ) ) ) ;
2014-05-16 21:50:28 -04:00
IDetailPropertyRow & ScoreWeightRow = ScoreCategory . AddProperty ( DetailLayout . GetProperty ( GET_MEMBER_NAME_CHECKED ( UEnvQueryTest , Weight ) ) ) ;
ScoreWeightRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FEnvQueryTestDetails : : GetScoreVisibility ) ) ) ;
2014-06-10 16:45:28 -04:00
// scoring & filter function preview
IDetailCategoryBuilder & PreviewCategory = DetailLayout . EditCategory ( " Preview " ) ;
PreviewCategory . AddCustomRow ( " Preview " ) . WholeRowWidget
[
SAssignNew ( PreviewWidget , STestFunctionWidget )
] ;
FSimpleDelegate OnGraphPreviewDataChangedDelegate = FSimpleDelegate : : CreateSP ( this , & FEnvQueryTestDetails : : UpdateTestFunctionPreview ) ;
TestPurposeHandle - > SetOnPropertyValueChanged ( OnGraphPreviewDataChangedDelegate ) ;
FilterTypeHandle - > SetOnPropertyValueChanged ( OnGraphPreviewDataChangedDelegate ) ;
ClampMaxTypeHandle - > SetOnPropertyValueChanged ( OnGraphPreviewDataChangedDelegate ) ;
ClampMinTypeHandle - > SetOnPropertyValueChanged ( OnGraphPreviewDataChangedDelegate ) ;
ScoreEquationHandle - > SetOnPropertyValueChanged ( OnGraphPreviewDataChangedDelegate ) ;
ScoreHandle - > SetOnPropertyValueChanged ( OnGraphPreviewDataChangedDelegate ) ;
UpdateTestFunctionPreview ( ) ;
2014-03-14 14:13:41 -04:00
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
2014-05-16 21:50:28 -04:00
void FEnvQueryTestDetails : : BuildFilterTestValues ( )
{
UEnum * TestConditionEnum = FindObject < UEnum > ( ANY_PACKAGE , TEXT ( " EEnvTestFilterType " ) ) ;
check ( TestConditionEnum ) ;
FilterTestValues . Reset ( ) ;
const UEnvQueryTest * EditedTest = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( EditedTest )
{
if ( EditedTest - > GetWorkOnFloatValues ( ) )
{
FilterTestValues . Add ( FStringIntPair ( TestConditionEnum - > GetEnumText ( EEnvTestFilterType : : Minimum ) . ToString ( ) , EEnvTestFilterType : : Minimum ) ) ;
FilterTestValues . Add ( FStringIntPair ( TestConditionEnum - > GetEnumText ( EEnvTestFilterType : : Maximum ) . ToString ( ) , EEnvTestFilterType : : Maximum ) ) ;
FilterTestValues . Add ( FStringIntPair ( TestConditionEnum - > GetEnumText ( EEnvTestFilterType : : Range ) . ToString ( ) , EEnvTestFilterType : : Range ) ) ;
}
else
{
FilterTestValues . Add ( FStringIntPair ( TestConditionEnum - > GetEnumText ( EEnvTestFilterType : : Match ) . ToString ( ) , EEnvTestFilterType : : Match ) ) ;
}
}
}
void FEnvQueryTestDetails : : BuildScoreEquationValues ( )
{
UEnum * TestScoreEquationEnum = FindObject < UEnum > ( ANY_PACKAGE , TEXT ( " EEnvTestScoreEquation " ) ) ;
check ( TestScoreEquationEnum ) ;
ScoreEquationValues . Reset ( ) ;
// Const scoring is always valid. But other equations are only valid if the score values can be other than boolean values.
ScoreEquationValues . Add ( FStringIntPair ( TestScoreEquationEnum - > GetEnumText ( EEnvTestScoreEquation : : Constant ) . ToString ( ) , EEnvTestScoreEquation : : Constant ) ) ;
const UEnvQueryTest * EditedTest = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( EditedTest )
{
if ( EditedTest - > GetWorkOnFloatValues ( ) )
{
ScoreEquationValues . Add ( FStringIntPair ( TestScoreEquationEnum - > GetEnumText ( EEnvTestScoreEquation : : Linear ) . ToString ( ) , EEnvTestScoreEquation : : Linear ) ) ;
ScoreEquationValues . Add ( FStringIntPair ( TestScoreEquationEnum - > GetEnumText ( EEnvTestScoreEquation : : Square ) . ToString ( ) , EEnvTestScoreEquation : : Square ) ) ;
ScoreEquationValues . Add ( FStringIntPair ( TestScoreEquationEnum - > GetEnumText ( EEnvTestScoreEquation : : InverseLinear ) . ToString ( ) , EEnvTestScoreEquation : : InverseLinear ) ) ;
}
}
}
2014-03-14 14:13:41 -04:00
void FEnvQueryTestDetails : : BuildConditionValues ( )
{
UEnum * TestConditionEnum = FindObject < UEnum > ( ANY_PACKAGE , TEXT ( " EEnvTestCondition " ) ) ;
check ( TestConditionEnum ) ;
ConditionValues . Reset ( ) ;
2014-04-23 18:22:33 -04:00
ConditionValues . Add ( FStringIntPair ( TestConditionEnum - > GetEnumText ( EEnvTestCondition : : NoCondition ) . ToString ( ) , EEnvTestCondition : : NoCondition ) ) ;
2014-03-14 14:13:41 -04:00
2014-05-16 21:50:28 -04:00
const UEnvQueryTest * EditedTest = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
2014-03-14 14:13:41 -04:00
if ( EditedTest )
{
2014-05-16 21:50:28 -04:00
if ( EditedTest - > GetWorkOnFloatValues ( ) )
2014-03-14 14:13:41 -04:00
{
2014-04-23 18:22:33 -04:00
ConditionValues . Add ( FStringIntPair ( TestConditionEnum - > GetEnumText ( EEnvTestCondition : : AtLeast ) . ToString ( ) , EEnvTestCondition : : AtLeast ) ) ;
ConditionValues . Add ( FStringIntPair ( TestConditionEnum - > GetEnumText ( EEnvTestCondition : : UpTo ) . ToString ( ) , EEnvTestCondition : : UpTo ) ) ;
2014-03-14 14:13:41 -04:00
}
else
{
2014-04-23 18:22:33 -04:00
ConditionValues . Add ( FStringIntPair ( TestConditionEnum - > GetEnumText ( EEnvTestCondition : : Match ) . ToString ( ) , EEnvTestCondition : : Match ) ) ;
2014-03-14 14:13:41 -04:00
}
}
}
2014-05-16 21:50:28 -04:00
void FEnvQueryTestDetails : : OnFilterTestChange ( int32 Index )
{
uint8 EnumValue = Index ;
FilterTypeHandle - > SetValue ( EnumValue ) ;
}
2014-03-14 14:13:41 -04:00
void FEnvQueryTestDetails : : OnConditionComboChange ( int32 Index )
{
uint8 EnumValue = Index ;
ConditionHandle - > SetValue ( EnumValue ) ;
}
2014-05-16 21:50:28 -04:00
void FEnvQueryTestDetails : : OnScoreEquationChange ( int32 Index )
{
uint8 EnumValue = Index ;
ScoreEquationHandle - > SetValue ( EnumValue ) ;
}
void FEnvQueryTestDetails : : BuildScoreClampingTypeValues ( bool bBuildMinValues , TArray < FStringIntPair > & ClampTypeValues ) const
{
UEnum * ScoringNormalizationEnum = FindObject < UEnum > ( ANY_PACKAGE , TEXT ( " EEnvQueryTestClamping " ) ) ;
check ( ScoringNormalizationEnum ) ;
ClampTypeValues . Reset ( ) ;
ClampTypeValues . Add ( FStringIntPair ( ScoringNormalizationEnum - > GetEnumText ( EEnvQueryTestClamping : : None ) . ToString ( ) , EEnvQueryTestClamping : : None ) ) ;
ClampTypeValues . Add ( FStringIntPair ( ScoringNormalizationEnum - > GetEnumText ( EEnvQueryTestClamping : : SpecifiedValue ) . ToString ( ) , EEnvQueryTestClamping : : SpecifiedValue ) ) ;
if ( IsFiltering ( ) )
{
bool bSupportFilterThreshold = false ;
if ( bBuildMinValues )
{
if ( UsesFilterMin ( ) )
{
bSupportFilterThreshold = true ;
}
}
else if ( UsesFilterMax ( ) )
{
bSupportFilterThreshold = true ;
}
if ( bSupportFilterThreshold )
{
ClampTypeValues . Add ( FStringIntPair ( ScoringNormalizationEnum - > GetEnumText ( EEnvQueryTestClamping : : FilterThreshold ) . ToString ( ) , EEnvQueryTestClamping : : FilterThreshold ) ) ;
}
}
}
void FEnvQueryTestDetails : : OnClampMinTestChange ( int32 Index )
{
check ( ClampMinTypeHandle . IsValid ( ) ) ;
uint8 EnumValue = Index ;
ClampMinTypeHandle - > SetValue ( EnumValue ) ;
}
void FEnvQueryTestDetails : : OnClampMaxTestChange ( int32 Index )
{
check ( ClampMaxTypeHandle . IsValid ( ) ) ;
uint8 EnumValue = Index ;
ClampMaxTypeHandle - > SetValue ( EnumValue ) ;
}
TSharedRef < SWidget > FEnvQueryTestDetails : : OnGetClampMinTypeContent ( )
{
BuildScoreClampingTypeValues ( true , ClampMinTypeValues ) ;
FMenuBuilder MenuBuilder ( true , NULL ) ;
for ( int32 i = 0 ; i < ClampMinTypeValues . Num ( ) ; i + + )
{
FUIAction ItemAction ( FExecuteAction : : CreateSP ( this , & FEnvQueryTestDetails : : OnClampMinTestChange , ClampMinTypeValues [ i ] . Int ) ) ;
MenuBuilder . AddMenuEntry ( FText : : FromString ( ClampMinTypeValues [ i ] . Str ) , TAttribute < FText > ( ) , FSlateIcon ( ) , ItemAction ) ;
}
return MenuBuilder . MakeWidget ( ) ;
}
TSharedRef < SWidget > FEnvQueryTestDetails : : OnGetClampMaxTypeContent ( )
{
BuildScoreClampingTypeValues ( false , ClampMaxTypeValues ) ;
FMenuBuilder MenuBuilder ( true , NULL ) ;
for ( int32 i = 0 ; i < ClampMaxTypeValues . Num ( ) ; i + + )
{
FUIAction ItemAction ( FExecuteAction : : CreateSP ( this , & FEnvQueryTestDetails : : OnClampMaxTestChange , ClampMaxTypeValues [ i ] . Int ) ) ;
MenuBuilder . AddMenuEntry ( FText : : FromString ( ClampMaxTypeValues [ i ] . Str ) , TAttribute < FText > ( ) , FSlateIcon ( ) , ItemAction ) ;
}
return MenuBuilder . MakeWidget ( ) ;
}
FString FEnvQueryTestDetails : : GetClampMinTypeDesc ( ) const
{
check ( ClampMinTypeHandle . IsValid ( ) ) ;
uint8 EnumValue ;
ClampMinTypeHandle - > GetValue ( EnumValue ) ;
for ( int32 i = 0 ; i < ClampMinTypeValues . Num ( ) ; i + + )
{
if ( ClampMinTypeValues [ i ] . Int = = EnumValue )
{
return ClampMinTypeValues [ i ] . Str ;
}
}
return FString ( ) ;
}
FString FEnvQueryTestDetails : : GetClampMaxTypeDesc ( ) const
{
check ( ClampMaxTypeHandle . IsValid ( ) ) ;
uint8 EnumValue ;
ClampMaxTypeHandle - > GetValue ( EnumValue ) ;
for ( int32 i = 0 ; i < ClampMaxTypeValues . Num ( ) ; i + + )
{
if ( ClampMaxTypeValues [ i ] . Int = = EnumValue )
{
return ClampMaxTypeValues [ i ] . Str ;
}
}
return FString ( ) ;
}
FString FEnvQueryTestDetails : : GetEquationValuesDesc ( ) const
{
check ( ScoreEquationHandle . IsValid ( ) ) ;
uint8 EnumValue ;
ScoreEquationHandle - > GetValue ( EnumValue ) ;
for ( int32 i = 0 ; i < ScoreEquationValues . Num ( ) ; i + + )
{
if ( ScoreEquationValues [ i ] . Int = = EnumValue )
{
return ScoreEquationValues [ i ] . Str ;
}
}
return FString ( ) ;
}
TSharedRef < SWidget > FEnvQueryTestDetails : : OnGetFilterTestContent ( )
{
BuildFilterTestValues ( ) ;
FMenuBuilder MenuBuilder ( true , NULL ) ;
for ( int32 i = 0 ; i < FilterTestValues . Num ( ) ; i + + )
{
FUIAction ItemAction ( FExecuteAction : : CreateSP ( this , & FEnvQueryTestDetails : : OnFilterTestChange , FilterTestValues [ i ] . Int ) ) ;
MenuBuilder . AddMenuEntry ( FText : : FromString ( FilterTestValues [ i ] . Str ) , TAttribute < FText > ( ) , FSlateIcon ( ) , ItemAction ) ;
}
return MenuBuilder . MakeWidget ( ) ;
}
FString FEnvQueryTestDetails : : GetCurrentFilterTestDesc ( ) const
{
uint8 EnumValue ;
FilterTypeHandle - > GetValue ( EnumValue ) ;
for ( int32 i = 0 ; i < FilterTestValues . Num ( ) ; i + + )
{
if ( FilterTestValues [ i ] . Int = = EnumValue )
{
return FilterTestValues [ i ] . Str ;
}
}
return FString ( ) ;
}
2014-03-14 14:13:41 -04:00
TSharedRef < SWidget > FEnvQueryTestDetails : : OnGetConditionContent ( )
{
BuildConditionValues ( ) ;
FMenuBuilder MenuBuilder ( true , NULL ) ;
for ( int32 i = 0 ; i < ConditionValues . Num ( ) ; i + + )
{
FUIAction ItemAction ( FExecuteAction : : CreateSP ( this , & FEnvQueryTestDetails : : OnConditionComboChange , ConditionValues [ i ] . Int ) ) ;
MenuBuilder . AddMenuEntry ( FText : : FromString ( ConditionValues [ i ] . Str ) , TAttribute < FText > ( ) , FSlateIcon ( ) , ItemAction ) ;
}
return MenuBuilder . MakeWidget ( ) ;
}
2014-05-16 21:50:28 -04:00
TSharedRef < SWidget > FEnvQueryTestDetails : : OnGetEquationValuesContent ( )
{
BuildScoreEquationValues ( ) ;
FMenuBuilder MenuBuilder ( true , NULL ) ;
for ( int32 i = 0 ; i < ScoreEquationValues . Num ( ) ; i + + )
{
FUIAction ItemAction ( FExecuteAction : : CreateSP ( this , & FEnvQueryTestDetails : : OnScoreEquationChange , ScoreEquationValues [ i ] . Int ) ) ;
MenuBuilder . AddMenuEntry ( FText : : FromString ( ScoreEquationValues [ i ] . Str ) , TAttribute < FText > ( ) , FSlateIcon ( ) , ItemAction ) ;
}
return MenuBuilder . MakeWidget ( ) ;
}
2014-03-14 14:13:41 -04:00
FString FEnvQueryTestDetails : : GetCurrentConditionDesc ( ) const
{
uint8 EnumValue ;
ConditionHandle - > GetValue ( EnumValue ) ;
for ( int32 i = 0 ; i < ConditionValues . Num ( ) ; i + + )
{
if ( ConditionValues [ i ] . Int = = EnumValue )
{
return ConditionValues [ i ] . Str ;
}
}
return FString ( ) ;
}
2014-05-16 21:50:28 -04:00
FString FEnvQueryTestDetails : : GetScoreEquationInfo ( ) const
2014-03-14 14:13:41 -04:00
{
uint8 EnumValue ;
2014-05-16 21:50:28 -04:00
ScoreEquationHandle - > GetValue ( EnumValue ) ;
2014-03-14 14:13:41 -04:00
switch ( EnumValue )
{
2014-05-16 21:50:28 -04:00
case EEnvTestScoreEquation : : Linear :
return LOCTEXT ( " Linear " , " Final score = Weight * NormalizedItemValue " ) . ToString ( ) ;
2014-03-14 14:13:41 -04:00
2014-05-16 21:50:28 -04:00
case EEnvTestScoreEquation : : Square :
return LOCTEXT ( " Square " , " Final score = Weight * (NormalizedItemValue * NormalizedItemValue) \ nBias towards items with big values . " ).ToString() ;
2014-03-14 14:13:41 -04:00
2014-05-16 21:50:28 -04:00
case EEnvTestScoreEquation : : InverseLinear :
return LOCTEXT ( " Inverse " , " Final score = Weight * (1.0 - NormalizedItemValue) \ nBias towards items with values close to zero . ( Linear , but flipped from 1 to 0 rather than 0 to 1. " ).ToString() ;
2014-03-14 14:13:41 -04:00
2014-05-16 21:50:28 -04:00
case EEnvTestScoreEquation : : Constant :
return LOCTEXT ( " Constant " , " Final score (for values that 'pass') = Weight \ nNOTE : In this case , the score is normally EITHER the Weight value or zero . \ nThe score will be zero if the Normalized Test Value is zero ( or if the test value is false for a boolean query ) . \ nOtherwise , score will be the Weight . " ).ToString() ;
2014-03-14 14:13:41 -04:00
2014-05-16 21:50:28 -04:00
default :
break ;
2014-03-14 14:13:41 -04:00
}
return TEXT ( " " ) ;
}
2014-05-16 21:50:28 -04:00
EVisibility FEnvQueryTestDetails : : GetVisibilityOfFilterMinForScoreClamping ( ) const
2014-03-14 14:13:41 -04:00
{
2014-05-16 21:50:28 -04:00
if ( GetFloatScoreVisibility ( ) = = EVisibility : : Visible )
{
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( ( MyTestOb ! = NULL ) & & ( MyTestOb - > ClampMinType = = EEnvQueryTestClamping : : FilterThreshold ) )
{
return EVisibility : : Visible ;
}
}
2014-03-14 14:13:41 -04:00
2014-05-16 21:50:28 -04:00
return EVisibility : : Collapsed ;
}
EVisibility FEnvQueryTestDetails : : GetVisibilityOfFilterMaxForScoreClamping ( ) const
{
if ( GetFloatScoreVisibility ( ) = = EVisibility : : Visible )
{
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( ( MyTestOb ! = NULL ) & & ( MyTestOb - > ClampMaxType = = EEnvQueryTestClamping : : FilterThreshold ) )
{
return EVisibility : : Visible ;
}
}
return EVisibility : : Collapsed ;
}
EVisibility FEnvQueryTestDetails : : GetVisibilityOfScoreClampingMinimum ( ) const
{
if ( GetFloatScoreVisibility ( ) = = EVisibility : : Visible )
{
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( ( MyTestOb ! = NULL ) & & ( MyTestOb - > ClampMinType = = EEnvQueryTestClamping : : SpecifiedValue ) )
{
return EVisibility : : Visible ;
}
}
return EVisibility : : Collapsed ;
}
EVisibility FEnvQueryTestDetails : : GetVisibilityOfScoreClampingMaximum ( ) const
{
if ( GetFloatScoreVisibility ( ) = = EVisibility : : Visible )
{
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( ( MyTestOb ! = NULL ) & & ( MyTestOb - > ClampMaxType = = EEnvQueryTestClamping : : SpecifiedValue ) )
{
return EVisibility : : Visible ;
}
}
return EVisibility : : Collapsed ;
}
EVisibility FEnvQueryTestDetails : : GetFloatTestVisibility ( ) const
{
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( ( MyTestOb ! = NULL ) & & MyTestOb - > GetWorkOnFloatValues ( ) )
2014-03-14 14:13:41 -04:00
{
return EVisibility : : Visible ;
}
return EVisibility : : Collapsed ;
}
2014-05-16 21:50:28 -04:00
bool FEnvQueryTestDetails : : IsFiltering ( ) const
2014-03-14 14:13:41 -04:00
{
2014-05-16 21:50:28 -04:00
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( MyTestOb = = NULL )
{
return false ;
}
2014-03-14 14:13:41 -04:00
2014-05-16 21:50:28 -04:00
return MyTestOb - > IsFiltering ( ) ;
}
bool FEnvQueryTestDetails : : IsScoring ( ) const
{
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( MyTestOb = = NULL )
{
return false ;
}
return MyTestOb - > IsScoring ( ) ;
}
EVisibility FEnvQueryTestDetails : : GetFloatFilterVisibility ( ) const
{
if ( IsFiltering ( ) )
{
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( MyTestOb & & MyTestOb - > GetWorkOnFloatValues ( ) )
{
return EVisibility : : Visible ;
}
}
return EVisibility : : Collapsed ;
}
EVisibility FEnvQueryTestDetails : : GetScoreVisibility ( ) const
{
if ( IsScoring ( ) )
2014-03-14 14:13:41 -04:00
{
return EVisibility : : Visible ;
}
return EVisibility : : Collapsed ;
}
2014-05-16 21:50:28 -04:00
EVisibility FEnvQueryTestDetails : : GetFloatScoreVisibility ( ) const
{
if ( IsScoring ( ) )
{
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( MyTestOb & & MyTestOb - > GetWorkOnFloatValues ( ) )
{
return EVisibility : : Visible ;
}
}
return EVisibility : : Collapsed ;
}
bool FEnvQueryTestDetails : : UsesFilterMin ( ) const
{
uint8 EnumValue ;
check ( FilterTypeHandle . IsValid ( ) ) ;
FilterTypeHandle - > GetValue ( EnumValue ) ;
return ( ( EnumValue = = EEnvTestFilterType : : Minimum ) | | ( EnumValue = = EEnvTestFilterType : : Range ) ) ;
}
bool FEnvQueryTestDetails : : UsesFilterMax ( ) const
{
uint8 EnumValue ;
check ( FilterTypeHandle . IsValid ( ) ) ;
FilterTypeHandle - > GetValue ( EnumValue ) ;
return ( ( EnumValue = = EEnvTestFilterType : : Maximum ) | | ( EnumValue = = EEnvTestFilterType : : Range ) ) ;
}
EVisibility FEnvQueryTestDetails : : GetVisibilityOfFloatFilterMin ( ) const
{
if ( IsFiltering ( ) )
{
uint8 EnumValue ;
FilterTypeHandle - > GetValue ( EnumValue ) ;
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( MyTestOb & & MyTestOb - > GetWorkOnFloatValues ( ) & &
( ( EnumValue = = EEnvTestFilterType : : Minimum ) | | ( EnumValue = = EEnvTestFilterType : : Range ) ) )
{
return EVisibility : : Visible ;
}
}
return EVisibility : : Collapsed ;
}
EVisibility FEnvQueryTestDetails : : GetVisibilityOfFloatFilterMax ( ) const
{
if ( IsFiltering ( ) )
{
uint8 EnumValue ;
FilterTypeHandle - > GetValue ( EnumValue ) ;
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( MyTestOb & & MyTestOb - > GetWorkOnFloatValues ( ) & &
( ( EnumValue = = EEnvTestFilterType : : Maximum ) | | ( EnumValue = = EEnvTestFilterType : : Range ) ) )
{
return EVisibility : : Visible ;
}
}
return EVisibility : : Collapsed ;
}
bool FEnvQueryTestDetails : : IsMatchingBoolValue ( ) const
{
// TODO: Decide whether this complex function needs to be so complex! At the moment, if it's not working on floats,
// it must be working on bools, in which case it MUST be using a Match test. So probably it could stop much earlier!
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( MyTestOb & & ! MyTestOb - > GetWorkOnFloatValues ( ) )
{
if ( FilterTypeHandle . IsValid ( ) )
{
uint8 EnumValue ;
FilterTypeHandle - > GetValue ( EnumValue ) ;
if ( EnumValue = = EEnvTestFilterType : : Match )
{
return true ;
}
}
}
return false ;
}
EVisibility FEnvQueryTestDetails : : GetBoolFilterVisibilityForScoring ( ) const
{
if ( ! IsFiltering ( ) )
{
if ( IsMatchingBoolValue ( ) )
{
return EVisibility : : Visible ;
}
}
return EVisibility : : Collapsed ;
}
EVisibility FEnvQueryTestDetails : : GetBoolFilterVisibility ( ) const
{
if ( IsFiltering ( ) )
{
if ( IsMatchingBoolValue ( ) )
{
return EVisibility : : Visible ;
}
}
return EVisibility : : Collapsed ;
}
2014-04-23 19:29:53 -04:00
EVisibility FEnvQueryTestDetails : : GetDiscardFailedVisibility ( ) const
{
uint8 EnumValue ;
ConditionHandle - > GetValue ( EnumValue ) ;
return ( EnumValue = = EEnvTestCondition : : NoCondition ) ? EVisibility : : Collapsed : EVisibility : : Visible ;
}
2014-06-10 16:45:28 -04:00
EVisibility FEnvQueryTestDetails : : GetTestPreviewVisibility ( ) const
{
const UEnvQueryTest * MyTestOb = Cast < const UEnvQueryTest > ( MyTest . Get ( ) ) ;
if ( ( MyTestOb ! = NULL ) & & MyTestOb - > GetWorkOnFloatValues ( ) )
{
return EVisibility : : Visible ;
}
return EVisibility : : Collapsed ;
}
void FEnvQueryTestDetails : : UpdateTestFunctionPreview ( ) const
{
// read values of properties
uint8 TestPurpose = 0 ;
uint8 FilterType = 0 ;
uint8 ClampMinType = 0 ;
uint8 ClampMaxType = 0 ;
uint8 ScoreEquation = 0 ;
float Score = 0.0f ;
TestPurposeHandle - > GetValue ( TestPurpose ) ;
FilterTypeHandle - > GetValue ( FilterType ) ;
ClampMinTypeHandle - > GetValue ( ClampMinType ) ;
ClampMaxTypeHandle - > GetValue ( ClampMaxType ) ;
ScoreEquationHandle - > GetValue ( ScoreEquation ) ;
ScoreHandle - > GetValue ( Score ) ;
// fill score equation samples
if ( TestPurpose = = EEnvTestPurpose : : Filter )
{
// pure filtering won't apply any scoring, draw flat line
ScoreEquation = EEnvTestScoreEquation : : Constant ;
}
FillEquationSamples ( ScoreEquation , Score < 0.0f , PreviewWidget - > ScoreValues ) ;
// fill everything else
const bool bCanFilter = ( TestPurpose ! = EEnvTestPurpose : : Score ) ;
PreviewWidget - > bShowClampMin = ( ClampMinType ! = EEnvQueryTestClamping : : None ) ;
PreviewWidget - > bShowClampMax = ( ClampMaxType ! = EEnvQueryTestClamping : : None ) ;
PreviewWidget - > bShowLowPassFilter = ( ( FilterType = = EEnvTestFilterType : : Minimum ) | | ( FilterType = = EEnvTestFilterType : : Range ) ) & & bCanFilter ;
PreviewWidget - > bShowHiPassFilter = ( ( FilterType = = EEnvTestFilterType : : Maximum ) | | ( FilterType = = EEnvTestFilterType : : Range ) ) & & bCanFilter ;
PreviewWidget - > FilterLowX = 0.2f ;
PreviewWidget - > FilterHiX = 0.8f ;
PreviewWidget - > ClampMinX = ( ClampMinType = = EEnvQueryTestClamping : : FilterThreshold ) ? PreviewWidget - > FilterLowX : 0.3f ;
PreviewWidget - > ClampMaxX = ( ClampMaxType = = EEnvQueryTestClamping : : FilterThreshold ) ? PreviewWidget - > FilterHiX : 0.7f ;
// postprocess samples for clamping
if ( PreviewWidget - > bShowClampMin )
{
const int32 FixedIdx = FMath : : TruncToInt ( PreviewWidget - > ClampMinX * 10.0f ) ;
for ( int32 Idx = 0 ; Idx < FixedIdx ; Idx + + )
{
PreviewWidget - > ScoreValues [ Idx ] = PreviewWidget - > ScoreValues [ FixedIdx ] ;
}
}
if ( PreviewWidget - > bShowClampMax )
{
const int32 FixedIdx = FMath : : TruncToInt ( PreviewWidget - > ClampMaxX * 10.0f ) + 1 ;
for ( int32 Idx = FixedIdx + 1 ; Idx < PreviewWidget - > ScoreValues . Num ( ) ; Idx + + )
{
PreviewWidget - > ScoreValues [ Idx ] = PreviewWidget - > ScoreValues [ FixedIdx ] ;
}
}
}
void FEnvQueryTestDetails : : FillEquationSamples ( uint8 EquationType , bool bInversed , TArray < float > & Samples ) const
{
const int32 MaxSamples = 11 ;
static float SamplesLinear [ MaxSamples ] = { 0.0f } ;
static float SamplesSquare [ MaxSamples ] = { 0.0f } ;
static float SamplesConstant [ MaxSamples ] = { 0.0f } ;
static bool bSamplesInitialized = false ;
if ( ! bSamplesInitialized )
{
bSamplesInitialized = true ;
for ( int32 Idx = 0 ; Idx < MaxSamples ; Idx + + )
{
const float XValue = 1.0f * Idx / ( MaxSamples - 1 ) ;
SamplesLinear [ Idx ] = XValue ;
SamplesSquare [ Idx ] = XValue * XValue ;
SamplesConstant [ Idx ] = 0.5f ; // just for looks on preview, not the actual value
}
}
const float * AllSamples [ ] = { SamplesLinear , SamplesSquare , SamplesLinear , SamplesConstant } ;
if ( EquationType > = ARRAY_COUNT ( AllSamples ) )
{
EquationType = EEnvTestScoreEquation : : Constant ;
}
const float * SamplesArray = AllSamples [ EquationType ] ;
if ( EquationType = = EEnvTestScoreEquation : : InverseLinear )
{
bInversed = ! bInversed ;
}
Samples . Reset ( ) ;
Samples . AddZeroed ( MaxSamples ) ;
for ( int32 Idx = 0 ; Idx < MaxSamples ; Idx + + )
{
Samples [ Idx ] = bInversed ? ( 1.0f - SamplesArray [ Idx ] ) : SamplesArray [ Idx ] ;
}
}
2014-03-14 14:13:41 -04:00
# undef LOCTEXT_NAMESPACE