Skip to content

Commit daa3fef

Browse files
committed
Addressed UE 5.6 deprecations
1 parent e6d5b9e commit daa3fef

File tree

5 files changed

+64
-18
lines changed

5 files changed

+64
-18
lines changed

Source/FlowEditor/Private/Asset/FlowObjectDiff.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@ void FFlowObjectDiff::InitializeDetailsDiffFromNode(UEdGraphNode* Node, const UO
5151

5252
if (NodeDiffType == ENodeDiffType::Old && !OldDetailsView.IsValid())
5353
{
54+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
5455
OldDetailsView = MakeShared<FDetailsDiff>(Object, FOnDisplayedPropertiesChanged());
56+
#else
57+
OldDetailsView = MakeShared<FDetailsDiff>(Object);
58+
#endif
5559
}
5660
else if (NodeDiffType == ENodeDiffType::New && !NewDetailsView.IsValid())
5761
{
62+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
5863
NewDetailsView = MakeShared<FDetailsDiff>(Object, FOnDisplayedPropertiesChanged());
64+
#else
65+
NewDetailsView = MakeShared<FDetailsDiff>(Object);
66+
#endif
5967
}
6068
}
6169

Source/FlowEditor/Private/Graph/FlowGraphConnectionDrawingPolicy.cpp

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,23 @@ void FFlowGraphConnectionDrawingPolicy::BuildPaths()
112112
}
113113
}
114114

115+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
115116
void FFlowGraphConnectionDrawingPolicy::DrawConnection(int32 LayerId, const FVector2D& Start, const FVector2D& End, const FConnectionParams& Params)
117+
#else
118+
void FFlowGraphConnectionDrawingPolicy::DrawConnection(int32 LayerId, const FVector2f& Start, const FVector2f& End, const FConnectionParams& Params)
119+
#endif
116120
{
117121
switch (UFlowGraphSettings::Get()->ConnectionDrawType)
118122
{
119123
case EFlowConnectionDrawType::Default:
120124
FConnectionDrawingPolicy::DrawConnection(LayerId, Start, End, Params);
121125
break;
122126
case EFlowConnectionDrawType::Circuit:
127+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
128+
DrawCircuitSpline(LayerId, FVector2f(Start), FVector2f(End), Params);
129+
#else
123130
DrawCircuitSpline(LayerId, Start, End, Params);
131+
#endif
124132
break;
125133
default: ;
126134
}
@@ -219,37 +227,41 @@ void FFlowGraphConnectionDrawingPolicy::Draw(TMap<TSharedRef<SWidget>, FArranged
219227
FConnectionDrawingPolicy::Draw(InPinGeometries, ArrangedNodes);
220228
}
221229

222-
void FFlowGraphConnectionDrawingPolicy::DrawCircuitSpline(const int32& LayerId, const FVector2D& Start, const FVector2D& End, const FConnectionParams& Params) const
230+
void FFlowGraphConnectionDrawingPolicy::DrawCircuitSpline(const int32& LayerId, const FVector2f& Start, const FVector2f& End, const FConnectionParams& Params) const
223231
{
224-
const FVector2D StartingPoint = FVector2D(Start.X + UFlowGraphSettings::Get()->CircuitConnectionSpacing.X, Start.Y);
225-
const FVector2D EndPoint = FVector2D(End.X - UFlowGraphSettings::Get()->CircuitConnectionSpacing.Y, End.Y);
226-
const FVector2D ControlPoint = GetControlPoint(StartingPoint, EndPoint);
232+
const FVector2f StartingPoint = FVector2f(Start.X + UFlowGraphSettings::Get()->CircuitConnectionSpacing.X, Start.Y);
233+
const FVector2f EndPoint = FVector2f(End.X - UFlowGraphSettings::Get()->CircuitConnectionSpacing.Y, End.Y);
234+
const FVector2f ControlPoint = GetControlPoint(StartingPoint, EndPoint);
227235

228-
const FVector2D StartDirection = (Params.StartDirection == EGPD_Output) ? FVector2D(1.0f, 0.0f) : FVector2D(-1.0f, 0.0f);
229-
const FVector2D EndDirection = (Params.EndDirection == EGPD_Input) ? FVector2D(1.0f, 0.0f) : FVector2D(-1.0f, 0.0f);
236+
const FVector2f StartDirection = (Params.StartDirection == EGPD_Output) ? FVector2f(1.0f, 0.0f) : FVector2f(-1.0f, 0.0f);
237+
const FVector2f EndDirection = (Params.EndDirection == EGPD_Input) ? FVector2f(1.0f, 0.0f) : FVector2f(-1.0f, 0.0f);
230238

231239
DrawCircuitConnection(LayerId, Start, StartDirection, StartingPoint, EndDirection, Params);
232240
DrawCircuitConnection(LayerId, StartingPoint, StartDirection, ControlPoint, EndDirection, Params);
233241
DrawCircuitConnection(LayerId, ControlPoint, StartDirection, EndPoint, EndDirection, Params);
234242
DrawCircuitConnection(LayerId, EndPoint, StartDirection, End, EndDirection, Params);
235243
}
236244

237-
void FFlowGraphConnectionDrawingPolicy::DrawCircuitConnection(const int32& LayerId, const FVector2D& Start, const FVector2D& StartDirection, const FVector2D& End, const FVector2D& EndDirection, const FConnectionParams& Params) const
245+
void FFlowGraphConnectionDrawingPolicy::DrawCircuitConnection(const int32& LayerId, const FVector2f& Start, const FVector2f& StartDirection, const FVector2f& End, const FVector2f& EndDirection, const FConnectionParams& Params) const
238246
{
239247
FSlateDrawElement::MakeDrawSpaceSpline(DrawElementsList, LayerId, Start, StartDirection, End, EndDirection, Params.WireThickness, ESlateDrawEffect::None, Params.WireColor);
240248

241249
if (Params.bDrawBubbles)
242250
{
243251
// This table maps distance along curve to alpha
244252
FInterpCurve<float> SplineReparamTable;
253+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
254+
const float SplineLength = MakeSplineReparamTable(FVector2D(Start), FVector2D(StartDirection), FVector2D(End), FVector2D(EndDirection), SplineReparamTable);
255+
#else
245256
const float SplineLength = MakeSplineReparamTable(Start, StartDirection, End, EndDirection, SplineReparamTable);
257+
#endif
246258

247259
// Draw bubbles on the spline
248260
if (Params.bDrawBubbles)
249261
{
250262
const float BubbleSpacing = 64.f * ZoomFactor;
251263
const float BubbleSpeed = 192.f * ZoomFactor;
252-
const FVector2D BubbleSize = BubbleImage->ImageSize * ZoomFactor * 0.2f * Params.WireThickness;
264+
const FVector2f BubbleSize = BubbleImage->ImageSize * ZoomFactor * 0.2f * Params.WireThickness;
253265

254266
const float Time = (FPlatformTime::Seconds() - GStartTime);
255267
const float BubbleOffset = FMath::Fmod(Time * BubbleSpeed, BubbleSpacing);
@@ -260,7 +272,7 @@ void FFlowGraphConnectionDrawingPolicy::DrawCircuitConnection(const int32& Layer
260272
if (Distance < SplineLength)
261273
{
262274
const float Alpha = SplineReparamTable.Eval(Distance, 0.f);
263-
FVector2D BubblePos = FMath::CubicInterp(Start, StartDirection, End, EndDirection, Alpha);
275+
FVector2f BubblePos = FMath::CubicInterp(Start, StartDirection, End, EndDirection, Alpha);
264276
BubblePos -= (BubbleSize * 0.5f);
265277

266278
FSlateDrawElement::MakeBox(DrawElementsList, LayerId, FPaintGeometry(BubblePos, BubbleSize, ZoomFactor), BubbleImage, ESlateDrawEffect::None, Params.WireColor);
@@ -270,9 +282,9 @@ void FFlowGraphConnectionDrawingPolicy::DrawCircuitConnection(const int32& Layer
270282
}
271283
}
272284

273-
FVector2D FFlowGraphConnectionDrawingPolicy::GetControlPoint(const FVector2D& Source, const FVector2D& Target)
285+
FVector2f FFlowGraphConnectionDrawingPolicy::GetControlPoint(const FVector2f& Source, const FVector2f& Target)
274286
{
275-
const FVector2D Delta = Target - Source;
287+
const FVector2f Delta = Target - Source;
276288
const float Tangent = FMath::Tan(UFlowGraphSettings::Get()->CircuitConnectionAngle * (PI / 180.f));
277289

278290
const float DeltaX = FMath::Abs(Delta.X);
@@ -281,24 +293,24 @@ FVector2D FFlowGraphConnectionDrawingPolicy::GetControlPoint(const FVector2D& So
281293
const float SlopeWidth = DeltaY / Tangent;
282294
if (DeltaX > SlopeWidth)
283295
{
284-
return Delta.X > 0.f ? FVector2D(Target.X - SlopeWidth, Source.Y) : FVector2D(Source.X - SlopeWidth, Target.Y);
296+
return Delta.X > 0.f ? FVector2f(Target.X - SlopeWidth, Source.Y) : FVector2f(Source.X - SlopeWidth, Target.Y);
285297
}
286298

287299
const float SlopeHeight = DeltaX * Tangent;
288300
if (DeltaY > SlopeHeight)
289301
{
290302
if (Delta.Y > 0.f)
291303
{
292-
return Delta.X < 0.f ? FVector2D(Source.X, Target.Y - SlopeHeight) : FVector2D(Target.X, Source.Y + SlopeHeight);
304+
return Delta.X < 0.f ? FVector2f(Source.X, Target.Y - SlopeHeight) : FVector2f(Target.X, Source.Y + SlopeHeight);
293305
}
294306

295307
if (Delta.X < 0.f)
296308
{
297-
return FVector2D(Source.X, Target.Y + SlopeHeight);
309+
return FVector2f(Source.X, Target.Y + SlopeHeight);
298310
}
299311
}
300312

301-
return FVector2D(Target.X, Source.Y - SlopeHeight);
313+
return FVector2f(Target.X, Source.Y - SlopeHeight);
302314
}
303315

304316
bool FFlowGraphConnectionDrawingPolicy::ShouldChangeTangentForReroute(UFlowGraphNode_Reroute* Reroute)

Source/FlowEditor/Private/Graph/FlowGraphEditor.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ void SFlowGraphEditor::Construct(const FArguments& InArgs, const TSharedPtr<FFlo
4646
Arguments._GraphEvents.OnSelectionChanged = FOnSelectionChanged::CreateSP(this, &SFlowGraphEditor::OnSelectedNodesChanged);
4747
Arguments._GraphEvents.OnNodeDoubleClicked = FSingleNodeEvent::CreateSP(this, &SFlowGraphEditor::OnNodeDoubleClicked);
4848
Arguments._GraphEvents.OnTextCommitted = FOnNodeTextCommitted::CreateSP(this, &SFlowGraphEditor::OnNodeTitleCommitted);
49+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
4950
Arguments._GraphEvents.OnSpawnNodeByShortcut = FOnSpawnNodeByShortcut::CreateStatic(&SFlowGraphEditor::OnSpawnGraphNodeByShortcut, static_cast<UEdGraph*>(FlowAsset->GetGraph()));
51+
#else
52+
Arguments._GraphEvents.OnSpawnNodeByShortcutAtLocation = FOnSpawnNodeByShortcutAtLocation::CreateStatic(&SFlowGraphEditor::OnSpawnGraphNodeByShortcut, static_cast<UEdGraph*>(FlowAsset->GetGraph()));
53+
#endif
5054

5155
SGraphEditor::Construct(Arguments);
5256
}
@@ -286,7 +290,11 @@ void SFlowGraphEditor::RedoGraphAction()
286290
GEditor->RedoTransaction();
287291
}
288292

293+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
289294
FReply SFlowGraphEditor::OnSpawnGraphNodeByShortcut(FInputChord InChord, const FVector2D& InPosition, UEdGraph* InGraph)
295+
#else
296+
FReply SFlowGraphEditor::OnSpawnGraphNodeByShortcut(FInputChord InChord, const FVector2f& InPosition, UEdGraph* InGraph)
297+
#endif
290298
{
291299
UEdGraph* Graph = InGraph;
292300

@@ -296,6 +304,7 @@ FReply SFlowGraphEditor::OnSpawnGraphNodeByShortcut(FInputChord InChord, const F
296304
if (Action.IsValid())
297305
{
298306
TArray<UEdGraphPin*> DummyPins;
307+
299308
Action->PerformAction(Graph, DummyPins, InPosition);
300309
return FReply::Handled();
301310
}
@@ -307,7 +316,11 @@ FReply SFlowGraphEditor::OnSpawnGraphNodeByShortcut(FInputChord InChord, const F
307316
void SFlowGraphEditor::OnCreateComment() const
308317
{
309318
FFlowGraphSchemaAction_NewComment CommentAction;
319+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
310320
CommentAction.PerformAction(FlowAsset->GetGraph(), nullptr, GetPasteLocation());
321+
#else
322+
CommentAction.PerformAction(FlowAsset->GetGraph(), nullptr, GetPasteLocation2f());
323+
#endif
311324
}
312325

313326
bool SFlowGraphEditor::IsTabFocused() const
@@ -657,7 +670,11 @@ bool SFlowGraphEditor::CanCopyNodes() const
657670

658671
void SFlowGraphEditor::PasteNodes()
659672
{
673+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
660674
PasteNodesHere(GetPasteLocation());
675+
#else
676+
PasteNodesHere(GetPasteLocation2f());
677+
#endif
661678
}
662679

663680
void SFlowGraphEditor::PasteNodesHere(const FVector2D& Location)

Source/FlowEditor/Public/Graph/FlowGraphConnectionDrawingPolicy.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,19 @@ class FLOWEDITOR_API FFlowGraphConnectionDrawingPolicy : public FConnectionDrawi
5454
void BuildPaths();
5555

5656
// FConnectionDrawingPolicy interface
57+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
5758
virtual void DrawConnection(int32 LayerId, const FVector2D& Start, const FVector2D& End, const FConnectionParams& Params) override;
59+
#else
60+
virtual void DrawConnection(int32 LayerId, const FVector2f& Start, const FVector2f& End, const FConnectionParams& Params);
61+
#endif
5862
virtual void DetermineWiringStyle(UEdGraphPin* OutputPin, UEdGraphPin* InputPin, FConnectionParams& Params) override;
5963
virtual void Draw(TMap<TSharedRef<SWidget>, FArrangedWidget>& PinGeometries, FArrangedChildren& ArrangedNodes) override;
6064
// End of FConnectionDrawingPolicy interface
6165

6266
protected:
63-
void DrawCircuitSpline(const int32& LayerId, const FVector2D& Start, const FVector2D& End, const FConnectionParams& Params) const;
64-
void DrawCircuitConnection(const int32& LayerId, const FVector2D& Start, const FVector2D& StartDirection, const FVector2D& End, const FVector2D& EndDirection, const FConnectionParams& Params) const;
65-
static FVector2D GetControlPoint(const FVector2D& Source, const FVector2D& Target);
67+
void DrawCircuitSpline(const int32& LayerId, const FVector2f& Start, const FVector2f& End, const FConnectionParams& Params) const;
68+
void DrawCircuitConnection(const int32& LayerId, const FVector2f& Start, const FVector2f& StartDirection, const FVector2f& End, const FVector2f& EndDirection, const FConnectionParams& Params) const;
69+
static FVector2f GetControlPoint(const FVector2f& Source, const FVector2f& Target);
6670

6771
bool ShouldChangeTangentForReroute(class UFlowGraphNode_Reroute* Reroute);
6872
bool FindPinCenter(const UEdGraphPin* Pin, FVector2D& OutCenter) const;

Source/FlowEditor/Public/Graph/FlowGraphEditor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ class FLOWEDITOR_API SFlowGraphEditor : public SGraphEditor
4646
static void UndoGraphAction();
4747
static void RedoGraphAction();
4848

49+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
4950
static FReply OnSpawnGraphNodeByShortcut(FInputChord InChord, const FVector2D& InPosition, UEdGraph* InGraph);
51+
#else
52+
static FReply OnSpawnGraphNodeByShortcut(FInputChord InChord, const FVector2f& InPosition, UEdGraph* InGraph);
53+
#endif
54+
5055
void OnCreateComment() const;
5156

5257
public:

0 commit comments

Comments
 (0)