A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueGraphNode_Base.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
3
4#include "Logging/TokenizedMessage.h"
5
7// Begin UObject interface
9{
10 Super::PostLoad();
12}
13
14void UDialogueGraphNode_Base::PostDuplicate(bool bDuplicateForPIE)
15{
16 Super::PostDuplicate(bDuplicateForPIE);
17
18 if (!bDuplicateForPIE)
19 {
20 CreateNewGuid();
21 }
22}
23
25{
26 Super::PostEditImport();
28}
29// End UObject interface
31
33// Begin UEdGraphNode interface
35{
36 // Only one input and output pin
37 check(Pins.Num() == 0);
40 check(Pins.Num() == 2);
41}
42
44{
45 // Most likely we also need to make sure the new connections are ok
46 Modify();
47
48 // Clear previously set messages
49 ErrorMsg.Reset();
50
51 // Break any links to 'orphan' pins
52 for (UEdGraphPin* Pin : Pins)
53 {
54 TArray<UEdGraphPin*>& LinkedToRef = Pin->LinkedTo;
55 for (UEdGraphPin* OtherPin : LinkedToRef)
56 {
57 // If we are linked to a pin that its owner doesn't know about, break that link
58 if (!OtherPin->GetOwningNode()->Pins.Contains(OtherPin))
59 {
60 Pin->LinkedTo.Remove(OtherPin);
61 }
62 }
63 }
64
65 // Store the old Input and Output pins
66 UEdGraphPin* OldInputPin = HasInputPin() ? GetInputPin() : nullptr;
67 UEdGraphPin* OldOutputPin = HasOutputPin() ? GetOutputPin() : nullptr;
68
69 // Move the existing pins to a saved array
70 TArray<UEdGraphPin*> OldPins(Pins);
71 Pins.Empty();
72
73 // Recreate the new pins
75
76 // Get new Input and Output pins
77 UEdGraphPin* NewInputPin = GetInputPin();
78 UEdGraphPin* NewOutputPin = GetOutputPin();
79
80 // Copy data from old to new
81 if (OldInputPin)
82 {
83 NewInputPin->CopyPersistentDataFromOldPin(*OldInputPin);
84 OldInputPin = nullptr;
85 }
86
87 if (OldOutputPin)
88 {
89 NewOutputPin->CopyPersistentDataFromOldPin(*OldOutputPin);
90 OldOutputPin = nullptr;
91 }
92
93 // Throw away the original (old) pins
94 for (UEdGraphPin* OldPin : OldPins)
95 {
96 OldPin->Modify();
97 OldPin->BreakAllPinLinks();
98 DestroyPin(OldPin);
99 }
100 OldPins.Empty();
101}
102
103// End UEdGraphNode interface
105
107// Begin own functions
108UDialogueGraphNode_Base::UDialogueGraphNode_Base(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
109{
110 bCanRenameNode = false;
111}
112
114{
115 for (UEdGraphPin* ChildInputPin : GetOutputPin()->LinkedTo)
116 {
117 if (ChildInputPin->GetOwningNode() == TargetNode)
118 {
119 return true;
120 }
121 }
122
123 return false;;
124}
125
127{
128 bHasCompilerMessage = false;
129 ErrorType = EMessageSeverity::Info;
130 ErrorMsg.Empty();
131}
132
134{
135 bHasCompilerMessage = true;
136 ErrorType = EMessageSeverity::Warning;
137 ErrorMsg = Message;
138}
139
141{
142 GetDialogue()->OnDialoguePropertyChanged.AddUObject(this, &UDialogueGraphNode_Base::OnDialoguePropertyChanged);
143}
144// End own functions
void SetCompilerWarningMessage(FString Message)
void PostDuplicate(bool bDuplicateForPIE) override
virtual void OnDialoguePropertyChanged(const FPropertyChangedEvent &PropertyChangedEvent)
virtual bool HasOutputConnectionToNode(const UEdGraphNode *TargetNode) const
UDlgDialogue * GetDialogue() const
UEdGraphPin * GetOutputPin() const
UDialogueGraphNode_Base(const FObjectInitializer &ObjectInitializer)
UEdGraphPin * GetInputPin() const