A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DlgNode_SpeechSequence.h
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#pragma once
3
4#include "Nodes/DlgNode.h"
5#include "DlgSystemSettings.h"
6#include "DlgNode_SpeechSequence.generated.h"
7
8class USoundWave;
9class USoundBase;
10class UDialogueWave;
11
12USTRUCT(BlueprintType)
13struct DLGSYSTEM_API FDlgSpeechSequenceEntry
14{
15 GENERATED_USTRUCT_BODY()
16 // NOTE: don't create a default constructor here, because otherwise if will fail because some CDO BS after you convert nodes to speech sequence
17
18public:
19 // The Participant Name (speaker) associated with this speech entry.
20 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node", Meta = (DisplayName = "Participant Name"))
21 FName Speaker;
22
23 // Text that will appear when this node participant name speaks to someone else.
24 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node", Meta = (MultiLine = true))
25 FText Text;
26
27 // Text that will appear when you want to continue down this edge to the next conversation. Usually "Next".
28 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node", Meta = (MultiLine = true))
29 FText EdgeText;
30
31 // State of the speaker attached to the entry. Passed to the GetParticipantIcon function.
32 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node")
33 FName SpeakerState;
34
35 // Node data that you can customize yourself with your own data types
36 UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced, Category = "Dialogue|Node")
37 UDlgNodeData* NodeData = nullptr;
38
39 // Voice attached to this node. The Sound Wave variant.
40 // NOTE: You should probably use the NodeData
41 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node", Meta = (DlgSaveOnlyReference))
42 USoundBase* VoiceSoundWave = nullptr;
43
44 // Voice attached to this node. The Dialogue Wave variant. Only the first wave from the dialogue context array should be used.
45 // NOTE: You should probably use the NodeData
46 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node", Meta = (DlgSaveOnlyReference))
47 UDialogueWave* VoiceDialogueWave = nullptr;
48
49 // Any generic object you would like
50 // NOTE: You should probably use the NodeData
51 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node", Meta = (DlgSaveOnlyReference))
52 UObject* GenericData = nullptr;
53};
54
55
60UCLASS(BlueprintType, ClassGroup = "Dialogue")
61class DLGSYSTEM_API UDlgNode_SpeechSequence : public UDlgNode
62{
63 GENERATED_BODY()
64
65public:
66 // Begin UObject Interface.
68 FString GetDesc() override
69 {
70 return TEXT("Sequence of speeches - each can have a different speaker independently from the node owner.\nThe node stays active and proceeds one step in the SpeechSequence (internal) array until everyone said everything.");
71 }
72#if WITH_EDITOR
73 void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
74#endif
75
76 // Begin UDlgNode interface
77 void UpdateTextsValuesFromDefaultsAndRemappings(const UDlgSystemSettings& Settings, bool bEdges, bool bUpdateGraphNode = true) override;
78 void UpdateTextsNamespacesAndKeys(const UDlgSystemSettings& Settings, bool bEdges, bool bUpdateGraphNode = true) override;
79 bool HandleNodeEnter(UDlgContext& Context, TSet<const UDlgNode*> NodesEnteredWithThisStep) override;
80 bool ReevaluateChildren(UDlgContext& Context, TSet<const UDlgNode*> AlreadyEvaluated) override;
81 bool OptionSelected(int32 OptionIndex, UDlgContext& Context) override;
82
83 // Getters
84 const FText& GetNodeText() const override;
85 UDlgNodeData* GetNodeData() const override;
86 USoundBase* GetNodeVoiceSoundBase() const override;
87 UDialogueWave* GetNodeVoiceDialogueWave() const override;
88 FName GetSpeakerState() const override;
89 void AddAllSpeakerStatesIntoSet(TSet<FName>& OutStates) const override;
90 UObject* GetNodeGenericData() const override;
91 FName GetNodeParticipantName() const override;
92 void GetAssociatedParticipants(TArray<FName>& OutArray) const override;
93
94#if WITH_EDITOR
95 FString GetNodeTypeString() const override { return TEXT("Speech Sequence"); }
96#endif
97
98 //
99 // Begin own functions
100 //
101
102 // Useful for multiplayer when you replicate the GetSpeechSequenceIndex
103 // This is different from OptionSelected because this just sets the ActualIndex = OptionIndex instead of incremeting
104 // the Actual Index
105 // TODO: Proper replicate ActualIndex instead of this hack and all the subnodes
106 bool OptionSelectedFromReplicated(int32 OptionIndex, UDlgContext& Context);
107 int32 GetSpeechSequenceIndex() const { return ActualIndex; }
108
109 // Fills the inner edges from the corresponding input data (SpeechSequence)
110 void AutoGenerateInnerEdges();
111
112 // Gets the SpeechSequence as a const array
113 UFUNCTION(BlueprintPure, Category = "Dialogue|Node")
114 const TArray<FDlgSpeechSequenceEntry>& GetNodeSpeechSequence() const { return SpeechSequence; }
115
116 // Gets the SpeechSequence as a mutable array
117 TArray<FDlgSpeechSequenceEntry>* GetMutableNodeSpeechSequence() { return &SpeechSequence; }
118
119 // Tells us if the speech sequence has any speeches (aka not empty)
120 UFUNCTION(BlueprintPure, Category = "Dialogue|Node")
121 bool HasSpeechSequences() const { return SpeechSequence.Num() > 0; }
122
123 // Helper functions to get the names of some properties. Used by the DlgSystemEditor module.
124 static FName GetMemberNameSpeechSequence() { return GET_MEMBER_NAME_CHECKED(UDlgNode_SpeechSequence, SpeechSequence); }
125
126protected:
127 // Array of important stuff to say
128 UPROPERTY(EditAnywhere, Category = "Dialogue|Node")
129 TArray<FDlgSpeechSequenceEntry> SpeechSequence;
130
131 // Inner edge, filled automatically based on SpeechSequence
132 UPROPERTY()
133 TArray<FDlgEdge> InnerEdges;
134
135 // The current active index in the SpeechSequence array
136 int32 ActualIndex = INDEX_NONE;
137};
UCLASS(BlueprintType)
Definition DlgContext.h:96
UCLASS(BlueprintType, ClassGroup = "Dialogue")
TArray< FDlgSpeechSequenceEntry > * GetMutableNodeSpeechSequence()
const TArray< FDlgSpeechSequenceEntry > & GetNodeSpeechSequence() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Node")
bool HasSpeechSequences() const
UFUNCTION(BlueprintPure, Category = "Dialogue|Node")
TArray< FDlgEdge > InnerEdges
UPROPERTY()
TArray< FDlgSpeechSequenceEntry > SpeechSequence
UPROPERTY(EditAnywhere, Category = "Dialogue|Node")
UCLASS(Blueprintable, BlueprintType, Abstract, EditInlineNew)
Definition DlgNodeData.h:18
UCLASS(BlueprintType, Abstract, EditInlineNew, ClassGroup = "Dialogue")
Definition DlgNode.h:40
UCLASS(Config = Engine, DefaultConfig, meta = (DisplayName = "Dialogue System Settings"))
USTRUCT(BlueprintType)
Definition DlgEdge.h:25
USTRUCT(BlueprintType)
FText Text
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node", Meta = (MultiLine = true))
FName Speaker
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node", Meta = (DisplayName = "Partic...
GENERATED_USTRUCT_BODY()
FName SpeakerState
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node")
FText EdgeText
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Node", Meta = (MultiLine = true))