From b5081a530b49095066eb411c3435e05a643e1ce4 Mon Sep 17 00:00:00 2001 From: Inari Zushi Date: Thu, 21 Apr 2016 15:11:38 -0400 Subject: [PATCH] Add play command to context menu When only one command is selected, an option will pop up to "Play from Selected Command" --- Assets/Fungus/Flowchart/Editor/BlockEditor.cs | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs index 9bffe4f0..a1d3a856 100644 --- a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs @@ -790,13 +790,20 @@ namespace Fungus bool showCopy = false; bool showDelete = false; bool showPaste = false; - + bool showPlay = false; + if (flowchart.selectedCommands.Count > 0) { showCut = true; showCopy = true; showDelete = true; - } + if (flowchart.selectedCommands.Count == 1) + { + showPlay = true; + } + } + + CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance(); @@ -842,13 +849,22 @@ namespace Fungus { commandMenu.AddDisabledItem(new GUIContent ("Delete")); } - + + if (showPlay) + { + commandMenu.AddItem(new GUIContent("Play from Selected Command"), false, PlayCommand); + } + else + { + commandMenu.AddDisabledItem(new GUIContent("Play from Selected Command")); + } + commandMenu.AddSeparator(""); commandMenu.AddItem (new GUIContent ("Select All"), false, SelectAll); commandMenu.AddItem (new GUIContent ("Select None"), false, SelectNone); - - commandMenu.ShowAsContext(); + + commandMenu.ShowAsContext(); } protected void SelectAll() @@ -1029,7 +1045,15 @@ namespace Fungus Repaint(); } - protected void SelectPrevious() + protected void PlayCommand() + { + Block block = target as Block; + Flowchart flowchart = block.GetFlowchart(); + Command command = flowchart.selectedCommands[0]; + //block.Execute(null, command.commandIndex); + } + + protected void SelectPrevious() { Block block = target as Block; Flowchart flowchart = block.GetFlowchart();