// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. #include "BlueprintGraphPrivatePCH.h" #include "../../../Runtime/Engine/Classes/Kismet/KismetMathLibrary.h" UK2Node_SwitchName::UK2Node_SwitchName(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) { FunctionName = TEXT("NotEqual_NameName"); FunctionClass = UKismetMathLibrary::StaticClass(); } void UK2Node_SwitchName::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) { bool bIsDirty = false; FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None; if (PropertyName == TEXT("PinNames")) { bIsDirty = true; } if (bIsDirty) { ReconstructNode(); GetGraph()->NotifyGraphChanged(); } Super::PostEditChangeProperty(PropertyChangedEvent); } FText UK2Node_SwitchName::GetNodeTitle(ENodeTitleType::Type TitleType) const { return NSLOCTEXT("K2Node", "Switch_Name", "Switch on Name"); } FString UK2Node_SwitchName::GetTooltip() const { return NSLOCTEXT("K2Node", "SwitchName_ToolTip", "Selects an output that matches the input value").ToString(); } void UK2Node_SwitchName::CreateSelectionPin() { const UEdGraphSchema_K2* K2Schema = GetDefault(); CreatePin(EGPD_Input, K2Schema->PC_Name, TEXT(""), NULL, false, false, TEXT("Selection")); } FString UK2Node_SwitchName::GetPinNameGivenIndex(int32 Index) { check(Index); return PinNames[Index].ToString(); } void UK2Node_SwitchName::CreateCasePins() { const UEdGraphSchema_K2* K2Schema = GetDefault(); for( TArray::TIterator it(PinNames); it; ++it ) { CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), NULL, false, false, (*it).ToString()); } } FString UK2Node_SwitchName::GetUniquePinName() { FString NewPinName; int32 Index = 0; while (true) { NewPinName = FString::Printf(TEXT("Case_%d"), Index++); if (!FindPin(NewPinName)) { break; } } return NewPinName; } void UK2Node_SwitchName::AddPinToSwitchNode() { FString PinName = GetUniquePinName(); PinNames.Add(FName(*PinName)); const UEdGraphSchema_K2* K2Schema = GetDefault(); CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), NULL, false, false, PinName); } void UK2Node_SwitchName::RemovePin(UEdGraphPin* TargetPin) { checkSlow(TargetPin); // Clean-up pin name array PinNames.Remove(FName(*TargetPin->PinName)); }