Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 60 additions & 14 deletions Source/Flow/Private/Nodes/FlowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,56 @@ bool UFlowNode::CanUserAddOutput() const
return K2_CanUserAddOutput();
}

bool UFlowNode::CanUserInsertInput(const FName& TargetPinName) const
{
return K2_CanUserInsertInput(TargetPinName);
}

bool UFlowNode::CanUserInsertOutput(const FName& TargetPinName) const
{
return K2_CanUserInsertOutput(TargetPinName);
}

void UFlowNode::AddUserInput(const FName& PinName, uint8 PinIndex)
{
if (InputPins.IsValidIndex(PinIndex))
{
InputPins.Insert(PinName, PinIndex);
}
else
{
InputPins.Add(PinName);
}

// update remaining pins
RenumberUserPins(InputPins, PinIndex);
}

void UFlowNode::AddUserOutput(const FName& PinName, uint8 PinIndex)
{
if (OutputPins.IsValidIndex(PinIndex))
{
OutputPins.Insert(PinName, PinIndex);
}
else
{
OutputPins.Add(PinName);
}

// update remaining pins
RenumberUserPins(OutputPins, PinIndex);
}

bool UFlowNode::CanUserRemoveInput(const FName& PinName) const
{
return K2_CanUserRemoveInput(PinName);
}

bool UFlowNode::CanUserRemoveOutput(const FName& PinName) const
{
return K2_CanUserRemoveOutput(PinName);
}

void UFlowNode::RemoveUserInput(const FName& PinName)
{
Modify();
Expand All @@ -324,16 +374,7 @@ void UFlowNode::RemoveUserInput(const FName& PinName)
}

// update remaining pins
if (RemovedPinIndex > INDEX_NONE)
{
for (int32 i = RemovedPinIndex; i < InputPins.Num(); ++i)
{
if (InputPins[i].PinName.ToString().IsNumeric())
{
InputPins[i].PinName = *FString::FromInt(i);
}
}
}
RenumberUserPins(InputPins, RemovedPinIndex);
}

void UFlowNode::RemoveUserOutput(const FName& PinName)
Expand All @@ -352,13 +393,18 @@ void UFlowNode::RemoveUserOutput(const FName& PinName)
}

// update remaining pins
if (RemovedPinIndex > INDEX_NONE)
RenumberUserPins(OutputPins, RemovedPinIndex);
}

void UFlowNode::RenumberUserPins(TArray<FFlowPin>& PinArray, int32 StartPinIndex)
{
if (StartPinIndex > INDEX_NONE)
{
for (int32 i = RemovedPinIndex; i < OutputPins.Num(); ++i)
for (int32 i = StartPinIndex; i < PinArray.Num(); ++i)
{
if (OutputPins[i].PinName.ToString().IsNumeric())
if (PinArray[i].PinName.ToString().IsNumeric())
{
OutputPins[i].PinName = *FString::FromInt(i);
PinArray[i].PinName = *FString::FromInt(i);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ UFlowNode_ExecutionMultiGate::UFlowNode_ExecutionMultiGate(const FObjectInitiali
AllowedSignalModes = {EFlowSignalMode::Enabled, EFlowSignalMode::Disabled};
}

#if WITH_EDITOR
bool UFlowNode_ExecutionMultiGate::CanUserRemoveOutput(const FName& PinName) const
{
return OutputPins.Num() > 2;
}
#endif

void UFlowNode_ExecutionMultiGate::ExecuteInput(const FName& PinName)
{
if (PinName == DefaultInputPin.PinName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ UFlowNode_ExecutionSequence::UFlowNode_ExecutionSequence(const FObjectInitialize
AllowedSignalModes = {EFlowSignalMode::Enabled, EFlowSignalMode::Disabled};
}

#if WITH_EDITOR
bool UFlowNode_ExecutionSequence::CanUserRemoveOutput(const FName& PinName) const
{
return OutputPins.Num() > 2;
}
#endif

void UFlowNode_ExecutionSequence::ExecuteInput(const FName& PinName)
{
if (bSavePinExecutionState)
Expand Down
7 changes: 7 additions & 0 deletions Source/Flow/Private/Nodes/Route/FlowNode_LogicalAND.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ UFlowNode_LogicalAND::UFlowNode_LogicalAND(const FObjectInitializer& ObjectIniti
SetNumberedInputPins(0, 1);
}

#if WITH_EDITOR
bool UFlowNode_LogicalAND::CanUserRemoveInput(const FName& PinName) const
{
return InputPins.Num() > 2;
}
#endif

void UFlowNode_LogicalAND::ExecuteInput(const FName& PinName)
{
ExecutedInputNames.Add(PinName);
Expand Down
17 changes: 17 additions & 0 deletions Source/Flow/Private/Nodes/Route/FlowNode_LogicalOR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ UFlowNode_LogicalOR::UFlowNode_LogicalOR(const FObjectInitializer& ObjectInitial
InputPins.Add(FFlowPin(TEXT("Disable"), TEXT("Disabling resets Execution Count")));
}

#if WITH_EDITOR
bool UFlowNode_LogicalOR::CanUserInsertInput(const FName& TargetPinName) const
{
return TargetPinName != TEXT("Enable") && TargetPinName != TEXT("Disable");
}

bool UFlowNode_LogicalOR::CanUserRemoveInput(const FName& PinName) const
{
if (PinName == TEXT("Enable") || PinName == TEXT("Disable"))
{
return false;
}

return CountNumberedInputs() > 2;
}
#endif

void UFlowNode_LogicalOR::ExecuteInput(const FName& PinName)
{
if (PinName == TEXT("Enable"))
Expand Down
25 changes: 25 additions & 0 deletions Source/Flow/Public/Nodes/FlowNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,26 @@ class FLOW_API UFlowNode
virtual bool CanUserAddInput() const;
virtual bool CanUserAddOutput() const;

// Check if user can insert new pin before or after TargetPinName
virtual bool CanUserInsertInput(const FName& TargetPinName) const;
virtual bool CanUserInsertOutput(const FName& TargetPinName) const;

void AddUserInput(const FName& PinName, uint8 PinIndex);
void AddUserOutput(const FName& PinName, uint8 PinIndex);

virtual bool CanUserRemoveInput(const FName& PinName) const;
virtual bool CanUserRemoveOutput(const FName& PinName) const;

void RemoveUserInput(const FName& PinName);
void RemoveUserOutput(const FName& PinName);

// Functions to determine acceptance for 'wildcard' data pin types (eg., singular, array, set, map)
// TODO (gtaylor) The data pins feature is under construction
bool DoesInputWildcardPinAcceptArray(const UEdGraphPin* Pin) const { return true; }
bool DoesOutputWildcardPinAcceptContainer(const UEdGraphPin* Pin) const { return true; }

private:
void RenumberUserPins(TArray<FFlowPin>& PinArray, int32 StartPinIndex);
#endif

protected:
Expand All @@ -155,6 +168,18 @@ class FLOW_API UFlowNode
UFUNCTION(BlueprintImplementableEvent, Category = "FlowNode", meta = (DisplayName = "Can User Add Output"))
bool K2_CanUserAddOutput() const;

UFUNCTION(BlueprintImplementableEvent, Category = "FlowNode", meta = (DisplayName = "Can User Insert Input", ToolTip = "Check if user can insert new pin before or after TargetPinName"))
bool K2_CanUserInsertInput(const FName& TargetPinName) const;

UFUNCTION(BlueprintImplementableEvent, Category = "FlowNode", meta = (DisplayName = "Can User Insert Output", ToolTip = "Check if user can insert new pin before or after TargetPinName"))
bool K2_CanUserInsertOutput(const FName& TargetPinName) const;

UFUNCTION(BlueprintImplementableEvent, Category = "FlowNode", meta = (DisplayName = "Can User Remove Input"))
bool K2_CanUserRemoveInput(const FName& PinName) const;

UFUNCTION(BlueprintImplementableEvent, Category = "FlowNode", meta = (DisplayName = "Can User Remove Output"))
bool K2_CanUserRemoveOutput(const FName& PinName) const;

//////////////////////////////////////////////////////////////////////////
// Connections to other nodes

Expand Down
2 changes: 2 additions & 0 deletions Source/Flow/Public/Nodes/Route/FlowNode_ExecutionMultiGate.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class FLOW_API UFlowNode_ExecutionMultiGate final : public UFlowNode
public:
#if WITH_EDITOR
virtual bool CanUserAddOutput() const override { return true; }
virtual bool CanUserInsertOutput(const FName& TargetPinName) const override { return true; }
virtual bool CanUserRemoveOutput(const FName& PinName) const override;
#endif

protected:
Expand Down
2 changes: 2 additions & 0 deletions Source/Flow/Public/Nodes/Route/FlowNode_ExecutionSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class FLOW_API UFlowNode_ExecutionSequence final : public UFlowNode
public:
#if WITH_EDITOR
virtual bool CanUserAddOutput() const override { return true; }
virtual bool CanUserInsertOutput(const FName& TargetPinName) const override { return true; }
virtual bool CanUserRemoveOutput(const FName& PinName) const override;
#endif

protected:
Expand Down
2 changes: 2 additions & 0 deletions Source/Flow/Public/Nodes/Route/FlowNode_LogicalAND.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class FLOW_API UFlowNode_LogicalAND final : public UFlowNode
#if WITH_EDITOR
public:
virtual bool CanUserAddInput() const override { return true; }
virtual bool CanUserInsertInput(const FName& TargetPinName) const override { return true; }
virtual bool CanUserRemoveInput(const FName& PinName) const override;
#endif

protected:
Expand Down
2 changes: 2 additions & 0 deletions Source/Flow/Public/Nodes/Route/FlowNode_LogicalOR.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class FLOW_API UFlowNode_LogicalOR final : public UFlowNode
#if WITH_EDITOR
public:
virtual bool CanUserAddInput() const override { return true; }
virtual bool CanUserInsertInput(const FName& TargetPinName) const override;
virtual bool CanUserRemoveInput(const FName& PinName) const override;
#endif

protected:
Expand Down
2 changes: 2 additions & 0 deletions Source/FlowEditor/Private/FlowEditorCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ void FFlowGraphCommands::RegisterCommands()

UI_COMMAND(AddInput, "Add Input", "Adds an input to the node", EUserInterfaceActionType::Button, FInputChord());
UI_COMMAND(AddOutput, "Add Output", "Adds an output to the node", EUserInterfaceActionType::Button, FInputChord());
UI_COMMAND(InsertPinBefore, "Insert Pin Before", "Inserts a pin before selected pin", EUserInterfaceActionType::Button, FInputChord());
UI_COMMAND(InsertPinAfter, "Insert Pin After", "Inserts a pin after selected pin", EUserInterfaceActionType::Button, FInputChord());
UI_COMMAND(RemovePin, "Remove Pin", "Removes a pin from the node", EUserInterfaceActionType::Button, FInputChord());

UI_COMMAND(AddPinBreakpoint, "Add Pin Breakpoint", "Adds a breakpoint to the pin", EUserInterfaceActionType::Button, FInputChord());
Expand Down
45 changes: 44 additions & 1 deletion Source/FlowEditor/Private/Graph/FlowGraphEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ void SFlowGraphEditor::BindGraphCommands()
FExecuteAction::CreateSP(this, &SFlowGraphEditor::AddOutput),
FCanExecuteAction::CreateSP(this, &SFlowGraphEditor::CanAddOutput));

CommandList->MapAction(FlowGraphCommands.InsertPinBefore,
FExecuteAction::CreateSP(this, &SFlowGraphEditor::InsertPin, EPinInsertPosition::Before),
FCanExecuteAction::CreateSP(this, &SFlowGraphEditor::CanInsertPin));

CommandList->MapAction(FlowGraphCommands.InsertPinAfter,
FExecuteAction::CreateSP(this, &SFlowGraphEditor::InsertPin, EPinInsertPosition::After),
FCanExecuteAction::CreateSP(this, &SFlowGraphEditor::CanInsertPin));

CommandList->MapAction(FlowGraphCommands.RemovePin,
FExecuteAction::CreateSP(this, &SFlowGraphEditor::RemovePin),
FCanExecuteAction::CreateSP(this, &SFlowGraphEditor::CanRemovePin));
Expand Down Expand Up @@ -1097,6 +1105,40 @@ bool SFlowGraphEditor::CanAddOutput() const
return false;
}

void SFlowGraphEditor::InsertPin(EPinInsertPosition Position)
{
if (UEdGraphPin* SelectedPin = GetGraphPinForMenu())
{
if (UFlowGraphNode* SelectedNode = Cast<UFlowGraphNode>(SelectedPin->GetOwningNode()))
{
SelectedNode->InsertInstancePin(SelectedPin, SelectedPin->Direction, Position);
}
}
}

bool SFlowGraphEditor::CanInsertPin()
{
if (CanEdit() && GetSelectedFlowNodes().Num() == 1)
{
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
{
if (const UFlowGraphNode* GraphNode = Cast<UFlowGraphNode>(Pin->GetOwningNode()))
{
if (Pin->Direction == EGPD_Input)
{
return GraphNode->CanUserInsertInput(Pin);
}
else
{
return GraphNode->CanUserInsertOutput(Pin);
}
}
}
}

return false;
}

void SFlowGraphEditor::RemovePin()
{
if (UEdGraphPin* SelectedPin = GetGraphPinForMenu())
Expand Down Expand Up @@ -1415,12 +1457,13 @@ bool SFlowGraphEditor::CanTogglePinBreakpoint()

void SFlowGraphEditor::SetSignalMode(const EFlowSignalMode Mode) const
{
const FScopedTransaction Transaction(LOCTEXT("SetSignalMode", "Set Signal Mode"));

for (UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
{
SelectedNode->SetSignalMode(Mode);
}

FlowAsset->Modify();
}

bool SFlowGraphEditor::CanSetSignalMode(const EFlowSignalMode Mode) const
Expand Down
Loading