2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-04-28 11:24:25 -04:00
# include "BlueprintGraphPrivatePCH.h"
2014-05-29 16:42:22 -04:00
# include "K2Node_GetInputVectorAxisValue.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-08-23 20:16:29 -04:00
# include "BlueprintActionDatabaseRegistrar.h"
2014-04-28 11:24:25 -04:00
2014-10-14 10:29:11 -04:00
UK2Node_GetInputVectorAxisValue : : UK2Node_GetInputVectorAxisValue ( const FObjectInitializer & ObjectInitializer )
: Super ( ObjectInitializer )
2014-04-28 11:24:25 -04:00
{
bConsumeInput = true ;
}
void UK2Node_GetInputVectorAxisValue : : Initialize ( const FKey AxisKey )
{
InputAxisKey = AxisKey ;
SetFromFunction ( AActor : : StaticClass ( ) - > FindFunctionByName ( TEXT ( " GetInputVectorAxisValue " ) ) ) ;
}
2014-09-03 18:14:09 -04:00
FText UK2Node_GetInputVectorAxisValue : : GetTooltipText ( ) const
2014-04-28 11:24:25 -04:00
{
FFormatNamedArguments Args ;
Args . Add ( TEXT ( " AxisKey " ) , InputAxisKey . GetDisplayName ( ) ) ;
2014-09-03 18:14:09 -04:00
return FText : : Format ( NSLOCTEXT ( " K2Node " , " GetInputVectorAxis_Tooltip " , " Returns the current value of input axis key {AxisKey}. If input is disabled for the actor the value will be (0, 0, 0). " ) , Args ) ;
2014-04-28 11:24:25 -04:00
}
void UK2Node_GetInputVectorAxisValue : : ValidateNodeDuringCompilation ( class FCompilerResultsLog & MessageLog ) const
{
// Skip GetInputKeyAxisValue validation
UK2Node_CallFunction : : ValidateNodeDuringCompilation ( MessageLog ) ;
if ( ! InputAxisKey . IsValid ( ) )
{
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " Invalid_GetInputVectorAxis_Warning " , " GetInputVectorAxis Value specifies invalid FKey'{0}' for @@ " ) , FText : : FromString ( InputAxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
}
else if ( ! InputAxisKey . IsVectorAxis ( ) )
{
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " NotAxis_GetInputVectorAxis_Warning " , " GetInputVectorAxis Value specifies FKey'{0}' which is not a vector axis for @@ " ) , FText : : FromString ( InputAxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
}
else if ( ! InputAxisKey . IsBindableInBlueprints ( ) )
{
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " NotBindanble_GetInputVectorAxis_Warning " , " GetInputVectorAxis Value specifies FKey'{0}' that is not blueprint bindable for @@ " ) , FText : : FromString ( InputAxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
}
}
UClass * UK2Node_GetInputVectorAxisValue : : GetDynamicBindingClass ( ) const
{
return UInputVectorAxisDelegateBinding : : StaticClass ( ) ;
}
void UK2Node_GetInputVectorAxisValue : : RegisterDynamicBinding ( UDynamicBlueprintBinding * BindingObject ) const
{
UInputVectorAxisDelegateBinding * InputVectorAxisBindingObject = CastChecked < UInputVectorAxisDelegateBinding > ( BindingObject ) ;
FBlueprintInputAxisKeyDelegateBinding Binding ;
Binding . AxisKey = InputAxisKey ;
Binding . bConsumeInput = bConsumeInput ;
Binding . bExecuteWhenPaused = bExecuteWhenPaused ;
InputVectorAxisBindingObject - > InputAxisKeyDelegateBindings . Add ( Binding ) ;
2014-07-14 13:19:37 -04:00
}
2014-08-23 20:16:29 -04:00
void UK2Node_GetInputVectorAxisValue : : GetMenuActions ( FBlueprintActionDatabaseRegistrar & ActionRegistrar ) const
2014-07-14 13:19:37 -04:00
{
TArray < FKey > AllKeys ;
EKeys : : GetAllKeys ( AllKeys ) ;
2014-09-10 17:09:26 -04:00
auto CustomizeInputNodeLambda = [ ] ( UEdGraphNode * NewNode , bool bIsTemplateNode , FKey Key )
{
UK2Node_GetInputVectorAxisValue * InputNode = CastChecked < UK2Node_GetInputVectorAxisValue > ( NewNode ) ;
InputNode - > Initialize ( Key ) ;
} ;
2014-09-17 17:07:37 -04:00
// actions get registered under specific object-keys; the idea is that
// actions might have to be updated (or deleted) if their object-key is
// mutated (or removed)... here we use the node's class (so if the node
// type disappears, then the action should go with it)
UClass * ActionKey = GetClass ( ) ;
2014-07-14 13:19:37 -04:00
for ( FKey const Key : AllKeys )
{
if ( ! Key . IsBindableInBlueprints ( ) | | ! Key . IsVectorAxis ( ) )
{
continue ;
}
2014-09-10 17:09:26 -04:00
// to keep from needlessly instantiating a UBlueprintNodeSpawner, first
// check to make sure that the registrar is looking for actions of this type
// (could be regenerating actions for a specific asset, and therefore the
// registrar would only accept actions corresponding to that asset)
if ( ! ActionRegistrar . IsOpenForRegistration ( ActionKey ) )
{
continue ;
}
2014-07-14 13:19:37 -04:00
UBlueprintNodeSpawner * NodeSpawner = UBlueprintNodeSpawner : : Create ( GetClass ( ) ) ;
check ( NodeSpawner ! = nullptr ) ;
2014-10-03 11:35:29 -04:00
NodeSpawner - > DefaultMenuSignature . MenuName = FText : : Format ( NSLOCTEXT ( " K2Node_GetInputVectorAxisValue " , " MenuName " , " Get {0} " ) , Key . GetDisplayName ( ) ) ;
2014-07-14 13:19:37 -04:00
NodeSpawner - > CustomizeNodeDelegate = UBlueprintNodeSpawner : : FCustomizeNodeDelegate : : CreateStatic ( CustomizeInputNodeLambda , Key ) ;
2014-09-10 17:09:26 -04:00
ActionRegistrar . AddBlueprintAction ( ActionKey , NodeSpawner ) ;
2014-07-14 13:19:37 -04:00
}
}