2019-12-26 15:33:43 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2014-04-28 11:24:25 -04:00
2014-05-29 16:42:22 -04:00
# include "K2Node_GetInputVectorAxisValue.h"
2022-08-24 22:45:13 -04:00
# include "BlueprintActionDatabaseRegistrar.h"
2014-07-14 13:19:37 -04:00
# include "BlueprintNodeSpawner.h"
2022-08-24 22:45:13 -04:00
# include "Containers/Array.h"
# include "Containers/UnrealString.h"
# include "Delegates/Delegate.h"
# include "EdGraph/EdGraphNode.h"
# include "Engine/DynamicBlueprintBinding.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
# include "Engine/InputAxisKeyDelegateBinding.h"
2014-08-11 03:23:38 -04:00
# include "Engine/InputVectorAxisDelegateBinding.h"
2022-08-24 22:45:13 -04:00
# include "GameFramework/Actor.h"
# include "HAL/Platform.h"
# include "HAL/PlatformCrt.h"
# include "Internationalization/Internationalization.h"
# include "K2Node_CallFunction.h"
# include "Kismet2/CompilerResultsLog.h"
# include "Misc/AssertionMacros.h"
# include "Templates/Casts.h"
# include "UObject/Class.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 ;
2015-06-05 11:45:49 -04:00
SetFromFunction ( AActor : : StaticClass ( ) - > FindFunctionByName ( GET_FUNCTION_NAME_CHECKED ( AActor , GetInputVectorAxisValue ) ) ) ;
2014-04-28 11:24:25 -04:00
}
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 ) ;
}
2020-08-11 01:36:57 -04:00
else if ( ! InputAxisKey . IsAxis2D ( ) & & ! InputAxisKey . IsAxis3D ( ) )
2014-04-28 11:24:25 -04:00
{
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 ) ;
}
2019-11-14 07:02:00 -05:00
else if ( InputAxisKey . IsDeprecated ( ) )
{
MessageLog . Warning ( * FText : : Format ( NSLOCTEXT ( " KismetCompiler " , " Deprecated_GetInputVectorAxis_Warning " , " GetInputVectorAxis Value specifies FKey'{0}' which has been deprecated for @@ " ) , FText : : FromString ( InputAxisKey . ToString ( ) ) ) . ToString ( ) , this ) ;
}
2014-04-28 11:24:25 -04:00
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 ) ;
} ;
2020-08-11 01:36:57 -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
2014-09-17 17:07:37 -04:00
// type disappears, then the action should go with it)
UClass * ActionKey = GetClass ( ) ;
2020-08-11 01:36:57 -04:00
// to keep from needlessly instantiating a UBlueprintNodeSpawner (and
// iterating over keys), 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
2015-06-18 13:40:47 -04:00
// corresponding to that asset)
if ( ActionRegistrar . IsOpenForRegistration ( ActionKey ) )
2014-07-14 13:19:37 -04:00
{
2020-08-11 01:36:57 -04:00
for ( const FKey & Key : AllKeys )
2014-07-14 13:19:37 -04:00
{
2020-08-11 01:36:57 -04:00
if ( ! Key . IsBindableInBlueprints ( ) | | ! ( InputAxisKey . IsAxis2D ( ) | | InputAxisKey . IsAxis3D ( ) ) )
2015-06-18 13:40:47 -04:00
{
continue ;
}
UBlueprintNodeSpawner * NodeSpawner = UBlueprintNodeSpawner : : Create ( GetClass ( ) ) ;
check ( NodeSpawner ! = nullptr ) ;
NodeSpawner - > DefaultMenuSignature . MenuName = FText : : Format ( NSLOCTEXT ( " K2Node_GetInputVectorAxisValue " , " MenuName " , " Get {0} " ) , Key . GetDisplayName ( ) ) ;
NodeSpawner - > CustomizeNodeDelegate = UBlueprintNodeSpawner : : FCustomizeNodeDelegate : : CreateStatic ( CustomizeInputNodeLambda , Key ) ;
ActionRegistrar . AddBlueprintAction ( ActionKey , NodeSpawner ) ;
2014-07-14 13:19:37 -04:00
}
}
}