Skip to content

Commit 1e8621c

Browse files
feat: add GetChildProperty to UConfigPropertyArray and UConfigPropertySection
1 parent d045d35 commit 1e8621c

6 files changed

Lines changed: 62 additions & 6 deletions

File tree

Mods/SML/Source/SML/Private/Configuration/Properties/ConfigPropertyArray.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,8 @@ FConfigVariableDescriptor UConfigPropertyArray::CreatePropertyDescriptor_Impleme
215215
return UConfigVariableLibrary::MakeConfigVariableArray(DefaultValue->CreatePropertyDescriptor(Context, OuterPath));
216216
}
217217

218-
#undef LOCTEXT_NAMESPACE
218+
UConfigProperty* UConfigPropertyArray::GetChildProperty_Implementation(const int32 PropertyIndex) {
219+
return Values[PropertyIndex];
220+
}
221+
222+
#undef LOCTEXT_NAMESPACE

Mods/SML/Source/SML/Private/Configuration/Properties/ConfigPropertySection.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,8 @@ FConfigVariableDescriptor UConfigPropertySection::CreatePropertyDescriptor_Imple
162162
return UConfigVariableLibrary::MakeConfigVariableGeneratedStruct(GeneratedStruct);
163163
}
164164

165-
#undef LOCTEXT_NAMESPACE
165+
UConfigProperty* UConfigPropertySection::GetChildProperty_Implementation(const FString& PropertyName) {
166+
return SectionProperties.FindRef(PropertyName);
167+
}
168+
169+
#undef LOCTEXT_NAMESPACE
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
#include "CoreMinimal.h"
3+
#include "Configuration/ConfigProperty.h"
4+
#include "ConfigValueArrayInterface.generated.h"
5+
6+
UINTERFACE(Blueprintable, BlueprintType)
7+
class SML_API UConfigValueArrayInterface : public UInterface {
8+
GENERATED_BODY()
9+
};
10+
11+
class SML_API IConfigValueArrayInterface {
12+
GENERATED_BODY()
13+
public:
14+
/** Returns the child property of this property at the specified index */
15+
UFUNCTION(BlueprintNativeEvent)
16+
UConfigProperty* GetChildProperty(const int32 PropertyIndex);
17+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
#include "CoreMinimal.h"
3+
#include "Configuration/ConfigProperty.h"
4+
#include "ConfigValueObjectInterface.generated.h"
5+
6+
UINTERFACE(Blueprintable, BlueprintType)
7+
class SML_API UConfigValueObjectInterface : public UInterface {
8+
GENERATED_BODY()
9+
};
10+
11+
class SML_API IConfigValueObjectInterface {
12+
GENERATED_BODY()
13+
public:
14+
/** Returns the child property of this property with the specified key */
15+
UFUNCTION(BlueprintNativeEvent)
16+
UConfigProperty* GetChildProperty(const FString& PropertyKey);
17+
};

Mods/SML/Source/SML/Public/Configuration/Properties/ConfigPropertyArray.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#pragma once
22
#include "Configuration/ConfigProperty.h"
3+
#include "Configuration/ConfigValueArrayInterface.h"
34
#include "Configuration/ConfigValueDirtyHandlerInterface.h"
45
#include "ConfigPropertyArray.generated.h"
56

67
/** Describes array configuration property with single nested element type */
78
UCLASS()
8-
class SML_API UConfigPropertyArray : public UConfigProperty, public IConfigValueDirtyHandlerInterface {
9+
class SML_API UConfigPropertyArray : public UConfigProperty, public IConfigValueDirtyHandlerInterface, public IConfigValueArrayInterface {
910
GENERATED_BODY()
1011
public:
1112
/** Defines the "template" default value used for allocating other values in the array */
@@ -62,4 +63,10 @@ class SML_API UConfigPropertyArray : public UConfigProperty, public IConfigValue
6263
//Begin IConfigValueDirtyHandlerInterface
6364
virtual void HandleMarkDirty_Implementation() override;
6465
//End IConfigValueDirtyHandlerInterface
65-
};
66+
67+
//Begin IConfigPropertyArrayInterface
68+
/** Returns the child property of this property at the specified index */
69+
UFUNCTION(BlueprintCallable, BlueprintPure, meta = (DisplayName = "Get Child By Index", CompactNodeTitle = ".", BlueprintAutocast), Category = "SML | Configuration")
70+
virtual UConfigProperty* GetChildProperty_Implementation(const int32 PropertyIndex) override;
71+
//End IConfigPropertyArrayInterface
72+
};

Mods/SML/Source/SML/Public/Configuration/Properties/ConfigPropertySection.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#pragma once
22
#include "Configuration/ConfigProperty.h"
33
#include "Configuration/ConfigValueDirtyHandlerInterface.h"
4+
#include "Configuration/ConfigValueObjectInterface.h"
45
#include "ConfigPropertySection.generated.h"
56

67
/** Describes a single configuration section with nested properties */
78
UCLASS()
8-
class SML_API UConfigPropertySection : public UConfigProperty, public IConfigValueDirtyHandlerInterface {
9+
class SML_API UConfigPropertySection : public UConfigProperty, public IConfigValueDirtyHandlerInterface, public IConfigValueObjectInterface {
910
GENERATED_BODY()
1011
public:
1112
/**
@@ -42,4 +43,10 @@ class SML_API UConfigPropertySection : public UConfigProperty, public IConfigVal
4243
//Begin IConfigValueDirtyHandlerInterface
4344
virtual void HandleMarkDirty_Implementation() override;
4445
//End IConfigValueDirtyHandlerInterface
45-
};
46+
47+
//Begin IConfigPropertyObjectInterface
48+
/** Returns the child property of this property with the specified key */
49+
UFUNCTION(BlueprintCallable, BlueprintPure, meta = (DisplayName = "Get Child By Key", CompactNodeTitle = ".", BlueprintAutocast), Category = "SML | Configuration")
50+
virtual UConfigProperty* GetChildProperty_Implementation(const FString& PropertyKey) override;
51+
//End IConfigPropertyObjectInterface
52+
};

0 commit comments

Comments
 (0)