From 467c1464aa09c472da186a0b820903a883ec4fc2 Mon Sep 17 00:00:00 2001 From: jyelon Date: Wed, 18 Mar 2026 23:20:10 -0400 Subject: [PATCH] Much better handling of type lookups --- Content/Luprex/CIBD.uasset | 3 -- .../HalfBaked/Blueprint_AddComponent.h | 13 ++++----- .../UEWingman/HalfBaked/Blueprint_Reparent.h | 21 +++----------- .../HalfBaked/Class_ShowProperties.h | 8 ++---- .../Source/UEWingman/Handlers/Asset_Search.h | 9 ++---- .../Source/UEWingman/Private/WingUtils.cpp | 28 ------------------- .../Source/UEWingman/Public/WingUtils.h | 3 +- 7 files changed, 15 insertions(+), 70 deletions(-) delete mode 100644 Content/Luprex/CIBD.uasset diff --git a/Content/Luprex/CIBD.uasset b/Content/Luprex/CIBD.uasset deleted file mode 100644 index acfda637..00000000 --- a/Content/Luprex/CIBD.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e0c36249548c314ec05f43d76188e8375e5741ba1f09a8e3d061c9f0e491d026 -size 5227 diff --git a/Plugins/UEWingman/Source/UEWingman/HalfBaked/Blueprint_AddComponent.h b/Plugins/UEWingman/Source/UEWingman/HalfBaked/Blueprint_AddComponent.h index 1db638b2..d191c6fd 100644 --- a/Plugins/UEWingman/Source/UEWingman/HalfBaked/Blueprint_AddComponent.h +++ b/Plugins/UEWingman/Source/UEWingman/HalfBaked/Blueprint_AddComponent.h @@ -4,6 +4,7 @@ #include "WingHandler.h" #include "WingFetcher.h" #include "WingUtils.h" +#include "WingTypes.h" #include "WingServer.h" #include "Engine/Blueprint.h" #include "Engine/SimpleConstructionScript.h" @@ -68,15 +69,11 @@ public: } // Resolve the component class by name - UClass* ComponentClassObj = WingUtils::FindClassByName(ComponentClass); - if (!ComponentClassObj || !ComponentClassObj->IsChildOf(UActorComponent::StaticClass())) + UClass* ComponentClassObj = UWingTypes::TextToOneObjectType(ComponentClass); + if (!ComponentClassObj) return; + if (!ComponentClassObj->IsChildOf(UActorComponent::StaticClass())) { - UWingServer::Printf(TEXT("ERROR: Component class '%s' not found or is not a subclass of UActorComponent. " - "Common classes: StaticMeshComponent, SkeletalMeshComponent, AudioComponent, " - "SceneComponent, BoxCollisionComponent, SphereCollisionComponent, CapsuleComponent, " - "ArrowComponent, ChildActorComponent, SpotLightComponent, PointLightComponent, " - "WidgetComponent, BillboardComponent\n"), - *ComponentClass); + UWingServer::Printf(TEXT("ERROR: '%s' is not a subclass of UActorComponent\n"), *ComponentClass); return; } diff --git a/Plugins/UEWingman/Source/UEWingman/HalfBaked/Blueprint_Reparent.h b/Plugins/UEWingman/Source/UEWingman/HalfBaked/Blueprint_Reparent.h index 9a480c45..6d572755 100644 --- a/Plugins/UEWingman/Source/UEWingman/HalfBaked/Blueprint_Reparent.h +++ b/Plugins/UEWingman/Source/UEWingman/HalfBaked/Blueprint_Reparent.h @@ -4,6 +4,7 @@ #include "WingHandler.h" #include "WingFetcher.h" #include "WingUtils.h" +#include "WingTypes.h" #include "WingServer.h" #include "Engine/Blueprint.h" #include "Kismet2/BlueprintEditorUtils.h" @@ -41,23 +42,9 @@ public: FString OldParentName = BP->ParentClass ? WingUtils::FormatName(BP->ParentClass) : TEXT("None"); - // Find the new parent class: try C++ classes first, then Blueprint package path - UClass* NewParentClassObj = WingUtils::FindClassByName(NewParentClass); - - if (!NewParentClassObj) - { - WingFetcher F2; - UBlueprint* ParentBP = F2.Asset(NewParentClass).Cast(); - if (ParentBP && ParentBP->GeneratedClass) - NewParentClassObj = ParentBP->GeneratedClass; - } - - if (!NewParentClassObj) - { - UWingServer::Printf(TEXT("ERROR: Could not find class '%s'. Provide a C++ class name or Blueprint package path.\n"), - *NewParentClass); - return; - } + // Find the new parent class by short type name + UClass* NewParentClassObj = UWingTypes::TextToOneObjectType(NewParentClass); + if (!NewParentClassObj) return; // Perform reparent BP->ParentClass = NewParentClassObj; diff --git a/Plugins/UEWingman/Source/UEWingman/HalfBaked/Class_ShowProperties.h b/Plugins/UEWingman/Source/UEWingman/HalfBaked/Class_ShowProperties.h index 1a4de83a..9840504b 100644 --- a/Plugins/UEWingman/Source/UEWingman/HalfBaked/Class_ShowProperties.h +++ b/Plugins/UEWingman/Source/UEWingman/HalfBaked/Class_ShowProperties.h @@ -31,12 +31,8 @@ public: virtual void Handle() override { - UClass* FoundClass = WingUtils::FindClassByName(ClassName); - if (!FoundClass) - { - UWingServer::Printf(TEXT("ERROR: Class '%s' not found\n"), *ClassName); - return; - } + UClass* FoundClass = UWingTypes::TextToOneObjectType(ClassName); + if (!FoundClass) return; UWingServer::Printf(TEXT("Properties of %s:\n"), *WingUtils::FormatName(FoundClass)); diff --git a/Plugins/UEWingman/Source/UEWingman/Handlers/Asset_Search.h b/Plugins/UEWingman/Source/UEWingman/Handlers/Asset_Search.h index 24af8a38..0f674c66 100644 --- a/Plugins/UEWingman/Source/UEWingman/Handlers/Asset_Search.h +++ b/Plugins/UEWingman/Source/UEWingman/Handlers/Asset_Search.h @@ -4,6 +4,7 @@ #include "WingServer.h" #include "WingHandler.h" #include "WingUtils.h" +#include "WingTypes.h" #include "AssetRegistry/AssetRegistryModule.h" #include "AssetRegistry/IAssetRegistry.h" #include "Asset_Search.generated.h" @@ -49,12 +50,8 @@ public: if (!Type.IsEmpty()) { - UClass* TypeClass = WingUtils::FindClassByName(Type); - if (!TypeClass) - { - UWingServer::Printf(TEXT("ERROR: Unknown asset type '%s'\n"), *Type); - return; - } + UClass* TypeClass = UWingTypes::TextToOneObjectType(Type); + if (!TypeClass) return; Filter.ClassPaths.Add(TypeClass->GetClassPathName()); } diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp b/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp index 3bf8aecf..0d202ea3 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp @@ -454,34 +454,6 @@ bool WingUtils::SaveBlueprintPackage(UBlueprint* BP) return bSuccess; -}// ============================================================ -// FindClassByName -// ============================================================ - -UClass* WingUtils::FindClassByName(const FString& ClassName) -{ - // Exact match first (handles both C++ classes and Blueprint _C classes) - for (TObjectIterator It; It; ++It) - { - FString Name = It->GetName(); - if (Name == ClassName || Name == ClassName + TEXT("_C")) - { - return *It; - } - } - - // Case-insensitive fallback - for (TObjectIterator It; It; ++It) - { - FString Name = It->GetName(); - if (Name.Equals(ClassName, ESearchCase::IgnoreCase) || - Name.Equals(ClassName + TEXT("_C"), ESearchCase::IgnoreCase)) - { - return *It; - } - } - - return nullptr; } // ============================================================ // Material helpers diff --git a/Plugins/UEWingman/Source/UEWingman/Public/WingUtils.h b/Plugins/UEWingman/Source/UEWingman/Public/WingUtils.h index 24598190..5d38ae7c 100644 --- a/Plugins/UEWingman/Source/UEWingman/Public/WingUtils.h +++ b/Plugins/UEWingman/Source/UEWingman/Public/WingUtils.h @@ -161,8 +161,7 @@ public: return Result; } - static bool SaveBlueprintPackage(UBlueprint* BP); - static UClass* FindClassByName(const FString& ClassName); + static bool SaveBlueprintPackage(UBlueprint* BP); // ----- Material helpers ----- static void EnsureMaterialGraph(UMaterial* Material);