2024-05-31 11:27:14 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "MVVMConversionFunctionGraphSchema.h"
# include "Bindings/MVVMConversionFunctionHelper.h"
# include "EdGraph/EdGraphNode.h"
# include "EdGraph/EdGraphPin.h"
bool UMVVMConversionFunctionGraphSchema : : TryCreateConnection ( UEdGraphPin * A , UEdGraphPin * B ) const
{
bool bResult = Super : : TryCreateConnection ( A , B ) ;
if ( bResult & & ! A - > LinkedTo . Contains ( B ) )
{
// ConversionNode or Promotion node was created between the 2 graph pins
if ( A - > LinkedTo . Num ( ) = = 1 )
{
if ( UEdGraphNode * AutogeneratedNode = A - > LinkedTo [ 0 ] - > GetOwningNode ( ) )
{
for ( UEdGraphPin * AutogeneratedPin : AutogeneratedNode - > Pins )
{
if ( AutogeneratedPin - > LinkedTo . Contains ( B ) )
{
UE : : MVVM : : ConversionFunctionHelper : : MarkNodeAsAutoPromote ( AutogeneratedNode ) ;
break ;
}
}
}
}
}
return bResult ;
}
2024-08-14 09:59:16 -04:00
2024-08-14 10:28:44 -04:00
const FPinConnectionResponse UMVVMConversionFunctionGraphSchema : : CanCreateConnection ( const UEdGraphPin * PinA , const UEdGraphPin * PinB ) const
{
check ( PinA ) ;
check ( PinB ) ;
if ( PinA - > PinType . PinCategory = = UEdGraphSchema_K2 : : PC_SoftObject & & PinB - > PinType . PinCategory = = UEdGraphSchema_K2 : : PC_Object )
{
FPinConnectionResponse Response ( CONNECT_RESPONSE_DISALLOW , FString : : Printf ( TEXT ( " Conversion disallowed from %s to %s " ) , * UEdGraphSchema_K2 : : PC_SoftObject . ToString ( ) , * UEdGraphSchema_K2 : : PC_Object . ToString ( ) ) ) ;
Response . SetFatal ( ) ;
return Response ;
}
return Super : : CanCreateConnection ( PinA , PinB ) ;
}
2024-08-14 09:59:16 -04:00
///////////////////////////////////////////////////////////////////////////////
EGraphType UMVVMFakeTestUbergraphSchema : : GetGraphType ( const UEdGraph * TestEdGraph ) const
{
return EGraphType : : GT_Ubergraph ;
}
UMVVMFakeTestUbergraph : : UMVVMFakeTestUbergraph ( )
{
Schema = UMVVMFakeTestUbergraphSchema : : StaticClass ( ) ;
}
UMVVMFakeTestFunctiongraph : : UMVVMFakeTestFunctiongraph ( )
{
Schema = UMVVMConversionFunctionGraphSchema : : StaticClass ( ) ;
}