Skip to content

Commit

Permalink
#91 Visualize in graph that Flow Node class is marked as "Deprecated"
Browse files Browse the repository at this point in the history
  • Loading branch information
MothDoctor committed Feb 13, 2022
1 parent a79777f commit 714baa0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Source/Flow/Private/Nodes/FlowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ UFlowNode::UFlowNode(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
#if WITH_EDITOR
, GraphNode(nullptr)
, bCanDelete(true)
, bCanDuplicate(true)
, bNodeDeprecated(false)
#endif
, bPreloaded(false)
, ActivationState(EFlowNodeState::NeverActivated)
{
#if WITH_EDITOR
Category = TEXT("Uncategorized");
NodeStyle = EFlowNodeStyle::Default;
bCanDelete = bCanDuplicate = true;
#endif

InputPins = {DefaultInputPin};
Expand Down
8 changes: 8 additions & 0 deletions Source/Flow/Public/Nodes/FlowNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class FLOW_API UFlowNode : public UObject, public IVisualLoggerDebugSnapshotInte
friend class SFlowGraphNode;
friend class UFlowAsset;
friend class UFlowGraphNode;
friend class UFlowGraphSchema;

//////////////////////////////////////////////////////////////////////////
// Node
Expand All @@ -47,6 +48,13 @@ class FLOW_API UFlowNode : public UObject, public IVisualLoggerDebugSnapshotInte
uint8 bCanDelete : 1;
uint8 bCanDuplicate : 1;

UPROPERTY(EditDefaultsOnly, Category = "FlowNode")
bool bNodeDeprecated;

// If this node is deprecated, it might be replaced by another node
UPROPERTY(EditDefaultsOnly, Category = "FlowNode")
TSubclassOf<UFlowNode> ReplacedBy;

public:
FFlowNodeEvent OnReconstructionRequested;
#endif
Expand Down
12 changes: 11 additions & 1 deletion Source/FlowEditor/Private/Graph/FlowGraphSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,17 @@ void UFlowGraphSchema::GetCommentAction(FGraphActionMenuBuilder& ActionMenuBuild

bool UFlowGraphSchema::IsFlowNodePlaceable(const UClass* Class)
{
return !Class->HasAnyClassFlags(CLASS_Abstract) && !Class->HasAnyClassFlags(CLASS_NotPlaceable) && !Class->HasAnyClassFlags(CLASS_Deprecated);
if (Class->HasAnyClassFlags(CLASS_Abstract) || Class->HasAnyClassFlags(CLASS_NotPlaceable) || Class->HasAnyClassFlags(CLASS_Deprecated))
{
return false;
}

if (const UFlowNode* DefaultObject = Class->GetDefaultObject<UFlowNode>())
{
return !DefaultObject->bNodeDeprecated;
}

return true;
}

void UFlowGraphSchema::OnBlueprintPreCompile(UBlueprint* Blueprint)
Expand Down
15 changes: 15 additions & 0 deletions Source/FlowEditor/Private/Graph/Widgets/SFlowGraphNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,21 @@ void SFlowGraphNode::UpdateGraphNode()
CreateAdvancedViewArrow(InnerVerticalBox);
}

void SFlowGraphNode::UpdateErrorInfo()
{
if (const UFlowNode* FlowNode = FlowGraphNode->GetFlowNode())
{
if (FlowNode->GetClass()->HasAnyClassFlags(CLASS_Deprecated) || FlowNode->bNodeDeprecated)
{
ErrorMsg = FlowNode->ReplacedBy ? FString::Printf(TEXT(" REPLACED BY: %s "), *FlowNode->ReplacedBy->GetName()) : FString(TEXT(" DEPRECATED! "));
ErrorColor = FEditorStyle::GetColor("ErrorReporting.WarningBackgroundColor");
return;
}
}

SGraphNode::UpdateErrorInfo();
}

TSharedRef<SWidget> SFlowGraphNode::CreateNodeContentArea()
{
return SNew(SBorder)
Expand Down
1 change: 1 addition & 0 deletions Source/FlowEditor/Public/Graph/Widgets/SFlowGraphNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SFlowGraphNode : public SGraphNode

// SGraphNode
virtual void UpdateGraphNode() override;
virtual void UpdateErrorInfo() override;
virtual TSharedRef<SWidget> CreateNodeContentArea() override;
virtual const FSlateBrush* GetNodeBodyBrush() const override;

Expand Down

0 comments on commit 714baa0

Please sign in to comment.