More fixes to blueprint exporter.

This commit is contained in:
2026-02-16 21:02:01 -05:00
parent 15997aee62
commit 55ad662d3f
5 changed files with 55 additions and 25 deletions

View File

@@ -11,12 +11,14 @@
#include "EdGraphNode_Comment.h"
#include "K2Node_VariableGet.h"
#include "K2Node_CallFunction.h"
#include "K2Node_FunctionEntry.h"
FlxBlueprintExporter::FlxBlueprintExporter(UEdGraph* InGraph)
: Graph(InGraph)
{
SortNodes();
AssignNodeNames();
EmitLocalVariables();
EmitNodeList();
EmitGraph();
}
@@ -33,20 +35,27 @@ FString FlxBlueprintExporter::SanitizeName(const FString& Title)
return Result.IsEmpty() ? TEXT("_") : Result;
}
FString FlxBlueprintExporter::FormatPinType(UEdGraphPin* Pin)
FString FlxBlueprintExporter::FormatPinType(const FEdGraphPinType& PinType)
{
if (UObject* SubObj = Pin->PinType.PinSubCategoryObject.Get())
if (UObject* SubObj = PinType.PinSubCategoryObject.Get())
{
return SubObj->GetName();
}
FString Type = Pin->PinType.PinCategory.ToString();
FString Type = PinType.PinCategory.ToString();
Type[0] = FChar::ToUpper(Type[0]);
return Type;
}
FString FlxBlueprintExporter::FormatPinType(UEdGraphPin* Pin)
{
return FormatPinType(Pin->PinType);
}
FString FlxBlueprintExporter::FormatNodeBaseName(UEdGraphNode* Node)
{
return SanitizeName(Node->GetNodeTitle(ENodeTitleType::ListView).ToString());
FString Title = Node->GetNodeTitle(ENodeTitleType::ListView).ToString();
Title = FName::NameToDisplayString(*Title, false);
return SanitizeName(Title);
}
@@ -344,6 +353,25 @@ void FlxBlueprintExporter::EmitNode(UEdGraphNode* Node)
}
}
void FlxBlueprintExporter::EmitLocalVariables()
{
for (UEdGraphNode* Node : Graph->Nodes)
{
UK2Node_FunctionEntry* EntryNode = Cast<UK2Node_FunctionEntry>(Node);
if (!EntryNode) continue;
for (const FBPVariableDescription& Var : EntryNode->LocalVariables)
{
FString Default = Var.DefaultValue.IsEmpty() ? TEXT("<default>") : Var.DefaultValue;
Output.Appendf(TEXT("local %s %s = %s\n"),
*FormatPinType(Var.VarType),
*SanitizeName(Var.VarName.ToString()),
*Default);
}
break;
}
}
void FlxBlueprintExporter::EmitGraph()
{
for (UEdGraphNode* Node : SortedNodes)

View File

@@ -33,6 +33,7 @@ private:
// or struct, for example. But that's OK, we don't
// need precise type info, we just need readability.
//
static FString FormatPinType(const FEdGraphPinType& PinType);
static FString FormatPinType(UEdGraphPin* Pin);
// Get the node base name as a sanitized string.
@@ -101,6 +102,7 @@ private:
void SortNodes();
void AssignNodeNames();
void EmitNode(UEdGraphNode* Node);
void EmitLocalVariables();
void EmitGraph();
void EmitNodeList();