Rearrange FormatDataLibrary to have less module coupling.
This commit is contained in:
@@ -2,9 +2,26 @@
|
||||
//
|
||||
// FormatDataLibrary.h
|
||||
//
|
||||
// Functions that convert data into
|
||||
// FFormatArgumentData structs, so that the data
|
||||
// can be passed to FText::Format.
|
||||
// The 'Format Message' and 'Format Log Message' nodes can format
|
||||
// ints, strings, vectors, and more. To support a new data type,
|
||||
// all you need to do is implement a blueprint-callable conversion
|
||||
// function like this one:
|
||||
//
|
||||
// UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"))
|
||||
// static FFormatArgumentData FormatArgumentDataBool(bool AutoConvertedValue, const FString &Name);
|
||||
//
|
||||
// This conversion function must have three things:
|
||||
//
|
||||
// * It returns FFormatArgumentData
|
||||
// * It accepts 'AutoConvertedValue', the value you want to format,
|
||||
// * It accepts 'Name', which must be copied into the FFormatArgumentData.
|
||||
//
|
||||
// The parameter names are required: you must use exactly these parameter
|
||||
// names if you want this to act as a conversion function. You can put a
|
||||
// conversion function like that anywhere in the system, in any UCLASS.
|
||||
// This module will find and use it.
|
||||
//
|
||||
// This file also contains the built-in converters for standard types.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -15,31 +32,40 @@
|
||||
#include "HAL/Platform.h"
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "UObject/UObjectGlobals.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "EditorSubsystem.h"
|
||||
|
||||
#include "FormatDataLibrary.generated.h"
|
||||
|
||||
class UlxLuaValues;
|
||||
struct FlxAnimationStep;
|
||||
struct FlxMovementComponentState;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// UlxFormatDataLibrary
|
||||
//
|
||||
// The FormatLogMessage K2Node scans this library using
|
||||
// reflection, looking for functions that have a parameter
|
||||
// named "AutoConvertedValue". It uses the type of that
|
||||
// parameter to determine which function to call for a given
|
||||
// pin type.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UlxFormatDataLibrary : public UBlueprintFunctionLibrary
|
||||
class UlxFormatDataLibrary : public UEditorSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
|
||||
// Get all converter functions (functions with an
|
||||
// "AutoConvertedValue" parameter) found across all
|
||||
// loaded classes.
|
||||
//
|
||||
const TArray<UFunction*>& GetConverters() const { return Converters; }
|
||||
|
||||
private:
|
||||
// Scan all loaded classes for converter functions.
|
||||
//
|
||||
void ScanForConverters();
|
||||
|
||||
// Cached list of converter functions.
|
||||
//
|
||||
TArray<UFunction*> Converters;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility")
|
||||
static FFormatArgumentData FormatArgumentDataBool(bool AutoConvertedValue, const FString &Name);
|
||||
@@ -89,15 +115,6 @@ public:
|
||||
UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility")
|
||||
static FFormatArgumentData FormatArgumentDataTransform(const FTransform &AutoConvertedValue, const FString &Name);
|
||||
|
||||
UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility")
|
||||
static FFormatArgumentData FormatArgumentDataLuaValues(const UlxLuaValues *AutoConvertedValue, const FString &Name);
|
||||
|
||||
UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility")
|
||||
static FFormatArgumentData FormatArgumentDataAnimationStep(const FlxAnimationStep &AutoConvertedValue, const FString &Name);
|
||||
|
||||
UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility")
|
||||
static FFormatArgumentData FormatArgumentDataMovementComponentState(const FlxMovementComponentState &AutoConvertedValue, const FString &Name);
|
||||
|
||||
// For pins that were never connected.
|
||||
//
|
||||
UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility")
|
||||
|
||||
Reference in New Issue
Block a user