Much better handling of type lookups
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<UBlueprint>();
|
||||
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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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<UClass> It; It; ++It)
|
||||
{
|
||||
FString Name = It->GetName();
|
||||
if (Name == ClassName || Name == ClassName + TEXT("_C"))
|
||||
{
|
||||
return *It;
|
||||
}
|
||||
}
|
||||
|
||||
// Case-insensitive fallback
|
||||
for (TObjectIterator<UClass> 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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user