A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueSearchResult.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
3
4#include "Widgets/Images/SImage.h"
5#include "Toolkits/AssetEditorManager.h"
6
10#include "DialogueStyle.h"
11
12#define LOCTEXT_NAMESPACE "DialogueSearchResult"
13
15// FDialogueSearchResult
16FDialogueSearchResult::FDialogueSearchResult(const FText& InDisplayText, const TSharedPtr<Self>& InParent)
17 : Super(InDisplayText, InParent)
18{
19}
20
21TSharedRef<SWidget> FDialogueSearchResult::CreateIcon() const
22{
23 const FLinearColor IconColor = FLinearColor::White;
24 const FSlateBrush* Brush = nullptr;
25
26 return SNew(SImage)
27 .Image(Brush)
28 .ColorAndOpacity(IconColor)
29 .ToolTipText(GetCategory());
30}
31
32TWeakObjectPtr<const UDlgDialogue> FDialogueSearchResult::GetParentDialogue() const
33{
34 if (Parent.IsValid())
35 {
36 return Parent.Pin()->GetParentDialogue();
37 }
38
39 return nullptr;
40}
41
43// FDialogueSearchResult_RootNode
45 Super(FText::FromString(TEXT("Display Text should not be visible")), nullptr)
46{
47 Category = FText::FromString(TEXT("ROOT NODE SHOULD NOT BE VISIBLE"));
48}
49
50
52// FDialogueSearchResult_DialogueNode
53FDialogueSearchResult_DialogueNode::FDialogueSearchResult_DialogueNode(const FText& InDisplayText, const TSharedPtr<FDialogueSearchResult>& InParent) :
54 Super(InDisplayText, InParent)
55{
56 Category = LOCTEXT("FDialogueSearchResult_DialogueNodeCategory", "Dialogue");
57}
58
60{
61 if (Dialogue.IsValid())
62 {
63 return FDialogueEditorUtilities::OpenEditorForAsset(Dialogue.Get()) ? FReply::Handled() : FReply::Unhandled();
64 }
65
66 return FReply::Unhandled();
67}
68
69TWeakObjectPtr<const UDlgDialogue> FDialogueSearchResult_DialogueNode::GetParentDialogue() const
70{
71 // Get the Dialogue from this.
72 if (Dialogue.IsValid())
73 {
74 return Dialogue;
75 }
76
78}
79
81{
82 const FSlateBrush* Brush = FDialogueStyle::Get()->GetBrush(FDialogueStyle::PROPERTY_DlgDialogueClassIcon);
83
84 return SNew(SImage)
85 .Image(Brush)
86 .ColorAndOpacity(FSlateColor::UseForeground())
87 .ToolTipText(GetCategory());
88}
89
90
92// FDialogueSearchResult_GraphNode
93FDialogueSearchResult_GraphNode::FDialogueSearchResult_GraphNode(const FText& InDisplayText, const TSharedPtr<FDialogueSearchResult>& InParent) :
94 Super(InDisplayText, InParent)
95{
96}
97
99{
100 if (GraphNode.IsValid())
101 {
102 return FDialogueEditorUtilities::OpenEditorAndJumpToGraphNode(GraphNode.Get()) ? FReply::Handled() : FReply::Unhandled();
103 }
104
105 return FReply::Unhandled();
106}
107
109{
110 if (GraphNode.IsValid())
111 {
112 FLinearColor Color;
113 const FSlateIcon Icon = GraphNode.Get()->GetIconAndTint(Color);
114 return SNew(SImage)
115 .Image(Icon.GetOptionalIcon())
116 .ColorAndOpacity(Color)
117 .ToolTipText(GetCategory());
118 }
119
120 return Super::CreateIcon();
121}
122
123
125// FDialogueSearchResult_EdgeNode
126FDialogueSearchResult_EdgeNode::FDialogueSearchResult_EdgeNode(const FText& InDisplayText, const TSharedPtr<FDialogueSearchResult>& InParent) :
127 Super(InDisplayText, InParent)
128{
129}
130
132{
133 if (EdgeNode.IsValid())
134 {
135 return FDialogueEditorUtilities::OpenEditorAndJumpToGraphNode(EdgeNode.Get()) ? FReply::Handled() : FReply::Unhandled();
136 }
137
138 return FReply::Unhandled();
139}
140
142{
143 if (EdgeNode.IsValid())
144 {
145 FLinearColor Color;
146 const FSlateIcon Icon = EdgeNode.Get()->GetIconAndTint(Color);
147 return SNew(SImage)
148 .Image(Icon.GetOptionalIcon())
149 .ColorAndOpacity(Color)
150 .ToolTipText(GetCategory());
151 }
152
153 return Super::CreateIcon();
154}
155
157// FDialogueSearchResult_CommentNode
158FDialogueSearchResult_CommentNode::FDialogueSearchResult_CommentNode(const FText& InDisplayText, const TSharedPtr<FDialogueSearchResult>& InParent) :
159 Super(InDisplayText, InParent)
160{
161}
162
164{
165 if (CommentNode.IsValid())
166 {
167 return FDialogueEditorUtilities::OpenEditorAndJumpToGraphNode(CommentNode.Get()) ? FReply::Handled() : FReply::Unhandled();
168 }
169
170 return FReply::Unhandled();
171}
172
174{
175 if (CommentNode.IsValid())
176 {
178 return SNew(SImage)
179 .Image(Icon.GetIcon())
180 .ColorAndOpacity(FColorList::White)
181 .ToolTipText(GetCategory());
182 }
183
184 return Super::CreateIcon();
185}
186
187#undef LOCTEXT_NAMESPACE
static bool OpenEditorAndJumpToGraphNode(const UEdGraphNode *GraphNode, bool bFocusIfOpen=false)
static bool OpenEditorForAsset(const UObject *Asset)
FDialogueSearchResult_CommentNode(const FText &InDisplayText, const TSharedPtr< FDialogueSearchResult > &InParent)
TSharedRef< SWidget > CreateIcon() const override
TWeakObjectPtr< const UEdGraphNode_Comment > CommentNode
TSharedRef< SWidget > CreateIcon() const override
FDialogueSearchResult_DialogueNode(const FText &InDisplayText, const TSharedPtr< FDialogueSearchResult > &InParent)
TWeakObjectPtr< const UDlgDialogue > GetParentDialogue() const override
TWeakObjectPtr< const UDlgDialogue > Dialogue
TWeakObjectPtr< const UDialogueGraphNode_Edge > EdgeNode
TSharedRef< SWidget > CreateIcon() const override
FDialogueSearchResult_EdgeNode(const FText &InDisplayText, const TSharedPtr< FDialogueSearchResult > &InParent)
FDialogueSearchResult_GraphNode(const FText &InDisplayText, const TSharedPtr< FDialogueSearchResult > &InParent)
TWeakObjectPtr< const UDialogueGraphNode > GraphNode
TSharedRef< SWidget > CreateIcon() const override
virtual TSharedRef< SWidget > CreateIcon() const
virtual TWeakObjectPtr< const UDlgDialogue > GetParentDialogue() const
FDialogueSearchResult(const FText &InDisplayText, const TSharedPtr< Self > &InParent)
static const FName PROPERTY_CommentBubbleOn
static TSharedPtr< ISlateStyle > Get()
static FName GetStyleSetName()
static const FName PROPERTY_DlgDialogueClassIcon
TWeakPtr< FDialogueSearchResult > Parent