2014-04-23 18:29:30 -04:00
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
# include "BlueprintGraphPrivatePCH.h"
2014-05-29 16:42:22 -04:00
# include "K2Node_GetInputAxisKeyValue.h"
2014-04-23 18:29:30 -04:00
# include "CompilerResultsLog.h"
2014-07-14 16:30:29 -04:00
# include "BlueprintNodeSpawner.h"
# include "EditorCategoryUtils.h"
2014-08-11 03:23:38 -04:00
# include "Engine/InputAxisKeyDelegateBinding.h"
2014-04-23 18:29:30 -04:00
2014-07-14 13:19:37 -04:00
# define LOCTEXT_NAMESPACE "K2Node_GetInputAxisKeyValue"
2014-04-23 18:29:30 -04:00
UK2Node_GetInputAxisKeyValue : : UK2Node_GetInputAxisKeyValue ( const class FPostConstructInitializeProperties & PCIP )
: Super ( PCIP )
{
bConsumeInput = true ;
}
void UK2Node_GetInputAxisKeyValue : : AllocateDefaultPins ( )
{
Super : : AllocateDefaultPins ( ) ;
UEdGraphPin * InputAxisKeyPin = FindPinChecked ( TEXT ( " InputAxisKey " ) ) ;
InputAxisKeyPin - > DefaultValue = InputAxisKey . ToString ( ) ;
}
void UK2Node_GetInputAxisKeyValue : : Initialize ( const FKey AxisKey )
{
InputAxisKey = AxisKey ;
SetFromFunction ( AActor : : StaticClass ( ) - > FindFunctionByName ( TEXT ( " GetInputAxisKeyValue " ) ) ) ;
}
2014-04-23 18:31:10 -04:00
FText UK2Node_GetInputAxisKeyValue : : GetNodeTitle ( ENodeTitleType : : Type TitleType ) const
2014-04-23 18:29:30 -04:00
{
2014-04-23 18:31:10 -04:00
FFormatNamedArguments Args ;
Args . Add ( TEXT ( " AxisKey " ) , InputAxisKey . GetDisplayName ( ) ) ;
2014-07-14 13:19:37 -04:00
FText TitleFormat = NSLOCTEXT ( " K2Node " , " GetInputAxisKey_Name " , " Get {AxisKey} " ) ;
if ( TitleType = = ENodeTitleType : : ListView )
{
TitleFormat = NSLOCTEXT ( " K2Node " , " GetInputAxisKey_ListTitle " , " {AxisKey} " ) ;
}
return FText : : Format ( TitleFormat , Args ) ;
2014-04-23 18:29:30 -04:00
}
FString UK2Node_GetInputAxisKeyValue : : GetTooltip ( ) const
{
2014-04-23 18:31:10 -04:00
FFormatNamedArguments Args ;
Args . Add ( TEXT ( " AxisKey " ) , InputAxisKey . GetDisplayName ( ) ) ;
return FText : : Format ( NSLOCTEXT ( " K2Node " , " GetInputAxisKey_Tooltip " , " Returns the current value of input axis key {AxisKey}. If input is disabled for the actor the value will be 0. " ) , Args ) . ToString ( ) ;
2014-04-23 18:29:30 -04:00
}
void UK2Node_GetInputAxisKeyValue : : ValidateNodeDuringCompilation ( class FCompilerResultsLog & MessageLog ) const
{
Super : : ValidateNodeDuringCompilation ( MessageLog ) ;
if ( ! InputAxisKey . IsValid ( ) )
{
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " Invalid_GetInputAxisKey_Warning " , " GetInputAxisKey Value specifies invalid FKey'{0}' for @@ " ) , FText : : FromString ( InputAxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
}
2014-04-28 11:24:25 -04:00
else if ( ! InputAxisKey . IsFloatAxis ( ) )
2014-04-23 18:29:30 -04:00
{
2014-04-28 11:24:25 -04:00
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " NotAxis_GetInputAxisKey_Warning " , " GetInputAxisKey Value specifies FKey'{0}' which is not a float axis for @@ " ) , FText : : FromString ( InputAxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
2014-04-23 18:29:30 -04:00
}
else if ( ! InputAxisKey . IsBindableInBlueprints ( ) )
{
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " NotBindanble_GetInputAxisKey_Warning " , " GetInputAxisKey Value specifies FKey'{0}' that is not blueprint bindable for @@ " ) , FText : : FromString ( InputAxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
}
}
UClass * UK2Node_GetInputAxisKeyValue : : GetDynamicBindingClass ( ) const
{
return UInputAxisKeyDelegateBinding : : StaticClass ( ) ;
}
void UK2Node_GetInputAxisKeyValue : : RegisterDynamicBinding ( UDynamicBlueprintBinding * BindingObject ) const
{
UInputAxisKeyDelegateBinding * InputAxisKeyBindingObject = CastChecked < UInputAxisKeyDelegateBinding > ( BindingObject ) ;
FBlueprintInputAxisKeyDelegateBinding Binding ;
Binding . AxisKey = InputAxisKey ;
Binding . bConsumeInput = bConsumeInput ;
Binding . bExecuteWhenPaused = bExecuteWhenPaused ;
InputAxisKeyBindingObject - > InputAxisKeyDelegateBindings . Add ( Binding ) ;
}
FName UK2Node_GetInputAxisKeyValue : : GetPaletteIcon ( FLinearColor & OutColor ) const
{
if ( InputAxisKey . IsMouseButton ( ) )
{
return TEXT ( " GraphEditor.MouseEvent_16x " ) ;
}
else if ( InputAxisKey . IsGamepadKey ( ) )
{
return TEXT ( " GraphEditor.PadEvent_16x " ) ;
}
else
{
return TEXT ( " GraphEditor.KeyEvent_16x " ) ;
}
2014-07-14 13:19:37 -04:00
}
void UK2Node_GetInputAxisKeyValue : : GetMenuActions ( TArray < UBlueprintNodeSpawner * > & ActionListOut ) const
{
TArray < FKey > AllKeys ;
EKeys : : GetAllKeys ( AllKeys ) ;
for ( FKey const Key : AllKeys )
{
if ( ! Key . IsBindableInBlueprints ( ) | | ! Key . IsFloatAxis ( ) )
{
continue ;
}
UBlueprintNodeSpawner * NodeSpawner = UBlueprintNodeSpawner : : Create ( GetClass ( ) ) ;
check ( NodeSpawner ! = nullptr ) ;
auto CustomizeInputNodeLambda = [ ] ( UEdGraphNode * NewNode , bool bIsTemplateNode , FKey Key )
{
UK2Node_GetInputAxisKeyValue * InputNode = CastChecked < UK2Node_GetInputAxisKeyValue > ( NewNode ) ;
InputNode - > Initialize ( Key ) ;
} ;
NodeSpawner - > CustomizeNodeDelegate = UBlueprintNodeSpawner : : FCustomizeNodeDelegate : : CreateStatic ( CustomizeInputNodeLambda , Key ) ;
ActionListOut . Add ( NodeSpawner ) ;
}
}
FText UK2Node_GetInputAxisKeyValue : : GetMenuCategory ( ) const
{
FText SubCategory ;
if ( InputAxisKey . IsGamepadKey ( ) )
{
SubCategory = LOCTEXT ( " GamepadSubCategory " , " Gamepad Values " ) ;
}
else if ( InputAxisKey . IsMouseButton ( ) )
{
SubCategory = LOCTEXT ( " MouseSubCategory " , " Mouse Values " ) ;
}
else
{
SubCategory = LOCTEXT ( " KeySubCategory " , " Key Values " ) ;
}
return FEditorCategoryUtils : : BuildCategoryString ( FCommonEditorCategory : : Input , SubCategory ) ;
}
# undef LOCTEXT_NAMESPACE