4#include "GraphEditAction.h"
15 : Super(ObjectInitializer)
18 if (!UDlgDialogue::GetDialogueEditorAccess().IsValid())
31 bool bWasSaved = Super::Modify(bAlwaysMarkDirty);
40 bWasSaved = bWasSaved && BaseNode->Modify(bAlwaysMarkDirty);
48 TArray<UDialogueGraphNode_Root*> RootNodeList;
49 GetNodesOfClass<UDialogueGraphNode_Root>( RootNodeList);
50 check(RootNodeList.Num() == 1);
51 return RootNodeList[0];
56 TArray<UDialogueGraphNode_Base*> AllBaseDialogueGraphNodes;
57 GetNodesOfClass<UDialogueGraphNode_Base>( AllBaseDialogueGraphNodes);
58 return AllBaseDialogueGraphNodes;
63 TArray<UDialogueGraphNode*> AllDialogueGraphNodes;
64 GetNodesOfClass<UDialogueGraphNode>( AllDialogueGraphNodes);
65 return AllDialogueGraphNodes;
70 TArray<UDialogueGraphNode_Edge*> AllEdgeDialogueGraphNodes;
71 GetNodesOfClass<UDialogueGraphNode_Edge>( AllEdgeDialogueGraphNodes);
72 return AllEdgeDialogueGraphNodes;
78 const int32 NumTimesNodeRemoved = Nodes.Remove(NodeToRemove);
83 GetSchema()->BreakNodeLinks(*NodeToRemove);
86 FEdGraphEditAction RemovalAction;
87 RemovalAction.Graph =
this;
88 RemovalAction.Action = GRAPHACTION_RemoveNode;
89 RemovalAction.Nodes.Add(NodeToRemove);
90 NotifyGraphChanged(RemovalAction);
92 return NumTimesNodeRemoved > 0;
98 check(Nodes.Num() == 0);
104 FGraphNodeCreator<UDialogueGraphNode_Root> NodeCreator(*
this);
116 NodeCreator.Finalize();
120 const TArray<UDlgNode*>& DialogueNodes =
Dialogue->GetNodes();
121 const int32 NodesNum = DialogueNodes.Num();
122 for (int32 NodeIndex = 0; NodeIndex < NodesNum; NodeIndex++)
124 FGraphNodeCreator<UDialogueGraphNode> NodeCreator(*
this);
132 NodeCreator.Finalize();
145 const TArray<UDlgNode*>& NodesDialogue =
Dialogue->GetNodes();
150 for (
UDlgNode* DialogueNode : NodesDialogue)
152 LinkGraphNodeToChildren(NodesDialogue, *DialogueNode, CastChecked<UDialogueGraphNode>(DialogueNode->GetGraphNode()));
157 const TArray<UDlgNode*>& NodesDialogue,
167 TSet<int32> NodeSeenEdges;
168 for (int32 ChildIndex = 0, ChildNum = NodeEdges.Num(); ChildIndex < ChildNum; ChildIndex++)
170 const int32 TargetIndex = NodeEdges[ChildIndex].TargetIndex;
172 if (TargetIndex == INDEX_NONE)
178 if (NodeSeenEdges.Contains(TargetIndex))
184 const UDlgNode& ChildNode = *NodesDialogue[TargetIndex];
185 UDialogueGraphNode* ChildGraphNode = CastChecked<UDialogueGraphNode>(ChildNode.GetGraphNode());
189 FDialogueEditorUtilities::SpawnGraphNodeFromTemplate<UDialogueGraphNode_Edge>(
195 NodeSeenEdges.Add(TargetIndex);
203 static constexpr bool bIsDirectionVertical =
true;
224 check(Nodes.Num() == 0);
229 return GetDefault<UDialogueGraphSchema>(Schema);
static bool AreDialogueNodesInSyncWithGraphNodes(const UDlgDialogue *Dialogue)
static bool CheckAndTryToFixDialogue(UDlgDialogue *Dialogue, bool bDisplayWarning=true)
static void AutoPositionGraphNodes(UDialogueGraphNode *RootNode, const TArray< UDialogueGraphNode * > &GraphNodes, int32 OffsetBetweenColumnsX, int32 OffsetBetweenRowsY, bool bIsDirectionVertical)
bool RemoveGraphNode(UEdGraphNode *NodeToRemove)
UDialogueGraph(const FObjectInitializer &ObjectInitializer)
UDlgDialogue * GetDialogue() const
void LinkGraphNodesFromDialogue() const
UDialogueGraphNode_Root * GetRootGraphNode() const
void LinkGraphNodeToChildren(const TArray< UDlgNode * > &NodesDialogue, const UDlgNode &NodeDialogue, UDialogueGraphNode *NodeGraph) const
bool Modify(bool bAlwaysMarkDirty=true) override
const UDialogueGraphSchema * GetDialogueGraphSchema() const
TArray< UDialogueGraphNode_Edge * > GetAllEdgeDialogueGraphNodes() const
void AutoPositionGraphNodes() const
TArray< UDialogueGraphNode_Base * > GetAllBaseDialogueGraphNodes() const
TArray< UDialogueGraphNode * > GetAllDialogueGraphNodes() const
void CreateGraphNodesFromDialogue()
UEdGraphPin * GetOutputPin() const
virtual void SetPosition(int32 X, int32 Y)
void CreateConnections(UDialogueGraphNode *ParentNode, UDialogueGraphNode *ChildNode)
void SetDialogueNodeDataChecked(int32 InIndex, UDlgNode *InNode)
virtual void SetDialogueNode(UDlgNode *InNode)
FIntPoint GetDefaultEdgePosition() const
void CheckAll() const override
void ApplyCompilerWarnings()
UCLASS(BlueprintType, Meta = (DisplayThumbnail = "true"))
UCLASS(BlueprintType, Abstract, EditInlineNew, ClassGroup = "Dialogue")
virtual const TArray< FDlgEdge > & GetNodeChildren() const
Gets this nodes children (edges) as a const/mutable array.
UCLASS(Config = Engine, DefaultConfig, meta = (DisplayName = "Dialogue System Settings"))
int32 OffsetBetweenColumnsX
UPROPERTY(Category = "Position", Config, EditAnywhere, AdvancedDisplay)
int32 OffsetBetweenRowsY
UPROPERTY(Category = "Position", Config, EditAnywhere, AdvancedDisplay)