// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. #include "BlueprintGraphPrivatePCH.h" #include "K2Node_GetInputVectorAxisValue.h" #include "CompilerResultsLog.h" #include "BlueprintNodeSpawner.h" #include "Engine/InputVectorAxisDelegateBinding.h" UK2Node_GetInputVectorAxisValue::UK2Node_GetInputVectorAxisValue(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) { bConsumeInput = true; } void UK2Node_GetInputVectorAxisValue::Initialize(const FKey AxisKey) { InputAxisKey = AxisKey; SetFromFunction(AActor::StaticClass()->FindFunctionByName(TEXT("GetInputVectorAxisValue"))); } FString UK2Node_GetInputVectorAxisValue::GetTooltip() const { FFormatNamedArguments Args; Args.Add(TEXT("AxisKey"), InputAxisKey.GetDisplayName()); 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).ToString(); } 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(BindingObject); FBlueprintInputAxisKeyDelegateBinding Binding; Binding.AxisKey = InputAxisKey; Binding.bConsumeInput = bConsumeInput; Binding.bExecuteWhenPaused = bExecuteWhenPaused; InputVectorAxisBindingObject->InputAxisKeyDelegateBindings.Add(Binding); } void UK2Node_GetInputVectorAxisValue::GetMenuActions(TArray& ActionListOut) const { TArray 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_GetInputVectorAxisValue* InputNode = CastChecked(NewNode); InputNode->Initialize(Key); }; NodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(CustomizeInputNodeLambda, Key); ActionListOut.Add(NodeSpawner); } }