Live Config
Loading...
Searching...
No Matches
LiveConfigPropertyTreeSubsystem.h
1// Copyright (c) 2026 Nicholas Arthur
2// Licensed under the MIT License
3
4#pragma once
5
6#include "CoreMinimal.h"
7#include "LiveConfigTypes.h"
8#include "EditorSubsystem.h"
9#include "LiveConfigPropertyTreeSubsystem.generated.h"
10
11// Canonical, shared tree node built from live config property definitions.
12// This model is owned by the subsystem and should be treated as read-only by views.
13struct FLiveConfigPropertyModelNode : public TSharedFromThis<FLiveConfigPropertyModelNode>
14{
15 FString DisplayName;
16 FString FullPath;
17 TSharedPtr<FLiveConfigPropertyDefinition> PropertyDefinition;
18 TArray<TSharedRef<FLiveConfigPropertyModelNode>> Children;
19 TWeakPtr<FLiveConfigPropertyModelNode> Parent;
20
21 bool IsProperty() const { return PropertyDefinition.IsValid() && PropertyDefinition->PropertyType != ELiveConfigPropertyType::Struct; }
22 bool IsStruct() const { return PropertyDefinition.IsValid() && PropertyDefinition->PropertyType == ELiveConfigPropertyType::Struct; }
23};
24
25// Editor-only subsystem that owns the property tree and shared definition list,
26// rebuilt on LiveConfigSystem updates for all manager views to consume.
27UCLASS()
28class LIVECONFIGEDITOR_API ULiveConfigPropertyTreeSubsystem : public UEditorSubsystem
29{
30 GENERATED_BODY()
31
32public:
34
35 // USubsystem
36 virtual void Initialize(FSubsystemCollectionBase& Collection) override;
37 virtual void Deinitialize() override;
38 // ~USubsystem
39
40 // Root nodes for the tree (folders/structs/properties).
41 const TArray<TSharedRef<FLiveConfigPropertyModelNode>>& GetRootNodes() const { return RootNodes; }
42
43 // Fast lookup of nodes by full property path.
44 const TMap<FString, TSharedPtr<FLiveConfigPropertyModelNode>>& GetNodeByPath() const { return NodeByPath; }
45
46 // Flat, alphabetically (natural) sorted list of shared property definitions backing the tree.
47 const TArray<TSharedPtr<FLiveConfigPropertyDefinition>>& GetDefinitions() const { return Definitions; }
48
49 void RebuildFromSystem();
50
51 // Shared definitions backing the canonical tree.
52 TArray<TSharedPtr<FLiveConfigPropertyDefinition>> Definitions;
53
54private:
55 void Rebuild(const TMap<FLiveConfigProperty, FLiveConfigPropertyDefinition>& InDefs);
56
57 TArray<TSharedRef<FLiveConfigPropertyModelNode>> RootNodes;
58 TMap<FString, TSharedPtr<FLiveConfigPropertyModelNode>> NodeByPath;
59 TMap<FString, TSharedPtr<FLiveConfigPropertyDefinition>> StructByName;
60 FDelegateHandle PropertiesUpdatedHandle;
61};
Definition LiveConfigPropertyTreeSubsystem.h:29
Definition LiveConfigPropertyTreeSubsystem.h:14