Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/Private/Core/N2CNodeTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ void FN2CNodeTranslator::ProcessNodeFlows(UK2Node* Node, const TArray<UEdGraphPi
// Always store flow from output pin to input pin
if (ActualSourcePin->Direction == EGPD_Output)
{
CurrentGraph->Flows.Data.Add(SourceRef, TargetRef);
CurrentGraph->Flows.Data.FindOrAdd(SourceRef).TargetPins.Add(TargetRef);

// Log data flow
FString FlowContext = FString::Printf(TEXT("Added data flow: %s.%s (%s.%s) -> %s.%s (%s.%s)"),
Expand All @@ -887,7 +887,7 @@ void FN2CNodeTranslator::ProcessNodeFlows(UK2Node* Node, const TArray<UEdGraphPi
}
else
{
CurrentGraph->Flows.Data.Add(TargetRef, SourceRef);
CurrentGraph->Flows.Data.FindOrAdd(TargetRef).TargetPins.Add(SourceRef);

// Log data flow
FString FlowContext = FString::Printf(TEXT("Added data flow: %s.%s (%s.%s) -> %s.%s (%s.%s)"),
Expand Down
13 changes: 9 additions & 4 deletions Source/Private/Core/N2CSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,17 @@ TSharedPtr<FJsonObject> FN2CSerializer::FlowsToJsonObject(const FN2CFlows& Flows
JsonObject->SetArrayField(TEXT("execution"), ExecutionArray);

// Add data flows object
TSharedPtr<FJsonObject> DataFlowsObject = MakeShared<FJsonObject>();
TArray<TSharedPtr<FJsonValue>> DataFlowConnections;
for (const auto& DataFlow : Flows.Data)
{
DataFlowsObject->SetStringField(DataFlow.Key, DataFlow.Value);
for (const auto& InputConnector : DataFlow.Value.TargetPins)
{
TSharedPtr<FJsonValueString> DataFlowConnection= MakeShared<FJsonValueString>(FString::Printf(TEXT("%s -> %s"), *DataFlow.Key, *InputConnector));
DataFlowConnections.Add(DataFlowConnection);
}
}
JsonObject->SetObjectField(TEXT("data"), DataFlowsObject);
TSharedPtr<FJsonValueArray> DataFlowsObject = MakeShared<FJsonValueArray>(DataFlowConnections);
JsonObject->SetField(TEXT("data"), DataFlowsObject);

return JsonObject;
}
Expand Down Expand Up @@ -751,7 +756,7 @@ bool FN2CSerializer::ParseFlowsFromJson(const TSharedPtr<FJsonObject>& JsonObjec
{
if (DataFlow.Value->Type == EJson::String)
{
OutFlows.Data.Add(DataFlow.Key, DataFlow.Value->AsString());
OutFlows.Data.FindOrAdd(DataFlow.Key).TargetPins.Add(DataFlow.Value->AsString());
}
}

Expand Down
17 changes: 10 additions & 7 deletions Source/Private/Utils/Validators/N2CBlueprintValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,17 @@ bool FN2CBlueprintValidator::ValidateFlowReferences(const FN2CGraph& Graph, FStr
return false;
}

// Validate target pin format (N#.P#)
TArray<FString> TargetParts;
DataFlow.Value.ParseIntoArray(TargetParts, TEXT("."));
if (TargetParts.Num() != 2 || !NodeIds.Contains(TargetParts[0]))
for (const auto& TargetPinName : DataFlow.Value.TargetPins)
{
OutError = FString::Printf(TEXT("Invalid target pin format %s in graph %s"), *DataFlow.Value, *Graph.Name);
FN2CLogger::Get().LogError(OutError);
return false;
// Validate target pin format (N#.P#)
TArray<FString> TargetParts;
TargetPinName.ParseIntoArray(TargetParts, TEXT("."));
if (TargetParts.Num() != 2 || !NodeIds.Contains(TargetParts[0]))
{
OutError = FString::Printf(TEXT("Invalid target pin format %s in graph %s"), *TargetPinName, *Graph.Name);
FN2CLogger::Get().LogError(OutError);
return false;
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion Source/Public/Models/N2CBlueprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ struct FN2CMetadata
FN2CMetadata() : Name(TEXT("")), BlueprintType(EN2CBlueprintType::Normal), BlueprintClass(TEXT("")) {}
};

USTRUCT(BlueprintType)
struct FN2CInputConnectors
{
GENERATED_BODY()

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Node to Code")
TSet<FString> TargetPins;
};

/**
* @struct FN2CFlows
* @brief Contains all execution and data flow connections between nodes
Expand All @@ -87,7 +96,7 @@ struct FN2CFlows

/** Data connections: a mapping from "N1.P4" to "N2.P3" */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Node to Code")
TMap<FString, FString> Data;
TMap<FString, FN2CInputConnectors> Data;

FN2CFlows()
{
Expand Down