Browse Source

Add play command to context menu

When only one command is selected, an option will pop up to "Play from
Selected Command"
master
Inari Zushi 9 years ago
parent
commit
b5081a530b
  1. 24
      Assets/Fungus/Flowchart/Editor/BlockEditor.cs

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

@ -790,14 +790,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)
{
showPlay = true;
}
} }
CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance(); CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance();
if (commandCopyBuffer.HasCommands()) if (commandCopyBuffer.HasCommands())
@ -843,6 +850,15 @@ namespace Fungus
commandMenu.AddDisabledItem(new GUIContent ("Delete")); 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.AddSeparator("");
commandMenu.AddItem (new GUIContent ("Select All"), false, SelectAll); commandMenu.AddItem (new GUIContent ("Select All"), false, SelectAll);
@ -1029,6 +1045,14 @@ namespace Fungus
Repaint(); Repaint();
} }
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() protected void SelectPrevious()
{ {
Block block = target as Block; Block block = target as Block;

Loading…
Cancel
Save