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 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 }
FReply FDragConnection::DroppedOnPin(FVector2D ScreenPosition, FVector2D GraphPosition) { TArray<UEdGraphPin*> ValidSourcePins; ValidateGraphPinList(/*out*/ ValidSourcePins); const FScopedTransaction Transaction( NSLOCTEXT("UnrealEd", "GraphEd_CreateConnection", "Create Pin Link") ); UEdGraphPin* PinB = GetHoveredPin(); bool bError = false; TSet<UEdGraphNode*> NodeList; for (UEdGraphPin* PinA : ValidSourcePins) { if ((PinA != NULL) && (PinB != NULL)) { UEdGraph* MyGraphObj = PinA->GetOwningNode()->GetGraph(); if (MyGraphObj->GetSchema()->TryCreateConnection(PinA, PinB)) { NodeList.Add(PinA->GetOwningNode()); NodeList.Add(PinB->GetOwningNode()); } } else { bError = true; } } // Send all nodes that received a new pin connection a notification for (auto It = NodeList.CreateConstIterator(); It; ++It) { UEdGraphNode* Node = (*It); Node->NodeConnectionListChanged(); } if (bError) { return FReply::Unhandled(); } return FReply::Handled(); }
void UEdGraphNode::BreakAllNodeLinks() { TSet<UEdGraphNode*> NodeList; NodeList.Add(this); // Iterate over each pin and break all links for(int32 PinIdx=0; PinIdx<Pins.Num(); PinIdx++) { Pins[PinIdx]->BreakAllPinLinks(); NodeList.Add(Pins[PinIdx]->GetOwningNode()); } // Send all nodes that received a new pin connection a notification for (auto It = NodeList.CreateConstIterator(); It; ++It) { UEdGraphNode* Node = (*It); Node->NodeConnectionListChanged(); } }
void USoundCueGraphNode_Base::AutowireNewNode(UEdGraphPin* FromPin) { if (FromPin != NULL) { const USoundCueGraphSchema* Schema = CastChecked<USoundCueGraphSchema>(GetSchema()); TSet<UEdGraphNode*> NodeList; // auto-connect from dragged pin to first compatible pin on the new node for (int32 i=0; i<Pins.Num(); i++) { UEdGraphPin* Pin = Pins[i]; check(Pin); FPinConnectionResponse Response = Schema->CanCreateConnection(FromPin, Pin); if (ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE == Response.Response) { if (Schema->TryCreateConnection(FromPin, Pin)) { NodeList.Add(FromPin->GetOwningNode()); NodeList.Add(this); } break; } else if(ECanCreateConnectionResponse::CONNECT_RESPONSE_BREAK_OTHERS_A == Response.Response) { InsertNewNode(FromPin, Pin, NodeList); break; } } // Send all nodes that received a new pin connection a notification for (auto It = NodeList.CreateConstIterator(); It; ++It) { UEdGraphNode* Node = (*It); Node->NodeConnectionListChanged(); } } }
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 UK2Node::AutowireNewNode(UEdGraphPin* FromPin) { const UEdGraphSchema_K2* K2Schema = CastChecked<UEdGraphSchema_K2>(GetSchema()); // Do some auto-connection if (FromPin != NULL) { TSet<UEdGraphNode*> NodeList; // sometimes we don't always find an ideal connection, but we want to exhaust // all our options first... this stores a secondary less-ideal pin to connect to, if nothing better was found UEdGraphPin* BackupConnection = NULL; // If not dragging an exec pin, auto-connect from dragged pin to first compatible pin on the new node for (int32 i=0; i<Pins.Num(); i++) { UEdGraphPin* Pin = Pins[i]; check(Pin); ECanCreateConnectionResponse ConnectResponse = K2Schema->CanCreateConnection(FromPin, Pin).Response; if (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE) { if (K2Schema->TryCreateConnection(FromPin, Pin)) { NodeList.Add(FromPin->GetOwningNode()); NodeList.Add(this); } // null out the backup connection (so we don't attempt to make it // once we exit the loop... we successfully made this connection!) BackupConnection = NULL; break; } else if((FromPin->PinType.PinCategory == K2Schema->PC_Exec) && (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_BREAK_OTHERS_A)) { InsertNewNode(FromPin, Pin, NodeList); // null out the backup connection (so we don't attempt to make it // once we exit the loop... we successfully made this connection!) BackupConnection = NULL; break; } else if ((BackupConnection == NULL) && (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE_WITH_CONVERSION_NODE)) { // save this off, in-case we don't make any connection at all BackupConnection = Pin; } } // if we didn't find an ideal connection, then lets connect this pin to // the BackupConnection (something, like a connection that requires a conversion node, etc.) if ((BackupConnection != NULL) && K2Schema->TryCreateConnection(FromPin, BackupConnection)) { NodeList.Add(FromPin->GetOwningNode()); NodeList.Add(this); } // If we were not dragging an exec pin, but it was an output pin, try and connect the Then and Execute pins if ((FromPin->PinType.PinCategory != K2Schema->PC_Exec && FromPin->Direction == EGPD_Output)) { UEdGraphNode* FromPinNode = FromPin->GetOwningNode(); UEdGraphPin* FromThenPin = FromPinNode->FindPin(K2Schema->PN_Then); UEdGraphPin* ToExecutePin = FindPin(K2Schema->PN_Execute); if ((FromThenPin != NULL) && (FromThenPin->LinkedTo.Num() == 0) && (ToExecutePin != NULL) && K2Schema->ArePinsCompatible(FromThenPin, ToExecutePin, NULL)) { if (K2Schema->TryCreateConnection(FromThenPin, ToExecutePin)) { NodeList.Add(FromPinNode); NodeList.Add(this); } } } // Send all nodes that received a new pin connection a notification for (auto It = NodeList.CreateConstIterator(); It; ++It) { UEdGraphNode* Node = (*It); Node->NodeConnectionListChanged(); } } }