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
20 changes: 18 additions & 2 deletions Source/Flow/Private/FlowAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,11 +1193,27 @@ void UFlowAsset::PreStartFlow()
#endif
}

void UFlowAsset::StartFlow(IFlowDataPinValueSupplierInterface* DataPinValueSupplier)
void UFlowAsset::StartFlow(IFlowDataPinValueSupplierInterface* DataPinValueSupplier /*= nullptr*/, const FGuid& StartingNodeGuid /*= FGuid()*/)
{
PreStartFlow();

if (UFlowNode* ConnectedEntryNode = GetDefaultEntryNode())
if (StartingNodeGuid.IsValid())
{
if (UFlowNode* StartingNode = Nodes.FindRef(StartingNodeGuid))
{
RecordedNodes.Add(StartingNode);

if (StartingNode->GetInputPins().Num() > 0)
{
StartingNode->TriggerInput(StartingNode->GetInputPins()[0].PinName);
}
else
{
StartingNode->TriggerFirstOutput(true);
}
}
}
else if (UFlowNode* ConnectedEntryNode = GetDefaultEntryNode())
{
RecordedNodes.Add(ConnectedEntryNode);

Expand Down
4 changes: 2 additions & 2 deletions Source/Flow/Private/FlowSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ void UFlowSubsystem::AbortActiveFlows()
RootInstances.Empty();
}

void UFlowSubsystem::StartRootFlow(UObject* Owner, UFlowAsset* FlowAsset, const bool bAllowMultipleInstances /* = true */)
void UFlowSubsystem::StartRootFlow(UObject* Owner, UFlowAsset* FlowAsset, const bool bAllowMultipleInstances /* = true */, const FGuid& StartingNodeGuid /* = FGuid() */)
{
if (FlowAsset)
{
if (UFlowAsset* NewFlow = CreateRootFlow(Owner, FlowAsset, bAllowMultipleInstances))
{
// todo: (gtaylor) In the future, we may want to provide a way to set a data pin value supplier
// for the root flow graph.
NewFlow->StartFlow();
NewFlow->StartFlow(nullptr, StartingNodeGuid);
}
}
#if WITH_EDITOR
Expand Down
2 changes: 1 addition & 1 deletion Source/Flow/Public/FlowAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class FLOW_API UFlowAsset : public UObject
virtual void PreloadNodes() {}

virtual void PreStartFlow();
virtual void StartFlow(IFlowDataPinValueSupplierInterface* DataPinValueSupplier = nullptr);
virtual void StartFlow(IFlowDataPinValueSupplierInterface* DataPinValueSupplier = nullptr, const FGuid& StartingNodeGuid = FGuid());

virtual void FinishFlow(const EFlowFinishPolicy InFinishPolicy, const bool bRemoveInstance = true);

Expand Down
2 changes: 1 addition & 1 deletion Source/Flow/Public/FlowSubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class FLOW_API UFlowSubsystem : public UGameInstanceSubsystem

/* Start the root Flow, graph that will eventually instantiate next Flow Graphs through the SubGraph node */
UFUNCTION(BlueprintCallable, Category = "FlowSubsystem", meta = (DefaultToSelf = "Owner"))
virtual void StartRootFlow(UObject* Owner, UFlowAsset* FlowAsset, const bool bAllowMultipleInstances = true);
virtual void StartRootFlow(UObject* Owner, UFlowAsset* FlowAsset, const bool bAllowMultipleInstances = true, const FGuid& StartingNodeGuid = FGuid());

virtual UFlowAsset* CreateRootFlow(UObject* Owner, UFlowAsset* FlowAsset, const bool bAllowMultipleInstances = true, const FString& NewInstanceName = FString());

Expand Down
1 change: 1 addition & 0 deletions Source/FlowEditor/Private/FlowEditorCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void FFlowGraphCommands::RegisterCommands()

UI_COMMAND(FocusViewport, "Focus Viewport", "Focus viewport on actor assigned to the node", EUserInterfaceActionType::Button, FInputChord());
UI_COMMAND(JumpToNodeDefinition, "Jump to Node Definition", "Jump to the node definition", EUserInterfaceActionType::Button, FInputChord());
UI_COMMAND(RunFromNode, "Run from this node", "Run the flow starting from this node", EUserInterfaceActionType::Button, FInputChord());
}

FFlowSpawnNodeCommands::FFlowSpawnNodeCommands()
Expand Down
37 changes: 36 additions & 1 deletion Source/FlowEditor/Private/Graph/FlowGraphEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

#include "Asset/FlowAssetEditor.h"
#include "FlowEditorCommands.h"
#include "FlowSubsystem.h"
#include "Graph/FlowGraphSchema.h"
#include "Graph/FlowGraphSchema_Actions.h"
#include "Graph/Nodes/FlowGraphNode.h"

#include "Engine/GameInstance.h"

#include "Debugger/FlowDebuggerSubsystem.h"

#include "EdGraphUtilities.h"
Expand Down Expand Up @@ -237,6 +241,10 @@ void SFlowGraphEditor::BindGraphCommands()
FExecuteAction::CreateSP(this, &SFlowGraphEditor::JumpToNodeDefinition),
FCanExecuteAction::CreateSP(this, &SFlowGraphEditor::CanJumpToNodeDefinition));

CommandList->MapAction(FlowGraphCommands.RunFromNode,
FExecuteAction::CreateSP(this, &SFlowGraphEditor::RunFromNode),
FCanExecuteAction::CreateSP(this, &SFlowGraphEditor::CanRunFromNode));

// Organisation Commands
CommandList->MapAction(GraphEditorCommands.AlignNodesTop,
FExecuteAction::CreateSP(this, &SFlowGraphEditor::OnAlignTop));
Expand Down Expand Up @@ -1451,7 +1459,34 @@ void SFlowGraphEditor::JumpToNodeDefinition() const

bool SFlowGraphEditor::CanJumpToNodeDefinition() const
{
return GetSelectedFlowNodes().Num() == 1;
return GetSelectedFlowNodes().Num() == 1 && GetSelectedFlowNodes().Array()[0]->CanJumpToDefinition();
}

void SFlowGraphEditor::RunFromNode() const
{
if (IsPIE())
{
const TSet<UFlowGraphNode*> SelectedNodes = GetSelectedFlowNodes();
if (SelectedNodes.Num() == 1)
{
if (const UFlowGraphNode* SelectedNode = SelectedNodes.Array()[0])
{
if (const UFlowNode* HelperNode = Cast<UFlowNode>(SelectedNode->GetFlowNodeBase()))
{
if (UFlowSubsystem* FlowSubsystem = GEditor->PlayWorld->GetGameInstance()->GetSubsystem<UFlowSubsystem>())
{
FlowSubsystem->AbortActiveFlows();
FlowSubsystem->StartRootFlow(GEditor->PlayWorld->GetGameInstance(), const_cast<UFlowAsset*>(FlowAsset.Get()), true, HelperNode->GetGuid());
}
}
}
}
}
}

bool SFlowGraphEditor::CanRunFromNode() const
{
return IsPIE() && GetSelectedFlowNodes().Num() == 1;
}

#undef LOCTEXT_NAMESPACE
5 changes: 5 additions & 0 deletions Source/FlowEditor/Private/Graph/Nodes/FlowGraphNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "FlowEditorCommands.h"
#include "Graph/FlowGraph.h"
#include "Graph/FlowGraphEditor.h"
#include "Graph/FlowGraphEditorSettings.h"
#include "Graph/FlowGraphSchema.h"
#include "Graph/FlowGraphSettings.h"
Expand Down Expand Up @@ -570,6 +571,10 @@ void UFlowGraphNode::GetNodeContextMenuActions(class UToolMenu* Menu, class UGra
{
Section.AddMenuEntry(FlowGraphCommands.JumpToNodeDefinition);
}
if (SFlowGraphEditor::IsPIE())
{
Section.AddMenuEntry(FlowGraphCommands.RunFromNode);
}
}

{
Expand Down
1 change: 1 addition & 0 deletions Source/FlowEditor/Public/FlowEditorCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class FLOWEDITOR_API FFlowGraphCommands : public TCommands<FFlowGraphCommands>
/** Jumps */
TSharedPtr<FUICommandInfo> FocusViewport;
TSharedPtr<FUICommandInfo> JumpToNodeDefinition;
TSharedPtr<FUICommandInfo> RunFromNode;

virtual void RegisterCommands() override;
};
Expand Down
3 changes: 3 additions & 0 deletions Source/FlowEditor/Public/Graph/FlowGraphEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,7 @@ class FLOWEDITOR_API SFlowGraphEditor : public SGraphEditor

void JumpToNodeDefinition() const;
bool CanJumpToNodeDefinition() const;

void RunFromNode() const;
bool CanRunFromNode() const;
};