A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
SDialogueBrowser.h
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#pragma once
3
4#include "Widgets/DeclarativeSyntaxSupport.h"
5#include "Widgets/SCompoundWidget.h"
6#include "Widgets/Views/SListView.h"
7#include "Widgets/Views/STreeView.h"
8#include "Widgets/Input/SSearchBox.h"
9
13
14enum class EDialogueBlueprintOpenType : unsigned char;
15class UDlgDialogue;
16class SImage;
17
22{
24 typedef TSharedPtr<FDialogueBrowserSortOption> SortOptionType;
25
26public:
28 SLATE_END_ARGS()
29
30 void Construct(const FArguments& InArgs);
31
32 // Updates the participants tree.
33 void RefreshTree(bool bPreserveExpansion);
34
35 // Get current filter text
36 FText GetFilterText() const { return FilterTextBoxWidget->GetText(); }
37
38protected:
39 // Handle filtering.
41
42 // Getters for widgets.
43 TSharedRef<SWidget> GetFilterTextBoxWidget();
44
45 // Add Dialogue Children of type TextType to the InItem.
47 const TSharedPtr<FDialogueBrowserTreeNode>& InItem,
48 const TSharedPtr<FDialogueBrowserTreeVariableProperties>* PropertyPtr,
50 );
51
52 // Add GraphNode Children of type TextType to the InItem.
54 const TSharedPtr<FDialogueBrowserTreeNode>& InItem,
55 const TSet<TWeakObjectPtr<const UDialogueGraphNode>>& GraphNodes,
57 );
58
59 // Add EdgeNode Children of type TextType to the InItem.
61 const TSharedPtr<FDialogueBrowserTreeNode>& InItem,
62 const TSet<TWeakObjectPtr<const UDialogueGraphNode_Edge>>& EdgeNodes,
64 );
65
66 // Add both GraphNode Children and EdgeNode Children to the InItem from The Property.
68 const TSharedPtr<FDialogueBrowserTreeNode>& InItem,
69 const TSharedPtr<FDialogueBrowserTreeVariableProperties>* PropertyPtr,
70 EDialogueTreeNodeTextType GraphNodeTextType,
71 EDialogueTreeNodeTextType EdgeNodeTextType);
72
73 // Adds the Variables to the Item
75 const TSharedPtr<FDialogueBrowserTreeNode>& Item,
76 const TMap<FName, TSharedPtr<FDialogueBrowserTreeVariableProperties>>& Variables,
77 EDialogueTreeNodeTextType VariableType
78 );
79
80 // Recursively build the view item.
81 void BuildTreeViewItem(const TSharedPtr<FDialogueBrowserTreeNode>& Item);
82
83 // helper function to generate inline widgets for item.
84 TSharedRef<SWidget> MakeInlineWidget(const TSharedPtr<FDialogueBrowserTreeNode>& InItem);
85
86 // Make the row of buttons for the graph nodes.
87 TSharedRef<SWidget> MakeButtonWidgetForGraphNodes(const TArray<TSharedPtr<FDialogueBrowserTreeNode>>& InChildren);
88
89 // Make the buttons to open the dialogue.
90 TSharedRef<SWidget> MakeButtonsWidgetForDialogue(const TSharedPtr<FDialogueBrowserTreeNode>& InItem);
91
92 // Text search changed
93 void HandleSearchTextCommitted(const FText& InText, ETextCommit::Type InCommitType);
94
95 // Make the row
96 TSharedRef<ITableRow> HandleGenerateRow(TSharedPtr<FDialogueBrowserTreeNode> InItem, const TSharedRef<STableViewBase>& OwnerTable);
97
98 // General Get children
99 void HandleGetChildren(TSharedPtr<FDialogueBrowserTreeNode> InItem, TArray<TSharedPtr<FDialogueBrowserTreeNode>>& OutChildren);
100
101 // Handles changes in the Tree View.
102 void HandleTreeSelectionChanged(TSharedPtr<FDialogueBrowserTreeNode> NewValue, ESelectInfo::Type SelectInfo);
103
104 // User clicked on item.
105 void HandleDoubleClick(TSharedPtr<FDialogueBrowserTreeNode> InItem);
106
107 // Refresh button clicked.
109 {
110 RefreshTree(true);
111 return FReply::Handled();
112 }
113
114 // Callback for expanding tree items recursively
115 void HandleSetExpansionRecursive(TSharedPtr<FDialogueBrowserTreeNode> InItem, bool bInIsItemExpanded);
116
117 // When the sort option selection changes.
118 void HandleSortSelectionChanged(SortOptionType Selection, ESelectInfo::Type SelectInfo);
119
120 // Finds the object of the item inside the Content browser.
121 FReply FindInContentBrowserForItem(TSharedPtr<FDialogueBrowserTreeNode> InItem);
122
123 // Makes Participant categories.
124 TArray<TSharedPtr<FDialogueBrowserTreeNode>> MakeParticipantCategoriesChildren(
125 const TSharedPtr<FDialogueBrowserTreeNode>& Parent,
126 const TSharedPtr<FDialogueBrowserTreeParticipantProperties>& ParticipantProperties,
127 bool bHideEmptyCategories
128 ) const;
129
130 // Makes Variable categories.
131 TArray<TSharedPtr<FDialogueBrowserTreeNode>> MakeVariableCategoriesChildren(
132 const TSharedPtr<FDialogueBrowserTreeNode>& Parent,
133 const TSharedPtr<FDialogueBrowserTreeParticipantProperties>& ParticipantProperties,
134 bool bHideEmptyCategories
135 ) const;
136
137 // Makes Class Variable categories.
138 TArray<TSharedPtr<FDialogueBrowserTreeNode>> MakeClassVariableCategoriesChildren(
139 const TSharedPtr<FDialogueBrowserTreeNode>& Parent,
140 const TSharedPtr<FDialogueBrowserTreeParticipantProperties>& ParticipantProperties,
141 bool bHideEmptyCategories
142 ) const;
143
144 // Makes a widget that has IconName. Text of item.
145 TSharedRef<SHorizontalBox> MakeIconAndTextWidget(
146 const FText& InText,
147 const FSlateBrush* IconBrush,
148 int32 IconSize = 24
149 );
150
151 // Makes a widget for a Class that has IconName. Text of item.
152 TSharedRef<SHorizontalBox> MakeCustomObjectIconAndTextWidget(
153 const FText& InText,
154 const FSlateBrush* IconBrush,
155 UClass* Class,
157 FName FunctionNameToOpen,
158 int32 IconSize = 24
159 );
160
161 // Fills the menu of the View Options
162 TSharedRef<SWidget> FillViewOptionsEntries();
163
164 static EVisibility GetOpenAssetButtonVisibility(UClass* Class);
165 static EVisibility GetBrowseAssetButtonVisibility(UClass* Class);
166 static FReply OnBrowseAssetClicked(UClass* Class);
167 static FReply OnOpenAssetClicked(
168 UClass* Class,
170 FName FunctionNameToOpen
171 );
172 static FText GetJumpToAssetText(UClass* Class);
173 static FText GetBrowseAssetText(UClass* Class);
174
175protected:
176 // The search box
177 TSharedPtr<SSearchBox> FilterTextBoxWidget;
178
179 // The filter text from the search box.
181
182 // The root data source
183 TSharedPtr<FDialogueBrowserTreeNode> RootTreeItem;
184
185 // The root children. Kept separate so that we do not corrupt the data.
186 TArray<TSharedPtr<FDialogueBrowserTreeNode>> RootChildren;
187
188 // Tree view for showing all participants, etc.
189 TSharedPtr<STreeView<TSharedPtr<FDialogueBrowserTreeNode>>> ParticipantsTreeView;
190
196 TMap<FName, TSharedPtr<FDialogueBrowserTreeParticipantProperties>> ParticipantsProperties;
197
198 //
199 // Sort variables
200 //
201
202 // The data sources
203 TArray<SortOptionType> SortOptions;
204
205 // Default option.
207
208 // Selected option.
210};
EDialogueTreeNodeTextType
EDialogueBlueprintOpenType
void AddGraphNodeChildrenToItem(const TSharedPtr< FDialogueBrowserTreeNode > &InItem, const TSet< TWeakObjectPtr< const UDialogueGraphNode > > &GraphNodes, EDialogueTreeNodeTextType TextType)
TMap< FName, TSharedPtr< FDialogueBrowserTreeParticipantProperties > > ParticipantsProperties
TArray< TSharedPtr< FDialogueBrowserTreeNode > > MakeClassVariableCategoriesChildren(const TSharedPtr< FDialogueBrowserTreeNode > &Parent, const TSharedPtr< FDialogueBrowserTreeParticipantProperties > &ParticipantProperties, bool bHideEmptyCategories) const
void HandleSetExpansionRecursive(TSharedPtr< FDialogueBrowserTreeNode > InItem, bool bInIsItemExpanded)
static EVisibility GetOpenAssetButtonVisibility(UClass *Class)
TSharedPtr< FDialogueBrowserSortOption > SortOptionType
TArray< TSharedPtr< FDialogueBrowserTreeNode > > MakeParticipantCategoriesChildren(const TSharedPtr< FDialogueBrowserTreeNode > &Parent, const TSharedPtr< FDialogueBrowserTreeParticipantProperties > &ParticipantProperties, bool bHideEmptyCategories) const
SortOptionType DefaultSortOption
TSharedPtr< STreeView< TSharedPtr< FDialogueBrowserTreeNode > > > ParticipantsTreeView
void HandleDoubleClick(TSharedPtr< FDialogueBrowserTreeNode > InItem)
TArray< SortOptionType > SortOptions
void AddEdgeNodeChildrenToItem(const TSharedPtr< FDialogueBrowserTreeNode > &InItem, const TSet< TWeakObjectPtr< const UDialogueGraphNode_Edge > > &EdgeNodes, EDialogueTreeNodeTextType TextType)
TArray< TSharedPtr< FDialogueBrowserTreeNode > > MakeVariableCategoriesChildren(const TSharedPtr< FDialogueBrowserTreeNode > &Parent, const TSharedPtr< FDialogueBrowserTreeParticipantProperties > &ParticipantProperties, bool bHideEmptyCategories) const
TSharedRef< SWidget > FillViewOptionsEntries()
void BuildTreeViewItem(const TSharedPtr< FDialogueBrowserTreeNode > &Item)
void HandleSortSelectionChanged(SortOptionType Selection, ESelectInfo::Type SelectInfo)
TArray< TSharedPtr< FDialogueBrowserTreeNode > > RootChildren
static EVisibility GetBrowseAssetButtonVisibility(UClass *Class)
void HandleGetChildren(TSharedPtr< FDialogueBrowserTreeNode > InItem, TArray< TSharedPtr< FDialogueBrowserTreeNode > > &OutChildren)
TSharedRef< ITableRow > HandleGenerateRow(TSharedPtr< FDialogueBrowserTreeNode > InItem, const TSharedRef< STableViewBase > &OwnerTable)
FText GetFilterText() const
FReply FindInContentBrowserForItem(TSharedPtr< FDialogueBrowserTreeNode > InItem)
TSharedRef< SWidget > MakeInlineWidget(const TSharedPtr< FDialogueBrowserTreeNode > &InItem)
TSharedRef< SWidget > GetFilterTextBoxWidget()
TSharedRef< SWidget > MakeButtonsWidgetForDialogue(const TSharedPtr< FDialogueBrowserTreeNode > &InItem)
TSharedPtr< SSearchBox > FilterTextBoxWidget
void RefreshTree(bool bPreserveExpansion)
void Construct(const FArguments &InArgs)
static FReply OnOpenAssetClicked(UClass *Class, EDialogueBlueprintOpenType OpenType, FName FunctionNameToOpen)
TSharedPtr< FDialogueBrowserTreeNode > RootTreeItem
void AddVariableChildrenToItem(const TSharedPtr< FDialogueBrowserTreeNode > &Item, const TMap< FName, TSharedPtr< FDialogueBrowserTreeVariableProperties > > &Variables, EDialogueTreeNodeTextType VariableType)
static FText GetBrowseAssetText(UClass *Class)
void HandleSearchTextCommitted(const FText &InText, ETextCommit::Type InCommitType)
SDialogueBrowser Self
TSharedRef< SHorizontalBox > MakeCustomObjectIconAndTextWidget(const FText &InText, const FSlateBrush *IconBrush, UClass *Class, EDialogueBlueprintOpenType OpenType, FName FunctionNameToOpen, int32 IconSize=24)
TSharedRef< SWidget > MakeButtonWidgetForGraphNodes(const TArray< TSharedPtr< FDialogueBrowserTreeNode > > &InChildren)
void AddDialogueChildrenToItemFromProperty(const TSharedPtr< FDialogueBrowserTreeNode > &InItem, const TSharedPtr< FDialogueBrowserTreeVariableProperties > *PropertyPtr, EDialogueTreeNodeTextType TextType)
SortOptionType SelectedSortOption
void HandleTreeSelectionChanged(TSharedPtr< FDialogueBrowserTreeNode > NewValue, ESelectInfo::Type SelectInfo)
TSharedRef< SHorizontalBox > MakeIconAndTextWidget(const FText &InText, const FSlateBrush *IconBrush, int32 IconSize=24)
void AddGraphNodeBaseChildrenToItemFromProperty(const TSharedPtr< FDialogueBrowserTreeNode > &InItem, const TSharedPtr< FDialogueBrowserTreeVariableProperties > *PropertyPtr, EDialogueTreeNodeTextType GraphNodeTextType, EDialogueTreeNodeTextType EdgeNodeTextType)
static FText GetJumpToAssetText(UClass *Class)
static FReply OnBrowseAssetClicked(UClass *Class)
UCLASS(BlueprintType, Meta = (DisplayThumbnail = "true"))
Definition DlgDialogue.h:85