Browse Source

Merge pull request #460 from snozbot/pr/459

Pr/459
master
Chris Gregan 9 years ago
parent
commit
03bda18e28
  1. 38
      Assets/Fungus/Flowchart/Editor/BlockEditor.cs

38
Assets/Fungus/Flowchart/Editor/BlockEditor.cs

@ -767,14 +767,21 @@ namespace Fungus
bool showCopy = false; bool showCopy = false;
bool showDelete = false; bool showDelete = false;
bool showPaste = false; bool showPaste = false;
bool showPlay = false;
if (flowchart.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
showCut = true; showCut = true;
showCopy = true; showCopy = true;
showDelete = true; showDelete = true;
if (flowchart.selectedCommands.Count == 1 && Application.isPlaying)
{
showPlay = true;
}
} }
CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance(); CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance();
if (commandCopyBuffer.HasCommands()) if (commandCopyBuffer.HasCommands())
@ -820,6 +827,11 @@ namespace Fungus
commandMenu.AddDisabledItem(new GUIContent ("Delete")); commandMenu.AddDisabledItem(new GUIContent ("Delete"));
} }
if (showPlay)
{
commandMenu.AddItem(new GUIContent("Play from selected"), false, PlayCommand);
}
commandMenu.AddSeparator(""); commandMenu.AddSeparator("");
commandMenu.AddItem (new GUIContent ("Select All"), false, SelectAll); commandMenu.AddItem (new GUIContent ("Select All"), false, SelectAll);
@ -1006,6 +1018,32 @@ namespace Fungus
Repaint(); Repaint();
} }
protected void PlayCommand()
{
Block targetBlock = target as Block;
Flowchart flowchart = targetBlock.GetFlowchart();
Command command = flowchart.selectedCommands[0];
if (targetBlock.IsExecuting())
{
// The Block is already executing.
// Tell the Block to stop, wait a little while so the executing command has a
// chance to stop, and then start execution again from the new command.
targetBlock.Stop();
flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.commandIndex, 0.2f));
}
else
{
// Block isn't executing yet so can start it now.
flowchart.ExecuteBlock(targetBlock, command.commandIndex);
}
}
protected IEnumerator RunBlock(Flowchart flowchart, Block targetBlock, int commandIndex, float delay)
{
yield return new WaitForSeconds(delay);
flowchart.ExecuteBlock(targetBlock, commandIndex);
}
protected void SelectPrevious() protected void SelectPrevious()
{ {
Block block = target as Block; Block block = target as Block;

Loading…
Cancel
Save