You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb tim.smith, lauren.barnes #jira UETOOL-3448 #preflight 60aceb521d02bb000144bc59 [CL 16447508 by sebastian nordgren in ue5-main branch]
142 lines
4.1 KiB
C++
142 lines
4.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "EditorConfig.h"
|
|
#include "EditorSubsystem.h"
|
|
|
|
#include "EditorMetadataOverrides.generated.h"
|
|
|
|
USTRUCT()
|
|
struct FMetadataSet
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
// map of metadata key to metadata value
|
|
UPROPERTY()
|
|
TMap<FName, FString> Strings;
|
|
|
|
UPROPERTY()
|
|
TMap<FName, bool> Bools;
|
|
|
|
UPROPERTY()
|
|
TMap<FName, int32> Ints;
|
|
|
|
UPROPERTY()
|
|
TMap<FName, float> Floats;
|
|
};
|
|
|
|
USTRUCT()
|
|
struct FStructMetadata
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
// map of field name to field metadata
|
|
UPROPERTY()
|
|
TMap<FName, FMetadataSet> Fields;
|
|
|
|
UPROPERTY()
|
|
FMetadataSet StructMetadata;
|
|
};
|
|
|
|
USTRUCT()
|
|
struct FMetadataConfig
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
// map of class name to class metadata
|
|
UPROPERTY()
|
|
TMap<FName, FStructMetadata> Classes;
|
|
};
|
|
|
|
UENUM()
|
|
enum class EMetadataType
|
|
{
|
|
None,
|
|
Bool,
|
|
Int,
|
|
Float,
|
|
String
|
|
};
|
|
|
|
UCLASS()
|
|
class EDITORCONFIG_API UEditorMetadataOverrides :
|
|
public UEditorSubsystem
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
UEditorMetadataOverrides();
|
|
virtual ~UEditorMetadataOverrides() {}
|
|
|
|
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
|
|
|
bool LoadFromConfig(TSharedPtr<FEditorConfig> Config);
|
|
void Save();
|
|
|
|
EMetadataType GetMetadataType(const FField* Field, FName Key) const;
|
|
EMetadataType GetMetadataType(const UStruct* Struct, FName Key) const;
|
|
|
|
bool GetStringMetadata(const FField* Field, FName Key, FString& OutValue) const;
|
|
void SetStringMetadata(const FField* Field, FName Key, FStringView Value);
|
|
|
|
bool GetFloatMetadata(const FField* Field, FName Key, float& OutValue) const;
|
|
void SetFloatMetadata(const FField* Field, FName Key, float Value);
|
|
|
|
bool GetIntMetadata(const FField* Field, FName Key, int32& OutValue) const;
|
|
void SetIntMetadata(const FField* Field, FName Key, int32 Value);
|
|
|
|
bool GetBoolMetadata(const FField* Field, FName Key, bool& OutValue) const;
|
|
void SetBoolMetadata(const FField* Field, FName Key, bool Value);
|
|
|
|
bool GetClassMetadata(const FField* Field, FName Key, UClass*& OutValue) const;
|
|
void SetClassMetadata(const FField* Field, FName Key, UClass* Value);
|
|
|
|
bool GetArrayMetadata(const FField* Field, FName Key, TArray<FString>& OutValue) const;
|
|
void SetArrayMetadata(const FField* Field, FName Key, const TArray<FString>& Value);
|
|
|
|
void AddToArrayMetadata(const FField* Field, FName Key, const FString& Value);
|
|
void RemoveFromArrayMetadata(const FField* Field, FName Key, const FString& Value);
|
|
|
|
void RemoveMetadata(const FField* Field, FName Key);
|
|
|
|
bool GetStringMetadata(const UStruct* Struct, FName Key, FString& OutValue) const;
|
|
void SetStringMetadata(const UStruct* Struct, FName Key, FStringView Value);
|
|
|
|
bool GetFloatMetadata(const UStruct* Struct, FName Key, float& OutValue) const;
|
|
void SetFloatMetadata(const UStruct* Struct, FName Key, float Value);
|
|
|
|
bool GetIntMetadata(const UStruct* Struct, FName Key, int32& OutValue) const;
|
|
void SetIntMetadata(const UStruct* Struct, FName Key, int32 Value);
|
|
|
|
bool GetBoolMetadata(const UStruct* Struct, FName Key, bool& OutValue) const;
|
|
void SetBoolMetadata(const UStruct* Struct, FName Key, bool Value);
|
|
|
|
bool GetClassMetadata(const UStruct* Struct, FName Key, UClass*& OutValue) const;
|
|
void SetClassMetadata(const UStruct* Struct, FName Key, UClass* Value);
|
|
|
|
bool GetArrayMetadata(const UStruct* Struct, FName Key, TArray<FString>& OutValue) const;
|
|
void SetArrayMetadata(const UStruct* Struct, FName Key, const TArray<FString>& Value);
|
|
|
|
void AddToArrayMetadata(const UStruct* Struct, FName Key, const FString& Value);
|
|
void RemoveFromArrayMetadata(const UStruct* Struct, FName Key, const FString& Value);
|
|
|
|
void RemoveMetadata(const UStruct* Struct, FName Key);
|
|
|
|
private:
|
|
const FMetadataSet* FindFieldMetadata(const FField* Field) const;
|
|
FMetadataSet* FindFieldMetadata(const FField* Field);
|
|
FMetadataSet* FindOrAddFieldMetadata(const FField* Field);
|
|
|
|
const FMetadataSet* FindStructMetadata(const UStruct* Struct) const;
|
|
FMetadataSet* FindStructMetadata(const UStruct* Struct);
|
|
FMetadataSet* FindOrAddStructMetadata(const UStruct* Struct);
|
|
|
|
void OnCompleted(bool bSuccess);
|
|
|
|
private:
|
|
TSharedPtr<FEditorConfig> SourceConfig;
|
|
FMetadataConfig LoadedMetadata;
|
|
};
|