void UK2Node_EaseFunction::RefreshPinVisibility() { const auto EaseFuncPin = GetEaseFuncPin(); UEnum * Enum = FindObject<UEnum>(ANY_PACKAGE, TEXT("EEasingFunc"), true); check(Enum != NULL); const int32 NewEasingFunc = CanCustomizeCurve() ? Enum->GetValueByName(*EaseFuncPin->DefaultValue) : -1; // Early exit in case no changes are required const UEdGraphSchema_K2* K2Schema = Cast<const UEdGraphSchema_K2>(GetSchema()); UEdGraphPin* BlendExpPin = FindPinChecked(FEaseFunctionNodeHelper::GetBlendExpPinName()); if (NewEasingFunc == -1 || NewEasingFunc == EEasingFunc::EaseIn || NewEasingFunc == EEasingFunc::EaseOut || NewEasingFunc == EEasingFunc::EaseInOut) { // Show the BlendExpPin BlendExpPin->bHidden = false; } else { // Hide the BlendExpPin: BlendExpPin->BreakAllPinLinks(); BlendExpPin->bHidden = true; } UEdGraphPin* StepsPin = FindPinChecked(FEaseFunctionNodeHelper::GetStepsPinName()); if (NewEasingFunc == -1 || NewEasingFunc == EEasingFunc::Step) { // Show the Steps pin: StepsPin->bHidden = false; } else { // Hide the Steps pin: StepsPin->BreakAllPinLinks(); StepsPin->bHidden = true; } }
void UK2Node_GetEnumeratorName::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) { Super::ExpandNode(CompilerContext, SourceGraph); UEnum* Enum = GetEnum(); if(NULL == Enum) { CompilerContext.MessageLog.Error(*FString::Printf(*NSLOCTEXT("K2Node", "GetEnumeratorNam_Error_MustHaveValidName", "@@ must have a valid enum defined").ToString()), this); return; } const UEdGraphSchema_K2* Schema = CompilerContext.GetSchema(); const UFunction* Function = UKismetNodeHelperLibrary::StaticClass()->FindFunctionByName( GetFunctionName() ); check(NULL != Function); UK2Node_CallFunction* CallGetName = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this, SourceGraph); CallGetName->SetFromFunction(Function); CallGetName->AllocateDefaultPins(); check(CallGetName->IsNodePure()); //OPUTPUT PIN UEdGraphPin* OrgReturnPin = FindPinChecked(Schema->PN_ReturnValue); UEdGraphPin* NewReturnPin = CallGetName->GetReturnValuePin(); check(NULL != NewReturnPin); CompilerContext.MovePinLinksToIntermediate(*OrgReturnPin, *NewReturnPin); //ENUM PIN UEdGraphPin* EnumPin = CallGetName->FindPinChecked(TEXT("Enum")); Schema->TrySetDefaultObject(*EnumPin, Enum); check(EnumPin->DefaultObject == Enum); //VALUE PIN UEdGraphPin* OrgInputPin = FindPinChecked(EnumeratorPinName); UEdGraphPin* IndexPin = CallGetName->FindPinChecked(TEXT("EnumeratorValue")); check(EGPD_Input == IndexPin->Direction && Schema->PC_Byte == IndexPin->PinType.PinCategory); CompilerContext.MovePinLinksToIntermediate(*OrgInputPin, *IndexPin); if (!IndexPin->LinkedTo.Num()) { //MAKE LITERAL BYTE FROM LITERAL ENUM const FString EnumLiteral = IndexPin->GetDefaultAsString(); const int32 NumericValue = Enum->GetValueByName(*EnumLiteral); if (NumericValue == INDEX_NONE) { CompilerContext.MessageLog.Error(*FString::Printf(*NSLOCTEXT("K2Node", "GetEnumeratorNam_Error_InvalidName", "@@ has invalid enum value '%s'").ToString(), *EnumLiteral), this); return; } const FString DefaultByteValue = FString::FromInt(NumericValue); // LITERAL BYTE FUNCTION const FName FunctionName = GET_FUNCTION_NAME_CHECKED(UKismetSystemLibrary, MakeLiteralByte); UK2Node_CallFunction* MakeLiteralByte = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this, SourceGraph); MakeLiteralByte->SetFromFunction(UKismetSystemLibrary::StaticClass()->FindFunctionByName(FunctionName)); MakeLiteralByte->AllocateDefaultPins(); UEdGraphPin* MakeLiteralByteReturnPin = MakeLiteralByte->FindPinChecked(Schema->PN_ReturnValue); Schema->TryCreateConnection(MakeLiteralByteReturnPin, IndexPin); UEdGraphPin* MakeLiteralByteInputPin = MakeLiteralByte->FindPinChecked(TEXT("Value")); MakeLiteralByteInputPin->DefaultValue = DefaultByteValue; } BreakAllNodeLinks(); }