// Copyright 2019-Present LexLiu. All Rights Reserved. #include "CoreMinimal.h" #include "IPropertyTypeCustomization.h" #include "Event/LGUIEventDelegate.h" #pragma once /** * */ class FLGUIEventDelegateCustomization : public IPropertyTypeCustomization { protected: TSharedPtr PropertyHandle; TSharedPtr PropertyUtilites; static TArray CopySourceData; TSharedPtr ColorPickerParentWidget; TArray> EventParameterWidgetArray; TSharedPtr EventsWidget; TArray EventDelegateInstances; private: bool CanChangeParameterType = true; bool IsParameterTypeValid(ELGUIEventDelegateParameterType InParamType) { return InParamType != ELGUIEventDelegateParameterType::None; } FText GetEventTitleName()const; FText GetEventItemFunctionName(TSharedRef EventItemPropertyHandle)const; UObject* GetEventItemTargetObject(TSharedRef EventItemPropertyHandle)const; AActor* GetEventItemHelperActor(TSharedRef EventItemPropertyHandle)const; FText GetComponentDisplayName(TSharedRef EventItemPropertyHandle)const; EVisibility GetNativeParameterWidgetVisibility(TSharedRef EventItemPropertyHandle)const; EVisibility GetDrawFunctionParameterWidgetVisibility(TSharedRef EventItemPropertyHandle)const; EVisibility GetNotValidParameterWidgetVisibility(TSharedRef EventItemPropertyHandle)const; public: FLGUIEventDelegateCustomization(bool InCanChangeParameterType) { CanChangeParameterType = InCanChangeParameterType; } ~FLGUIEventDelegateCustomization() { } static TSharedRef MakeInstance() { return MakeShareable(new FLGUIEventDelegateCustomization(true)); } /** IDetailCustomization interface */ virtual void CustomizeHeader(TSharedRef InPropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& CustomizationUtils) override {}; ELGUIEventDelegateParameterType GetNativeParameterType()const; void AddNativeParameterTypeProperty(IDetailChildrenBuilder& ChildBuilder); ELGUIEventDelegateParameterType GetEventDataParameterType(TSharedRef EventDataItemHandle)const; virtual void CustomizeChildren(TSharedRef InPropertyHandle, IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& CustomizationUtils)override; void SetEventDataParameterType(TSharedRef EventDataItemHandle, ELGUIEventDelegateParameterType ParameterType); private: void UpdateEventsLayout(); TSharedPtr GetEventListHandle()const; FOptionalSize GetEventItemHeight(int itemIndex)const { return EventParameterWidgetArray[itemIndex]->GetCachedGeometry().Size.Y + 60;//60 is other's size } FOptionalSize GetEventTotalHeight()const { float result = EventParameterWidgetArray.Num() > 0 ? 32 : 40;//32 & 40 is the header and tail size for (int i = 0; i < EventParameterWidgetArray.Num(); i++) { result += GetEventItemHeight(i).Get(); } return result; } TSharedRef MakeComponentSelectorMenu(int32 itemIndex); TSharedRef MakeFunctionSelectorMenu(int32 itemIndex); void OnActorParameterChange(TSharedRef ItemPropertyHandle); void OnSelectComponent(UActorComponent* Comp, TSharedRef ItemPropertyHandle); void OnSelectActorSelf(TSharedRef ItemPropertyHandle); void OnSelectFunction(FName FuncName, ELGUIEventDelegateParameterType ParamType, bool UseNativeParameter, TSharedRef ItemPropertyHandle); bool IsComponentSelectorMenuEnabled(TSharedRef ItemPropertyHandle)const; bool IsFunctionSelectorMenuEnabled(TSharedRef ItemPropertyHandle)const; void OnClickListAdd(); void OnClickListEmpty(); FReply OnClickAddRemove(bool AddOrRemove, int32 Index, int32 Count); FReply OnClickCopyPaste(bool CopyOrPaste, int32 Index); FReply OnClickDuplicate(int32 Index); FReply OnClickMoveUpDown(bool UpOrDown, int32 Index); TSharedRef DrawFunctionParameter(TSharedRef InDataContainerHandle, ELGUIEventDelegateParameterType InFunctionParameterType, UFunction* InFunction); //function's parameter editor TSharedRef DrawFunctionReferenceParameter(TSharedRef InDataContainerHandle, ELGUIEventDelegateParameterType FunctionParameterType, UFunction* InFunction); void ObjectValueChange(const FAssetData& InObj, TSharedPtr BufferHandle, TSharedPtr ObjectReferenceHandle, bool ObjectOrActor); const UClass* GetClassValue(TSharedPtr ClassReferenceHandle)const; void ClassValueChange(const UClass* InClass, TSharedPtr ClassReferenceHandle); void EnumValueChange(int32 InValue, ESelectInfo::Type SelectionType, TSharedPtr ValueHandle, TSharedPtr BufferHandle); void BoolValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void FloatValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void DoubleValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void Int8ValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void UInt8ValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void Int16ValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void UInt16ValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void Int32ValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void UInt32ValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void Int64ValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void UInt64ValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void StringValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void NameValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void TextValueChange(TSharedPtr ValueHandle, TSharedPtr BufferHandle); void Vector2ItemValueChange(float NewValue, ETextCommit::Type CommitInfo, int AxisType, TSharedPtr ValueHandle, TSharedPtr BufferHandle); TOptional Vector2GetItemValue(int AxisType, TSharedPtr ValueHandle, TSharedPtr BufferHandle)const; void Vector3ItemValueChange(float NewValue, ETextCommit::Type CommitInfo, int AxisType, TSharedPtr ValueHandle, TSharedPtr BufferHandle); TOptional Vector3GetItemValue(int AxisType, TSharedPtr ValueHandle, TSharedPtr BufferHandle)const; void Vector4ItemValueChange(float NewValue, ETextCommit::Type CommitInfo, int AxisType, TSharedPtr ValueHandle, TSharedPtr BufferHandle); TOptional Vector4GetItemValue(int AxisType, TSharedPtr ValueHandle, TSharedPtr BufferHandle)const; FLinearColor LinearColorGetValue(bool bIsLinearColor, TSharedPtr ValueHandle, TSharedPtr BufferHandle)const; void LinearColorValueChange(FLinearColor NewValue, bool bIsLinearColor, TSharedPtr ValueHandle, TSharedPtr BufferHandle); FReply OnMouseButtonDownColorBlock(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, bool bIsLinearColor, TSharedPtr ValueHandle, TSharedPtr BufferHandle); TOptional RotatorGetItemValue(int AxisType, TSharedPtr ValueHandle, TSharedPtr BufferHandle)const; void RotatorValueChange(float NewValue, ETextCommit::Type CommitInfo, int AxisType, TSharedPtr ValueHandle, TSharedPtr BufferHandle); void SetBufferValue(TSharedPtr BufferHandle, const TArray& BufferArray); void SetBufferLength(TSharedPtr BufferHandle, int32 Count); TArray GetBuffer(TSharedPtr BufferHandle); TArray GetPropertyBuffer(TSharedPtr BufferHandle) const; int32 GetEnumValue(TSharedPtr ValueHandle)const; FText GetTextValue(TSharedPtr ValueHandle)const; void SetTextValue(const FText& InText, ETextCommit::Type InCommitType, TSharedPtr ValueHandle); void ClearValueBuffer(TSharedPtr InItemPropertyHandle); void ClearReferenceValue(TSharedPtr InItemPropertyHandle); void ClearObjectValue(TSharedPtr InItemPropertyHandle); void OnParameterTypeChange(TSharedRef InItemPropertyHandle); void CreateColorPicker(bool bIsLinearColor, TSharedPtr ValueHandle, TSharedPtr BufferHandle); };