From 55ad662d3fac84976ab2a14f022d9e1075813c57 Mon Sep 17 00:00:00 2001 From: jyelon Date: Mon, 16 Feb 2026 21:02:01 -0500 Subject: [PATCH] More fixes to blueprint exporter. --- CLAUDE.md | 1 + Content/Tangibles/TAN_Character.uasset | 4 +-- Docs/Blueprint Text Export.md | 37 ++++++++++++------------ Source/Integration/BlueprintExporter.cpp | 36 ++++++++++++++++++++--- Source/Integration/BlueprintExporter.h | 2 ++ 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 3229fc41..e260434c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -115,6 +115,7 @@ Do not use git to make changes (commit, push, branch, etc.). Read-only git comma ## Coding Conventions +- Prefer early returns and `continue` to reduce nesting (never-nester style). - Do not use static functions in Unreal code. Use class methods or namespace-scoped functions instead. - Use `LogLuprexIntegration` for log messages, not `LogTemp`. - When writing UFUNCTIONs that take an `AActor*`, `UObject*`, or similar "self" parameter, add `DefaultToSelf` meta to that pin. Most functions should have this on the obvious pin so the user doesn't have to manually wire it in blueprints. diff --git a/Content/Tangibles/TAN_Character.uasset b/Content/Tangibles/TAN_Character.uasset index 1d6a3406..2de42b5a 100644 --- a/Content/Tangibles/TAN_Character.uasset +++ b/Content/Tangibles/TAN_Character.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5d217aee4204290fcb79f9e1b45697d4f8b6f8a9af3908eeb88491035b76e2ce -size 353527 +oid sha256:25c5f83c86df91f0bbf89a60038aec3c87865a19f1706b3414688cb517dc43b4 +size 353650 diff --git a/Docs/Blueprint Text Export.md b/Docs/Blueprint Text Export.md index 5aa911b6..897acdf0 100644 --- a/Docs/Blueprint Text Export.md +++ b/Docs/Blueprint Text Export.md @@ -10,35 +10,34 @@ The exporter class (`Source/Integration/BlueprintExporter.h/.cpp`) processes one ## Output Format -Each file has two sections: +The graph file is written to `Saved/BlueprintExports//.txt`. A details file with node-name-to-GUID mappings is written to `Saved/BlueprintExports//DETAILS/.txt`. -**NodeList** maps readable node names to GUIDs: -``` -NodeList: - Event_Tick = 44BAE739C72246DD9E9A72803C3B67CA - Set_Tick_Delta_Seconds = 204486800C0C4906A456A378F9F7ADE4 -``` +Every line in the graph file starts with a keyword, making it easy to parse. The format is: -**Graph** shows the flow with pins and connections: ``` -Graph: - - Event_Tick - return Output_Delegate,Delta_Seconds +node Event_Tick + return Output_Delegate, Delta_Seconds goto Set_Tick_Delta_Seconds - Set_Tick_Delta_Seconds - Real Tick_Delta_Seconds = Event_Tick.Delta_Seconds +node Set_Tick_Delta_Seconds + input Real Tick_Delta_Seconds = Event_Tick.Delta_Seconds return Output_Get goto CallFunctionByName ``` -- Input data pins: `Type Name = Source` where Source is a `Node.Pin` reference, a literal value, ``, or ``. -- Output data pins: `return Pin1,Pin2`. -- Exec flow: `goto Target` (single output), `goto Target if PinName` (multiple outputs), or `then goto`/`else goto` (branch nodes). +### Line Keywords + +- `node Name` — starts a new node block. +- `input Type Name = Source` — an input data pin. Source is a `Node.Pin` reference, a literal value, ``, or ``. +- `return Pin1, Pin2` — output data pins. +- `goto Target` — exec flow (single output). +- `goto-if PinName Target` — exec flow (multiple outputs, e.g. branch true/false). +- `// comment text` — comment node. + +### Special Handling + - String defaults are shown in quotes. -- Variable get nodes are inlined (the variable name appears directly at the point of use). -- Comment nodes appear as `// comment text`. +- Variable get nodes are inlined (the variable name appears directly at the point of use rather than as a separate node). - Knot (reroute) nodes are followed through transparently. ## Node Ordering diff --git a/Source/Integration/BlueprintExporter.cpp b/Source/Integration/BlueprintExporter.cpp index 2a3baf28..9ad8e540 100644 --- a/Source/Integration/BlueprintExporter.cpp +++ b/Source/Integration/BlueprintExporter.cpp @@ -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(Node); + if (!EntryNode) continue; + + for (const FBPVariableDescription& Var : EntryNode->LocalVariables) + { + FString Default = Var.DefaultValue.IsEmpty() ? TEXT("") : 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) diff --git a/Source/Integration/BlueprintExporter.h b/Source/Integration/BlueprintExporter.h index 8e01e036..1baa9697 100644 --- a/Source/Integration/BlueprintExporter.h +++ b/Source/Integration/BlueprintExporter.h @@ -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();