|
|
@ -26,6 +26,27 @@ namespace Fungus |
|
|
|
public int index; |
|
|
|
public int index; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void DrawSequenceName(FungusScript fungusScript) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
serializedObject.Update(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SerializedProperty sequenceNameProperty = serializedObject.FindProperty("sequenceName"); |
|
|
|
|
|
|
|
Rect sequenceLabelRect = new Rect(45, 5, 120, 16); |
|
|
|
|
|
|
|
EditorGUI.LabelField(sequenceLabelRect, new GUIContent("Sequence Name")); |
|
|
|
|
|
|
|
Rect sequenceNameRect = new Rect(45, 21, 180, 16); |
|
|
|
|
|
|
|
EditorGUI.PropertyField(sequenceNameRect, sequenceNameProperty, new GUIContent("")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ensure sequence name is unique for this Fungus Script |
|
|
|
|
|
|
|
Sequence sequence = target as Sequence; |
|
|
|
|
|
|
|
string uniqueName = fungusScript.GetUniqueSequenceKey(sequenceNameProperty.stringValue, sequence); |
|
|
|
|
|
|
|
if (uniqueName != sequence.sequenceName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
sequenceNameProperty.stringValue = uniqueName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
serializedObject.ApplyModifiedProperties(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual void DrawSequenceGUI(FungusScript fungusScript) |
|
|
|
public virtual void DrawSequenceGUI(FungusScript fungusScript) |
|
|
|
{ |
|
|
|
{ |
|
|
|
serializedObject.Update(); |
|
|
|
serializedObject.Update(); |
|
|
@ -46,19 +67,6 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
UpdateIndentLevels(sequence); |
|
|
|
UpdateIndentLevels(sequence); |
|
|
|
|
|
|
|
|
|
|
|
SerializedProperty sequenceNameProperty = serializedObject.FindProperty("sequenceName"); |
|
|
|
|
|
|
|
Rect sequenceLabelRect = new Rect(45, 5, 120, 16); |
|
|
|
|
|
|
|
EditorGUI.LabelField(sequenceLabelRect, new GUIContent("Sequence Name")); |
|
|
|
|
|
|
|
Rect sequenceNameRect = new Rect(45, 21, 180, 16); |
|
|
|
|
|
|
|
EditorGUI.PropertyField(sequenceNameRect, sequenceNameProperty, new GUIContent("")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ensure sequence name is unique for this Fungus Script |
|
|
|
|
|
|
|
string uniqueName = fungusScript.GetUniqueSequenceKey(sequenceNameProperty.stringValue, sequence); |
|
|
|
|
|
|
|
if (uniqueName != sequence.sequenceName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
sequenceNameProperty.stringValue = uniqueName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure each command has a reference to its parent sequence |
|
|
|
// Make sure each command has a reference to its parent sequence |
|
|
|
foreach (Command command in sequence.commandList) |
|
|
|
foreach (Command command in sequence.commandList) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -82,23 +90,6 @@ namespace Fungus |
|
|
|
ShowContextMenu(); |
|
|
|
ShowContextMenu(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GUILayout.BeginHorizontal(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Previous Command |
|
|
|
|
|
|
|
if ((Event.current.type == EventType.keyDown) && (Event.current.keyCode == KeyCode.PageUp)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SelectPrevious(); |
|
|
|
|
|
|
|
GUI.FocusControl("dummycontrol"); |
|
|
|
|
|
|
|
Event.current.Use(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Next Command |
|
|
|
|
|
|
|
if ((Event.current.type == EventType.keyDown) && (Event.current.keyCode == KeyCode.PageDown)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SelectNext(); |
|
|
|
|
|
|
|
GUI.FocusControl("dummycontrol"); |
|
|
|
|
|
|
|
Event.current.Use(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (GUIUtility.keyboardControl == 0) //Only call keyboard shortcuts when not typing in a text field |
|
|
|
if (GUIUtility.keyboardControl == 0) //Only call keyboard shortcuts when not typing in a text field |
|
|
|
{ |
|
|
|
{ |
|
|
|
Event e = Event.current; |
|
|
|
Event e = Event.current; |
|
|
@ -111,6 +102,7 @@ namespace Fungus |
|
|
|
e.Use(); |
|
|
|
e.Use(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Copy") |
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Copy") |
|
|
|
{ |
|
|
|
{ |
|
|
|
Copy(); |
|
|
|
Copy(); |
|
|
@ -125,6 +117,7 @@ namespace Fungus |
|
|
|
e.Use(); |
|
|
|
e.Use(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Cut") |
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Cut") |
|
|
|
{ |
|
|
|
{ |
|
|
|
Cut(); |
|
|
|
Cut(); |
|
|
@ -140,6 +133,7 @@ namespace Fungus |
|
|
|
e.Use(); |
|
|
|
e.Use(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Paste") |
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Paste") |
|
|
|
{ |
|
|
|
{ |
|
|
|
Paste(); |
|
|
|
Paste(); |
|
|
@ -154,6 +148,7 @@ namespace Fungus |
|
|
|
e.Use(); |
|
|
|
e.Use(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Duplicate") |
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Duplicate") |
|
|
|
{ |
|
|
|
{ |
|
|
|
Copy(); |
|
|
|
Copy(); |
|
|
@ -169,6 +164,7 @@ namespace Fungus |
|
|
|
e.Use(); |
|
|
|
e.Use(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Delete") |
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "Delete") |
|
|
|
{ |
|
|
|
{ |
|
|
|
Delete(); |
|
|
|
Delete(); |
|
|
@ -180,6 +176,7 @@ namespace Fungus |
|
|
|
{ |
|
|
|
{ |
|
|
|
e.Use(); |
|
|
|
e.Use(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "SelectAll") |
|
|
|
if (e.type == EventType.ExecuteCommand && e.commandName == "SelectAll") |
|
|
|
{ |
|
|
|
{ |
|
|
|
SelectAll(); |
|
|
|
SelectAll(); |
|
|
@ -187,47 +184,6 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Up Button |
|
|
|
|
|
|
|
Texture2D upIcon = Resources.Load("Icons/up") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(upIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SelectPrevious(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Down Button |
|
|
|
|
|
|
|
Texture2D downIcon = Resources.Load("Icons/down") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(downIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SelectNext(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GUILayout.FlexibleSpace(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GUILayout.FlexibleSpace(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add Button |
|
|
|
|
|
|
|
Texture2D addIcon = Resources.Load("Icons/add") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(addIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ShowCommandMenu(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Duplicate Button |
|
|
|
|
|
|
|
Texture2D duplicateIcon = Resources.Load("Icons/duplicate") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(duplicateIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Copy(); |
|
|
|
|
|
|
|
Paste(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Delete Button |
|
|
|
|
|
|
|
Texture2D deleteIcon = Resources.Load("Icons/delete") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(deleteIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Delete(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GUILayout.EndHorizontal(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Remove any null entries in the command list. |
|
|
|
// Remove any null entries in the command list. |
|
|
@ -244,6 +200,66 @@ namespace Fungus |
|
|
|
serializedObject.ApplyModifiedProperties(); |
|
|
|
serializedObject.ApplyModifiedProperties(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void DrawButtonToolbar() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GUILayout.BeginHorizontal(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Previous Command |
|
|
|
|
|
|
|
if ((Event.current.type == EventType.keyDown) && (Event.current.keyCode == KeyCode.PageUp)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SelectPrevious(); |
|
|
|
|
|
|
|
GUI.FocusControl("dummycontrol"); |
|
|
|
|
|
|
|
Event.current.Use(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Next Command |
|
|
|
|
|
|
|
if ((Event.current.type == EventType.keyDown) && (Event.current.keyCode == KeyCode.PageDown)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SelectNext(); |
|
|
|
|
|
|
|
GUI.FocusControl("dummycontrol"); |
|
|
|
|
|
|
|
Event.current.Use(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Up Button |
|
|
|
|
|
|
|
Texture2D upIcon = Resources.Load("Icons/up") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(upIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SelectPrevious(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Down Button |
|
|
|
|
|
|
|
Texture2D downIcon = Resources.Load("Icons/down") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(downIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SelectNext(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GUILayout.FlexibleSpace(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add Button |
|
|
|
|
|
|
|
Texture2D addIcon = Resources.Load("Icons/add") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(addIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ShowCommandMenu(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Duplicate Button |
|
|
|
|
|
|
|
Texture2D duplicateIcon = Resources.Load("Icons/duplicate") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(duplicateIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Copy(); |
|
|
|
|
|
|
|
Paste(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Delete Button |
|
|
|
|
|
|
|
Texture2D deleteIcon = Resources.Load("Icons/delete") as Texture2D; |
|
|
|
|
|
|
|
if (GUILayout.Button(deleteIcon)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Delete(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GUILayout.EndHorizontal(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void DrawEventHandlerGUI(FungusScript fungusScript) |
|
|
|
protected void DrawEventHandlerGUI(FungusScript fungusScript) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Show available Event Handlers in a drop down list with type of current |
|
|
|
// Show available Event Handlers in a drop down list with type of current |
|
|
@ -454,7 +470,22 @@ namespace Fungus |
|
|
|
void ShowCommandMenu() |
|
|
|
void ShowCommandMenu() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Sequence sequence = target as Sequence; |
|
|
|
Sequence sequence = target as Sequence; |
|
|
|
int index = sequence.commandList.Count; |
|
|
|
|
|
|
|
|
|
|
|
FungusScript fungusScript = sequence.GetFungusScript(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Use index of last selected command in list, or end of list if nothing selected. |
|
|
|
|
|
|
|
int index = -1; |
|
|
|
|
|
|
|
foreach (Command command in fungusScript.selectedCommands) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (command.commandIndex + 1 > index) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
index = command.commandIndex + 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (index == -1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
index = sequence.commandList.Count; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GenericMenu commandMenu = new GenericMenu(); |
|
|
|
GenericMenu commandMenu = new GenericMenu(); |
|
|
|
|
|
|
|
|
|
|
@ -544,7 +575,7 @@ namespace Fungus |
|
|
|
Undo.RecordObject(sequence, "Set command type"); |
|
|
|
Undo.RecordObject(sequence, "Set command type"); |
|
|
|
if (commandOperation.index < sequence.commandList.Count - 1) |
|
|
|
if (commandOperation.index < sequence.commandList.Count - 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
sequence.commandList[commandOperation.index] = newCommand; |
|
|
|
sequence.commandList.Insert(commandOperation.index, newCommand); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|