You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Copying //Tasks/UE4/Release-4.20-EnterpriseLateFeatures to Release-4.20 (//UE4/Release-4.20) #rb simon.tourangeau #jira UE-59798, UE-58919, UE-59480 #ROBOMERGE-SOURCE: CL 4119095 in //UE4/Release-4.20/... #ROBOMERGE-BOT: RELEASE (Release-4.20 -> Release-Staging-4.20) [CL 4119100 by jerome delattre in Staging-4.20 branch]
103 lines
3.0 KiB
C++
103 lines
3.0 KiB
C++
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "FrameRateCustomization.h"
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
#include "Widgets/SFrameRatePicker.h"
|
|
#include "IPropertyUtilities.h"
|
|
#include "IPropertyTypeCustomization.h"
|
|
#include "PropertyHandle.h"
|
|
#include "DetailLayoutBuilder.h"
|
|
#include "DetailWidgetRow.h"
|
|
#include "IDetailChildrenBuilder.h"
|
|
#include "Misc/FrameRate.h"
|
|
#include "Editor.h"
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "FrameRateCustomization"
|
|
|
|
|
|
TSharedRef<IPropertyTypeCustomization> FFrameRateCustomization::MakeInstance()
|
|
{
|
|
return MakeShareable(new FFrameRateCustomization);
|
|
}
|
|
|
|
|
|
void FFrameRateCustomization::CustomizeHeader(TSharedRef<IPropertyHandle> InPropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& CustomizationUtils)
|
|
{
|
|
StructPropertyHandle = InPropertyHandle;
|
|
}
|
|
|
|
|
|
void FFrameRateCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> InPropertyHandle, IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& CustomizationUtils)
|
|
{
|
|
TSharedPtr<IPropertyUtilities> PropertyUtils = CustomizationUtils.GetPropertyUtilities();
|
|
|
|
FDetailWidgetRow& CustomRow = ChildBuilder.AddCustomRow(StructPropertyHandle->GetPropertyDisplayName());
|
|
|
|
CustomRow.NameContent()
|
|
[
|
|
StructPropertyHandle->CreatePropertyNameWidget()
|
|
];
|
|
|
|
CustomRow.ValueContent()
|
|
[
|
|
SNew(SFrameRatePicker)
|
|
.Font(CustomizationUtils.GetRegularFont())
|
|
.HasMultipleValues(this, &FFrameRateCustomization::HasMultipleValues)
|
|
.Value(this, &FFrameRateCustomization::GetFirstFrameRate)
|
|
.OnValueChanged(this, &FFrameRateCustomization::SetFrameRate)
|
|
].IsEnabled(MakeAttributeLambda([=] { return !InPropertyHandle->IsEditConst() && PropertyUtils->IsPropertyEditingEnabled(); }));
|
|
}
|
|
|
|
|
|
FFrameRate FFrameRateCustomization::GetFirstFrameRate() const
|
|
{
|
|
TArray<const void*> RawData;
|
|
StructPropertyHandle->AccessRawData(RawData);
|
|
|
|
for (const void* RawPtr : RawData)
|
|
{
|
|
return *reinterpret_cast<const FFrameRate*>(RawPtr);
|
|
}
|
|
|
|
return FFrameRate();
|
|
}
|
|
|
|
void FFrameRateCustomization::SetFrameRate(FFrameRate NewFrameRate)
|
|
{
|
|
if (UStructProperty* StructProperty = Cast<UStructProperty>(StructPropertyHandle->GetProperty()))
|
|
{
|
|
TArray<void*> RawData;
|
|
StructPropertyHandle->AccessRawData(RawData);
|
|
FFrameRate* PreviousFrameRate = reinterpret_cast<FFrameRate*>(RawData[0]);
|
|
|
|
FString TextValue;
|
|
StructProperty->Struct->ExportText(TextValue, &NewFrameRate, PreviousFrameRate, nullptr, EPropertyPortFlags::PPF_None, nullptr);
|
|
ensure(StructPropertyHandle->SetValueFromFormattedString(TextValue, EPropertyValueSetFlags::InteractiveChange) == FPropertyAccess::Result::Success);
|
|
}
|
|
}
|
|
|
|
bool FFrameRateCustomization::HasMultipleValues() const
|
|
{
|
|
TArray<const void*> RawData;
|
|
StructPropertyHandle->AccessRawData(RawData);
|
|
|
|
TOptional<FFrameRate> CompareAgainst;
|
|
for (const void* RawPtr : RawData)
|
|
{
|
|
FFrameRate ThisRate = *reinterpret_cast<const FFrameRate*>(RawPtr);
|
|
|
|
if (!CompareAgainst.IsSet())
|
|
{
|
|
CompareAgainst = ThisRate;
|
|
}
|
|
else if (ThisRate != CompareAgainst.GetValue())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE |