Much better handling of type lookups
This commit is contained in:
BIN
Content/Luprex/CIBD.uasset
LFS
BIN
Content/Luprex/CIBD.uasset
LFS
Binary file not shown.
@@ -4,6 +4,7 @@
|
|||||||
#include "WingHandler.h"
|
#include "WingHandler.h"
|
||||||
#include "WingFetcher.h"
|
#include "WingFetcher.h"
|
||||||
#include "WingUtils.h"
|
#include "WingUtils.h"
|
||||||
|
#include "WingTypes.h"
|
||||||
#include "WingServer.h"
|
#include "WingServer.h"
|
||||||
#include "Engine/Blueprint.h"
|
#include "Engine/Blueprint.h"
|
||||||
#include "Engine/SimpleConstructionScript.h"
|
#include "Engine/SimpleConstructionScript.h"
|
||||||
@@ -68,15 +69,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the component class by name
|
// Resolve the component class by name
|
||||||
UClass* ComponentClassObj = WingUtils::FindClassByName(ComponentClass);
|
UClass* ComponentClassObj = UWingTypes::TextToOneObjectType(ComponentClass);
|
||||||
if (!ComponentClassObj || !ComponentClassObj->IsChildOf(UActorComponent::StaticClass()))
|
if (!ComponentClassObj) return;
|
||||||
|
if (!ComponentClassObj->IsChildOf(UActorComponent::StaticClass()))
|
||||||
{
|
{
|
||||||
UWingServer::Printf(TEXT("ERROR: Component class '%s' not found or is not a subclass of UActorComponent. "
|
UWingServer::Printf(TEXT("ERROR: '%s' is not a subclass of UActorComponent\n"), *ComponentClass);
|
||||||
"Common classes: StaticMeshComponent, SkeletalMeshComponent, AudioComponent, "
|
|
||||||
"SceneComponent, BoxCollisionComponent, SphereCollisionComponent, CapsuleComponent, "
|
|
||||||
"ArrowComponent, ChildActorComponent, SpotLightComponent, PointLightComponent, "
|
|
||||||
"WidgetComponent, BillboardComponent\n"),
|
|
||||||
*ComponentClass);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "WingHandler.h"
|
#include "WingHandler.h"
|
||||||
#include "WingFetcher.h"
|
#include "WingFetcher.h"
|
||||||
#include "WingUtils.h"
|
#include "WingUtils.h"
|
||||||
|
#include "WingTypes.h"
|
||||||
#include "WingServer.h"
|
#include "WingServer.h"
|
||||||
#include "Engine/Blueprint.h"
|
#include "Engine/Blueprint.h"
|
||||||
#include "Kismet2/BlueprintEditorUtils.h"
|
#include "Kismet2/BlueprintEditorUtils.h"
|
||||||
@@ -41,23 +42,9 @@ public:
|
|||||||
|
|
||||||
FString OldParentName = BP->ParentClass ? WingUtils::FormatName(BP->ParentClass) : TEXT("None");
|
FString OldParentName = BP->ParentClass ? WingUtils::FormatName(BP->ParentClass) : TEXT("None");
|
||||||
|
|
||||||
// Find the new parent class: try C++ classes first, then Blueprint package path
|
// Find the new parent class by short type name
|
||||||
UClass* NewParentClassObj = WingUtils::FindClassByName(NewParentClass);
|
UClass* NewParentClassObj = UWingTypes::TextToOneObjectType(NewParentClass);
|
||||||
|
if (!NewParentClassObj) return;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform reparent
|
// Perform reparent
|
||||||
BP->ParentClass = NewParentClassObj;
|
BP->ParentClass = NewParentClassObj;
|
||||||
|
|||||||
@@ -31,12 +31,8 @@ public:
|
|||||||
|
|
||||||
virtual void Handle() override
|
virtual void Handle() override
|
||||||
{
|
{
|
||||||
UClass* FoundClass = WingUtils::FindClassByName(ClassName);
|
UClass* FoundClass = UWingTypes::TextToOneObjectType(ClassName);
|
||||||
if (!FoundClass)
|
if (!FoundClass) return;
|
||||||
{
|
|
||||||
UWingServer::Printf(TEXT("ERROR: Class '%s' not found\n"), *ClassName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UWingServer::Printf(TEXT("Properties of %s:\n"), *WingUtils::FormatName(FoundClass));
|
UWingServer::Printf(TEXT("Properties of %s:\n"), *WingUtils::FormatName(FoundClass));
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "WingServer.h"
|
#include "WingServer.h"
|
||||||
#include "WingHandler.h"
|
#include "WingHandler.h"
|
||||||
#include "WingUtils.h"
|
#include "WingUtils.h"
|
||||||
|
#include "WingTypes.h"
|
||||||
#include "AssetRegistry/AssetRegistryModule.h"
|
#include "AssetRegistry/AssetRegistryModule.h"
|
||||||
#include "AssetRegistry/IAssetRegistry.h"
|
#include "AssetRegistry/IAssetRegistry.h"
|
||||||
#include "Asset_Search.generated.h"
|
#include "Asset_Search.generated.h"
|
||||||
@@ -49,12 +50,8 @@ public:
|
|||||||
|
|
||||||
if (!Type.IsEmpty())
|
if (!Type.IsEmpty())
|
||||||
{
|
{
|
||||||
UClass* TypeClass = WingUtils::FindClassByName(Type);
|
UClass* TypeClass = UWingTypes::TextToOneObjectType(Type);
|
||||||
if (!TypeClass)
|
if (!TypeClass) return;
|
||||||
{
|
|
||||||
UWingServer::Printf(TEXT("ERROR: Unknown asset type '%s'\n"), *Type);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Filter.ClassPaths.Add(TypeClass->GetClassPathName());
|
Filter.ClassPaths.Add(TypeClass->GetClassPathName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -454,34 +454,6 @@ bool WingUtils::SaveBlueprintPackage(UBlueprint* BP)
|
|||||||
|
|
||||||
return bSuccess;
|
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
|
// Material helpers
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool SaveBlueprintPackage(UBlueprint* BP);
|
static bool SaveBlueprintPackage(UBlueprint* BP);
|
||||||
static UClass* FindClassByName(const FString& ClassName);
|
|
||||||
|
|
||||||
// ----- Material helpers -----
|
// ----- Material helpers -----
|
||||||
static void EnsureMaterialGraph(UMaterial* Material);
|
static void EnsureMaterialGraph(UMaterial* Material);
|
||||||
|
|||||||
Reference in New Issue
Block a user