77 lines
2.6 KiB
C++
77 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "WingServer.h"
|
|
#include "WingHandler.h"
|
|
#include "WingTypes.h"
|
|
#include "WingUtils.h"
|
|
#include "Class_ShowProperties.generated.h"
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
|
UCLASS()
|
|
class UWing_Class_ShowProperties : public UObject, public IWingHandler
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
UPROPERTY(meta=(Description="Class name to list properties for"))
|
|
FString ClassName;
|
|
|
|
UPROPERTY(meta=(Optional, Description="Substring filter for property names"))
|
|
FString Query;
|
|
|
|
virtual FString GetDescription() const override
|
|
{
|
|
return TEXT("List properties on a UClass, including type, owning class, and property flags.");
|
|
}
|
|
|
|
virtual void Handle() override
|
|
{
|
|
UClass* FoundClass = UWingTypes::TextToOneObjectType(ClassName);
|
|
if (!FoundClass) return;
|
|
|
|
UWingServer::Printf(TEXT("Properties of %s:\n"), *WingUtils::FormatName(FoundClass));
|
|
|
|
int32 Count = 0;
|
|
for (TFieldIterator<FProperty> PropIt(FoundClass); PropIt; ++PropIt)
|
|
{
|
|
FProperty* Prop = *PropIt;
|
|
if (!Prop) continue;
|
|
|
|
FString PropName = Prop->GetName();
|
|
|
|
if (!Query.IsEmpty() && !PropName.Contains(Query, ESearchCase::IgnoreCase))
|
|
continue;
|
|
|
|
// Build compact flags string
|
|
TStringBuilder<256> Flags;
|
|
if (Prop->HasAnyPropertyFlags(CPF_BlueprintVisible)) Flags.Append(TEXT(" BlueprintVisible"));
|
|
if (Prop->HasAnyPropertyFlags(CPF_BlueprintReadOnly)) Flags.Append(TEXT(" BlueprintReadOnly"));
|
|
if (Prop->HasAnyPropertyFlags(CPF_Edit)) Flags.Append(TEXT(" EditAnywhere"));
|
|
if (Prop->HasAnyPropertyFlags(CPF_EditConst)) Flags.Append(TEXT(" VisibleOnly"));
|
|
if (Prop->HasAnyPropertyFlags(CPF_Config)) Flags.Append(TEXT(" Config"));
|
|
if (Prop->HasAnyPropertyFlags(CPF_SaveGame)) Flags.Append(TEXT(" SaveGame"));
|
|
if (Prop->HasAnyPropertyFlags(CPF_Transient)) Flags.Append(TEXT(" Transient"));
|
|
if (Prop->HasAnyPropertyFlags(CPF_RepNotify)) Flags.Append(TEXT(" RepNotify"));
|
|
|
|
UClass* OwnerClass = Prop->GetOwnerClass();
|
|
UWingServer::Printf(TEXT(" %s %s"), *UWingTypes::TypeToText(Prop), *PropName);
|
|
if (OwnerClass && OwnerClass != FoundClass)
|
|
UWingServer::Printf(TEXT(" [%s]"), *WingUtils::FormatName(OwnerClass));
|
|
if (Flags.Len() > 0)
|
|
UWingServer::Printf(TEXT(" (%s)"), Flags.ToString() + 1); // skip leading space
|
|
UWingServer::Print(TEXT("\n"));
|
|
Count++;
|
|
}
|
|
|
|
if (Count == 0)
|
|
{
|
|
UWingServer::Print(TEXT("No properties found.\n"));
|
|
}
|
|
}
|
|
};
|