A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueBrowserTreeNode.h
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5#include "Widgets/Views/STreeView.h"
6
8
10class UDlgDialogue;
13
14// The types of categories.
39
93
94
99class FDialogueBrowserTreeNode : public FDlgTreeViewNode<FDialogueBrowserTreeNode>
100{
103
104public:
105 FDialogueBrowserTreeNode(const FText& InDisplayText, const TSharedPtr<Self>& InParent);
106
108 virtual FName GetParentParticipantName() const;
109
111 virtual FName GetParentVariableName() const;
112
114 virtual UClass* GetParentClass() const;
115
116 //
117 // Getters for the properties
118 //
119
120 // TextType:
122 void SetTextType(EDialogueTreeNodeTextType InTextType) { TextType = InTextType; }
123
124 // CategoryType:
126
127 // Children/InlineChildren:
128 void AddChild(const TSharedPtr<Self>& ChildNode) override
129 {
130 ensure(!IsSeparator());
131 Super::AddChild(ChildNode);
132 }
133 void ClearChildren() override
134 {
136 InlineChildren.Empty();
137 }
138
139 void AddInlineChild(const TSharedPtr<Self>& ChildNode, bool bIsInline = false)
140 {
141 ensure(!ChildNode->IsRoot());
142 ensure(!IsSeparator());
143 ChildNode->SetParent(this->AsShared());
144 InlineChildren.Add(ChildNode);
145 }
146 bool HasInlineChildren() const { return InlineChildren.Num() > 0; }
147 const TArray<TSharedPtr<Self>>& GetInlineChildren() const { return InlineChildren; }
148 void SetInlineChildren(const TArray<TSharedPtr<Self>>& InChildren)
149 {
150 InlineChildren = InChildren;
151 for (const TSharedPtr<Self>& Child : InlineChildren)
152 {
153 Child->SetParent(this->AsShared());
154 }
155 }
156
157 // Checks type of this Node.
158 virtual bool IsText() const { return TextType != EDialogueTreeNodeTextType::Default; }
159 virtual bool IsCategory() const { return false; }
160 virtual bool IsSeparator() const { return false; }
178 bool IsEventText() const
179 {
181 }
212
213 // Gets the textual representation of this item
214 FString ToString() const;
215
216 // Is this equal with Other?
217 virtual bool IsEqual(const Self& Other)
218 {
219 return TextType == Other.GetTextType() &&
220 CategoryType == Other.GetCategoryType() &&
221 DisplayText.EqualTo(Other.GetDisplayText()) &&
222 GetParentParticipantName() == Other.GetParentParticipantName() &&
223 GetParentVariableName() == Other.GetParentVariableName();
224 }
225
226 bool operator==(const Self& Other)
227 {
228 return IsEqual(Other);
229 }
230
231protected:
232 // FDlgTreeViewNode Interface
233 void PostFilterPathsToNodes(const TSharedPtr<Self>& Child) override
234 {
236
237 // Hide separators
238 if (Child->IsSeparator())
239 {
240 Child->SetIsVisible(false);
241 }
242 // Some child has the InSearch or this Node has the text
243 //Children[Index]->SetIsVisible(NumBefore != OutNodes.Num() || Children[Index]->TextContains(InSearch));
244 }
245
246 void PostBuildPathToTopMostParent(const TSharedPtr<Self>& CurrentParentNode) override
247 {
248 Super::PostBuildPathToTopMostParent(CurrentParentNode);
249 check(!CurrentParentNode->IsSeparator());
250 }
251
252 bool FilterIsChildVisible(const TSharedPtr<Self>& GrandChild) override
253 {
254 return !GrandChild->IsSeparator() && !GrandChild->IsCategory() && Super::FilterIsChildVisible(GrandChild);
255 }
256
257 bool FilterDoesChildContainText(const TSharedPtr<Self>& Child, const FString& InSearch) override
258 {
259 return !Child->IsSeparator() && Super::FilterDoesChildContainText(Child, InSearch);
260 }
261
262protected:
263 // Specific category type, only used if Type is Category.
265
266 // Specific text type, only used if the Type is Text.
268
269 // Inline Nodes, Nodes that are displayed in the same line as this Node
270 TArray<TSharedPtr<Self>> InlineChildren;
271};
272
273
274// Root node of the Dialogue browser
281
282
283// Separator node of the Dialogue browser
285{
287public:
288 FDialogueBrowserTreeSeparatorNode(const TSharedPtr<FDialogueBrowserTreeNode>& InParent = nullptr);
289 bool IsText() const override { return false; }
290 bool IsCategory() const override { return false; }
291 bool IsSeparator() const override { return true; }
292};
293
294
300{
302public:
304 const FText& InDisplayText,
305 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
306 EDialogueTreeNodeCategoryType InCategoryType
307 );
308
309 bool IsText() const override { return false; }
311};
312
313
314// Node results that represents the Participant Name.
316{
319public:
321 const FText& InDisplayText,
322 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
323 FName InParticipantName
324 );
325
326 // ParticipantName:
327 FName GetParentParticipantName() const override;
328
329protected:
331 FName ParticipantName = NAME_None;
332};
333
334
335// Node results that represents a Variable Name.
337{
340
341public:
343 const FText& InDisplayText,
344 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
345 FName InVariableName
346 );
347
348 // VariableName:
349 FName GetParentVariableName() const override;
350
351protected:
352 // Used to store Event, Condition, IntName, Dialogue name etc
353 FName VariableName = NAME_None;
354};
355
356// Node result that represents a custom object
358{
361
362public:
364 const FText& InDisplayText,
365 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
366 UClass* ObjectClass
367 );
368
369 // Class
370 UClass* GetClass() const { return Class.Get(); }
371 UClass* GetParentClass() const { return GetClass(); }
372
373protected:
374 // Class this represents
375 TWeakObjectPtr<UClass> Class = nullptr;
376};
377
378
379// Similar to the FDialogueBrowserTreeParticipantNode only this is a Category
381{
383public:
385 const FText& InDisplayText,
386 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
387 FName InParticipantName
388 );
389
390 bool IsText() const override { return false; }
391 bool IsCategory() const override { return true; }
392};
393
394
395// Node results that represents the Dialogue.
397{
400public:
402 const FText& InDisplayText,
403 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
404 const TWeakObjectPtr<const UDlgDialogue>& InObject
405 );
406
407 // Dialogue:
408 const TWeakObjectPtr<const UDlgDialogue>& GetDialogue() const { return Dialogue; }
409 FReply OnClick() override;
410
411 bool IsEqual(const Super& Other) override
412 {
413 if (const Self* OtherSelf = static_cast<const Self*>(&Other))
414 {
415 return Dialogue == OtherSelf->GetDialogue() && Super::IsEqual(Other);
416 }
417 return false;
418 }
419
420protected:
421 // The Dialogue this represents.
422 TWeakObjectPtr<const UDlgDialogue> Dialogue;
423};
424
425
426// Node results that represents the GraphNode.
428{
431public:
433 const FText& InDisplayText,
434 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
435 const TWeakObjectPtr<const UDialogueGraphNode>& InObject
436 );
437
438 // GraphNode:
439 const TWeakObjectPtr<const UDialogueGraphNode>& GetGraphNode() const { return GraphNode; }
440 FReply OnClick() override;
441
442 bool IsEqual(const Super& Other) override
443 {
444 if (const Self* OtherSelf = static_cast<const Self*>(&Other))
445 {
446 return GraphNode == OtherSelf->GetGraphNode() && Super::IsEqual(Other);
447 }
448 return false;
449 }
450
451protected:
452 // The GraphNode this represents.
453 TWeakObjectPtr<const UDialogueGraphNode> GraphNode;
454};
455
456
457// Node results that represents the EdgeNode.
459{
462public:
464 const FText& InDisplayText,
465 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
466 const TWeakObjectPtr<const UDialogueGraphNode_Edge>& InObject
467 );
468
469 // EdgeNode:
470 const TWeakObjectPtr<const UDialogueGraphNode_Edge>& GetEdgeNode() const { return EdgeNode; }
471 FReply OnClick() override;
472
473 bool IsEqual(const Super& Other) override
474 {
475 if (const Self* OtherSelf = static_cast<const Self*>(&Other))
476 {
477 return EdgeNode == OtherSelf->GetEdgeNode() && Super::IsEqual(Other);
478 }
479 return false;
480 }
481
482protected:
483 // The EdgeNode this represents.
484 TWeakObjectPtr<const UDialogueGraphNode_Edge> EdgeNode;
485};
EDialogueTreeNodeTextType
EDialogueTreeNodeCategoryType
FDialogueBrowserTreeCategoryNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, EDialogueTreeNodeCategoryType InCategoryType)
FDialogueBrowserTreeCategoryParticipantNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, FName InParticipantName)
FDialogueBrowserTreeCustomObjectNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, UClass *ObjectClass)
FDialogueBrowserTreeCustomObjectNode Self
bool IsEqual(const Super &Other) override
FDialogueBrowserTreeDialogueNode Self
FDialogueBrowserTreeDialogueNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, const TWeakObjectPtr< const UDlgDialogue > &InObject)
const TWeakObjectPtr< const UDlgDialogue > & GetDialogue() const
TWeakObjectPtr< const UDlgDialogue > Dialogue
bool IsEqual(const Super &Other) override
TWeakObjectPtr< const UDialogueGraphNode_Edge > EdgeNode
FDialogueBrowserTreeEdgeNode Self
const TWeakObjectPtr< const UDialogueGraphNode_Edge > & GetEdgeNode() const
FDialogueBrowserTreeEdgeNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, const TWeakObjectPtr< const UDialogueGraphNode_Edge > &InObject)
FDialogueBrowserTreeGraphNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, const TWeakObjectPtr< const UDialogueGraphNode > &InObject)
bool IsEqual(const Super &Other) override
FDialogueBrowserTreeGraphNode Self
const TWeakObjectPtr< const UDialogueGraphNode > & GetGraphNode() const
TWeakObjectPtr< const UDialogueGraphNode > GraphNode
void AddChild(const TSharedPtr< Self > &ChildNode) override
virtual UClass * GetParentClass() const
bool FilterDoesChildContainText(const TSharedPtr< Self > &Child, const FString &InSearch) override
void SetInlineChildren(const TArray< TSharedPtr< Self > > &InChildren)
TArray< TSharedPtr< Self > > InlineChildren
bool FilterIsChildVisible(const TSharedPtr< Self > &GrandChild) override
EDialogueTreeNodeTextType TextType
virtual bool IsEqual(const Self &Other)
void PostFilterPathsToNodes(const TSharedPtr< Self > &Child) override
virtual FName GetParentParticipantName() const
bool operator==(const Self &Other)
EDialogueTreeNodeCategoryType CategoryType
void AddInlineChild(const TSharedPtr< Self > &ChildNode, bool bIsInline=false)
FDialogueBrowserTreeNode Self
void SetTextType(EDialogueTreeNodeTextType InTextType)
EDialogueTreeNodeTextType GetTextType() const
FDialogueBrowserTreeNode(const FText &InDisplayText, const TSharedPtr< Self > &InParent)
virtual FName GetParentVariableName() const
void PostBuildPathToTopMostParent(const TSharedPtr< Self > &CurrentParentNode) override
EDialogueTreeNodeCategoryType GetCategoryType() const
const TArray< TSharedPtr< Self > > & GetInlineChildren() const
FDialogueBrowserTreeParticipantNode Self
FDialogueBrowserTreeParticipantNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, FName InParticipantName)
FDialogueBrowserTreeSeparatorNode(const TSharedPtr< FDialogueBrowserTreeNode > &InParent=nullptr)
FDialogueBrowserTreeVariableNode Self
FDialogueBrowserTreeVariableNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, FName InVariableName)
virtual void PostBuildPathToTopMostParent(const TSharedPtr< SelfType > &CurrentParentNode)
virtual bool FilterDoesChildContainText(const TSharedPtr< SelfType > &Child, const FString &InSearch)
virtual void PostFilterPathsToNodes(const TSharedPtr< SelfType > &Child)
virtual void AddChild(const TSharedPtr< SelfType > &ChildNode)
virtual bool FilterIsChildVisible(const TSharedPtr< SelfType > &GrandChild)
virtual void ClearChildren()
UCLASS(BlueprintType, Meta = (DisplayThumbnail = "true"))
Definition DlgDialogue.h:85