From 80bf4c1a5b304d3fc9cbc581ad99545a540ae653 Mon Sep 17 00:00:00 2001 From: szabob Date: Thu, 6 Feb 2025 16:24:37 +0100 Subject: [PATCH] SFlowGraphPinExec with Custom "PinColorModifier": + Added PinColorModifier FLinearColor Property into FFlowPin -> With this we can choose the Color Modifier of a Pin in Runtime module + FlowNode stores the "PinColorModifier" value in a map for each PinName -> PinFactory can access this information + New "PinModifierColor" Slate Argument in SFlowGraphPinExec + Pin Factory set the "PinModifierColor" Argument when Construct the Pin (cherry picked from commit 43af73f0da9436aaccd566bed82fa526367bfc0e) --- Source/Flow/Public/Nodes/FlowPin.h | 3 +++ Source/FlowEditor/Private/Graph/FlowGraphPinFactory.cpp | 3 ++- Source/FlowEditor/Private/Graph/Nodes/FlowGraphNode.cpp | 7 +++++++ Source/FlowEditor/Private/Graph/Widgets/SFlowGraphNode.cpp | 1 + Source/FlowEditor/Public/Graph/Nodes/FlowGraphNode.h | 6 ++++++ Source/FlowEditor/Public/Graph/Widgets/SFlowGraphNode.h | 5 ++++- 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Source/Flow/Public/Nodes/FlowPin.h b/Source/Flow/Public/Nodes/FlowPin.h index c5e9bf2bd..61994ef63 100644 --- a/Source/Flow/Public/Nodes/FlowPin.h +++ b/Source/Flow/Public/Nodes/FlowPin.h @@ -30,6 +30,9 @@ struct FLOW_API FFlowPin UPROPERTY(EditDefaultsOnly, Category = FlowPin) FString PinToolTip; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "FlowPin") + FLinearColor PinColorModifier = FLinearColor::White; + protected: // PinType (implies PinCategory) UPROPERTY(EditAnywhere, Category = FlowPin) diff --git a/Source/FlowEditor/Private/Graph/FlowGraphPinFactory.cpp b/Source/FlowEditor/Private/Graph/FlowGraphPinFactory.cpp index 83e891c1e..8f937b994 100644 --- a/Source/FlowEditor/Private/Graph/FlowGraphPinFactory.cpp +++ b/Source/FlowEditor/Private/Graph/FlowGraphPinFactory.cpp @@ -29,7 +29,8 @@ TSharedPtr FFlowGraphPinFactory::CreatePin(UEdGraphPin* InPin) const // Create the widget for a Flow 'Exec'-style pin if (FlowGraphNode && FFlowPin::IsExecPinCategory(InPin->PinType.PinCategory)) { - const TSharedPtr NewPinWidget = SNew(SFlowGraphPinExec, InPin); + const TSharedPtr NewPinWidget = SNew(SFlowGraphPinExec, InPin) + .PinModifierColor(FlowGraphNode->GetPinModifierColor(InPin)); const UFlowNode* FlowNode = Cast(FlowGraphNode->GetFlowNodeBase()); diff --git a/Source/FlowEditor/Private/Graph/Nodes/FlowGraphNode.cpp b/Source/FlowEditor/Private/Graph/Nodes/FlowGraphNode.cpp index d24aab90b..cfb5e864c 100644 --- a/Source/FlowEditor/Private/Graph/Nodes/FlowGraphNode.cpp +++ b/Source/FlowEditor/Private/Graph/Nodes/FlowGraphNode.cpp @@ -339,11 +339,13 @@ void UFlowGraphNode::AllocateDefaultPins() for (const FFlowPin& InputPin : FlowNode->InputPins) { CreateInputPin(InputPin); + PinColorModifierMap.Add(InputPin.PinName, InputPin.PinColorModifier); } for (const FFlowPin& OutputPin : FlowNode->OutputPins) { CreateOutputPin(OutputPin); + PinColorModifierMap.Add(OutputPin.PinName, OutputPin.PinColorModifier); } } } @@ -945,6 +947,11 @@ void UFlowGraphNode::AddUserOutput() AddInstancePin(EGPD_Output, FlowNode->CountNumberedOutputs()); } +FLinearColor UFlowGraphNode::GetPinModifierColor(const UEdGraphPin* Pin) const +{ + return PinColorModifierMap.FindRef(Pin->PinName, FColor::White); +} + void UFlowGraphNode::AddInstancePin(const EEdGraphPinDirection Direction, const uint8 NumberedPinsAmount) { const FScopedTransaction Transaction(LOCTEXT("AddInstancePin", "Add Instance Pin")); diff --git a/Source/FlowEditor/Private/Graph/Widgets/SFlowGraphNode.cpp b/Source/FlowEditor/Private/Graph/Widgets/SFlowGraphNode.cpp index 6ca9ca6b7..60299e4ae 100644 --- a/Source/FlowEditor/Private/Graph/Widgets/SFlowGraphNode.cpp +++ b/Source/FlowEditor/Private/Graph/Widgets/SFlowGraphNode.cpp @@ -45,6 +45,7 @@ void SFlowGraphPinExec::Construct(const FArguments& InArgs, UEdGraphPin* InPin) { SGraphPinExec::Construct(SGraphPinExec::FArguments(), InPin); bUsePinColorForText = true; + PinColorModifier = InArgs._PinModifierColor; } const FLinearColor SFlowGraphNode::UnselectedNodeTint = FLinearColor(1.0f, 1.0f, 1.0f, 0.5f); diff --git a/Source/FlowEditor/Public/Graph/Nodes/FlowGraphNode.h b/Source/FlowEditor/Public/Graph/Nodes/FlowGraphNode.h index 1c2348744..0cbdcd4d7 100644 --- a/Source/FlowEditor/Public/Graph/Nodes/FlowGraphNode.h +++ b/Source/FlowEditor/Public/Graph/Nodes/FlowGraphNode.h @@ -192,6 +192,8 @@ class FLOWEDITOR_API UFlowGraphNode : public UEdGraphNode void AddUserInput(); void AddUserOutput(); + FLinearColor GetPinModifierColor(const UEdGraphPin* Pin) const; + // Add pin only on this instance of node, under default pins void AddInstancePin(const EEdGraphPinDirection Direction, const uint8 NumberedPinsAmount); @@ -344,6 +346,10 @@ class FLOWEDITOR_API UFlowGraphNode : public UEdGraphNode UPROPERTY() FString ErrorMessage; +protected: + UPROPERTY() + TMap PinColorModifierMap; + private: /** parent UFlowGraphNode for this node, * note, this is not saved, and is restored in when the graph is opened in the editor via diff --git a/Source/FlowEditor/Public/Graph/Widgets/SFlowGraphNode.h b/Source/FlowEditor/Public/Graph/Widgets/SFlowGraphNode.h index 17116380f..f660eafea 100644 --- a/Source/FlowEditor/Public/Graph/Widgets/SFlowGraphNode.h +++ b/Source/FlowEditor/Public/Graph/Widgets/SFlowGraphNode.h @@ -12,7 +12,10 @@ class FLOWEDITOR_API SFlowGraphPinExec : public SGraphPinExec public: SFlowGraphPinExec(); - SLATE_BEGIN_ARGS(SFlowGraphPinExec) {} + SLATE_BEGIN_ARGS(SFlowGraphPinExec) : + _PinModifierColor(FLinearColor::White) + {} + SLATE_ARGUMENT(FLinearColor, PinModifierColor) SLATE_END_ARGS() void Construct(const FArguments& InArgs, UEdGraphPin* InPin);