Files
UnrealEngineUWP/Engine/Source/Editor/BlueprintGraph/Private/K2Node_CallParentFunction.cpp
Mike Beach 3beb0cd5f6 FMemberReferences now default to the authoritative class (unless set through the SetDirect() function).
This is to support references being set for the skeleton class (in the new BP menu system).

#codereview Nick.Whiting

[CL 2308582 by Mike Beach in Main branch]
2014-09-24 14:15:01 -04:00

73 lines
2.1 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "BlueprintGraphPrivatePCH.h"
#define LOCTEXT_NAMESPACE "K2Node"
UK2Node_CallParentFunction::UK2Node_CallParentFunction(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
bIsFinalFunction = true;
}
FText UK2Node_CallParentFunction::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
UFunction* Function = FunctionReference.ResolveMember<UFunction>(this);
FString FunctionName = Function ? GetUserFacingFunctionName( Function ) : FunctionReference.GetMemberName().ToString();
if( GEditor && GetDefault<UEditorStyleSettings>()->bShowFriendlyNames )
{
FunctionName = FName::NameToDisplayString(FunctionName, false);
}
FFormatNamedArguments Args;
Args.Add(TEXT("FunctionName"), FText::FromString( FunctionName ));
return FText::Format( LOCTEXT( "CallSuperFunction", "Parent: {FunctionName}" ), Args);
}
FLinearColor UK2Node_CallParentFunction::GetNodeTitleColor() const
{
return GetDefault<UGraphEditorSettings>()->ParentFunctionCallNodeTitleColor;
}
void UK2Node_CallParentFunction::AllocateDefaultPins()
{
Super::AllocateDefaultPins();
const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();
UEdGraphPin* SelfPin = Schema->FindSelfPin(*this, EGPD_Input);
if( SelfPin )
{
SelfPin->bHidden = true;
}
}
void UK2Node_CallParentFunction::SetFromFunction(const UFunction* Function)
{
if (Function != NULL)
{
bIsPureFunc = Function->HasAnyFunctionFlags(FUNC_BlueprintPure);
bIsConstFunc = Function->HasAnyFunctionFlags(FUNC_Const);
UClass* OwnerClass = Function->GetOwnerClass();
FGuid FunctionGuid;
if (OwnerClass != nullptr)
{
OwnerClass = OwnerClass->GetAuthoritativeClass();
UBlueprint::GetGuidFromClassByFieldName<UFunction>(OwnerClass, Function->GetFName(), FunctionGuid);
}
FunctionReference.SetDirect(Function->GetFName(), FunctionGuid, OwnerClass, /*bIsConsideredSelfContext =*/false);
}
}
void UK2Node_CallParentFunction::PostPlacedNewNode()
{
// We don't want to check if our function exists in the current scope
UK2Node::PostPlacedNewNode();
}
#undef LOCTEXT_NAMESPACE