A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
SDialogueGraphNode_Base.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
3
4#include "Widgets/Layout/SBox.h"
6#include "IDocumentation.h"
7#include "GraphEditorDragDropAction.h"
8
9#include "SDialogueGraphPin.h"
10
11#define LOCTEXT_NAMESPACE "DialogueEditor"
12
13
15// SDialogueGraphNode_Base
16void SDialogueGraphNode_Base::Construct(const FArguments& InArgs, UDialogueGraphNode_Base* InNode)
17{
18 GraphNode = Cast<UEdGraphNode>(InNode);
20 Settings = GetDefault<UDlgSystemSettings>();
21}
22
24{
25 // Create only one pin, the output one, the rest is handled by FDialogueGraphConnectionDrawingPolicy
26 UEdGraphPin* OutputPin = DialogueGraphNode_Base->GetOutputPin();
27 UEdGraphPin* InputPin = DialogueGraphNode_Base->GetInputPin();
28
29 // Order is important, or something like that.
30 if (!IsValidPin(InputPin))
31 {
32 return;
33 }
34
35 //CreateStandardPinWidget(InputPin);
36
37 if (!IsValidPin(OutputPin))
38 {
39 return;
40 }
41
42 CreateStandardPinWidget(OutputPin);
43}
44
46{
47 Super::CreateStandardPinWidget(Pin);
48}
49
51{
52 // Reset variables that are going to be exposed, in case we are refreshing an already setup node.
53 InputPins.Empty();
54 OutputPins.Empty();
55 RightNodeBox.Reset();
56 LeftNodeBox.Reset();
57 PinsNodeBox.Reset();
58 SAssignNew(PinsNodeBox, SVerticalBox);
59
60 // This Node visibility
61 SetVisibility(TAttribute<EVisibility>::Create(TAttribute<EVisibility>::FGetter::CreateSP(this, &Self::GetNodeVisibility)));
62}
63
64void SDialogueGraphNode_Base::SetOwner(const TSharedRef<SGraphPanel>& OwnerPanel)
65{
66 check(!OwnerGraphPanelPtr.IsValid());
67 SetParentPanel(OwnerPanel);
68 OwnerGraphPanelPtr = OwnerPanel;
69 GraphNode->DEPRECATED_NodeWidget = SharedThis(this);
70
71 // Once we have an owner, and if hide Unused pins is enabled, we need to remake our pins to drop the hidden ones
72 if (OwnerGraphPanelPtr.Pin()->GetPinVisibility() != SGraphEditor::Pin_Show && PinsNodeBox.IsValid())
73 {
74 PinsNodeBox->ClearChildren();
76 }
77}
78
79TSharedPtr<SGraphPin> SDialogueGraphNode_Base::CreatePinWidget(UEdGraphPin* Pin) const
80{
81 // Called by CreateStandardPinWidget
82 return SNew(SDialogueGraphPin, Pin);
83}
84
85void SDialogueGraphNode_Base::AddPin(const TSharedRef<SGraphPin>& PinToAdd)
86{
87 PinToAdd->SetOwner(SharedThis(this));
88 PinsNodeBox->AddSlot()
89 .HAlign(HAlign_Fill)
90 .VAlign(VAlign_Fill)
91 .FillHeight(1.0f)
92 [
93 PinToAdd
94 ];
95
96 if (PinToAdd->GetDirection() == EGPD_Output)
97 {
98 OutputPins.Add(PinToAdd);
99 }
100 else
101 {
102 InputPins.Add(PinToAdd);
103 }
104}
105// End SGraphNode interface
107
108#undef LOCTEXT_NAMESPACE
TSharedPtr< SGraphPin > CreatePinWidget(UEdGraphPin *Pin) const override
const UDlgSystemSettings * Settings
UDialogueGraphNode_Base * DialogueGraphNode_Base
void AddPin(const TSharedRef< SGraphPin > &PinToAdd) override
virtual EVisibility GetNodeVisibility() const
void SetOwner(const TSharedRef< SGraphPanel > &OwnerPanel) override
TSharedPtr< SVerticalBox > PinsNodeBox
void Construct(const FArguments &InArgs, UDialogueGraphNode_Base *InNode)
bool IsValidPin(UEdGraphPin *Pin)
void CreateStandardPinWidget(UEdGraphPin *Pin) override
UEdGraphPin * GetOutputPin() const
UEdGraphPin * GetInputPin() const