A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueSearchUtilities.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
6#include "DlgEvent.h"
7#include "DlgCondition.h"
8#include "DlgTextArgument.h"
9
11// FDialogueESearchUtilities
12
13class UDlgDialogue;
15struct FDlgNode;
16class UEdGraph;
19
20// Represents the found result of the search functions.
22{
23private:
25
26public:
27 static TSharedPtr<FDialogueSearchFoundResult> Make() { return MakeShared<Self>(); }
28
29public:
30 // Nodes that satisfy the search result.
31 TArray<TWeakObjectPtr<const UDialogueGraphNode>> GraphNodes;
32
33 // Edges that satisfy the search result.
34 TArray<TWeakObjectPtr<const UDialogueGraphNode_Edge>> EdgeNodes;
35};
36
42{
43public:
44
45 // Gets all the graph nodes that contain the specified EventName (of the EventType Event)
46 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForEventEventName(FName EventName, const UDlgDialogue* Dialogue);
47
48 // Gets all the graph nodes that contain the custom Event EventClass
49 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForCustomEvent(const UClass* EventClass, const UDlgDialogue* Dialogue);
50
51
56 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForConditionEventCallName(FName ConditionName, const UDlgDialogue* Dialogue);
57
62 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForIntVariableName(FName IntVariableName, const UDlgDialogue* Dialogue)
63 {
64 TSharedPtr<FDialogueSearchFoundResult> FoundResult = GetGraphNodesForVariablesOfNameAndType(
65 IntVariableName,
69 );
71 return FoundResult;
72 }
73
78 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForFloatVariableName(FName FloatVariableName, const UDlgDialogue* Dialogue)
79 {
80 TSharedPtr<FDialogueSearchFoundResult> FoundResult = GetGraphNodesForVariablesOfNameAndType(
81 FloatVariableName,
85 );
87 return FoundResult;
88 }
89
94 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForBoolVariableName(FName BoolVariableName, const UDlgDialogue* Dialogue)
95 {
97 BoolVariableName,
101 );
102 }
103
108 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForFNameVariableName(FName FNameVariableName, const UDlgDialogue* Dialogue)
109 {
111 FNameVariableName,
112 Dialogue,
115 );
116 }
117
122 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForClassIntVariableName(FName IntVariableName, const UDlgDialogue* Dialogue)
123 {
124 TSharedPtr<FDialogueSearchFoundResult> FoundResult = GetGraphNodesForVariablesOfNameAndType(
125 IntVariableName,
126 Dialogue,
129 );
131 return FoundResult;
132 }
133
138 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForClassFloatVariableName(FName FloatVariableName, const UDlgDialogue* Dialogue)
139 {
140
141 TSharedPtr<FDialogueSearchFoundResult> FoundResult = GetGraphNodesForVariablesOfNameAndType(
142 FloatVariableName,
143 Dialogue,
146 );
148 return FoundResult;
149 }
150
155 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForClassBoolVariableName(FName BoolVariableName, const UDlgDialogue* Dialogue)
156 {
158 BoolVariableName,
159 Dialogue,
162 );
163 }
164
169 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForClassFNameVariableName(FName FNameVariableName, const UDlgDialogue* Dialogue)
170 {
172 FNameVariableName,
173 Dialogue,
176 );
177 }
178
183 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForClassFTextVariableName(FName FTextVariableName, const UDlgDialogue* Dialogue)
184 {
185 TSharedPtr<FDialogueSearchFoundResult> FoundResult = FDialogueSearchFoundResult::Make();
187 return FoundResult;
188 }
189
190 // Does Conditions contain the ConditionName (of type ConditionType)?
192 FName ConditionName,
193 EDlgConditionType ConditionType,
194 const TArray<FDlgCondition>& Conditions
195 )
196 {
197 for (const FDlgCondition& Condition : Conditions)
198 {
199 // Matches the First participant
200 if (Condition.CallbackName == ConditionName && Condition.ConditionType == ConditionType)
201 {
202 return true;
203 }
204
205 // Matches the second Participant
206 if (Condition.CompareType != EDlgCompare::ToConst && Condition.OtherVariableName == ConditionName)
207 {
208 if (FDlgCondition::IsSameValueType(ConditionType, Condition.ConditionType))
209 {
210 return true;
211 }
212 }
213 }
214 return false;
215 }
216
217 // Does Events contain the EventName (of type EventType)?
218 static bool IsEventInArray(FName EventName, EDlgEventType EventType, const TArray<FDlgEvent>& Events)
219 {
220 for (const FDlgEvent& Event : Events)
221 {
222 if (Event.EventType == EventType && Event.EventName == EventName)
223 {
224 return true;
225 }
226 }
227 return false;
228 }
229
230 // Does the Events contain a Custom Event of Class EventClass
231 static bool IsCustomEventInArray(const UClass* EventClass, const TArray<FDlgEvent>& Events)
232 {
233 for (const FDlgEvent& Event : Events)
234 {
235 if (Event.EventType == EDlgEventType::Custom && Event.CustomEvent && Event.CustomEvent->GetClass() == EventClass)
236 {
237 return true;
238 }
239 }
240 return false;
241 }
242
243 // Does Events contain the EventName (of type EventType)?
244 static bool IsTextArgumentInArray(FName TextArgumentName, EDlgTextArgumentType TextArgumentType, const TArray<FDlgTextArgument>& TextArguments)
245 {
246 for (const FDlgTextArgument& TextArgument : TextArguments)
247 {
248 if (TextArgument.Type == TextArgumentType && TextArgument.VariableName == TextArgumentName)
249 {
250 return true;
251 }
252 }
253 return false;
254 }
255
256 // Does the SearchString exist in the GUID? We test every possible format
257 // In case of success we return the GUID as a string in OutStringGUID
258 static bool DoesGUIDContainString(const FGuid& GUID, const FString& SearchString, FString& OutGUIDString);
259
260 // Does the SearchString exist in the GUID Class name?
261 // In case of success we return the GUID as a string in OutNameString
262 static bool DoesObjectClassNameContainString(const UObject* Object, const FString& SearchString, FString& OutNameString);
263
264private:
265 static TSharedPtr<FDialogueSearchFoundResult> GetGraphNodesForVariablesOfNameAndType(
266 FName VariableName,
267 const UDlgDialogue* Dialogue,
268 EDlgEventType EventType,
269 EDlgConditionType ConditionType
270 );
271
273 FName VariableName,
274 const UDlgDialogue* Dialogue,
275 EDlgTextArgumentType ArgumentType,
276 TSharedPtr<FDialogueSearchFoundResult>& FoundResult
277 );
278};
EDlgConditionType
UENUM(BlueprintType)
EDlgEventType
UENUM(BlueprintType)
Definition DlgEvent.h:16
@ ModifyClassFloatVariable
EDlgTextArgumentType
UENUM(BlueprintType)
The FDialogueSearchUtilities class.
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForClassFloatVariableName(FName FloatVariableName, const UDlgDialogue *Dialogue)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForClassFNameVariableName(FName FNameVariableName, const UDlgDialogue *Dialogue)
static bool IsCustomEventInArray(const UClass *EventClass, const TArray< FDlgEvent > &Events)
static bool DoesGUIDContainString(const FGuid &GUID, const FString &SearchString, FString &OutGUIDString)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForCustomEvent(const UClass *EventClass, const UDlgDialogue *Dialogue)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForEventEventName(FName EventName, const UDlgDialogue *Dialogue)
static bool DoesObjectClassNameContainString(const UObject *Object, const FString &SearchString, FString &OutNameString)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForConditionEventCallName(FName ConditionName, const UDlgDialogue *Dialogue)
static bool IsConditionInArray(FName ConditionName, EDlgConditionType ConditionType, const TArray< FDlgCondition > &Conditions)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForFNameVariableName(FName FNameVariableName, const UDlgDialogue *Dialogue)
static bool IsEventInArray(FName EventName, EDlgEventType EventType, const TArray< FDlgEvent > &Events)
static void GetGraphNodesForTextArgumentVariable(FName VariableName, const UDlgDialogue *Dialogue, EDlgTextArgumentType ArgumentType, TSharedPtr< FDialogueSearchFoundResult > &FoundResult)
static bool IsTextArgumentInArray(FName TextArgumentName, EDlgTextArgumentType TextArgumentType, const TArray< FDlgTextArgument > &TextArguments)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForFloatVariableName(FName FloatVariableName, const UDlgDialogue *Dialogue)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForVariablesOfNameAndType(FName VariableName, const UDlgDialogue *Dialogue, EDlgEventType EventType, EDlgConditionType ConditionType)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForBoolVariableName(FName BoolVariableName, const UDlgDialogue *Dialogue)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForClassIntVariableName(FName IntVariableName, const UDlgDialogue *Dialogue)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForIntVariableName(FName IntVariableName, const UDlgDialogue *Dialogue)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForClassBoolVariableName(FName BoolVariableName, const UDlgDialogue *Dialogue)
static TSharedPtr< FDialogueSearchFoundResult > GetGraphNodesForClassFTextVariableName(FName FTextVariableName, const UDlgDialogue *Dialogue)
UCLASS(BlueprintType, Meta = (DisplayThumbnail = "true"))
Definition DlgDialogue.h:85
static TSharedPtr< FDialogueSearchFoundResult > Make()
TArray< TWeakObjectPtr< const UDialogueGraphNode_Edge > > EdgeNodes
FDialogueSearchFoundResult Self
TArray< TWeakObjectPtr< const UDialogueGraphNode > > GraphNodes
USTRUCT(Blueprintable)
static bool IsSameValueType(EDlgConditionType FirstType, EDlgConditionType SecondType)
USTRUCT(BlueprintType)
Definition DlgEvent.h:59
USTRUCT(BlueprintType)