2014-04-28 11:24:25 -04:00
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
# include "BlueprintGraphPrivatePCH.h"
2014-05-29 16:42:22 -04:00
# include "K2Node_InputVectorAxisEvent.h"
2014-04-28 11:24:25 -04:00
# include "CompilerResultsLog.h"
2014-07-14 13:19:37 -04:00
# include "BlueprintNodeSpawner.h"
2014-08-11 03:23:38 -04:00
# include "Engine/InputVectorAxisDelegateBinding.h"
2014-04-28 11:24:25 -04:00
UK2Node_InputVectorAxisEvent : : UK2Node_InputVectorAxisEvent ( const class FPostConstructInitializeProperties & PCIP )
: Super ( PCIP )
{
EventSignatureName = TEXT ( " InputVectorAxisHandlerDynamicSignature__DelegateSignature " ) ;
}
void UK2Node_InputVectorAxisEvent : : ValidateNodeDuringCompilation ( class FCompilerResultsLog & MessageLog ) const
{
// Skip AxisKeyEvent validation
UK2Node_Event : : ValidateNodeDuringCompilation ( MessageLog ) ;
if ( ! AxisKey . IsValid ( ) )
{
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " Invalid_InputVectorAxis_Warning " , " InputVectorAxis Event specifies invalid FKey'{0}' for @@ " ) , FText : : FromString ( AxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
}
else if ( ! AxisKey . IsVectorAxis ( ) )
{
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " NotAxis_InputVectorAxis_Warning " , " InputVectorAxis Event specifies FKey'{0}' which is not a vector axis for @@ " ) , FText : : FromString ( AxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
}
else if ( ! AxisKey . IsBindableInBlueprints ( ) )
{
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " NotBindable_InputVectorAxis_Warning " , " InputVectorAxis Event specifies FKey'{0}' that is not blueprint bindable for @@ " ) , FText : : FromString ( AxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
}
}
UClass * UK2Node_InputVectorAxisEvent : : GetDynamicBindingClass ( ) const
{
return UInputVectorAxisDelegateBinding : : StaticClass ( ) ;
}
void UK2Node_InputVectorAxisEvent : : RegisterDynamicBinding ( UDynamicBlueprintBinding * BindingObject ) const
{
UInputVectorAxisDelegateBinding * InputVectorAxisBindingObject = CastChecked < UInputVectorAxisDelegateBinding > ( BindingObject ) ;
FBlueprintInputAxisKeyDelegateBinding Binding ;
Binding . AxisKey = AxisKey ;
Binding . bConsumeInput = bConsumeInput ;
Binding . bExecuteWhenPaused = bExecuteWhenPaused ;
Binding . bOverrideParentBinding = bOverrideParentBinding ;
Binding . FunctionNameToBind = CustomFunctionName ;
InputVectorAxisBindingObject - > InputAxisKeyDelegateBindings . Add ( Binding ) ;
2014-07-14 13:19:37 -04:00
}
void UK2Node_InputVectorAxisEvent : : GetMenuActions ( TArray < UBlueprintNodeSpawner * > & ActionListOut ) const
{
TArray < FKey > AllKeys ;
EKeys : : GetAllKeys ( AllKeys ) ;
for ( FKey const Key : AllKeys )
{
if ( ! Key . IsBindableInBlueprints ( ) | | ! Key . IsVectorAxis ( ) )
{
continue ;
}
UBlueprintNodeSpawner * NodeSpawner = UBlueprintNodeSpawner : : Create ( GetClass ( ) ) ;
check ( NodeSpawner ! = nullptr ) ;
auto CustomizeInputNodeLambda = [ ] ( UEdGraphNode * NewNode , bool bIsTemplateNode , FKey Key )
{
UK2Node_InputAxisKeyEvent * InputNode = CastChecked < UK2Node_InputAxisKeyEvent > ( NewNode ) ;
InputNode - > Initialize ( Key ) ;
} ;
NodeSpawner - > CustomizeNodeDelegate = UBlueprintNodeSpawner : : FCustomizeNodeDelegate : : CreateStatic ( CustomizeInputNodeLambda , Key ) ;
ActionListOut . Add ( NodeSpawner ) ;
}
}