void UK2Node_SwitchInteger::ReallocatePinsDuringReconstruction(TArray<UEdGraphPin*>& OldPins) { Super::ReallocatePinsDuringReconstruction(OldPins); const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); int32 ExecOutPinCount = StartIndex; UEdGraphPin* DefaultPin = GetDefaultPin(); for (int32 i = bHasDefaultPin ? 1 : 0; i < OldPins.Num(); ++i) { UEdGraphPin* TestPin = OldPins[i]; if (K2Schema->IsExecPin(*TestPin) && (TestPin->Direction == EGPD_Output)) { // Skip the default pin to avoid creating an extra output pin in the case where the default pin has been toggled off if(TestPin->PinName != TEXT("Default")) { FString NewPinName = GetPinNameGivenIndex(ExecOutPinCount); ExecOutPinCount++; // Make sure the old pin and new pin names match TestPin->PinName = NewPinName; // Create the new output pin to match CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), NULL, false, false, NewPinName); } } } }
void UK2Node_Switch::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) { FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None; if (PropertyName == TEXT("bHasDefaultPin")) { // Signal to the reconstruction logic that the default pin value has changed bHasDefaultPinValueChanged = true; if (!bHasDefaultPin) { UEdGraphPin* DefaultPin = GetDefaultPin(); if (DefaultPin) { const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); K2Schema->BreakPinLinks(*DefaultPin, true); } } ReconstructNode(); // Clear the default pin value change flag bHasDefaultPinValueChanged = false; } Super::PostEditChangeProperty(PropertyChangedEvent); }
void UK2Node_SwitchInteger::RemovePin(UEdGraphPin* /*TargetPin*/) { const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); int32 PinIndex = (StartIndex >= 0) ? StartIndex : 0; UEdGraphPin* DefaultPin = GetDefaultPin(); for (int32 i = 0; i < Pins.Num(); ++i) { UEdGraphPin* PotentialPin = Pins[i]; if (K2Schema->IsExecPin(*PotentialPin) && (PotentialPin->Direction == EGPD_Output) && (PotentialPin != DefaultPin)) { PotentialPin->PinName = GetPinNameGivenIndex(PinIndex); ++PinIndex; } } }
void UK2Node_Switch::RemovePinFromSwitchNode(UEdGraphPin* TargetPin) { // If removing the default pin, we'll need to reconstruct the node, so send a property changed event to handle that if(bHasDefaultPin && TargetPin == GetDefaultPin()) { UProperty* HasDefaultPinProperty = FindField<UProperty>(GetClass(), "bHasDefaultPin"); if(HasDefaultPinProperty != NULL) { PreEditChange(HasDefaultPinProperty); bHasDefaultPin = false; FPropertyChangedEvent HasDefaultPinPropertyChangedEvent(HasDefaultPinProperty); PostEditChangeProperty(HasDefaultPinPropertyChangedEvent); } } else { TargetPin->MarkPendingKill(); Pins.Remove(TargetPin); } }