From f68efa9772fe0cf004b5835acd72e98b4597b822 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 e6a060e4..122581b7 100644 --- a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs @@ -767,13 +767,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(); @@ -819,13 +826,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() @@ -1006,7 +1022,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();