// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #include "DetailCustomizationsPrivatePCH.h" #include "InputStructCustomization.h" #include "InputSettingsDetails.h" #include "GameFramework/PlayerInput.h" #define LOCTEXT_NAMESPACE "InputStructCustomization" /////////////////////////////////// // FInputAxisConfigCustomization // /////////////////////////////////// TSharedRef FInputAxisConfigCustomization::MakeInstance() { return MakeShareable( new FInputAxisConfigCustomization ); } void FInputAxisConfigCustomization::CustomizeHeader( TSharedRef InStructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils ) { FString AxisKeyName; InStructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FInputAxisConfigEntry, AxisKeyName))->GetValue(AxisKeyName); HeaderRow.NameContent() [ InStructPropertyHandle->CreatePropertyNameWidget(FText::FromString(AxisKeyName)) ]; } void FInputAxisConfigCustomization::CustomizeChildren( TSharedRef InStructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils ) { TSharedPtr AxisProperties = InStructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FInputAxisConfigEntry, AxisProperties)); uint32 NumChildren; AxisProperties->GetNumChildren( NumChildren ); for( uint32 ChildIndex = 0; ChildIndex < NumChildren; ++ChildIndex ) { StructBuilder.AddChildProperty( AxisProperties->GetChildHandle(ChildIndex).ToSharedRef() ); } } ////////////////////////////////////// // FInputActionMappingCustomization // ////////////////////////////////////// TSharedRef FInputActionMappingCustomization::MakeInstance() { return MakeShareable( new FInputActionMappingCustomization ); } void FInputActionMappingCustomization::CustomizeHeader( TSharedRef InStructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils ) { ActionMappingHandle = InStructPropertyHandle; } void FInputActionMappingCustomization::CustomizeChildren( TSharedRef InStructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils ) { TSharedPtr KeyHandle = InStructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FInputActionKeyMapping, Key)); TSharedPtr ShiftHandle = InStructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FInputActionKeyMapping, bShift)); TSharedPtr CtrlHandle = InStructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FInputActionKeyMapping, bCtrl)); TSharedPtr AltHandle = InStructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FInputActionKeyMapping, bAlt)); TSharedPtr CmdHandle = InStructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FInputActionKeyMapping, bCmd)); TSharedRef RemoveButton = PropertyCustomizationHelpers::MakeDeleteButton(FSimpleDelegate::CreateSP(this, &FInputActionMappingCustomization::RemoveActionMappingButton_OnClick), LOCTEXT("RemoveActionMappingToolTip", "Removes Action Mapping")); StructBuilder.AddChildContent( LOCTEXT("KeySearchStr", "Key") ) [ SNew(SHorizontalBox) + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .AutoWidth() [ SNew( SBox ) .WidthOverride( InputConstants::TextBoxWidth ) [ StructBuilder.GenerateStructValueWidget( KeyHandle.ToSharedRef() ) ] ] + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ ShiftHandle->CreatePropertyNameWidget() ] + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ ShiftHandle->CreatePropertyValueWidget() ] + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ CtrlHandle->CreatePropertyNameWidget() ] + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ CtrlHandle->CreatePropertyValueWidget() ] + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ AltHandle->CreatePropertyNameWidget() ] + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ AltHandle->CreatePropertyValueWidget() ] + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ CmdHandle->CreatePropertyNameWidget() ] + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ CmdHandle->CreatePropertyValueWidget() ] + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ RemoveButton ] ]; } void FInputActionMappingCustomization::RemoveActionMappingButton_OnClick() { if( ActionMappingHandle->IsValidHandle() ) { const TSharedPtr ParentHandle = ActionMappingHandle->GetParentHandle(); const TSharedPtr ParentArrayHandle = ParentHandle->AsArray(); ParentArrayHandle->DeleteItem( ActionMappingHandle->GetIndexInArray() ); } } ////////////////////////////////////// // FInputAxisMappingCustomization // ////////////////////////////////////// TSharedRef FInputAxisMappingCustomization::MakeInstance() { return MakeShareable( new FInputAxisMappingCustomization ); } void FInputAxisMappingCustomization::CustomizeHeader( TSharedRef InStructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils ) { AxisMappingHandle = InStructPropertyHandle; } void FInputAxisMappingCustomization::CustomizeChildren( TSharedRef InStructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils ) { TSharedPtr KeyHandle = InStructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FInputAxisKeyMapping, Key)); TSharedPtr ScaleHandle = InStructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FInputAxisKeyMapping, Scale)); TSharedRef RemoveButton = PropertyCustomizationHelpers::MakeDeleteButton( FSimpleDelegate::CreateSP( this, &FInputAxisMappingCustomization::RemoveAxisMappingButton_OnClick), LOCTEXT("RemoveAxisMappingToolTip", "Removes Axis Mapping") ); StructBuilder.AddChildContent( LOCTEXT("KeySearchStr", "Key") ) [ SNew(SHorizontalBox) + SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .AutoWidth() [ SNew( SBox ) .WidthOverride( InputConstants::TextBoxWidth ) [ StructBuilder.GenerateStructValueWidget( KeyHandle.ToSharedRef() ) ] ] +SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ ScaleHandle->CreatePropertyNameWidget() ] +SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Left) .VAlign(VAlign_Center) .AutoWidth() [ SNew(SBox) .WidthOverride(InputConstants::ScaleBoxWidth) [ ScaleHandle->CreatePropertyValueWidget() ] ] +SHorizontalBox::Slot() .Padding(InputConstants::PropertyPadding) .HAlign(HAlign_Center) .VAlign(VAlign_Center) .AutoWidth() [ RemoveButton ] ]; } void FInputAxisMappingCustomization::RemoveAxisMappingButton_OnClick() { if( AxisMappingHandle->IsValidHandle() ) { const TSharedPtr ParentHandle = AxisMappingHandle->GetParentHandle(); const TSharedPtr ParentArrayHandle = ParentHandle->AsArray(); ParentArrayHandle->DeleteItem( AxisMappingHandle->GetIndexInArray() ); } } #undef LOCTEXT_NAMESPACE