2026-02-13 23:24:18 -05:00
|
|
|
|
|
|
|
|
#include "FormatDataLibrary.h"
|
2026-02-25 16:49:37 -05:00
|
|
|
#include "Common.h"
|
2026-02-13 23:24:18 -05:00
|
|
|
#include "Kismet/KismetTextLibrary.h"
|
2026-02-25 16:49:37 -05:00
|
|
|
#include "UObject/UObjectIterator.h"
|
|
|
|
|
|
|
|
|
|
void UlxFormatDataLibrary::Initialize(FSubsystemCollectionBase& Collection)
|
|
|
|
|
{
|
|
|
|
|
Super::Initialize(Collection);
|
|
|
|
|
ScanForConverters();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UlxFormatDataLibrary::ScanForConverters()
|
|
|
|
|
{
|
|
|
|
|
Converters.Empty();
|
|
|
|
|
for (TObjectIterator<UClass> It; It; ++It)
|
|
|
|
|
{
|
|
|
|
|
UClass* Class = *It;
|
|
|
|
|
for (TFieldIterator<UFunction> FuncIt(Class, EFieldIteratorFlags::ExcludeSuper); FuncIt; ++FuncIt)
|
|
|
|
|
{
|
|
|
|
|
UFunction* Function = *FuncIt;
|
|
|
|
|
|
|
|
|
|
// Must have an AutoConvertedValue parameter.
|
|
|
|
|
if (Function->FindPropertyByName(TEXT("AutoConvertedValue")) == nullptr) continue;
|
|
|
|
|
|
|
|
|
|
// Must have a Name parameter that is a string.
|
|
|
|
|
FProperty* NameProp = Function->FindPropertyByName(TEXT("Name"));
|
|
|
|
|
if (NameProp == nullptr) continue;
|
|
|
|
|
if (CastField<FStrProperty>(NameProp) == nullptr) continue;
|
|
|
|
|
|
|
|
|
|
// Must return FFormatArgumentData.
|
|
|
|
|
FStructProperty* ReturnProp = CastField<FStructProperty>(Function->GetReturnProperty());
|
|
|
|
|
if (ReturnProp == nullptr) continue;
|
|
|
|
|
if (ReturnProp->Struct->GetFName() != TEXT("FormatArgumentData")) continue;
|
|
|
|
|
|
|
|
|
|
// Must have exactly three properties: AutoConvertedValue, Name, and ReturnValue.
|
|
|
|
|
int PropCount = 0;
|
|
|
|
|
for (TFieldIterator<FProperty> PropIt(Function); PropIt; ++PropIt) PropCount++;
|
|
|
|
|
if (PropCount != 3) continue;
|
|
|
|
|
|
|
|
|
|
Converters.Add(Function);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (UFunction* Func : Converters)
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogLuprexIntegration, Display, TEXT("FormatData converter: %s::%s"), *Func->GetOuterUClass()->GetName(), *Func->GetName());
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-13 23:24:18 -05:00
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataBool(bool AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = UKismetTextLibrary::Conv_BoolToText(AutoConvertedValue);
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataByte(uint8 AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Int;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValueInt = AutoConvertedValue;
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataInt(int AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Int;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValueInt = AutoConvertedValue;
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataInt64(int64 AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Int;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValueInt = AutoConvertedValue;
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataFloat(float AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Float;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValueFloat = AutoConvertedValue;
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataDouble(double AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Double;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValueDouble = AutoConvertedValue;
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataText(FText AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = AutoConvertedValue;
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataString(FString AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = UKismetTextLibrary::Conv_StringToText(AutoConvertedValue);
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataName(FName AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = UKismetTextLibrary::Conv_NameToText(AutoConvertedValue);
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataKey(FKey AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = UKismetTextLibrary::Conv_NameToText(AutoConvertedValue.GetFName());
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataGender(ETextGender AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Gender;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValueGender = AutoConvertedValue;
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataObject(UObject *AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = UKismetTextLibrary::Conv_ObjectToText(AutoConvertedValue);
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataVector(const FVector &AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = UKismetTextLibrary::Conv_VectorToText(AutoConvertedValue);
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataVector2D(const FVector2D &AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = UKismetTextLibrary::Conv_Vector2dToText(AutoConvertedValue);
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataRotator(const FRotator &AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = UKismetTextLibrary::Conv_RotatorToText(AutoConvertedValue);
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataTransform(const FTransform &AutoConvertedValue, const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = UKismetTextLibrary::Conv_TransformToText(AutoConvertedValue);
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataBlank(const FString &Name)
|
|
|
|
|
{
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = FText();
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataEnum(uint8 Value, const FString &Name, const UObject *PinSubCategoryObject)
|
|
|
|
|
{
|
|
|
|
|
const UEnum *Enum = Cast<const UEnum>(PinSubCategoryObject);
|
|
|
|
|
FFormatArgumentData Result;
|
|
|
|
|
if (Enum == nullptr)
|
|
|
|
|
{
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Int;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValueInt = Value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Result.ArgumentValueType = EFormatArgumentType::Text;
|
|
|
|
|
Result.ArgumentName = Name;
|
|
|
|
|
Result.ArgumentValue = FText::Format(INVTEXT("<{0}>"), Enum->GetDisplayNameTextByValue(Value));
|
|
|
|
|
}
|
|
|
|
|
return Result;
|
|
|
|
|
}
|