109 lines
3.3 KiB
C++
109 lines
3.3 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "MCPServer.h"
|
|
#include "MCPTypes.h"
|
|
#include "MCPHandler.h"
|
|
#include "MCPFetcher.h"
|
|
#include "MCPUtils.h"
|
|
#include "Engine/Blueprint.h"
|
|
#include "Animation/AnimBlueprint.h"
|
|
#include "Animation/Skeleton.h"
|
|
#include "Engine/SimpleConstructionScript.h"
|
|
#include "Engine/SCS_Node.h"
|
|
#include "Blueprint_Dump.generated.h"
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
|
UCLASS()
|
|
class UMCP_Blueprint_Dump : public UObject, public IMCPHandler
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
UPROPERTY(meta=(Description="Blueprint name or package path"))
|
|
FString Blueprint;
|
|
|
|
virtual FString GetDescription() const override
|
|
{
|
|
return TEXT("Dump a Blueprint's structure: variables, interfaces, components, "
|
|
"and graph names. Does not include graph contents (use DumpGraphs for that).");
|
|
}
|
|
|
|
virtual void Handle() override
|
|
{
|
|
MCPFetcher F;
|
|
UBlueprint* BP = F.Walk(Blueprint).Cast<UBlueprint>();
|
|
if (!BP) return;
|
|
|
|
// Header
|
|
UMCPServer::Printf(TEXT("Blueprint: %s\n"), *MCPUtils::FormatName(BP));
|
|
UMCPServer::Printf(TEXT("Parent: %s\n"), BP->ParentClass ? *MCPUtils::FormatName(BP->ParentClass) : TEXT("None"));
|
|
UMCPServer::Printf(TEXT("Type: %s\n"),
|
|
*MCPUtils::EnumToString(BP->BlueprintType));
|
|
|
|
// Animation Blueprint
|
|
if (UAnimBlueprint* AnimBP = Cast<UAnimBlueprint>(BP))
|
|
{
|
|
if (AnimBP->TargetSkeleton)
|
|
UMCPServer::Printf(TEXT("TargetSkeleton: %s\n"), *AnimBP->TargetSkeleton->GetPathName());
|
|
}
|
|
|
|
// Interfaces
|
|
for (const FBPInterfaceDescription& I : BP->ImplementedInterfaces)
|
|
{
|
|
if (I.Interface)
|
|
UMCPServer::Printf(TEXT("Interface: %s\n"), *MCPUtils::FormatName(I.Interface));
|
|
}
|
|
|
|
// Variables
|
|
if (!BP->NewVariables.IsEmpty())
|
|
{
|
|
UMCPServer::Print(TEXT("\nVariables:\n"));
|
|
for (const FBPVariableDescription& V : BP->NewVariables)
|
|
{
|
|
UMCPServer::Printf(TEXT(" %s %s"),
|
|
*UMCPTypes::TypeToText(V.VarType),
|
|
*MCPUtils::FormatName(V));
|
|
if (!V.DefaultValue.IsEmpty())
|
|
UMCPServer::Printf(TEXT(" = %s"), *V.DefaultValue);
|
|
if (!V.Category.IsEmpty() && V.Category.ToString() != TEXT("Default"))
|
|
UMCPServer::Printf(TEXT(" [%s]"), *V.Category.ToString());
|
|
UMCPServer::Print(TEXT("\n"));
|
|
}
|
|
}
|
|
|
|
// Components
|
|
if (USimpleConstructionScript* SCS = BP->SimpleConstructionScript)
|
|
{
|
|
const TArray<USCS_Node*>& AllNodes = SCS->GetAllNodes();
|
|
if (!AllNodes.IsEmpty())
|
|
{
|
|
UMCPServer::Print(TEXT("\nComponents:\n"));
|
|
for (USCS_Node* Node : AllNodes)
|
|
{
|
|
if (!Node || !Node->ComponentTemplate) continue;
|
|
UMCPServer::Printf(TEXT(" %s (%s)"),
|
|
*MCPUtils::FormatName(Node->ComponentTemplate),
|
|
*MCPUtils::FormatName(Node->ComponentClass));
|
|
if (Node->ParentComponentOrVariableName != NAME_None)
|
|
UMCPServer::Printf(TEXT(" parent=%s"), *Node->ParentComponentOrVariableName.ToString());
|
|
UMCPServer::Print(TEXT("\n"));
|
|
}
|
|
}
|
|
}
|
|
|
|
// Graph names (without contents)
|
|
TArray<UEdGraph*> Graphs = MCPUtils::AllGraphs(BP);
|
|
if (!Graphs.IsEmpty())
|
|
{
|
|
UMCPServer::Print(TEXT("\nGraphs:\n"));
|
|
for (UEdGraph* Graph : Graphs)
|
|
UMCPServer::Printf(TEXT(" %s\n"), *MCPUtils::FormatName(Graph));
|
|
}
|
|
}
|
|
};
|