A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
SDlgDataDisplay.h
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#pragma once
3#include "Widgets/DeclarativeSyntaxSupport.h"
4#include "Widgets/SCompoundWidget.h"
5#include "Widgets/Views/STreeView.h"
6#include "Widgets/Input/SSearchBox.h"
7
10
11DECLARE_LOG_CATEGORY_EXTERN(LogDlgSystemDataDisplay, Verbose, All);
12
13// Implements the Runtime Dialogue Data Display
14class DLGSYSTEM_API SDlgDataDisplay : public SCompoundWidget
15{
17
18public:
20 SLATE_END_ARGS()
21
22 void Construct(const FArguments& InArgs, const TWeakObjectPtr<const UObject>& InWorldContextObjectPtr);
23
24 void SetWorldContextObject(const TWeakObjectPtr<const UObject>& InWorldContextObjectPtr)
25 {
26 WorldContextObjectPtr = InWorldContextObjectPtr;
27 }
28
29 // Updates the actors tree.
30 void RefreshTree(bool bPreserveExpansion);
31
32 // Get current filter text
33 FText GetFilterText() const { return FilterTextBoxWidget->GetText(); }
34
35private:
36 // Handle filtering.
37 void GenerateFilteredItems();
38
39 // Getters for widgets.
40 TSharedRef<SWidget> GetFilterTextBoxWidget();
41
42 // Add the Variables as children to the Item
43 void AddVariableChildrenToItem(
44 const TSharedPtr<FDlgDataDisplayTreeNode>& Item,
45 const TMap<FName, TSharedPtr<FDlgDataDisplayVariableProperties>>& Variables,
46 const FText& DisplayTextFormat,
48 );
49
50 // Recursively build the view item.
51 void BuildTreeViewItem(const TSharedPtr<FDlgDataDisplayTreeNode>& Item);
52
53 // Text search changed
54 void HandleSearchTextCommited(const FText& InText, ETextCommit::Type InCommitType);
55
56 // Refresh button clicked.
58 {
59 RefreshTree(true);
60 return FReply::Handled();
61 }
62
63 // Make the row
64 TSharedRef<ITableRow> HandleGenerateRow(TSharedPtr<FDlgDataDisplayTreeNode> InItem, const TSharedRef<STableViewBase>& OwnerTable);
65
66 // General Get children
67 void HandleGetChildren(TSharedPtr<FDlgDataDisplayTreeNode> InItem, TArray<TSharedPtr<FDlgDataDisplayTreeNode>>& OutChildren);
68
69 // Handles changes in the Tree View.
70 void HandleTreeSelectionChanged(TSharedPtr<FDlgDataDisplayTreeNode> InItem, ESelectInfo::Type SelectInfo);
71
72 // User clicked on item.
73 void HandleDoubleClick(TSharedPtr<FDlgDataDisplayTreeNode> InItem);
74
75 // Callback for expanding tree items recursively
76 void HandleSetExpansionRecursive(TSharedPtr<FDlgDataDisplayTreeNode> InItem, bool bInIsItemExpanded);
77
78 // Compare two FDlgDataDisplayTreeNode
79 static bool PredicateCompareDlgDataDisplayTreeNode(const TSharedPtr<FDlgDataDisplayTreeNode>& FirstNode, const TSharedPtr<FDlgDataDisplayTreeNode>& SecondNode)
80 {
81 if (!FirstNode.IsValid() || !SecondNode.IsValid())
82 {
83 return false;
84 }
85 return *FirstNode == *SecondNode;
86 }
87
88private:
89 // The search box
90 TSharedPtr<SSearchBox> FilterTextBoxWidget;
91
92 // The filter text from the search box.
93 FString FilterString;
94
95 // The root data source
96 TSharedPtr<FDlgDataDisplayTreeNode> RootTreeItem;
97
98 // The root children. Kept separate so that we do not corrupt the data.
99 TArray<TSharedPtr<FDlgDataDisplayTreeNode>> RootChildren;
100
101 // Tree view for showing all Actors that implement the , etc.
102 TSharedPtr<STreeView<TSharedPtr<FDlgDataDisplayTreeNode>>> ActorsTreeView;
103
104 // Used for fast lookup of each actor
105 // Key: Weak Pointer to the Actor
106 // Value: Actor properties
107 TMap<TWeakObjectPtr<AActor>, TSharedPtr<FDlgDataDisplayActorProperties>> ActorsProperties;
108
109 // Reference Object used to get the World
110 TWeakObjectPtr<const UObject> WorldContextObjectPtr = nullptr;
111};
EDlgDataDisplayVariableTreeNodeType
DECLARE_LOG_CATEGORY_EXTERN(LogDlgSystemDataDisplay, Verbose, All)
TMap< TWeakObjectPtr< AActor >, TSharedPtr< FDlgDataDisplayActorProperties > > ActorsProperties
TSharedPtr< STreeView< TSharedPtr< FDlgDataDisplayTreeNode > > > ActorsTreeView
FReply HandleOnRefresh()
TSharedPtr< FDlgDataDisplayTreeNode > RootTreeItem
static bool PredicateCompareDlgDataDisplayTreeNode(const TSharedPtr< FDlgDataDisplayTreeNode > &FirstNode, const TSharedPtr< FDlgDataDisplayTreeNode > &SecondNode)
FText GetFilterText() const
TArray< TSharedPtr< FDlgDataDisplayTreeNode > > RootChildren
SDlgDataDisplay Self
TSharedPtr< SSearchBox > FilterTextBoxWidget