void UK2Node_Composite::AllocateDefaultPins() { UK2Node::AllocateDefaultPins(); if (OutputSourceNode) { for (TArray<UEdGraphPin*>::TIterator PinIt(OutputSourceNode->Pins); PinIt; ++PinIt) { UEdGraphPin* PortPin = *PinIt; if (PortPin->Direction == EGPD_Input) { UEdGraphPin* NewPin = CreatePin(UEdGraphPin::GetComplementaryDirection(PortPin->Direction), PortPin->PinType, PortPin->PinName); NewPin->DefaultValue = NewPin->AutogeneratedDefaultValue = PortPin->DefaultValue; } } } if (InputSinkNode) { for (TArray<UEdGraphPin*>::TIterator PinIt(InputSinkNode->Pins); PinIt; ++PinIt) { UEdGraphPin* PortPin = *PinIt; if (PortPin->Direction == EGPD_Output) { UEdGraphPin* NewPin = CreatePin(UEdGraphPin::GetComplementaryDirection(PortPin->Direction), PortPin->PinType, PortPin->PinName); NewPin->DefaultValue = NewPin->AutogeneratedDefaultValue = PortPin->DefaultValue; } } } }
void UEdGraphSchema::BreakPinLinks(UEdGraphPin& TargetPin, bool bSendsNodeNotifcation) const { #if WITH_EDITOR // Copy the old pin links TArray<class UEdGraphPin*> OldLinkedTo(TargetPin.LinkedTo); #endif TargetPin.BreakAllPinLinks(); #if WITH_EDITOR TSet<UEdGraphNode*> NodeList; // Notify this node TargetPin.GetOwningNode()->PinConnectionListChanged(&TargetPin); NodeList.Add(TargetPin.GetOwningNode()); // As well as all other nodes that were connected for (TArray<UEdGraphPin*>::TIterator PinIt(OldLinkedTo); PinIt; ++PinIt) { UEdGraphPin* OtherPin = *PinIt; UEdGraphNode* OtherNode = OtherPin->GetOwningNode(); OtherNode->PinConnectionListChanged(OtherPin); NodeList.Add(OtherNode); } if (bSendsNodeNotifcation) { // Send all nodes that received a new pin connection a notification for (auto It = NodeList.CreateConstIterator(); It; ++It) { UEdGraphNode* Node = (*It); Node->NodeConnectionListChanged(); } } #endif //#if WITH_EDITOR }
void UK2Node_DelegateSet::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) { Super::ExpandNode(CompilerContext, SourceGraph); if (SourceGraph != CompilerContext.ConsolidatedEventGraph) { CompilerContext.MessageLog.Error(*FString::Printf(*NSLOCTEXT("KismetCompiler", "InvalidNodeOutsideUbergraph_Error", "Unexpected node @@ found outside ubergraph.").ToString()), this); } else { UFunction* TargetFunction = GetDelegateSignature(); if(TargetFunction != NULL) { const UEdGraphSchema_K2* Schema = CompilerContext.GetSchema(); // First, create an event node matching the delegate signature UK2Node_Event* DelegateEvent = CompilerContext.SpawnIntermediateEventNode<UK2Node_Event>(this, nullptr, SourceGraph); DelegateEvent->EventReference.SetFromField<UFunction>(TargetFunction, false); DelegateEvent->CustomFunctionName = GetDelegateTargetEntryPointName(); DelegateEvent->bInternalEvent = true; DelegateEvent->AllocateDefaultPins(); // Move the pins over to the newly created event node for( TArray<UEdGraphPin*>::TIterator PinIt(DelegateEvent->Pins); PinIt; ++PinIt ) { UEdGraphPin* CurrentPin = *PinIt; check(CurrentPin); if( CurrentPin->Direction == EGPD_Output ) { if( CurrentPin->PinType.PinCategory == Schema->PC_Exec ) { // Hook up the exec pin specially, since it has a different name on the dynamic delegate node UEdGraphPin* OldExecPin = FindPin(Schema->PN_DelegateEntry); check(OldExecPin); CompilerContext.MovePinLinksToIntermediate(*OldExecPin, *CurrentPin); } else if( CurrentPin->PinName != UK2Node_Event::DelegateOutputName ) { // Hook up all other pins, EXCEPT the delegate output pin, which isn't needed in this case UEdGraphPin* OldPin = FindPin(CurrentPin->PinName); if( !OldPin ) { // If we couldn't find the old pin, the function signature is out of date. Tell them to reconstruct CompilerContext.MessageLog.Error(*FString::Printf(*NSLOCTEXT("KismetCompiler", "EventNodeOutOfDate_Error", "Event node @@ is out-of-date. Please refresh it.").ToString()), this); return; } CompilerContext.MovePinLinksToIntermediate(*OldPin, *CurrentPin); } } } } else { CompilerContext.MessageLog.Error(*FString::Printf(*LOCTEXT("DelegateSigNotFound_Error", "Set Delegate node @@ unable to find function.").ToString()), this); } } }
void UEdGraphSchema::BreakNodeLinks(UEdGraphNode& TargetNode) const { #if WITH_EDITOR for (TArray<UEdGraphPin*>::TIterator PinIt(TargetNode.Pins); PinIt; ++PinIt) { BreakPinLinks(*(*PinIt), false); } TargetNode.NodeConnectionListChanged(); #endif //#if WITH_EDITOR }
void UK2Node_MacroInstance::AllocateDefaultPins() { UK2Node::AllocateDefaultPins(); PreloadObject(MacroGraphReference.GetBlueprint()); UEdGraph* MacroGraph = MacroGraphReference.GetGraph(); if (MacroGraph != NULL) { PreloadObject(MacroGraph); // Preload the macro graph, if needed, so that we can get the proper pins if (MacroGraph->HasAnyFlags(RF_NeedLoad)) { PreloadObject(MacroGraph); FBlueprintEditorUtils::PreloadMembers(MacroGraph); } for (TArray<UEdGraphNode*>::TIterator NodeIt(MacroGraph->Nodes); NodeIt; ++NodeIt) { if (UK2Node_Tunnel* TunnelNode = Cast<UK2Node_Tunnel>(*NodeIt)) { // Only want exact tunnel nodes, more specific nodes like composites or macro instances shouldn't be grabbed. if (TunnelNode->GetClass() == UK2Node_Tunnel::StaticClass()) { for (TArray<UEdGraphPin*>::TIterator PinIt(TunnelNode->Pins); PinIt; ++PinIt) { UEdGraphPin* PortPin = *PinIt; // We're not interested in any pins that have been expanded internally on the macro if (PortPin->ParentPin == NULL) { UEdGraphPin* NewLocalPin = CreatePin( UEdGraphPin::GetComplementaryDirection(PortPin->Direction), PortPin->PinType.PinCategory, PortPin->PinType.PinSubCategory, PortPin->PinType.PinSubCategoryObject.Get(), PortPin->PinType.bIsArray, PortPin->PinType.bIsReference, PortPin->PinName); NewLocalPin->DefaultValue = NewLocalPin->AutogeneratedDefaultValue = PortPin->DefaultValue; } } } } } } }
void UEdGraphSchema::BreakNodeLinks(UEdGraphNode& TargetNode) const { #if WITH_EDITOR TSet<UEdGraphNode*> NodeList; NodeList.Add(&TargetNode); // Iterate over each pin and break all links for (TArray<UEdGraphPin*>::TIterator PinIt(TargetNode.Pins); PinIt; ++PinIt) { UEdGraphPin* TargetPin = *PinIt; if (TargetPin) { // Keep track of which node(s) the pin's connected to for (auto OtherPin : TargetPin->LinkedTo) { if (OtherPin) { UEdGraphNode* OtherNode = OtherPin->GetOwningNode(); if (OtherNode) { NodeList.Add(OtherNode); } } } BreakPinLinks(*TargetPin, false); } } // Send all nodes that lost connections a notification for (auto It = NodeList.CreateConstIterator(); It; ++It) { UEdGraphNode* Node = (*It); Node->NodeConnectionListChanged(); } #endif //#if WITH_EDITOR }
void SFindInMaterial::MatchTokens(const TArray<FString> &Tokens) { RootSearchResult.Reset(); UEdGraph* Graph = MaterialEditorPtr.Pin()->Material->MaterialGraph; if (Graph == NULL) { return; } RootSearchResult = FSearchResult(new FFindInMaterialResult(FString("BehaviorTreeRoot"))); for (auto It(Graph->Nodes.CreateConstIterator()); It; ++It) { UEdGraphNode* Node = *It; const FString NodeName = Node->GetNodeTitle(ENodeTitleType::ListView).ToString(); FSearchResult NodeResult(new FFindInMaterialResult(NodeName, RootSearchResult, Node)); FString NodeSearchString = NodeName + Node->NodeComment; NodeSearchString = NodeSearchString.Replace(TEXT(" "), TEXT("")); bool bNodeMatchesSearch = StringMatchesSearchTokens(Tokens, NodeSearchString); // Use old Material Expression search functions too if (!bNodeMatchesSearch) { bool bMatchesAllTokens = true; if (UMaterialGraphNode* MatNode = Cast<UMaterialGraphNode>(Node)) { for (int32 Index = 0; Index < Tokens.Num(); ++Index) { if (!MatNode->MaterialExpression->MatchesSearchQuery(*Tokens[Index])) { bMatchesAllTokens = false; break; } } } else if (UMaterialGraphNode_Comment* MatComment = Cast<UMaterialGraphNode_Comment>(Node)) { for (int32 Index = 0; Index < Tokens.Num(); ++Index) { if (!MatComment->MaterialExpressionComment->MatchesSearchQuery(*Tokens[Index])) { bMatchesAllTokens = false; break; } } } else { bMatchesAllTokens = false; } if (bMatchesAllTokens) { bNodeMatchesSearch = true; } } for (TArray<UEdGraphPin*>::TIterator PinIt(Node->Pins); PinIt; ++PinIt) { UEdGraphPin* Pin = *PinIt; if (Pin && Pin->PinFriendlyName.CompareTo(FText::FromString(TEXT(" "))) != 0) { FText PinName = Pin->GetSchema()->GetPinDisplayName(Pin); FString PinSearchString = Pin->PinName + Pin->PinFriendlyName.ToString() + Pin->DefaultValue + Pin->PinType.PinCategory + Pin->PinType.PinSubCategory + (Pin->PinType.PinSubCategoryObject.IsValid() ? Pin->PinType.PinSubCategoryObject.Get()->GetFullName() : TEXT("")); PinSearchString = PinSearchString.Replace(TEXT(" "), TEXT("")); if (StringMatchesSearchTokens(Tokens, PinSearchString)) { FSearchResult PinResult(new FFindInMaterialResult(PinName.ToString(), NodeResult, Pin)); NodeResult->Children.Add(PinResult); } } } if ((NodeResult->Children.Num() > 0) || bNodeMatchesSearch) { ItemsFound.Add(NodeResult); } } }