FText SGraphNodeK2CreateDelegate::GetCurrentFunctionDescription() const { UK2Node_CreateDelegate* Node = Cast<UK2Node_CreateDelegate>(GraphNode); UFunction* FunctionSignature = Node ? Node->GetDelegateSignature() : NULL; UClass* ScopeClass = Node ? Node->GetScopeClass() : NULL; if(!FunctionSignature || !ScopeClass) { return NSLOCTEXT("GraphNodeK2Create", "NoneLabel", "None"); } if (const auto Func = FindField<UFunction>(ScopeClass, Node->GetFunctionName())) { return FText::FromString(FunctionDescription(Func)); } if (Node->GetFunctionName() != NAME_None) { return FText::Format(NSLOCTEXT("GraphNodeK2Create", "ErrorLabelFmt", "Error? {0}"), FText::FromName(Node->GetFunctionName())); } return NSLOCTEXT("GraphNodeK2Create", "SelectFunctionLabel", "Select Function"); }
void FKCHandler_CreateDelegate::Compile(FKismetFunctionContext& Context, UEdGraphNode* Node) { UK2Node_CreateDelegate * DelegateNode = CastChecked<UK2Node_CreateDelegate>(Node); check(NULL != DelegateNode); FBlueprintCompiledStatement& Statement = Context.AppendStatementForNode(Node); Statement.Type = KCST_BindDelegate; { UEdGraphPin* OutPin = DelegateNode->GetDelegateOutPin(); check(NULL != OutPin); UEdGraphPin* Net = FEdGraphUtilities::GetNetFromPin(OutPin); check(NULL != Net); FBPTerminal** FoundTerm = Context.NetMap.Find(Net); check(FoundTerm && *FoundTerm); Statement.LHS = *FoundTerm; } { FBPTerminal* DelegateNameTerm = Context.CreateLocalTerminal(ETerminalSpecification::TS_Literal); DelegateNameTerm->Type.PinCategory = CompilerContext.GetSchema()->PC_Name; DelegateNameTerm->Name = DelegateNode->GetFunctionName().ToString(); DelegateNameTerm->bIsLiteral = true; Statement.RHS.Add(DelegateNameTerm); } { UEdGraphPin* InputPin = DelegateNode->GetObjectInPin(); check(NULL != InputPin); UEdGraphPin* Net = FEdGraphUtilities::GetNetFromPin(InputPin); FBPTerminal** FoundTerm = Context.NetMap.Find(Net); check(FoundTerm && *FoundTerm); Statement.RHS.Add(*FoundTerm); } FNodeHandlingFunctor::Compile(Context, Node); }
void FKCHandler_CreateDelegate::RegisterNets(FKismetFunctionContext& Context, UEdGraphNode* Node) { UK2Node_CreateDelegate * DelegateNode = CastChecked<UK2Node_CreateDelegate>(Node); check(NULL != DelegateNode); const FName DelegateFunctionName = DelegateNode->GetFunctionName(); if(DelegateFunctionName == NAME_None) { CompilerContext.MessageLog.Error(*LOCTEXT("NoDelegateFunctionName", "No delegate function name @@").ToString(), DelegateNode); return; } if(!DelegateNode->GetDelegateSignature()) { const FString ErrorStr = FString::Printf( *LOCTEXT("NoDelegateFunction", "No delegate function '%' @@").ToString(), *DelegateFunctionName.ToString()); CompilerContext.MessageLog.Error(*ErrorStr, DelegateNode); return; } { UEdGraphPin* InputPin = DelegateNode->GetObjectInPin(); check(NULL != InputPin); UEdGraphPin* Net = FEdGraphUtilities::GetNetFromPin(InputPin); FBPTerminal** FoundTerm = Context.NetMap.Find(Net); FBPTerminal* InputObjTerm = FoundTerm ? *FoundTerm : NULL; if(NULL == InputObjTerm) { if (InputPin->LinkedTo.Num() == 0) { InputObjTerm = Context.CreateLocalTerminal(ETerminalSpecification::TS_Literal); InputObjTerm->Name = Context.NetNameMap->MakeValidName(Net); InputObjTerm->Type.PinSubCategory = CompilerContext.GetSchema()->PN_Self; } else { InputObjTerm = Context.CreateLocalTerminalFromPinAutoChooseScope(Net, Context.NetNameMap->MakeValidName(Net)); } Context.NetMap.Add(Net, InputObjTerm); } } { UEdGraphPin* OutPin = DelegateNode->GetDelegateOutPin(); check(NULL != OutPin); if(!OutPin->LinkedTo.Num()) { CompilerContext.MessageLog.Error(*LOCTEXT("NoDelegateSignature", "No delegate signature @@").ToString(), DelegateNode); return; } UEdGraphPin* Net = FEdGraphUtilities::GetNetFromPin(OutPin); FBPTerminal** FoundTerm = Context.NetMap.Find(Net); FBPTerminal* OutDelegateTerm = FoundTerm ? *FoundTerm : NULL; if(NULL == OutDelegateTerm) { OutDelegateTerm = Context.CreateLocalTerminalFromPinAutoChooseScope(Net, Context.NetNameMap->MakeValidName(Net)); if (NULL == FMemberReference::ResolveSimpleMemberReference<UFunction>(OutDelegateTerm->Type.PinSubCategoryMemberReference)) { FMemberReference::FillSimpleMemberReference<UFunction>(DelegateNode->GetDelegateSignature(), OutDelegateTerm->Type.PinSubCategoryMemberReference); } if (NULL == FMemberReference::ResolveSimpleMemberReference<UFunction>(OutDelegateTerm->Type.PinSubCategoryMemberReference)) { CompilerContext.MessageLog.Error(*LOCTEXT("UnconnectedDelegateSig", "Event Dispatcher has no signature @@").ToString(), OutPin); return; } Context.NetMap.Add(Net, OutDelegateTerm); } } }