79 lines
2.0 KiB
C++
79 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "WingServer.h"
|
|
#include "WingHandler.h"
|
|
#include "WingFetcher.h"
|
|
#include "WingPropHandle.h"
|
|
#include "WingUtils.h"
|
|
#include "WingTypes.h"
|
|
#include "Property_Dump2.generated.h"
|
|
|
|
UCLASS()
|
|
class UWing_Property_Dump2 : public UWingHandler
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
UPROPERTY(meta=(Description="Target object"))
|
|
FString Object;
|
|
|
|
UPROPERTY(meta=(Optional, Description="Substring filter for property names"))
|
|
FString Query;
|
|
|
|
virtual void Register() override
|
|
{
|
|
UWingServer::AddHandler(this,
|
|
TEXT("Test handler: dump properties using IPropertyHandle."));
|
|
}
|
|
|
|
virtual void Handle() override
|
|
{
|
|
WingFetcher F;
|
|
UObject* Target = F.Walk(Object).Cast<UObject>();
|
|
if (!Target) return;
|
|
|
|
WingPropHandle Props;
|
|
WingPropHandle::Handles Handles = Props.GetDetails(Target, false);
|
|
|
|
// Sort by category name for consistent grouping.
|
|
Handles.Sort([](const TSharedPtr<IPropertyHandle>& A, const TSharedPtr<IPropertyHandle>& B)
|
|
{
|
|
return A->GetProperty()->GetMetaData(TEXT("Category")) < B->GetProperty()->GetMetaData(TEXT("Category"));
|
|
});
|
|
|
|
FString QueryLower = Query.ToLower();
|
|
FString CurrentCategory;
|
|
|
|
for (const TSharedPtr<IPropertyHandle>& H : Handles)
|
|
{
|
|
FProperty* Prop = H->GetProperty();
|
|
FString Name = WingUtils::FormatName(Prop);
|
|
if (!QueryLower.IsEmpty() && !Name.ToLower().Contains(QueryLower))
|
|
continue;
|
|
|
|
FString Category = Prop->GetMetaData(TEXT("Category"));
|
|
if (Category.IsEmpty()) Category = TEXT("Unclassified");
|
|
if (Category != CurrentCategory)
|
|
{
|
|
if (!CurrentCategory.IsEmpty())
|
|
UWingServer::Print(TEXT("\n"));
|
|
CurrentCategory = Category;
|
|
UWingServer::Printf(TEXT("%s:\n"), *CurrentCategory);
|
|
}
|
|
|
|
FString Value;
|
|
H->GetValueAsFormattedString(Value);
|
|
if (Value.Len() > 100) { Value.LeftInline(100); Value += TEXT("..."); }
|
|
|
|
bool bEditable = !H->IsEditConst();
|
|
|
|
UWingServer::Printf(TEXT(" %s %s %s = %s\n"),
|
|
bEditable ? TEXT("editable") : TEXT("readonly"),
|
|
*UWingTypes::TypeToText(Prop),
|
|
*Name,
|
|
*Value);
|
|
}
|
|
}
|
|
};
|