A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueGraphNode_Edge.h
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#pragma once
3
4#include "CoreTypes.h"
5
7#include "DialogueGraphNode.h"
8
9#include "DialogueGraphNode_Edge.generated.h"
10
11
18UCLASS()
20{
21 GENERATED_BODY()
22
23public:
24 // Begin UObject Interface.
30 void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
31
41 bool Modify(bool bAlwaysMarkDirty = true) override;
42
47 bool SuperModify(bool bAlwaysMarkDirty = true) { return Super::Modify(bAlwaysMarkDirty); }
48
49 // UEdGraphNode interface.
51 void AllocateDefaultPins() override;
52
54 FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
55
57 FText GetTooltipText() const override;
58
60 void PinConnectionListChanged(UEdGraphPin* Pin) override;
61
63 void PostPasteNode() override;
64
66 FSlateIcon GetIconAndTint(FLinearColor& OutColor) const override
67 {
68 static const FSlateIcon Icon = FSlateIcon(FEditorStyle::GetStyleSetName(), "Graph.TransitionNode.Icon");
69 OutColor = GetNodeBackgroundColor();
70 return Icon;
71 }
72
73 // Begin UDialogueGraphNode_Base interface
75 FLinearColor GetNodeBackgroundColor() const override { return FColorList::White; }
76
77 // Begin own functions
79 bool HasParentNode() const
80 {
81 if (HasInputPin())
82 {
83 UEdGraphPin* InputPin = GetInputPin();
84 return InputPin->LinkedTo.Num() == 1 && InputPin->LinkedTo[0] != nullptr &&
85 InputPin->LinkedTo[0]->GetOwningNodeUnchecked() != nullptr;
86 }
87
88 return false;
89 }
90
92 bool HasChildNode() const
93 {
94 if (HasOutputPin())
95 {
96 UEdGraphPin* OutputPin = GetOutputPin();
97 return OutputPin->LinkedTo.Num() == 1 && OutputPin->LinkedTo[0] != nullptr &&
98 OutputPin->LinkedTo[0]->GetOwningNodeUnchecked() != nullptr;
99 }
100
101 return false;
102 }
103
105 UDialogueGraphNode* GetParentNode() const
106 {
107 check(HasParentNode());
108 return CastChecked<UDialogueGraphNode>(GetInputPin()->LinkedTo[0]->GetOwningNode());
109 }
110
112 UDialogueGraphNode* GetChildNode() const
113 {
114 check(HasChildNode());
115 return CastChecked<UDialogueGraphNode>(GetOutputPin()->LinkedTo[0]->GetOwningNode());
116 }
117
119 void CreateConnections(UDialogueGraphNode* ParentNode, UDialogueGraphNode* ChildNode);
120
121 // Begin own function
123 const FDlgEdge& GetDialogueEdge() const { return DialogueEdge; }
124 FDlgEdge& GetDialogueEdge() { return DialogueEdge; }
127 void SetDialogueEdge(const FDlgEdge& InEdge) { DialogueEdge = InEdge; }
128
130 void SetDialogueEdgeTargetIndex(int32 InIndex) { DialogueEdge.TargetIndex = InIndex; }
131
133 void SetDialogueEdgeText(const FText& InText)
134 {
135 DialogueEdge.SetText(InText);
136 }
137
139 bool HasConditions() const { return DialogueEdge.Conditions.Num() > 0; }
140
142 FLinearColor GetEdgeColor(bool bIsHovered) const;
143
145 bool IsPrimaryEdge() const { return bIsPrimaryEdge; }
146
148 void SetIsPrimaryEdge(bool bValue) { bIsPrimaryEdge = bValue; }
149
151 bool ShouldDrawEdge() const
152 {
153 // If The parent or the child is hidden, we also hide this edge no matter the settings
154 if (HasInputPin() && HasOutputPin())
155 {
156 if (!GetParentNode()->ShouldDrawNode() || !GetChildNode()->ShouldDrawNode())
157 {
158 return false;
159 }
160 }
161
162 const UDlgSystemSettings* Settings = GetDefault<UDlgSystemSettings>();
163 if (Settings->bShowPrimarySecondaryEdges)
164 {
165 return IsPrimaryEdge() ? Settings->bDrawPrimaryEdges : Settings->bDrawSecondaryEdges;
166 }
167
168 return true;
169 }
170 // End own functions
171
172protected:
173 // Begin UDialogueGraphNode_Base interface
175 void CreateInputPin() override
176 {
177 static const FName PinName(TEXT("Input"));
178 static const FName CategoryName(TEXT("Transition"));
179 FCreatePinParams PinParams;
180 PinParams.Index = INDEX_PIN_Input;
181 CreatePin(EGPD_Input, CategoryName, PinName, PinParams);
182 }
183
185 void CreateOutputPin() override
186 {
187 static const FName PinName(TEXT("Output"));
188 static const FName CategoryName(TEXT("Transition"));
189 FCreatePinParams PinParams;
190 PinParams.Index = INDEX_PIN_Output;
191 CreatePin(EGPD_Output, CategoryName, PinName, PinParams);
192 }
193
194private:
195 // Begin own functions
197 FDlgEdge* GetMutableDialogueEdgeFromParentNode() const;
198
199private:
201 UPROPERTY(EditAnywhere, Category = DialogueGraphNode, Meta = (ShowOnlyInnerProperties))
202 FDlgEdge DialogueEdge;
203
208 UPROPERTY()
209 bool bIsPrimaryEdge = true;
210};
static constexpr int32 INDEX_PIN_Output
UEdGraphPin * GetOutputPin() const
UEdGraphPin * GetInputPin() const
static constexpr int32 INDEX_PIN_Input
bool Modify(bool bAlwaysMarkDirty=true) override
UDialogueGraphNode * GetChildNode() const
const FDlgEdge & GetDialogueEdge() const
void PinConnectionListChanged(UEdGraphPin *Pin) override
UDialogueGraphNode * GetParentNode() const
FDlgEdge DialogueEdge
UPROPERTY(EditAnywhere, Category = DialogueGraphNode, Meta = (ShowOnlyInnerProperties))
bool SuperModify(bool bAlwaysMarkDirty=true)
void CreateConnections(UDialogueGraphNode *ParentNode, UDialogueGraphNode *ChildNode)
FText GetNodeTitle(ENodeTitleType::Type TitleType) const override
void PostEditChangeProperty(FPropertyChangedEvent &PropertyChangedEvent) override
void SetDialogueEdgeTargetIndex(int32 InIndex)
FLinearColor GetNodeBackgroundColor() const override
FSlateIcon GetIconAndTint(FLinearColor &OutColor) const override
FLinearColor GetEdgeColor(bool bIsHovered) const
FText GetTooltipText() const override
void SetDialogueEdgeText(const FText &InText)
FDlgEdge * GetMutableDialogueEdgeFromParentNode() const
void SetDialogueEdge(const FDlgEdge &InEdge)
UCLASS(Config = Engine, DefaultConfig, meta = (DisplayName = "Dialogue System Settings"))
bool bShowPrimarySecondaryEdges
UPROPERTY(Category = "Graph Edge", Config, EditAnywhere)
bool bDrawPrimaryEdges
UPROPERTY(Category = "Graph Edge", Config, EditAnywhere)
bool bDrawSecondaryEdges
UPROPERTY(Category = "Graph Edge", Config, EditAnywhere)
USTRUCT(BlueprintType)
Definition DlgEdge.h:25
TArray< FDlgCondition > Conditions
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue|Edge")
Definition DlgEdge.h:134
int32 TargetIndex
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Dialogue|Edge", Meta = (ClampMin = -1))
Definition DlgEdge.h:126
void SetText(const FText &NewText)
Definition DlgEdge.h:79