From 9304dc54ac351edb018be6fc94b2561a69b71734 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Sun, 6 Sep 2015 21:57:51 +0100 Subject: [PATCH] Can filter the list of supported commands by subclassing Flowchart --- Assets/Fungus/Flowchart/Editor/BlockEditor.cs | 6 ++++++ Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs | 7 ++++++- Assets/Fungus/Flowchart/Scripts/Flowchart.cs | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs index 505c03e0..42d5479a 100644 --- a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs @@ -674,6 +674,12 @@ namespace Fungus foreach(var keyPair in filteredAttributes) { + // Skip command type if the Flowchart doesn't support it + if (!flowchart.IsCommandSupported(keyPair.Value)) + { + continue; + } + AddCommandOperation commandOperation = new AddCommandOperation(); commandOperation.block = block; diff --git a/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs b/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs index a457b255..bc5e2e76 100755 --- a/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs @@ -522,7 +522,12 @@ namespace Fungus { Block block = windowBlockMap[windowId]; Flowchart flowchart = block.GetFlowchart(); - + + if (flowchart == null) + { + return; + } + // Select block when node is clicked if (Event.current.button == 0 && Event.current.type == EventType.MouseDown && diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index e0359574..2178e1b1 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -838,6 +838,14 @@ namespace Fungus } } + /** + * Override this in a Flowchart subclass to filter which commands are shown in the Add Command list. + */ + public virtual bool IsCommandSupported(CommandInfoAttribute commandInfo) + { + return true; + } + public virtual string SubstituteVariables(string text) { string subbedText = text;