4#include "Templates/SubclassOf.h"
10#include "DlgDialogue.generated.h"
20 BeforeCustomVersionWasAdded = 0,
35 LatestVersion = VersionPlusOne - 1
50 GENERATED_USTRUCT_BODY()
55 FName ParticipantName = NAME_None;
59 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Dialogue|
Participant", meta = (MustImplement = "DlgDialogueParticipant"))
60 UClass* ParticipantClass =
nullptr;
69UCLASS(BlueprintType, Meta = (DisplayThumbnail = "true"))
80 FString GetDesc()
override {
return TEXT(
" DESCRIPTION = ") + GetName(); }
88 void PreSave(
const class ITargetPlatform* TargetPlatform)
override;
91 void Serialize(FArchive& Ar)
override;
97 void PostLoad()
override;
104 void PostInitProperties()
override;
107 void PostRename(
UObject* OldOuter, FName OldName)
override;
113 void PostDuplicate(
bool bDuplicateForPIE)
override;
120 void PostEditImport()
override;
132 bool Modify(
bool bAlwaysMarkDirty =
true)
override;
139 void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
override;
145 void PostEditChangeChainProperty(
struct FPropertyChangedChainEvent& PropertyChangedEvent)
override;
154 static void AddReferencedObjects(
UObject* InThis, FReferenceCollector& Collector);
162 DECLARE_EVENT_OneParam(
UDlgDialogue, FDialoguePropertyChanged,
const FPropertyChangedEvent& );
163 FDialoguePropertyChanged OnDialoguePropertyChanged;
166 static FName GetMemberNameName() {
return GET_MEMBER_NAME_CHECKED(
UDlgDialogue,
Name); }
167 static FName GetMemberNameGUID() {
return GET_MEMBER_NAME_CHECKED(
UDlgDialogue, GUID); }
168 static FName GetMemberNameParticipantsData() {
return GET_MEMBER_NAME_CHECKED(
UDlgDialogue, ParticipantsData); }
169 static FName GetMemberNameStartNode() {
return GET_MEMBER_NAME_CHECKED(
UDlgDialogue, StartNode); }
170 static FName GetMemberNameNodes() {
return GET_MEMBER_NAME_CHECKED(
UDlgDialogue, Nodes); }
191 void InitialCompileDialogueNodesFromGraphNodes()
193 if (bWasCompiledAtLeastOnce)
196 CompileDialogueNodesFromGraphNodes();
197 bWasCompiledAtLeastOnce =
true;
201 void CompileDialogueNodesFromGraphNodes();
204 static void SetDialogueEditorAccess(
const TSharedPtr<IDlgDialogueEditorAccess>& InDialogueEditor)
206 check(!DialogueEditorAccess.IsValid());
207 check(InDialogueEditor.IsValid());
208 DialogueEditorAccess = InDialogueEditor;
212 static TSharedPtr<IDlgDialogueEditorAccess> GetDialogueEditorAccess() {
return DialogueEditorAccess; }
215 void EnableCompileDialogue() { bCompileDialogue =
true; }
216 void DisableCompileDialogue() { bCompileDialogue =
false; }
221 T* ConstructDialogueNode(TSubclassOf<UDlgNode> DialogueNodeClass = T::StaticClass())
224 T* DialogueNode = NewObject<T>(
this, DialogueNodeClass, NAME_None, RF_Transactional);
233 UFUNCTION(BlueprintPure, Category =
"Dialogue")
234 const TMap<FName, FDlgParticipantData>& GetParticipantsData()
const {
return ParticipantsData; }
237 UFUNCTION(BlueprintPure, Category =
"Dialogue")
238 bool HasParticipant(FName ParticipantName)
const {
return ParticipantsData.Contains(ParticipantName); }
241 UFUNCTION(BlueprintPure, Category =
"Dialogue")
242 int32 GetParticipantsNum()
const {
return ParticipantsData.Num(); }
245 UFUNCTION(BlueprintPure, Category =
"Dialogue")
246 void GetAllParticipantNames(TSet<FName>& OutSet)
const
248 for (
const auto& Element : ParticipantsData)
251 OutSet.Add(Element.Key);
255 UFUNCTION(BlueprintPure, Category =
"Dialogue")
256 const TArray<
FDlgParticipantClass>& GetAllParticipantClasses()
const {
return ParticipantsClasses; }
259 UFUNCTION(BlueprintPure, Category =
"Dialogue")
260 UClass* GetParticipantClass(FName ParticipantName)
const
264 if (Pair.ParticipantName == ParticipantName)
274 UFUNCTION(BlueprintPure, Category =
"Dialogue")
275 void GetConditions(FName ParticipantName, TSet<FName>& OutSet)
const
277 if (ParticipantsData.Contains(ParticipantName))
279 OutSet.Append(ParticipantsData[ParticipantName].Conditions);
284 UFUNCTION(BlueprintPure, Category =
"Dialogue")
285 void GetEvents(FName ParticipantName, TSet<FName>& OutSet)
const
287 if (ParticipantsData.Contains(ParticipantName))
289 OutSet.Append(ParticipantsData[ParticipantName].Events);
294 UFUNCTION(BlueprintPure, Category =
"Dialogue")
295 void GetCustomEvents(FName ParticipantName, TSet<UClass*>& OutSet)
const
297 if (ParticipantsData.Contains(ParticipantName))
299 OutSet.Append(ParticipantsData[ParticipantName].CustomEvents);
304 UFUNCTION(BlueprintPure, Category =
"Dialogue")
305 void GetIntNames(FName ParticipantName, TSet<FName>& OutSet)
const
307 if (ParticipantsData.Contains(ParticipantName))
309 OutSet.Append(ParticipantsData[ParticipantName].IntVariableNames);
314 UFUNCTION(BlueprintPure, Category =
"Dialogue")
315 void GetFloatNames(FName ParticipantName, TSet<FName>& OutSet)
const
317 if (ParticipantsData.Contains(ParticipantName))
319 OutSet.Append(ParticipantsData[ParticipantName].FloatVariableNames);
324 UFUNCTION(BlueprintPure, Category =
"Dialogue")
325 void GetBoolNames(FName ParticipantName, TSet<FName>& OutSet)
const
327 if (ParticipantsData.Contains(ParticipantName))
329 OutSet.Append(ParticipantsData[ParticipantName].BoolVariableNames);
334 UFUNCTION(BlueprintPure, Category =
"Dialogue")
335 void GetNameNames(FName ParticipantName, TSet<FName>& OutSet)
const
337 if (ParticipantsData.Contains(ParticipantName))
339 OutSet.Append(ParticipantsData[ParticipantName].NameVariableNames);
345 UFUNCTION(BlueprintPure, Category =
"Dialogue")
346 void GetClassIntNames(FName ParticipantName, TSet<FName>& OutSet)
const
348 if (ParticipantsData.Contains(ParticipantName))
350 OutSet.Append(ParticipantsData[ParticipantName].ClassIntVariableNames);
355 UFUNCTION(BlueprintPure, Category =
"Dialogue")
356 void GetClassFloatNames(FName ParticipantName, TSet<FName>& OutSet)
const
358 if (ParticipantsData.Contains(ParticipantName))
360 OutSet.Append(ParticipantsData[ParticipantName].ClassFloatVariableNames);
365 UFUNCTION(BlueprintPure, Category =
"Dialogue")
366 void GetClassBoolNames(FName ParticipantName, TSet<FName>& OutSet)
const
368 if (ParticipantsData.Contains(ParticipantName))
370 OutSet.Append(ParticipantsData[ParticipantName].ClassBoolVariableNames);
375 UFUNCTION(BlueprintPure, Category =
"Dialogue")
376 void GetClassNameNames(FName ParticipantName, TSet<FName>& OutSet)
const
378 if (ParticipantsData.Contains(ParticipantName))
380 OutSet.Append(ParticipantsData[ParticipantName].ClassNameVariableNames);
385 UFUNCTION(BlueprintPure, Category =
"Dialogue")
386 void GetClassTextNames(FName ParticipantName, TSet<FName>& OutSet)
const
388 if (ParticipantsData.Contains(ParticipantName))
390 OutSet.Append(ParticipantsData[ParticipantName].ClassTextVariableNames);
395 UFUNCTION(BlueprintPure, Category =
"Dialogue")
396 void GetAllSpeakerStates(TSet<FName>& OutSet)
const
398 OutSet.Append(AllSpeakerStates);
401 UFUNCTION(BlueprintPure, Category =
"Dialogue")
402 int32 GetDialogueVersion()
const {
return Version; }
405 UFUNCTION(BlueprintPure, Category =
"Dialogue")
406 FString GetDialogueName()
const
415 UFUNCTION(BlueprintPure, Category =
"Dialogue")
416 FName GetDialogueFName()
const {
return GetFName(); }
419 UFUNCTION(BlueprintPure, Category =
"Dialogue|GUID")
420 FGuid GetGUID()
const { check(GUID.IsValid());
return GUID; }
423 void RegenerateGUID() { GUID = FGuid::NewGuid(); }
425 UFUNCTION(BlueprintPure, Category =
"Dialogue|GUID")
426 bool HasGUID()
const {
return GUID.IsValid(); }
429 UFUNCTION(BlueprintPure, Category =
"Dialogue")
430 const TArray<
UDlgNode*>& GetNodes()
const {
return Nodes; }
433 UFUNCTION(BlueprintPure, Category =
"Dialogue",
DisplayName =
"Get Start Node")
434 UDlgNode* GetMutableStartNode()
const {
return StartNode; }
435 const UDlgNode& GetStartNode()
const {
return *StartNode; }
437 UFUNCTION(BlueprintPure, Category =
"Dialogue")
438 bool IsValidNodeIndex(int32 NodeIndex)
const {
return Nodes.IsValidIndex(NodeIndex); }
440 UFUNCTION(BlueprintPure, Category =
"Dialogue")
441 bool IsValidNodeGUID(const FGuid& NodeGUID)
const {
return IsValidNodeIndex(GetNodeIndexForGUID(NodeGUID)); }
444 UFUNCTION(BlueprintPure, Category =
"Dialogue",
DisplayName =
"Get Node GUID For Index")
445 FGuid GetNodeGUIDForIndex(int32 NodeIndex) const;
450 int32 GetNodeIndexForGUID(const FGuid& NodeGUID) const;
454 UDlgNode* GetMutableNodeFromIndex(int32 NodeIndex)
const {
return Nodes.IsValidIndex(NodeIndex) ? Nodes[NodeIndex] :
nullptr; }
456 UFUNCTION(BlueprintPure, Category =
"Dialogue|Data",
DisplayName =
"Get Node From GUID")
457 UDlgNode* GetMutableNodeFromGUID(const FGuid& NodeGUID)
const {
return GetMutableNodeFromIndex(GetNodeIndexForGUID(NodeGUID)); }
460 void SetStartNode(
UDlgNode* InStartNode);
466 void EmptyNodesGUIDToIndexMap() { NodesGUIDToIndexMap.Empty(); }
469 void SetNodes(
const TArray<UDlgNode*>& InNodes);
472 void SetNode(int32 NodeIndex,
UDlgNode* InNode);
475 bool IsEndNode(int32 NodeIndex)
const;
478 void ImportFromFile();
481 void OnPreAssetSaved();
484 void InitialSyncWithTextFile()
486 if (bIsSyncedWithTextFile)
492 bIsSyncedWithTextFile =
true;
496 void ExportToFile()
const;
501 void UpdateAndRefreshData(
bool bUpdateTextsNamespacesAndKeys =
false);
504 int32 AddNode(
UDlgNode* NodeToAdd) {
return Nodes.Add(NodeToAdd); }
510 FString GetTextFilePathName(
bool bAddExtension =
true)
const;
515 bool DeleteTextFileForExtension(
const FString& FileExtension)
const;
516 bool DeleteAllTextFiles()
const;
519 bool IsInProjectDirectory()
const;
525 static FString GetTextFilePathNameFromAssetPathName(
const FString& AssetPathName);
529 void AddConditionsDataFromNodeEdges(
const UDlgNode* Node, int32 NodeIndex);
532 FDlgParticipantData& GetParticipantDataEntry(FName ParticipantName, FName FallbackParticipantName,
bool bCheckNone,
const FString& ContextMessage);
549 void UpdateGUIDToIndexMap(
const UDlgNode* Node, int32 NodeIndex);
557 UPROPERTY(VisibleAnywhere, Category = "
Dialogue")
565 UPROPERTY(EditAnywhere, EditFixedSize, Category = "
Dialogue")
569 UPROPERTY(VisibleAnywhere, AdvancedDisplay, Category = "
Dialogue", Meta = (DlgNoExport))
573 UPROPERTY(VisibleAnywhere, AdvancedDisplay, Category = "
Dialogue", Meta = (DlgNoExport))
574 TSet<FName> AllSpeakerStates;
584 UPROPERTY(AdvancedDisplay, EditFixedSize, Instanced, Meta = (DlgWriteIndex))
588 UPROPERTY(VisibleAnywhere, AdvancedDisplay, Category = "
Dialogue",
DisplayName = "Nodes GUID To Index Map")
589 TMap<FGuid, int32> NodesGUIDToIndexMap;
592 bool bIsSyncedWithTextFile = false;
594#if WITH_EDITORONLY_DATA
596 UPROPERTY(Meta = (DlgNoExport))
600 static TSharedPtr<IDlgDialogueEditorAccess> DialogueEditorAccess;
603 bool bCompileDialogue =
true;
606 bool bWasCompiledAtLeastOnce =
false;
609 int32 BroadcastPropertyNodeIndexChanged = INDEX_NONE;
613 bool bWasLoaded =
false;
EDlgDialogueTextFormat
UENUM()
UCLASS(BlueprintType, Meta = (DisplayThumbnail = "true"))
TSet< FName > AllSpeakerStates
UPROPERTY(VisibleAnywhere, AdvancedDisplay, Category = "Dialogue", Meta = (DlgNoExport))
TMap< FName, FDlgParticipantData > ParticipantsData
UPROPERTY(VisibleAnywhere, AdvancedDisplay, Category = "Dialogue", Meta = (DlgNoExport))
void GetClassFloatNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
const TMap< FName, FDlgParticipantData > & GetParticipantsData() const
UFUNCTION(BlueprintPure, Category = "Dialogue")
UDlgNode * GetMutableNodeFromGUID(const FGuid &NodeGUID) const
UFUNCTION(BlueprintPure, Category = "Dialogue|Data", DisplayName = "Get Node From GUID")
bool IsValidNodeIndex(int32 NodeIndex) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
const TArray< FDlgParticipantClass > & GetAllParticipantClasses() const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetAllParticipantNames(TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
const TArray< UDlgNode * > & GetNodes() const
UFUNCTION(BlueprintPure, Category = "Dialogue")
UDlgNode * StartNode
UPROPERTY(Instanced)
void GetClassTextNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetClassBoolNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
UClass * GetParticipantClass(FName ParticipantName) const
EDITOR function, it only works if the participant class is setup in the ParticipantsClasses array.
const UDlgNode & GetStartNode() const
void GetClassIntNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetEvents(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
FGuid GUID
UPROPERTY(VisibleAnywhere, Category = "Dialogue")
void GetBoolNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
bool HasGUID() const
UFUNCTION(BlueprintPure, Category = "Dialogue|GUID")
bool HasParticipant(FName ParticipantName) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetClassNameNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetNameNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
FGuid GetGUID() const
UFUNCTION(BlueprintPure, Category = "Dialogue|GUID")
T * ConstructDialogueNode(TSubclassOf< UDlgNode > DialogueNodeClass=T::StaticClass())
UDlgNode * GetMutableStartNode() const
UFUNCTION(BlueprintPure, Category = "Dialogue", DisplayName = "Get Start Node")
int32 GetParticipantsNum() const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetCustomEvents(FName ParticipantName, TSet< UClass * > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
bool IsValidNodeGUID(const FGuid &NodeGUID) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
TMap< FGuid, int32 > NodesGUIDToIndexMap
UPROPERTY(VisibleAnywhere, AdvancedDisplay, Category = "Dialogue", DisplayName = "Nodes GUID To Index...
void InitialSyncWithTextFile()
FString GetDialogueName() const
UFUNCTION(BlueprintPure, Category = "Dialogue")
UDlgNode * GetMutableNodeFromIndex(int32 NodeIndex) const
UFUNCTION(BlueprintPure, Category = "Dialogue", DisplayName = "Get Node From Index")
FString GetDesc() override
FName Name
UPROPERTY(VisibleAnywhere, Category = "Dialogue")
void GetConditions(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
void GetFloatNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
TArray< FDlgParticipantClass > ParticipantsClasses
UPROPERTY(EditAnywhere, EditFixedSize, Category = "Dialogue")
void GetIntNames(FName ParticipantName, TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
int32 GetDialogueVersion() const
UFUNCTION(BlueprintPure, Category = "Dialogue")
int32 AddNode(UDlgNode *NodeToAdd)
void GetAllSpeakerStates(TSet< FName > &OutSet) const
UFUNCTION(BlueprintPure, Category = "Dialogue")
FName GetDialogueFName() const
UFUNCTION(BlueprintPure, Category = "Dialogue")
TArray< UDlgNode * > Nodes
UPROPERTY(AdvancedDisplay, EditFixedSize, Instanced, Meta = (DlgWriteIndex))
void EmptyNodesGUIDToIndexMap()
UCLASS(BlueprintType, Abstract, EditInlineNew, ClassGroup = "Dialogue")
UCLASS(Config = Engine, DefaultConfig, meta = (DisplayName = "Dialogue System Settings"))
FDlgDialogueObjectVersion()
@ UseOnlyOneOutputAndInputPin
@ AddCustomObjectsToParticipantsData
@ AddComparisonWithOtherParticipant
@ ConvertedNodesToUObject
@ AddLocalizationOverwrittenNamespacesAndKeys
@ ConvertDialogueDataArraysToSets
@ MergeVirtualParentAndSelectorTypes
@ AddVirtualParentFireDirectChildEnterEvents
UClass * ParticipantClass
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Participant", meta = (MustImplement ...