Files
UnrealEngineUWP/Engine/Source/Editor/GraphEditor/Private/KismetNodes/SGraphNodeCallParameterCollectionFunction.cpp
Matthew Griffin bb70b349ce Merging CL 2804086 from //UE4/Release-4.11 to Dev-Main (//UE4/Dev-Main) to isolate copyright update
#lockdown Nick.Penwarden

[CL 2819020 by Matthew Griffin in Main branch]
2016-01-07 08:17:16 -05:00

57 lines
1.7 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "GraphEditorCommon.h"
#include "SGraphNode.h"
#include "KismetPins/SGraphPinObject.h"
#include "NodeFactory.h"
#include "SGraphNodeK2Base.h"
#include "SGraphNodeK2Default.h"
#include "SGraphNodeCallParameterCollectionFunction.h"
#include "SGraphPinNameList.h"
#include "Materials/MaterialParameterCollection.h"
//////////////////////////////////////////////////////////////////////////
// SGraphNodeCallParameterCollectionFunction
TSharedPtr<SGraphPin> SGraphNodeCallParameterCollectionFunction::CreatePinWidget(UEdGraphPin* Pin) const
{
UK2Node_CallMaterialParameterCollectionFunction* CallFunctionNode = Cast<UK2Node_CallMaterialParameterCollectionFunction>(GraphNode);
// Create a special pin class for the ParameterName pin
if (CallFunctionNode
&& Pin->PinName == TEXT("ParameterName")
&& Pin->PinType.PinCategory == GetDefault<UEdGraphSchema_K2>()->PC_Name)
{
TArray<FName> NameList;
UEdGraphPin* CollectionPin = GraphNode->FindPin(TEXT("Collection"));
if (CollectionPin)
{
UMaterialParameterCollection* Collection = Cast<UMaterialParameterCollection>(CollectionPin->DefaultObject);
if (Collection)
{
// Populate the ParameterName pin combobox with valid options from the Collection
const bool bVectorParameters = CallFunctionNode->FunctionReference.GetMemberName().ToString().Contains(TEXT("Vector"));
Collection->GetParameterNames(NameList, bVectorParameters);
}
}
TArray<TSharedPtr<FName>> NamePtrList;
for (FName NameItem : NameList)
{
NamePtrList.Add(MakeShareable( new FName(NameItem)));
}
TSharedPtr<SGraphPin> NewPin = SNew(SGraphPinNameList, Pin, NamePtrList);
return NewPin;
}
else
{
return FNodeFactory::CreatePinWidget(Pin);
}
}