More MCP work

This commit is contained in:
2026-03-08 21:28:47 -04:00
parent 93d4ed2038
commit 695de53b30
19 changed files with 388 additions and 546 deletions

View File

@@ -7,79 +7,14 @@
#include "Misc/Paths.h"
#include "ShaderCore.h"
#if WITH_EDITOR
#include "Engine/Blueprint.h"
#include "UObject/SavePackage.h"
#include "UObject/ObjectSaveContext.h"
#include "EdGraph/EdGraph.h"
#include "BlueprintExporter.h"
#include "Misc/FileHelper.h"
#include "Exporters/Exporter.h"
#include "UnrealExporter.h"
#endif
IMPLEMENT_PRIMARY_GAME_MODULE(FlxIntegrationModuleImpl, Integration, "Integration");
void FlxIntegrationModuleImpl::StartupModule()
{
FString ShaderDir = FPaths::Combine(FPaths::ProjectDir(), TEXT("Shaders"));
AddShaderSourceDirectoryMapping(TEXT("/Project/Integration"), ShaderDir);
#if WITH_EDITOR
OnAssetSavedHandle = UPackage::PackageSavedWithContextEvent.AddRaw(
this, &FlxIntegrationModuleImpl::OnAssetSaved);
#endif
}
void FlxIntegrationModuleImpl::ShutdownModule()
{
#if WITH_EDITOR
UPackage::PackageSavedWithContextEvent.Remove(OnAssetSavedHandle);
#endif
}
#if WITH_EDITOR
void FlxIntegrationModuleImpl::OnAssetSaved(const FString& PackageFilename, UPackage* Package, FObjectPostSaveContext Context)
{
if (!Package) return;
FString PkDir = FPaths::ProjectDir() / TEXT("Saved") / TEXT("BlueprintExports") / FPaths::GetBaseFilename(PackageFilename);
IFileManager::Get().DeleteDirectory(*PkDir, false, true);
// Export the whole package in both formats for comparison.
{
FStringOutputDevice Archive;
const FExportObjectInnerContext InnerContext;
UExporter::ExportToOutputDevice(&InnerContext, Package, nullptr, Archive, TEXT("copy"), 0);
FFileHelper::SaveStringToFile(Archive, *(PkDir / TEXT("COPY_DUMP.txt")));
}
{
FStringOutputDevice Archive;
const FExportObjectInnerContext InnerContext;
UExporter::ExportToOutputDevice(&InnerContext, Package, nullptr, Archive, TEXT("t3d"), 0);
FFileHelper::SaveStringToFile(Archive, *(PkDir / TEXT("T3D_DUMP.txt")));
}
TArray<UObject*> AllObjects;
GetObjectsWithPackage(Package, AllObjects);
for (UObject *Obj : AllObjects)
{
if (UBlueprint *BP = Cast<UBlueprint>(Obj))
{
FString BPDir = PkDir / BP->GetName();
TArray<UEdGraph*> AllGraphs;
BP->GetAllGraphs(AllGraphs);
for (UEdGraph* Graph : AllGraphs)
{
FlxBlueprintExporter Exporter(Graph);
FString FilePath = BPDir / Graph->GetName() + TEXT(".txt");
FString DetailsPath = BPDir / TEXT("DETAILS") / Graph->GetName() + TEXT(".txt");
FFileHelper::SaveStringToFile(Exporter.GetOutput(), *FilePath);
FFileHelper::SaveStringToFile(Exporter.GetDetails(), *DetailsPath);
UE_LOG(LogLuprexIntegration, Warning, TEXT("Blueprint export: %s"), *FilePath);
}
}
}
}
#endif