A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueBrowserTreeNode.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
3
4#include "Widgets/Views/STreeView.h"
5
9
11// FDialogueBrowserTreeNode
12FDialogueBrowserTreeNode::FDialogueBrowserTreeNode(const FText& InDisplayText, const TSharedPtr<Self>& InParent)
13 : Super(InDisplayText, InParent)
14{
15}
16
18{
19 if (Parent.IsValid())
20 {
21 return Parent.Pin()->GetParentParticipantName();
22 }
23
24 return NAME_None;
25}
26
28{
29 if (Parent.IsValid())
30 {
31 return Parent.Pin()->GetParentVariableName();
32 }
33
34 return NAME_None;
35}
36
38{
39 if (Parent.IsValid())
40 {
41 return Parent.Pin()->GetParentClass();
42 }
43
44 return nullptr;
45}
46
48{
49 // static const ANSICHAR* EDialogueTreeItemCategoryTypeStringMap[] = {
50 // "Default",
51 // "Participant",
52 // "Dialogue",
53 // "Event",
54 // "Condition",
55 // "Variable",
56 // "VariableInt",
57 // "VariableFloat",
58 // "VariableBool",
59 // "Max"
60 // };
61
62 FString Output = "FTextItem { ";
63
64 auto AddKeyValueField = [&Output](const FString& Key, const FString& Value, const bool bAddSeparator = true)
65 {
66 if (bAddSeparator)
67 {
68 Output += " | ";
69 }
70 Output += Key + " = `" + Value + "`";
71 };
72 auto AddFNameToOutput = [&Output, &AddKeyValueField](const FString& Name, FName Value)
73 {
74 if (!Value.IsNone() && Value.IsValid())
75 {
76 AddKeyValueField(Name, Value.ToString());
77 }
78 };
79
80 AddKeyValueField("Text", DisplayText.ToString(), false);
81 //AddFNameToOutput("ParticipantName", ParticipantName);
82 //AddFNameToOutput("VariableName", VariableName);
83
84 // if (Object.IsValid())
85 // {
86 // AddKeyValueField("Object Name", Object.Get()->GetName());
87 // }
88 AddKeyValueField("Children Num", FString::FromInt(Children.Num()));
89
90 return Output + " }";
91}
92
93
95// FDialogueBrowserTreeRootNode
97 Super(FText::FromString(TEXT("ROOT")), nullptr)
98{
99}
100
101
103// FDialogueBrowserTreeSeparatorNode
105 const TSharedPtr<FDialogueBrowserTreeNode>& InParent)
106 : Super(FText::FromString(TEXT("SEPARATOR")), InParent)
107{
108}
109
110
112// FDialogueBrowserTreeCategoryNode
114 const FText& InDisplayText,
115 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
116 EDialogueTreeNodeCategoryType InCategoryType
117) : Super(InDisplayText, InParent)
118{
119 CategoryType = InCategoryType;
120}
121
122
124// FDialogueBrowserTreeParticipantNode
126 const FText& InDisplayText,
127 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
128 FName InParticipantName
129) : Super(InDisplayText, InParent), ParticipantName(InParticipantName)
130{
131}
132
134{
135 if (ParticipantName.IsValid() && !ParticipantName.IsNone())
136 {
137 return ParticipantName;
138 }
139
141}
142
143
145// FDialogueBrowserTreeVariableNode
147 const FText& InDisplayText,
148 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
149 FName InVariableName
150) : Super(InDisplayText, InParent), VariableName(InVariableName)
151{
152}
153
155{
156 if (VariableName.IsValid() && !VariableName.IsNone())
157 {
158 return VariableName;
159 }
160
162}
163
165// FDialogueBrowserTreeCustomObjectNode
166
168 const FText& InDisplayText,
169 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
170 UClass* ObjectClass
171) : Super(InDisplayText, InParent), Class(ObjectClass)
172{
173
174}
175
177// FDialogueBrowserTreeCategoryParticipantNode
179 const FText& InDisplayText,
180 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
181 FName InParticipantName
182) : Super(InDisplayText, InParent, InParticipantName)
183{
185}
186
187
189// FDialogueBrowserTreeDialogueNode
191 const FText& InDisplayText,
192 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
193 const TWeakObjectPtr<const UDlgDialogue>& InObject
194) : Super(InDisplayText, InParent), Dialogue(InObject)
195{
196}
197
199{
200 if (Dialogue.IsValid())
201 {
203 return FReply::Handled();
204 }
205
206 return FReply::Unhandled();
207}
208
209
211// FDialogueBrowserTreeGraphNode
213 const FText& InDisplayText,
214 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
215 const TWeakObjectPtr<const UDialogueGraphNode>& InObject
216) : Super(InDisplayText, InParent), GraphNode(InObject)
217{
218}
219
221{
222 if (GraphNode.IsValid())
223 {
224 return FDialogueEditorUtilities::OpenEditorAndJumpToGraphNode(Cast<UDialogueGraphNode_Base>(GraphNode.Get()))
225 ? FReply::Handled() : FReply::Unhandled();
226 }
227
228 return FReply::Unhandled();
229}
230
231
233// FDialogueBrowserTreeEdgeNode
235 const FText& InDisplayText,
236 const TSharedPtr<FDialogueBrowserTreeNode>& InParent,
237 const TWeakObjectPtr<const UDialogueGraphNode_Edge>& InObject
238) : Super(InDisplayText, InParent), EdgeNode(InObject)
239{
240}
241
243{
244 if (EdgeNode.IsValid())
245 {
246 return FDialogueEditorUtilities::OpenEditorAndJumpToGraphNode(Cast<UDialogueGraphNode_Base>(EdgeNode.Get()))
247 ? FReply::Handled() : FReply::Unhandled();
248 }
249
250 return FReply::Unhandled();
251}
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)
FDialogueBrowserTreeDialogueNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, const TWeakObjectPtr< const UDlgDialogue > &InObject)
TWeakObjectPtr< const UDlgDialogue > Dialogue
TWeakObjectPtr< const UDialogueGraphNode_Edge > EdgeNode
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)
TWeakObjectPtr< const UDialogueGraphNode > GraphNode
virtual UClass * GetParentClass() const
virtual FName GetParentParticipantName() const
EDialogueTreeNodeCategoryType CategoryType
FDialogueBrowserTreeNode(const FText &InDisplayText, const TSharedPtr< Self > &InParent)
virtual FName GetParentVariableName() const
FDialogueBrowserTreeParticipantNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, FName InParticipantName)
FDialogueBrowserTreeSeparatorNode(const TSharedPtr< FDialogueBrowserTreeNode > &InParent=nullptr)
FDialogueBrowserTreeVariableNode(const FText &InDisplayText, const TSharedPtr< FDialogueBrowserTreeNode > &InParent, FName InVariableName)
static bool OpenEditorAndJumpToGraphNode(const UEdGraphNode *GraphNode, bool bFocusIfOpen=false)
static bool OpenEditorForAsset(const UObject *Asset)
TArray< TSharedPtr< FDialogueBrowserTreeNode > > Children
TWeakPtr< FDialogueBrowserTreeNode > Parent