Browse Source

Merge branch 'Rename-core-classes'

master
chrisgregan 10 years ago
parent
commit
5a931441d4
  1. 4
      Assets/Fungus/Camera/Editor/CameraMenuItems.cs
  2. 6
      Assets/Fungus/Camera/Editor/ViewEditor.cs
  3. 4
      Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs
  4. 2
      Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs
  5. 0
      Assets/Fungus/Flowchart.meta
  6. 0
      Assets/Fungus/Flowchart/Editor.meta
  7. 12
      Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs
  8. 0
      Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs.meta
  9. 14
      Assets/Fungus/Flowchart/Editor/CallEditor.cs
  10. 0
      Assets/Fungus/Flowchart/Editor/CallEditor.cs.meta
  11. 8
      Assets/Fungus/Flowchart/Editor/CommandEditor.cs
  12. 0
      Assets/Fungus/Flowchart/Editor/CommandEditor.cs.meta
  13. 62
      Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs
  14. 0
      Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs.meta
  15. 0
      Assets/Fungus/Flowchart/Editor/CustomGUI.cs
  16. 0
      Assets/Fungus/Flowchart/Editor/CustomGUI.cs.meta
  17. 0
      Assets/Fungus/Flowchart/Editor/EditorExtensions.cs
  18. 0
      Assets/Fungus/Flowchart/Editor/EditorExtensions.cs.meta
  19. 0
      Assets/Fungus/Flowchart/Editor/EditorZoomArea.cs
  20. 0
      Assets/Fungus/Flowchart/Editor/EditorZoomArea.cs.meta
  21. 2
      Assets/Fungus/Flowchart/Editor/EventHandlerEditor.cs
  22. 0
      Assets/Fungus/Flowchart/Editor/EventHandlerEditor.cs.meta
  23. 34
      Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs
  24. 0
      Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs.meta
  25. 8
      Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs
  26. 0
      Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs.meta
  27. 726
      Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs
  28. 0
      Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs.meta
  29. 26
      Assets/Fungus/Flowchart/Editor/FountainExporter.cs
  30. 0
      Assets/Fungus/Flowchart/Editor/FountainExporter.cs.meta
  31. 0
      Assets/Fungus/Flowchart/Editor/FungusEditorResources.cs
  32. 0
      Assets/Fungus/Flowchart/Editor/FungusEditorResources.cs.meta
  33. 0
      Assets/Fungus/Flowchart/Editor/GLDraw.cs
  34. 0
      Assets/Fungus/Flowchart/Editor/GLDraw.cs.meta
  35. 4
      Assets/Fungus/Flowchart/Editor/IfEditor.cs
  36. 0
      Assets/Fungus/Flowchart/Editor/IfEditor.cs.meta
  37. 2
      Assets/Fungus/Flowchart/Editor/JumpEditor.cs
  38. 0
      Assets/Fungus/Flowchart/Editor/JumpEditor.cs.meta
  39. 10
      Assets/Fungus/Flowchart/Editor/LabelEditor.cs
  40. 0
      Assets/Fungus/Flowchart/Editor/LabelEditor.cs.meta
  41. 0
      Assets/Fungus/Flowchart/Editor/Resources.meta
  42. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons.meta
  43. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/ResizeHandle.png
  44. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/ResizeHandle.png.meta
  45. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/add.png
  46. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/add.png.meta
  47. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/delete.png
  48. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/delete.png.meta
  49. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/down.png
  50. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/down.png.meta
  51. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/duplicate.png
  52. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/duplicate.png.meta
  53. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/left.png
  54. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/left.png.meta
  55. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/right.png
  56. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/right.png.meta
  57. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/up.png
  58. 0
      Assets/Fungus/Flowchart/Editor/Resources/Icons/up.png.meta
  59. 6
      Assets/Fungus/Flowchart/Editor/SendEventEditor.cs
  60. 0
      Assets/Fungus/Flowchart/Editor/SendEventEditor.cs.meta
  61. 337
      Assets/Fungus/Flowchart/Editor/SequenceEditor.cs
  62. 0
      Assets/Fungus/Flowchart/Editor/SequenceEditor.cs.meta
  63. 66
      Assets/Fungus/Flowchart/Editor/SequenceInspector.cs
  64. 0
      Assets/Fungus/Flowchart/Editor/SequenceInspector.cs.meta
  65. 4
      Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs
  66. 0
      Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs.meta
  67. 22
      Assets/Fungus/Flowchart/Editor/VariableEditor.cs
  68. 0
      Assets/Fungus/Flowchart/Editor/VariableEditor.cs.meta
  69. 16
      Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs
  70. 0
      Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs.meta
  71. 0
      Assets/Fungus/Flowchart/Resources.meta
  72. 4
      Assets/Fungus/Flowchart/Resources/Flowchart.prefab
  73. 0
      Assets/Fungus/Flowchart/Resources/Flowchart.prefab.meta
  74. 0
      Assets/Fungus/Flowchart/Scripts.meta
  75. 58
      Assets/Fungus/Flowchart/Scripts/Block.cs
  76. 0
      Assets/Fungus/Flowchart/Scripts/Block.cs.meta
  77. 64
      Assets/Fungus/Flowchart/Scripts/Command.cs
  78. 0
      Assets/Fungus/Flowchart/Scripts/Command.cs.meta
  79. 4
      Assets/Fungus/Flowchart/Scripts/CommandCopyBuffer.cs
  80. 0
      Assets/Fungus/Flowchart/Scripts/CommandCopyBuffer.cs.meta
  81. 0
      Assets/Fungus/Flowchart/Scripts/Commands.meta
  82. 4
      Assets/Fungus/Flowchart/Scripts/Commands/Break.cs
  83. 0
      Assets/Fungus/Flowchart/Scripts/Commands/Break.cs.meta
  84. 22
      Assets/Fungus/Flowchart/Scripts/Commands/Call.cs
  85. 0
      Assets/Fungus/Flowchart/Scripts/Commands/Call.cs.meta
  86. 0
      Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs
  87. 0
      Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs.meta
  88. 0
      Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs
  89. 0
      Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs.meta
  90. 6
      Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs
  91. 0
      Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs.meta
  92. 4
      Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs
  93. 0
      Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs.meta
  94. 0
      Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs
  95. 0
      Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs.meta
  96. 8
      Assets/Fungus/Flowchart/Scripts/Commands/Else.cs
  97. 0
      Assets/Fungus/Flowchart/Scripts/Commands/Else.cs.meta
  98. 10
      Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs
  99. 0
      Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs.meta
  100. 2
      Assets/Fungus/Flowchart/Scripts/Commands/End.cs
  101. Some files were not shown because too many files have changed in this diff Show More

4
Assets/Fungus/Camera/Editor/CameraMenuItems.cs

@ -1,4 +1,4 @@
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using System.Collections; using System.Collections;
@ -10,7 +10,7 @@ namespace Fungus
[MenuItem("Tools/Fungus/Create/View", false, 100)] [MenuItem("Tools/Fungus/Create/View", false, 100)]
static void CreateView() static void CreateView()
{ {
FungusScriptMenuItems.SpawnPrefab("View"); FlowchartMenuItems.SpawnPrefab("View");
} }
} }

6
Assets/Fungus/Camera/Editor/ViewEditor.cs

@ -164,10 +164,10 @@ namespace Fungus
bool highlight = Selection.activeGameObject == view.gameObject; bool highlight = Selection.activeGameObject == view.gameObject;
FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); Flowchart flowchart = FlowchartWindow.GetFlowchart();
if (fungusScript != null) if (flowchart != null)
{ {
foreach (Command command in fungusScript.selectedCommands) foreach (Command command in flowchart.selectedCommands)
{ {
MoveToView moveToViewCommand = command as MoveToView; MoveToView moveToViewCommand = command as MoveToView;
if (moveToViewCommand != null && if (moveToViewCommand != null &&

4
Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs

@ -6,7 +6,7 @@ namespace Fungus
{ {
[CommandInfo("Camera", [CommandInfo("Camera",
"Fade To View", "Fade To View",
"Fades the camera out and in again at a position specified by a View object. Select [Game Object > Fungus > Camera > View] to create a View object.")] "Fades the camera out and in again at a position specified by a View object.")]
[AddComponentMenu("")] [AddComponentMenu("")]
public class FadeToView : Command public class FadeToView : Command
{ {
@ -14,7 +14,7 @@ namespace Fungus
public float duration = 1f; public float duration = 1f;
[Tooltip("View to transition to when Fade is complete")] [Tooltip("View to transition to when Fade is complete")]
public Fungus.View targetView; public View targetView;
[Tooltip("Wait until the fade has finished before executing next command")] [Tooltip("Wait until the fade has finished before executing next command")]
public bool waitUntilFinished = true; public bool waitUntilFinished = true;

2
Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs

@ -6,7 +6,7 @@ namespace Fungus
{ {
[CommandInfo("Camera", [CommandInfo("Camera",
"Move To View", "Move To View",
"Moves the camera to a location specified by a View object. Select [Game Object > Fungus > Camera > View] to create a View object.")] "Moves the camera to a location specified by a View object.")]
[AddComponentMenu("")] [AddComponentMenu("")]
public class MoveToView : Command public class MoveToView : Command
{ {

0
Assets/Fungus/FungusScript.meta → Assets/Fungus/Flowchart.meta

0
Assets/Fungus/FungusScript/Editor.meta → Assets/Fungus/Flowchart/Editor.meta

12
Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs → Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs

@ -8,7 +8,7 @@ using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/** /**
* Prevents saving of selected sequence and commands to avoid version control conflicts * Prevents saving of selected blocks and commands to avoid version control conflicts
*/ */
public class AssetModProcessor : UnityEditor.AssetModificationProcessor public class AssetModProcessor : UnityEditor.AssetModificationProcessor
{ {
@ -30,13 +30,13 @@ namespace Fungus
} }
// Reset these variables before save so that they won't cause a git conflict // Reset these variables before save so that they won't cause a git conflict
FungusScript[] allFungusScripts = UnityEngine.Object.FindObjectsOfType<FungusScript>(); Flowchart[] flowcharts = UnityEngine.Object.FindObjectsOfType<Flowchart>();
foreach (FungusScript fs in allFungusScripts) foreach (Flowchart f in flowcharts)
{ {
if (!fs.saveSelection) if (!f.saveSelection)
{ {
fs.selectedSequence = null; f.selectedBlock = null;
fs.ClearSelectedCommands(); f.ClearSelectedCommands();
} }
} }

0
Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs.meta → Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs.meta

14
Assets/Fungus/FungusScript/Editor/CallEditor.cs → Assets/Fungus/Flowchart/Editor/CallEditor.cs

@ -8,11 +8,11 @@ namespace Fungus
[CustomEditor (typeof(Call))] [CustomEditor (typeof(Call))]
public class CallEditor : CommandEditor public class CallEditor : CommandEditor
{ {
protected SerializedProperty targetSequenceProp; protected SerializedProperty targetBlockProp;
protected virtual void OnEnable() protected virtual void OnEnable()
{ {
targetSequenceProp = serializedObject.FindProperty("targetSequence"); targetBlockProp = serializedObject.FindProperty("targetBlock");
} }
public override void DrawCommandGUI() public override void DrawCommandGUI()
@ -21,16 +21,16 @@ namespace Fungus
Call t = target as Call; Call t = target as Call;
FungusScript fungusScript = t.GetFungusScript(); Flowchart flowchart = t.GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }
SequenceEditor.SequenceField(targetSequenceProp, BlockEditor.BlockField(targetBlockProp,
new GUIContent("Target Sequence", "Sequence to call"), new GUIContent("Target Block", "Block to call"),
new GUIContent("<Continue>"), new GUIContent("<Continue>"),
fungusScript); flowchart);
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }

0
Assets/Fungus/FungusScript/Editor/CallEditor.cs.meta → Assets/Fungus/Flowchart/Editor/CallEditor.cs.meta

8
Assets/Fungus/FungusScript/Editor/CommandEditor.cs → Assets/Fungus/Flowchart/Editor/CommandEditor.cs

@ -35,8 +35,8 @@ namespace Fungus
return; return;
} }
FungusScript fungusScript = t.GetFungusScript(); Flowchart flowchart = t.GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }
@ -51,7 +51,7 @@ namespace Fungus
if (t.enabled) if (t.enabled)
{ {
if (fungusScript.colorCommands) if (flowchart.colorCommands)
{ {
GUI.backgroundColor = t.GetButtonColor(); GUI.backgroundColor = t.GetButtonColor();
} }
@ -117,7 +117,7 @@ namespace Fungus
// http://answers.unity3d.com/questions/550829/how-to-add-a-script-field-in-custom-inspector.html // http://answers.unity3d.com/questions/550829/how-to-add-a-script-field-in-custom-inspector.html
// Users should not be able to change the MonoScript for the command using the usual Script field. // Users should not be able to change the MonoScript for the command using the usual Script field.
// Doing so could cause sequence.commandList to contain null entries. // Doing so could cause block.commandList to contain null entries.
// To avoid this we manually display all properties, except for m_Script. // To avoid this we manually display all properties, except for m_Script.
serializedObject.Update(); serializedObject.Update();
SerializedProperty iterator = serializedObject.GetIterator(); SerializedProperty iterator = serializedObject.GetIterator();

0
Assets/Fungus/FungusScript/Editor/CommandEditor.cs.meta → Assets/Fungus/Flowchart/Editor/CommandEditor.cs.meta

62
Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs → Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs

@ -81,22 +81,22 @@ namespace Fungus
Command AddNewCommand() Command AddNewCommand()
{ {
FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); Flowchart flowchart = FlowchartWindow.GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return null; return null;
} }
Sequence sequence = fungusScript.selectedSequence; Block block = flowchart.selectedBlock;
if (sequence == null) if (block == null)
{ {
return null; return null;
} }
Command newCommand = Undo.AddComponent<Comment>(sequence.gameObject) as Command; Command newCommand = Undo.AddComponent<Comment>(block.gameObject) as Command;
newCommand.commandId = fungusScript.NextCommandId(); newCommand.commandId = flowchart.NextCommandId();
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
fungusScript.AddSelectedCommand(newCommand); flowchart.AddSelectedCommand(newCommand);
return newCommand; return newCommand;
} }
@ -106,11 +106,11 @@ namespace Fungus
Command command = _arrayProperty.GetArrayElementAtIndex(index).objectReferenceValue as Command; Command command = _arrayProperty.GetArrayElementAtIndex(index).objectReferenceValue as Command;
// Add the command as a new component // Add the command as a new component
Sequence parentSequence = command.GetComponent<Sequence>(); Block parentBlock = command.GetComponent<Block>();
System.Type type = command.GetType(); System.Type type = command.GetType();
Command newCommand = Undo.AddComponent(parentSequence.gameObject, type) as Command; Command newCommand = Undo.AddComponent(parentBlock.gameObject, type) as Command;
newCommand.commandId = newCommand.GetFungusScript().NextCommandId(); newCommand.commandId = newCommand.GetFlowchart().NextCommandId();
System.Reflection.FieldInfo[] fields = type.GetFields(); System.Reflection.FieldInfo[] fields = type.GetFields();
foreach (System.Reflection.FieldInfo field in fields) foreach (System.Reflection.FieldInfo field in fields)
{ {
@ -161,8 +161,8 @@ namespace Fungus
return; return;
} }
FungusScript fungusScript = command.GetFungusScript(); Flowchart flowchart = command.GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }
@ -195,7 +195,7 @@ namespace Fungus
} }
bool commandIsSelected = false; bool commandIsSelected = false;
foreach (Command selectedCommand in fungusScript.selectedCommands) foreach (Command selectedCommand in flowchart.selectedCommands)
{ {
if (selectedCommand == command) if (selectedCommand == command)
{ {
@ -244,37 +244,37 @@ namespace Fungus
Event.current.button == 0 && Event.current.button == 0 &&
position.Contains(Event.current.mousePosition)) position.Contains(Event.current.mousePosition))
{ {
if (fungusScript.selectedCommands.Contains(command) && Event.current.button == 0) if (flowchart.selectedCommands.Contains(command) && Event.current.button == 0)
{ {
// Left click on already selected command // Left click on already selected command
// Command key and shift key is not pressed // Command key and shift key is not pressed
if (!EditorGUI.actionKey && !Event.current.shift) if (!EditorGUI.actionKey && !Event.current.shift)
{ {
fungusScript.selectedCommands.Remove(command); flowchart.selectedCommands.Remove(command);
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
} }
// Command key pressed // Command key pressed
if (EditorGUI.actionKey) if (EditorGUI.actionKey)
{ {
fungusScript.selectedCommands.Remove(command); flowchart.selectedCommands.Remove(command);
} }
// Shift key pressed // Shift key pressed
if (Event.current.shift) if (Event.current.shift)
{ {
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
if (pinShiftToTop) if (pinShiftToTop)
{ {
for (int i = firstSelectedIndex; i < index+1; ++i) for (int i = firstSelectedIndex; i < index+1; ++i)
{ {
fungusScript.AddSelectedCommand(fungusScript.selectedSequence.commandList[i]); flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[i]);
} }
} }
else else
{ {
for (int i = index; i < lastSelectedIndex+1; ++i) for (int i = index; i < lastSelectedIndex+1; ++i)
{ {
fungusScript.AddSelectedCommand(fungusScript.selectedSequence.commandList[i]); flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[i]);
} }
} }
} }
@ -284,22 +284,22 @@ namespace Fungus
// Left click and no command key // Left click and no command key
if (!Event.current.shift && !EditorGUI.actionKey && Event.current.button == 0) if (!Event.current.shift && !EditorGUI.actionKey && Event.current.button == 0)
{ {
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
} }
fungusScript.AddSelectedCommand(command); flowchart.AddSelectedCommand(command);
bool firstSelectedCommandFound = false; bool firstSelectedCommandFound = false;
if (fungusScript.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
if ( fungusScript.selectedSequence != null) if ( flowchart.selectedBlock != null)
{ {
for (int i = 0; i < fungusScript.selectedSequence.commandList.Count; i++) for (int i = 0; i < flowchart.selectedBlock.commandList.Count; i++)
{ {
Command commandInSequence = fungusScript.selectedSequence.commandList[i]; Command commandInBlock = flowchart.selectedBlock.commandList[i];
foreach (Command selectedCommand in fungusScript.selectedCommands) foreach (Command selectedCommand in flowchart.selectedCommands)
{ {
if (commandInSequence == selectedCommand) if (commandInBlock == selectedCommand)
{ {
if (!firstSelectedCommandFound) if (!firstSelectedCommandFound)
{ {
@ -317,7 +317,7 @@ namespace Fungus
{ {
for (int i = firstSelectedIndex; i < lastSelectedIndex; ++i) for (int i = firstSelectedIndex; i < lastSelectedIndex; ++i)
{ {
fungusScript.AddSelectedCommand(fungusScript.selectedSequence.commandList[i]); flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[i]);
} }
} }
if (index == firstSelectedIndex) if (index == firstSelectedIndex)
@ -333,7 +333,7 @@ namespace Fungus
} }
Color commandLabelColor = Color.white; Color commandLabelColor = Color.white;
if (fungusScript.colorCommands) if (flowchart.colorCommands)
{ {
commandLabelColor = command.GetButtonColor(); commandLabelColor = command.GetButtonColor();
} }

0
Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs.meta → Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs.meta

0
Assets/Fungus/FungusScript/Editor/CustomGUI.cs → Assets/Fungus/Flowchart/Editor/CustomGUI.cs

0
Assets/Fungus/FungusScript/Editor/CustomGUI.cs.meta → Assets/Fungus/Flowchart/Editor/CustomGUI.cs.meta

0
Assets/Fungus/FungusScript/Editor/EditorExtensions.cs → Assets/Fungus/Flowchart/Editor/EditorExtensions.cs

0
Assets/Fungus/FungusScript/Editor/EditorExtensions.cs.meta → Assets/Fungus/Flowchart/Editor/EditorExtensions.cs.meta

0
Assets/Fungus/FungusScript/Editor/EditorZoomArea.cs → Assets/Fungus/Flowchart/Editor/EditorZoomArea.cs

0
Assets/Fungus/FungusScript/Editor/EditorZoomArea.cs.meta → Assets/Fungus/Flowchart/Editor/EditorZoomArea.cs.meta

2
Assets/Fungus/FungusScript/Editor/EventHandlerEditor.cs → Assets/Fungus/Flowchart/Editor/EventHandlerEditor.cs

@ -31,7 +31,7 @@ namespace Fungus
public virtual void DrawInspectorGUI() public virtual void DrawInspectorGUI()
{ {
// Users should not be able to change the MonoScript for the command using the usual Script field. // Users should not be able to change the MonoScript for the command using the usual Script field.
// Doing so could cause sequence.commandList to contain null entries. // Doing so could cause block.commandList to contain null entries.
// To avoid this we manually display all properties, except for m_Script. // To avoid this we manually display all properties, except for m_Script.
serializedObject.Update(); serializedObject.Update();
SerializedProperty iterator = serializedObject.GetIterator(); SerializedProperty iterator = serializedObject.GetIterator();

0
Assets/Fungus/FungusScript/Editor/EventHandlerEditor.cs.meta → Assets/Fungus/Flowchart/Editor/EventHandlerEditor.cs.meta

34
Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs → Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs

@ -9,12 +9,12 @@ using System.IO;
namespace Fungus namespace Fungus
{ {
[CustomEditor (typeof(FungusScript))] [CustomEditor (typeof(Flowchart))]
public class FungusScriptEditor : Editor public class FlowchartEditor : Editor
{ {
protected class AddVariableInfo protected class AddVariableInfo
{ {
public FungusScript fungusScript; public Flowchart flowchart;
public System.Type variableType; public System.Type variableType;
} }
@ -39,9 +39,9 @@ namespace Fungus
{ {
serializedObject.Update(); serializedObject.Update();
FungusScript fungusScript = target as FungusScript; Flowchart flowchart = target as Flowchart;
fungusScript.UpdateHideFlags(); flowchart.UpdateHideFlags();
EditorGUILayout.PropertyField(descriptionProp); EditorGUILayout.PropertyField(descriptionProp);
EditorGUILayout.PropertyField(colorCommandsProp); EditorGUILayout.PropertyField(colorCommandsProp);
@ -51,17 +51,17 @@ namespace Fungus
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
if (GUILayout.Button("Open Editor")) if (GUILayout.Button("Flowchart Window"))
{ {
EditorWindow.GetWindow(typeof(FungusScriptWindow), false, "Fungus Script"); EditorWindow.GetWindow(typeof(FlowchartWindow), false, "Flowchart");
} }
if (GUILayout.Button(new GUIContent("Export Text", "Export all story text in .fountain format."))) if (GUILayout.Button(new GUIContent("Export Text", "Export all story text in .fountain format.")))
{ {
FountainExporter.ExportStrings(fungusScript); FountainExporter.ExportStrings(flowchart);
} }
if (GUILayout.Button(new GUIContent("Import Text", "Import story text from a file in .fountain format."))) if (GUILayout.Button(new GUIContent("Import Text", "Import story text from a file in .fountain format.")))
{ {
FountainExporter.ImportStrings(fungusScript); FountainExporter.ImportStrings(flowchart);
} }
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
@ -74,7 +74,7 @@ namespace Fungus
{ {
serializedObject.Update(); serializedObject.Update();
FungusScript t = target as FungusScript; Flowchart t = target as Flowchart;
if (t.variables.Count == 0) if (t.variables.Count == 0)
{ {
@ -160,7 +160,7 @@ namespace Fungus
} }
AddVariableInfo addVariableInfo = new AddVariableInfo(); AddVariableInfo addVariableInfo = new AddVariableInfo();
addVariableInfo.fungusScript = t; addVariableInfo.flowchart = t;
addVariableInfo.variableType = type; addVariableInfo.variableType = type;
GUIContent typeName = new GUIContent(variableInfo.VariableType); GUIContent typeName = new GUIContent(variableInfo.VariableType);
@ -179,7 +179,7 @@ namespace Fungus
} }
AddVariableInfo info = new AddVariableInfo(); AddVariableInfo info = new AddVariableInfo();
info.fungusScript = t; info.flowchart = t;
info.variableType = type; info.variableType = type;
GUIContent typeName = new GUIContent(variableInfo.Category + "/" + variableInfo.VariableType); GUIContent typeName = new GUIContent(variableInfo.Category + "/" + variableInfo.VariableType);
@ -202,13 +202,13 @@ namespace Fungus
return; return;
} }
FungusScript fungusScript = addVariableInfo.fungusScript; Flowchart flowchart = addVariableInfo.flowchart;
System.Type variableType = addVariableInfo.variableType; System.Type variableType = addVariableInfo.variableType;
Undo.RecordObject(fungusScript, "Add Variable"); Undo.RecordObject(flowchart, "Add Variable");
Variable newVariable = fungusScript.gameObject.AddComponent(variableType) as Variable; Variable newVariable = flowchart.gameObject.AddComponent(variableType) as Variable;
newVariable.key = fungusScript.GetUniqueVariableKey(""); newVariable.key = flowchart.GetUniqueVariableKey("");
fungusScript.variables.Add(newVariable); flowchart.variables.Add(newVariable);
} }
public static List<System.Type> FindAllDerivedTypes<T>() public static List<System.Type> FindAllDerivedTypes<T>()

0
Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs.meta → Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs.meta

8
Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs → Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs

@ -6,12 +6,12 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
public class FungusScriptMenuItems public class FlowchartMenuItems
{ {
[MenuItem("Tools/Fungus/Create/Fungus Script", false, 0)] [MenuItem("Tools/Fungus/Create/Flowchart", false, 0)]
static void CreateFungusScript() static void CreateFlowchart()
{ {
SpawnPrefab("FungusScript"); SpawnPrefab("Flowchart");
} }
public static GameObject SpawnPrefab(string prefabName) public static GameObject SpawnPrefab(string prefabName)

0
Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs.meta → Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs.meta

726
Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs

@ -0,0 +1,726 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
public class FlowchartWindow : EditorWindow
{
public static List<Block> deleteList = new List<Block>();
protected List<Block> windowBlockMap = new List<Block>();
// The ReorderableList control doesn't drag properly when used with GUI.DragWindow(),
// so we just implement dragging ourselves.
protected int dragWindowId = -1;
protected Vector2 startDragPosition;
protected const float minZoomValue = 0.25f;
protected const float maxZoomValue = 1f;
protected GUIStyle nodeStyle = new GUIStyle();
protected static BlockInspector blockInspector;
public const float playIconFadeTime = 0.5f;
protected bool mouseOverVariables = false;
protected int forceRepaintCount;
[MenuItem("Tools/Fungus/Flowchart Window")]
static void Init()
{
GetWindow(typeof(FlowchartWindow), false, "Flowchart");
}
protected virtual void OnEnable()
{
// All block nodes use the same GUIStyle, but with a different background
nodeStyle.border.left = 20;
nodeStyle.border.right = 20;
nodeStyle.border.top = 5;
nodeStyle.border.bottom = 5;
nodeStyle.padding.left = 20;
nodeStyle.padding.right = 20;
nodeStyle.padding.top = 5;
nodeStyle.padding.bottom = 5;
nodeStyle.contentOffset = Vector2.zero;
nodeStyle.alignment = TextAnchor.MiddleCenter;
nodeStyle.wordWrap = true;
}
protected virtual void OnInspectorUpdate()
{
// Ensure the Block Inspector is always showing the currently selected block
Flowchart flowchart = GetFlowchart();
if (flowchart == null)
{
return;
}
if (flowchart.selectedBlock != null)
{
if (blockInspector == null)
{
ShowBlockInspector(flowchart);
}
blockInspector.block = flowchart.selectedBlock;
}
forceRepaintCount--;
forceRepaintCount = Math.Max(0, forceRepaintCount);
Repaint();
}
static public Flowchart GetFlowchart()
{
// Using a temp hidden object to track the active Flowchart across
// serialization / deserialization when playing the game in the editor.
FungusState fungusState = GameObject.FindObjectOfType<FungusState>();
if (fungusState == null)
{
GameObject go = new GameObject("_FungusState");
go.hideFlags = HideFlags.HideInHierarchy;
fungusState = go.AddComponent<FungusState>();
}
if (Selection.activeGameObject != null)
{
Flowchart fs = Selection.activeGameObject.GetComponent<Flowchart>();
if (fs != null)
{
fungusState.selectedFlowchart = fs;
}
}
return fungusState.selectedFlowchart;
}
protected virtual void OnGUI()
{
Flowchart flowchart = GetFlowchart();
if (flowchart == null)
{
GUILayout.Label("No Flowchart scene object selected");
return;
}
// Delete any scheduled objects
foreach (Block deleteBlock in deleteList)
{
bool isSelected = (flowchart.selectedBlock == deleteBlock);
foreach (Command command in deleteBlock.commandList)
{
Undo.DestroyObjectImmediate(command);
}
Undo.DestroyObjectImmediate(deleteBlock);
flowchart.ClearSelectedCommands();
if (isSelected)
{
// Revert to showing properties for the Flowchart
Selection.activeGameObject = flowchart.gameObject;
}
}
deleteList.Clear();
DrawFlowchartView(flowchart);
DrawOverlay(flowchart);
if (forceRepaintCount > 0)
{
// Redraw on next frame to get crisp refresh rate
Repaint();
}
}
protected virtual void DrawOverlay(Flowchart flowchart)
{
GUILayout.Space(8);
GUILayout.BeginHorizontal();
GUILayout.Space(8);
if (GUILayout.Button(new GUIContent(FungusEditorResources.texAddButton, "Add a new block")))
{
Vector2 newNodePosition = new Vector2(50 - flowchart.scrollPos.x,
50 - flowchart.scrollPos.y);
CreateBlock(flowchart, newNodePosition);
}
GUILayout.Space(8);
flowchart.zoom = GUILayout.HorizontalSlider(flowchart.zoom, minZoomValue, maxZoomValue, GUILayout.Width(100));
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.BeginVertical(GUILayout.Width(440));
GUILayout.FlexibleSpace();
flowchart.variablesScrollPos = GUILayout.BeginScrollView(flowchart.variablesScrollPos, GUILayout.MaxHeight(position.height * 0.75f));
GUILayout.FlexibleSpace();
GUILayout.Space(8);
FlowchartEditor flowchartEditor = Editor.CreateEditor (flowchart) as FlowchartEditor;
flowchartEditor.DrawVariablesGUI();
DestroyImmediate(flowchartEditor);
Rect variableWindowRect = GUILayoutUtility.GetLastRect();
if (flowchart.variablesExpanded &&
flowchart.variables.Count > 0)
{
variableWindowRect.y -= 20;
variableWindowRect.height += 20;
}
if (Event.current.type == EventType.Repaint)
{
mouseOverVariables = variableWindowRect.Contains(Event.current.mousePosition);
}
GUILayout.EndScrollView();
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.Label(flowchart.name, EditorStyles.whiteBoldLabel);
if (flowchart.description.Length > 0)
{
GUILayout.Label(flowchart.description, EditorStyles.whiteLargeLabel);
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
protected virtual void DrawFlowchartView(Flowchart flowchart)
{
Block[] blocks = flowchart.GetComponentsInChildren<Block>(true);
foreach (Block block in blocks)
{
flowchart.scrollViewRect.xMin = Mathf.Min(flowchart.scrollViewRect.xMin, block.nodeRect.xMin - 400);
flowchart.scrollViewRect.xMax = Mathf.Max(flowchart.scrollViewRect.xMax, block.nodeRect.xMax + 400);
flowchart.scrollViewRect.yMin = Mathf.Min(flowchart.scrollViewRect.yMin, block.nodeRect.yMin - 400);
flowchart.scrollViewRect.yMax = Mathf.Max(flowchart.scrollViewRect.yMax, block.nodeRect.yMax + 400);
}
// Calc rect for script view
Rect scriptViewRect = new Rect(0, 0, this.position.width / flowchart.zoom, this.position.height / flowchart.zoom);
EditorZoomArea.Begin(flowchart.zoom, scriptViewRect);
DrawGrid(flowchart);
GLDraw.BeginGroup(scriptViewRect);
if (Event.current.button == 0 &&
Event.current.type == EventType.MouseDown &&
!mouseOverVariables)
{
flowchart.selectedBlock = null;
if (!EditorGUI.actionKey)
{
flowchart.ClearSelectedCommands();
}
Selection.activeGameObject = flowchart.gameObject;
}
// Draw connections
foreach (Block block in blocks)
{
DrawConnections(flowchart, block, false);
}
foreach (Block block in blocks)
{
DrawConnections(flowchart, block, true);
}
GUIStyle windowStyle = new GUIStyle();
windowStyle.stretchHeight = true;
BeginWindows();
windowBlockMap.Clear();
for (int i = 0; i < blocks.Length; ++i)
{
Block block = blocks[i];
float nodeWidthA = nodeStyle.CalcSize(new GUIContent(block.blockName)).x + 10;
float nodeWidthB = 0f;
if (block.eventHandler != null)
{
nodeWidthB = nodeStyle.CalcSize(new GUIContent(block.eventHandler.GetSummary())).x + 10;
}
block.nodeRect.width = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120);
block.nodeRect.height = 40;
if (Event.current.button == 0)
{
if (Event.current.type == EventType.MouseDrag && dragWindowId == i)
{
block.nodeRect.x += Event.current.delta.x;
block.nodeRect.y += Event.current.delta.y;
forceRepaintCount = 6;
}
else if (Event.current.type == EventType.MouseUp &&
dragWindowId == i)
{
Vector2 newPos = new Vector2(block.nodeRect.x, block.nodeRect.y);
block.nodeRect.x = startDragPosition.x;
block.nodeRect.y = startDragPosition.y;
Undo.RecordObject(block, "Node Position");
block.nodeRect.x = newPos.x;
block.nodeRect.y = newPos.y;
dragWindowId = -1;
forceRepaintCount = 6;
}
}
Rect windowRect = new Rect(block.nodeRect);
windowRect.x += flowchart.scrollPos.x;
windowRect.y += flowchart.scrollPos.y;
GUILayout.Window(i, windowRect, DrawWindow, "", windowStyle);
GUI.backgroundColor = Color.white;
windowBlockMap.Add(block);
}
EndWindows();
// Draw play icons beside all executing blocks
if (Application.isPlaying)
{
foreach (Block s in blocks)
{
if (s.IsExecuting())
{
s.executingIconTimer = playIconFadeTime;
forceRepaintCount = 6;
}
if (s.executingIconTimer > 0f)
{
s.executingIconTimer = Mathf.Max(s.executingIconTimer - Time.deltaTime, 0f);
Rect rect = new Rect(s.nodeRect);
rect.x += flowchart.scrollPos.x - 37;
rect.y += flowchart.scrollPos.y + 3;
rect.width = 34;
rect.height = 34;
if (!s.IsExecuting() && s.executingIconTimer < playIconFadeTime)
{
float alpha = s.executingIconTimer / playIconFadeTime;
GUI.color = new Color(1f, 1f, 1f, alpha);
}
if (GUI.Button(rect, FungusEditorResources.texPlayBig as Texture, new GUIStyle()))
{
SelectBlock(flowchart, s);
}
GUI.color = Color.white;
}
}
}
// Right click to drag view
if (Event.current.button == 1 && Event.current.type == EventType.MouseDrag)
{
flowchart.scrollPos += Event.current.delta;
forceRepaintCount = 6;
}
else if (Event.current.type == EventType.ScrollWheel)
{
flowchart.zoom -= Event.current.delta.y * 0.01f;
flowchart.zoom = Mathf.Clamp(flowchart.zoom, minZoomValue, maxZoomValue);
forceRepaintCount = 6;
}
GLDraw.EndGroup();
EditorZoomArea.End();
}
protected virtual void DrawGrid(Flowchart flowchart)
{
float width = this.position.width / flowchart.zoom;
float height = this.position.height / flowchart.zoom;
// Match background color of scene view
if (EditorGUIUtility.isProSkin)
{
GUI.color = new Color32(71, 71, 71, 255);
}
else
{
GUI.color = new Color32(86, 86, 86, 255);
}
GUI.DrawTexture( new Rect(0,0, width, height), EditorGUIUtility.whiteTexture );
GUI.color = Color.white;
Color color = new Color32(96, 96, 96, 255);
float gridSize = 128f;
float x = flowchart.scrollPos.x % gridSize;
while (x < width)
{
GLDraw.DrawLine(new Vector2(x, 0), new Vector2(x, height), color, 1f);
x += gridSize;
}
float y = (flowchart.scrollPos.y % gridSize);
while (y < height)
{
if (y >= 0)
{
GLDraw.DrawLine(new Vector2(0, y), new Vector2(width, y), color, 1f);
}
y += gridSize;
}
}
protected virtual void SelectBlock(Flowchart flowchart, Block block)
{
// Select the block and also select currently executing command
ShowBlockInspector(flowchart);
flowchart.selectedBlock = block;
flowchart.ClearSelectedCommands();
if (block.activeCommand != null)
{
flowchart.AddSelectedCommand(block.activeCommand);
}
}
public static Block CreateBlock(Flowchart flowchart, Vector2 position)
{
Block newBlock = flowchart.CreateBlock(position);
Undo.RegisterCreatedObjectUndo(newBlock, "New Block");
ShowBlockInspector(flowchart);
flowchart.selectedBlock = newBlock;
flowchart.ClearSelectedCommands();
return newBlock;
}
protected virtual void DeleteBlock(Flowchart flowchart, Block block)
{
foreach (Command command in block.commandList)
{
Undo.DestroyObjectImmediate(command);
}
Undo.DestroyObjectImmediate(block);
flowchart.ClearSelectedCommands();
}
protected virtual void DrawWindow(int windowId)
{
Block block = windowBlockMap[windowId];
Flowchart flowchart = block.GetFlowchart();
// Select block when node is clicked
if (Event.current.button == 0 &&
Event.current.type == EventType.MouseDown &&
!mouseOverVariables)
{
// Check if might be start of a window drag
if (Event.current.button == 0)
{
dragWindowId = windowId;
startDragPosition.x = block.nodeRect.x;
startDragPosition.y = block.nodeRect.y;
}
if (windowId < windowBlockMap.Count)
{
Undo.RecordObject(flowchart, "Select");
SelectBlock(flowchart, block);
GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus)
}
}
bool selected = (flowchart.selectedBlock == block);
GUIStyle nodeStyleCopy = new GUIStyle(nodeStyle);
if (block.eventHandler != null)
{
nodeStyleCopy.normal.background = selected ? FungusEditorResources.texEventNodeOn : FungusEditorResources.texEventNodeOff;
}
else
{
// Count the number of unique connections (excluding self references)
List<Block> uniqueList = new List<Block>();
List<Block> connectedBlocks = block.GetConnectedBlocks();
foreach (Block connectedBlock in connectedBlocks)
{
if (connectedBlock == block ||
uniqueList.Contains(connectedBlock))
{
continue;
}
uniqueList.Add(connectedBlock);
}
if (uniqueList.Count > 1)
{
nodeStyleCopy.normal.background = selected ? FungusEditorResources.texChoiceNodeOn : FungusEditorResources.texChoiceNodeOff;
}
else
{
nodeStyleCopy.normal.background = selected ? FungusEditorResources.texProcessNodeOn : FungusEditorResources.texProcessNodeOff;
}
}
nodeStyleCopy.normal.textColor = Color.black;
// Show event handler name, or a custom summary if one is provided
string nodeName = "";
if (block.eventHandler != null)
{
string handlerSummary = block.eventHandler.GetSummary();
if (handlerSummary == "")
{
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block.eventHandler.GetType());
if (info != null)
{
handlerSummary = info.EventHandlerName;
}
}
nodeName = "(" + handlerSummary + ")\n";
}
nodeName += block.blockName;
// Make sure node is wide enough to fit the node name text
float width = nodeStyleCopy.CalcSize(new GUIContent(nodeName)).x;
block.nodeRect.width = Mathf.Max (block.nodeRect.width, width);
GUI.backgroundColor = Color.white;
GUILayout.Box(nodeName, nodeStyleCopy, GUILayout.Width(block.nodeRect.width), GUILayout.Height(block.nodeRect.height));
if (block.description.Length > 0)
{
GUIStyle descriptionStyle = new GUIStyle(EditorStyles.whiteLabel);
descriptionStyle.wordWrap = true;
GUILayout.Label(block.description, descriptionStyle);
}
if (Event.current.type == EventType.ContextClick)
{
GenericMenu menu = new GenericMenu ();
menu.AddItem(new GUIContent ("Duplicate"), false, DuplicateBlock, block);
menu.AddItem(new GUIContent ("Delete"), false, DeleteBlock, block);
menu.ShowAsContext();
}
}
protected virtual void DrawConnections(Flowchart flowchart, Block block, bool highlightedOnly)
{
if (block == null)
{
return;
}
List<Block> connectedBlocks = new List<Block>();
bool blockIsSelected = (flowchart.selectedBlock == block);
foreach (Command command in block.commandList)
{
if (command == null)
{
continue;
}
bool commandIsSelected = false;
foreach (Command selectedCommand in flowchart.selectedCommands)
{
if (selectedCommand == command)
{
commandIsSelected = true;
break;
}
}
bool highlight = command.IsExecuting() || (blockIsSelected && commandIsSelected);
if (highlightedOnly && !highlight ||
!highlightedOnly && highlight)
{
continue;
}
connectedBlocks.Clear();
command.GetConnectedBlocks(ref connectedBlocks);
foreach (Block blockB in connectedBlocks)
{
if (blockB == null ||
block == blockB ||
blockB.GetFlowchart() != flowchart)
{
continue;
}
Rect startRect = new Rect(block.nodeRect);
startRect.x += flowchart.scrollPos.x;
startRect.y += flowchart.scrollPos.y;
Rect endRect = new Rect(blockB.nodeRect);
endRect.x += flowchart.scrollPos.x;
endRect.y += flowchart.scrollPos.y;
DrawRectConnection(startRect, endRect, highlight);
}
}
}
protected virtual void DrawRectConnection(Rect rectA, Rect rectB, bool highlight)
{
Vector2[] pointsA = new Vector2[] {
new Vector2(rectA.xMin + 5, rectA.center.y),
new Vector2(rectA.xMin + rectA.width / 2, rectA.yMin + 2),
new Vector2(rectA.xMin + rectA.width / 2, rectA.yMax - 2),
new Vector2(rectA.xMax - 5, rectA.center.y)
};
Vector2[] pointsB = new Vector2[] {
new Vector2(rectB.xMin + 5, rectB.center.y),
new Vector2(rectB.xMin + rectB.width / 2, rectB.yMin + 2),
new Vector2(rectB.xMin + rectB.width / 2, rectB.yMax - 2),
new Vector2(rectB.xMax - 5, rectB.center.y)
};
Vector2 pointA = Vector2.zero;
Vector2 pointB = Vector2.zero;
float minDist = float.MaxValue;
foreach (Vector2 a in pointsA)
{
foreach (Vector2 b in pointsB)
{
float d = Vector2.Distance(a, b);
if (d < minDist)
{
pointA = a;
pointB = b;
minDist = d;
}
}
}
Color color = Color.grey;
if (highlight)
{
color = Color.green;
}
GLDraw.DrawConnectingCurve(pointA, pointB, color, 1.025f);
Rect dotARect = new Rect(pointA.x - 5, pointA.y - 5, 10, 10);
GUI.Label(dotARect, "", new GUIStyle("U2D.dragDotActive"));
Rect dotBRect = new Rect(pointB.x - 5, pointB.y - 5, 10, 10);
GUI.Label(dotBRect, "", new GUIStyle("U2D.dragDotActive"));
}
public static void DeleteBlock(object obj)
{
Block block = obj as Block;
FlowchartWindow.deleteList.Add(block);
}
protected static void DuplicateBlock(object obj)
{
Flowchart flowchart = GetFlowchart();
Block block = obj as Block;
Vector2 newPosition = new Vector2(block.nodeRect.position.x +
block.nodeRect.width + 20,
block.nodeRect.y);
Block oldBlock = block;
Block newBlock = FlowchartWindow.CreateBlock(flowchart, newPosition);
newBlock.blockName = flowchart.GetUniqueBlockKey(oldBlock.blockName + " (Copy)");
Undo.RecordObject(newBlock, "Duplicate Block");
foreach (Command command in oldBlock.commandList)
{
System.Type type = command.GetType();
Command newCommand = Undo.AddComponent(flowchart.gameObject, type) as Command;
System.Reflection.FieldInfo[] fields = type.GetFields();
foreach (System.Reflection.FieldInfo field in fields)
{
field.SetValue(newCommand, field.GetValue(command));
}
newCommand.commandId = flowchart.NextCommandId();
newBlock.commandList.Add(newCommand);
}
if (oldBlock.eventHandler != null)
{
EventHandler eventHandler = oldBlock.eventHandler;
System.Type type = eventHandler.GetType();
EventHandler newEventHandler = Undo.AddComponent(flowchart.gameObject, type) as EventHandler;
System.Reflection.FieldInfo[] fields = type.GetFields();
foreach (System.Reflection.FieldInfo field in fields)
{
field.SetValue(newEventHandler, field.GetValue(eventHandler));
}
newEventHandler.parentBlock = newBlock;
newBlock.eventHandler = newEventHandler;
}
}
protected static void ShowBlockInspector(Flowchart flowchart)
{
if (blockInspector == null)
{
// Create a Scriptable Object with a custom editor which we can use to inspect the selected block.
// Editors for Scriptable Objects display using the full height of the inspector window.
blockInspector = ScriptableObject.CreateInstance<BlockInspector>() as BlockInspector;
blockInspector.hideFlags = HideFlags.DontSave;
}
Selection.activeObject = blockInspector;
EditorUtility.SetDirty(blockInspector);
}
}
}

0
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs.meta → Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs.meta

26
Assets/Fungus/FungusScript/Editor/FountainExporter.cs → Assets/Fungus/Flowchart/Editor/FountainExporter.cs

@ -1,4 +1,4 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -17,15 +17,15 @@ namespace Fungus
public class FountainExporter public class FountainExporter
{ {
public static void ExportStrings(FungusScript fungusScript) public static void ExportStrings(Flowchart flowchart)
{ {
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }
string path = EditorUtility.SaveFilePanel("Export strings", "", string path = EditorUtility.SaveFilePanel("Export strings", "",
fungusScript.name + ".txt", ""); flowchart.name + ".txt", "");
if(path.Length == 0) if(path.Length == 0)
{ {
@ -34,17 +34,17 @@ namespace Fungus
// Write out character names // Write out character names
string exportText = "Title: " + fungusScript.name + "\n"; string exportText = "Title: " + flowchart.name + "\n";
exportText += "Draft date: " + System.DateTime.Today.ToString("d") + "\n"; exportText += "Draft date: " + System.DateTime.Today.ToString("d") + "\n";
exportText += "\n"; exportText += "\n";
// In every sequence, write out Say & Menu text in order // In every block, write out Say & Menu text in order
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>(); Block[] blocks = flowchart.GetComponentsInChildren<Block>();
foreach (Sequence s in sequences) foreach (Block block in blocks)
{ {
// Check for any Say, Menu or Comment commands // Check for any Say, Menu or Comment commands
bool hasText = false; bool hasText = false;
foreach (Command c in s.commandList) foreach (Command c in block.commandList)
{ {
System.Type t = c.GetType(); System.Type t = c.GetType();
if (t == typeof(Say) || if (t == typeof(Say) ||
@ -59,9 +59,9 @@ namespace Fungus
continue; continue;
} }
exportText += "." + s.sequenceName.ToUpper() + "\n\n"; exportText += "." + block.blockName.ToUpper() + "\n\n";
foreach (Command c in s.commandList) foreach (Command c in block.commandList)
{ {
if (c.GetType() == typeof(Say)) if (c.GetType() == typeof(Say))
{ {
@ -124,7 +124,7 @@ namespace Fungus
File.WriteAllText(path, exportText); File.WriteAllText(path, exportText);
} }
public static void ImportStrings(FungusScript fungusScript) public static void ImportStrings(Flowchart flowchart)
{ {
string path = EditorUtility.OpenFilePanel("Import strings", "", ""); string path = EditorUtility.OpenFilePanel("Import strings", "", "");
@ -140,7 +140,7 @@ namespace Fungus
// Build dict of commands // Build dict of commands
Dictionary<int, Command> commandDict = new Dictionary<int, Command>(); Dictionary<int, Command> commandDict = new Dictionary<int, Command>();
foreach (Command c in fungusScript.gameObject.GetComponentsInChildren<Command>()) foreach (Command c in flowchart.gameObject.GetComponentsInChildren<Command>())
{ {
commandDict.Add (c.commandId, c); commandDict.Add (c.commandId, c);
} }

0
Assets/Fungus/FungusScript/Editor/FountainExporter.cs.meta → Assets/Fungus/Flowchart/Editor/FountainExporter.cs.meta

0
Assets/Fungus/FungusScript/Editor/FungusEditorResources.cs → Assets/Fungus/Flowchart/Editor/FungusEditorResources.cs

0
Assets/Fungus/FungusScript/Editor/FungusEditorResources.cs.meta → Assets/Fungus/Flowchart/Editor/FungusEditorResources.cs.meta

0
Assets/Fungus/FungusScript/Editor/GLDraw.cs → Assets/Fungus/Flowchart/Editor/GLDraw.cs

0
Assets/Fungus/FungusScript/Editor/GLDraw.cs.meta → Assets/Fungus/Flowchart/Editor/GLDraw.cs.meta

4
Assets/Fungus/FungusScript/Editor/IfEditor.cs → Assets/Fungus/Flowchart/Editor/IfEditor.cs

@ -33,8 +33,8 @@ namespace Fungus
If t = target as If; If t = target as If;
FungusScript fungusScript = t.GetFungusScript(); Flowchart flowchart = t.GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }

0
Assets/Fungus/FungusScript/Editor/IfEditor.cs.meta → Assets/Fungus/Flowchart/Editor/IfEditor.cs.meta

2
Assets/Fungus/FungusScript/Editor/JumpEditor.cs → Assets/Fungus/Flowchart/Editor/JumpEditor.cs

@ -23,7 +23,7 @@ namespace Fungus
LabelEditor.LabelField(targetLabelProp, LabelEditor.LabelField(targetLabelProp,
new GUIContent("Target Label", "Label to jump to"), new GUIContent("Target Label", "Label to jump to"),
t.parentSequence); t.parentBlock);
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }

0
Assets/Fungus/FungusScript/Editor/JumpEditor.cs.meta → Assets/Fungus/Flowchart/Editor/JumpEditor.cs.meta

10
Assets/Fungus/FungusScript/Editor/LabelEditor.cs → Assets/Fungus/Flowchart/Editor/LabelEditor.cs

@ -15,7 +15,7 @@ namespace Fungus
static public void LabelField(SerializedProperty property, static public void LabelField(SerializedProperty property,
GUIContent labelText, GUIContent labelText,
Sequence sequence) Block block)
{ {
List<string> labelKeys = new List<string>(); List<string> labelKeys = new List<string>();
List<Label> labelObjects = new List<Label>(); List<Label> labelObjects = new List<Label>();
@ -27,7 +27,7 @@ namespace Fungus
int index = 0; int index = 0;
int selectedIndex = 0; int selectedIndex = 0;
foreach (Command command in sequence.commandList) foreach (Command command in block.commandList)
{ {
Label label = command as Label; Label label = command as Label;
if (label == null) if (label == null)
@ -60,8 +60,8 @@ namespace Fungus
{ {
Label t = target as Label; Label t = target as Label;
FungusScript fungusScript = t.GetFungusScript(); Flowchart flowchart = t.GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }
@ -69,7 +69,7 @@ namespace Fungus
serializedObject.Update(); serializedObject.Update();
EditorGUILayout.PropertyField(keyProp); EditorGUILayout.PropertyField(keyProp);
keyProp.stringValue = fungusScript.GetUniqueLabelKey(keyProp.stringValue, t); keyProp.stringValue = flowchart.GetUniqueLabelKey(keyProp.stringValue, t);
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }

0
Assets/Fungus/FungusScript/Editor/LabelEditor.cs.meta → Assets/Fungus/Flowchart/Editor/LabelEditor.cs.meta

0
Assets/Fungus/FungusScript/Editor/Resources.meta → Assets/Fungus/Flowchart/Editor/Resources.meta

0
Assets/Fungus/FungusScript/Editor/Resources/Icons.meta → Assets/Fungus/Flowchart/Editor/Resources/Icons.meta

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/ResizeHandle.png → Assets/Fungus/Flowchart/Editor/Resources/Icons/ResizeHandle.png

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/ResizeHandle.png.meta → Assets/Fungus/Flowchart/Editor/Resources/Icons/ResizeHandle.png.meta

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/add.png → Assets/Fungus/Flowchart/Editor/Resources/Icons/add.png

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/add.png.meta → Assets/Fungus/Flowchart/Editor/Resources/Icons/add.png.meta

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/delete.png → Assets/Fungus/Flowchart/Editor/Resources/Icons/delete.png

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/delete.png.meta → Assets/Fungus/Flowchart/Editor/Resources/Icons/delete.png.meta

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/down.png → Assets/Fungus/Flowchart/Editor/Resources/Icons/down.png

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/down.png.meta → Assets/Fungus/Flowchart/Editor/Resources/Icons/down.png.meta

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/duplicate.png → Assets/Fungus/Flowchart/Editor/Resources/Icons/duplicate.png

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/duplicate.png.meta → Assets/Fungus/Flowchart/Editor/Resources/Icons/duplicate.png.meta

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/left.png → Assets/Fungus/Flowchart/Editor/Resources/Icons/left.png

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/left.png.meta → Assets/Fungus/Flowchart/Editor/Resources/Icons/left.png.meta

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/right.png → Assets/Fungus/Flowchart/Editor/Resources/Icons/right.png

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/right.png.meta → Assets/Fungus/Flowchart/Editor/Resources/Icons/right.png.meta

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/up.png → Assets/Fungus/Flowchart/Editor/Resources/Icons/up.png

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
Assets/Fungus/FungusScript/Editor/Resources/Icons/up.png.meta → Assets/Fungus/Flowchart/Editor/Resources/Icons/up.png.meta

6
Assets/Fungus/FungusScript/Editor/SendEventEditor.cs → Assets/Fungus/Flowchart/Editor/SendEventEditor.cs

@ -10,12 +10,12 @@ namespace Fungus
public class SendEventEditor : CommandEditor public class SendEventEditor : CommandEditor
{ {
protected SerializedProperty targetEventProp; protected SerializedProperty targetEventProp;
protected SerializedProperty stopCurrentScriptProp; protected SerializedProperty stopCurrentFlowchartProp;
protected virtual void OnEnable() protected virtual void OnEnable()
{ {
targetEventProp = serializedObject.FindProperty("targetEvent"); targetEventProp = serializedObject.FindProperty("targetEvent");
stopCurrentScriptProp = serializedObject.FindProperty("stopCurrentScript"); stopCurrentFlowchartProp = serializedObject.FindProperty("stopCurrentFlowchart");
} }
public override void DrawCommandGUI() public override void DrawCommandGUI()
@ -29,7 +29,7 @@ namespace Fungus
serializedObject.Update(); serializedObject.Update();
EditorGUILayout.PropertyField(targetEventProp); EditorGUILayout.PropertyField(targetEventProp);
EditorGUILayout.PropertyField(stopCurrentScriptProp); EditorGUILayout.PropertyField(stopCurrentFlowchartProp);
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }

0
Assets/Fungus/FungusScript/Editor/SendEventEditor.cs.meta → Assets/Fungus/Flowchart/Editor/SendEventEditor.cs.meta

337
Assets/Fungus/FungusScript/Editor/SequenceEditor.cs → Assets/Fungus/Flowchart/Editor/SequenceEditor.cs

@ -11,52 +11,52 @@ using System.IO;
namespace Fungus namespace Fungus
{ {
[CustomEditor (typeof(Sequence))] [CustomEditor (typeof(Block))]
public class SequenceEditor : Editor public class BlockEditor : Editor
{ {
protected class SetEventHandlerOperation protected class SetEventHandlerOperation
{ {
public Sequence sequence; public Block block;
public Type eventHandlerType; public Type eventHandlerType;
} }
protected class AddCommandOperation protected class AddCommandOperation
{ {
public Sequence sequence; public Block block;
public Type commandType; public Type commandType;
public int index; public int index;
} }
public virtual void DrawSequenceName(FungusScript fungusScript) public virtual void DrawBlockName(Flowchart flowchart)
{ {
serializedObject.Update(); serializedObject.Update();
SerializedProperty sequenceNameProperty = serializedObject.FindProperty("sequenceName"); SerializedProperty blockNameProperty = serializedObject.FindProperty("blockName");
Rect sequenceLabelRect = new Rect(45, 5, 120, 16); Rect blockLabelRect = new Rect(45, 5, 120, 16);
EditorGUI.LabelField(sequenceLabelRect, new GUIContent("Sequence Name")); EditorGUI.LabelField(blockLabelRect, new GUIContent("Block Name"));
Rect sequenceNameRect = new Rect(45, 21, 180, 16); Rect blockNameRect = new Rect(45, 21, 180, 16);
EditorGUI.PropertyField(sequenceNameRect, sequenceNameProperty, new GUIContent("")); EditorGUI.PropertyField(blockNameRect, blockNameProperty, new GUIContent(""));
// Ensure sequence name is unique for this Fungus Script // Ensure block name is unique for this Flowchart
Sequence sequence = target as Sequence; Block block = target as Block;
string uniqueName = fungusScript.GetUniqueSequenceKey(sequenceNameProperty.stringValue, sequence); string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block);
if (uniqueName != sequence.sequenceName) if (uniqueName != block.blockName)
{ {
sequenceNameProperty.stringValue = uniqueName; blockNameProperty.stringValue = uniqueName;
} }
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
public virtual void DrawSequenceGUI(FungusScript fungusScript) public virtual void DrawBlockGUI(Flowchart flowchart)
{ {
serializedObject.Update(); serializedObject.Update();
Sequence sequence = target as Sequence; Block block = target as Block;
SerializedProperty commandListProperty = serializedObject.FindProperty("commandList"); SerializedProperty commandListProperty = serializedObject.FindProperty("commandList");
if (sequence == fungusScript.selectedSequence) if (block == flowchart.selectedBlock)
{ {
SerializedProperty descriptionProp = serializedObject.FindProperty("description"); SerializedProperty descriptionProp = serializedObject.FindProperty("description");
EditorGUILayout.PropertyField(descriptionProp); EditorGUILayout.PropertyField(descriptionProp);
@ -64,32 +64,36 @@ namespace Fungus
SerializedProperty runSlowInEditorProp = serializedObject.FindProperty("runSlowInEditor"); SerializedProperty runSlowInEditorProp = serializedObject.FindProperty("runSlowInEditor");
EditorGUILayout.PropertyField(runSlowInEditorProp); EditorGUILayout.PropertyField(runSlowInEditorProp);
DrawEventHandlerGUI(fungusScript); DrawEventHandlerGUI(flowchart);
UpdateIndentLevels(sequence); UpdateIndentLevels(block);
// Make sure each command has a reference to its parent sequence // Make sure each command has a reference to its parent block
foreach (Command command in sequence.commandList) foreach (Command command in block.commandList)
{ {
if (command == null) // Will be deleted from the list later on if (command == null) // Will be deleted from the list later on
{ {
continue; continue;
} }
command.parentSequence = sequence; command.parentBlock = block;
} }
ReorderableListGUI.Title("Commands"); ReorderableListGUI.Title("Commands");
CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0); CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0);
adaptor.nodeRect = sequence.nodeRect; adaptor.nodeRect = block.nodeRect;
ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu; ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu;
ReorderableListControl.DrawControlFromState(adaptor, null, flags); ReorderableListControl.DrawControlFromState(adaptor, null, flags);
<<<<<<< HEAD:Assets/Fungus/FungusScript/Editor/SequenceEditor.cs
// EventType.contextClick doesn't register since we moved the Sequence Editor to be inside // EventType.contextClick doesn't register since we moved the Sequence Editor to be inside
// a GUI Area, no idea why. As a workaround we just check for right click instead. // a GUI Area, no idea why. As a workaround we just check for right click instead.
if (Event.current.type == EventType.mouseUp && if (Event.current.type == EventType.mouseUp &&
Event.current.button == 1) Event.current.button == 1)
=======
if (Event.current.type == EventType.ContextClick)
>>>>>>> Rename-core-classes:Assets/Fungus/Flowchart/Editor/SequenceEditor.cs
{ {
ShowContextMenu(); ShowContextMenu();
} }
@ -101,7 +105,7 @@ namespace Fungus
// Copy keyboard shortcut // Copy keyboard shortcut
if (e.type == EventType.ValidateCommand && e.commandName == "Copy") if (e.type == EventType.ValidateCommand && e.commandName == "Copy")
{ {
if (fungusScript.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
e.Use(); e.Use();
} }
@ -116,7 +120,7 @@ namespace Fungus
// Cut keyboard shortcut // Cut keyboard shortcut
if (e.type == EventType.ValidateCommand && e.commandName == "Cut") if (e.type == EventType.ValidateCommand && e.commandName == "Cut")
{ {
if (fungusScript.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
e.Use(); e.Use();
} }
@ -147,7 +151,7 @@ namespace Fungus
// Duplicate keyboard shortcut // Duplicate keyboard shortcut
if (e.type == EventType.ValidateCommand && e.commandName == "Duplicate") if (e.type == EventType.ValidateCommand && e.commandName == "Duplicate")
{ {
if (fungusScript.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
e.Use(); e.Use();
} }
@ -163,7 +167,7 @@ namespace Fungus
// Delete keyboard shortcut // Delete keyboard shortcut
if (e.type == EventType.ValidateCommand && e.commandName == "Delete") if (e.type == EventType.ValidateCommand && e.commandName == "Delete")
{ {
if (fungusScript.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
e.Use(); e.Use();
} }
@ -264,17 +268,17 @@ namespace Fungus
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
} }
protected void DrawEventHandlerGUI(FungusScript fungusScript) protected void DrawEventHandlerGUI(Flowchart flowchart)
{ {
// 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
// event handler selected. // event handler selected.
List<System.Type> eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList(); List<System.Type> eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList();
Sequence sequence = target as Sequence; Block block = target as Block;
System.Type currentType = null; System.Type currentType = null;
if (sequence.eventHandler != null) if (block.eventHandler != null)
{ {
currentType = sequence.eventHandler.GetType(); currentType = block.eventHandler.GetType();
} }
string currentHandlerName = "<None>"; string currentHandlerName = "<None>";
@ -289,7 +293,7 @@ namespace Fungus
if (GUILayout.Button(new GUIContent(currentHandlerName), EditorStyles.popup)) if (GUILayout.Button(new GUIContent(currentHandlerName), EditorStyles.popup))
{ {
SetEventHandlerOperation noneOperation = new SetEventHandlerOperation(); SetEventHandlerOperation noneOperation = new SetEventHandlerOperation();
noneOperation.sequence = sequence; noneOperation.block = block;
noneOperation.eventHandlerType = null; noneOperation.eventHandlerType = null;
GenericMenu eventHandlerMenu = new GenericMenu(); GenericMenu eventHandlerMenu = new GenericMenu();
@ -302,7 +306,7 @@ namespace Fungus
if (info.Category.Length == 0) if (info.Category.Length == 0)
{ {
SetEventHandlerOperation operation = new SetEventHandlerOperation(); SetEventHandlerOperation operation = new SetEventHandlerOperation();
operation.sequence = sequence; operation.block = block;
operation.eventHandlerType = type; operation.eventHandlerType = type;
eventHandlerMenu.AddItem(new GUIContent(info.EventHandlerName), false, OnSelectEventHandler, operation); eventHandlerMenu.AddItem(new GUIContent(info.EventHandlerName), false, OnSelectEventHandler, operation);
@ -316,7 +320,7 @@ namespace Fungus
if (info.Category.Length > 0) if (info.Category.Length > 0)
{ {
SetEventHandlerOperation operation = new SetEventHandlerOperation(); SetEventHandlerOperation operation = new SetEventHandlerOperation();
operation.sequence = sequence; operation.block = block;
operation.eventHandlerType = type; operation.eventHandlerType = type;
string typeName = info.Category + "/" + info.EventHandlerName; string typeName = info.Category + "/" + info.EventHandlerName;
eventHandlerMenu.AddItem(new GUIContent(typeName), false, OnSelectEventHandler, operation); eventHandlerMenu.AddItem(new GUIContent(typeName), false, OnSelectEventHandler, operation);
@ -328,9 +332,9 @@ namespace Fungus
} }
EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal();
if (sequence.eventHandler != null) if (block.eventHandler != null)
{ {
EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(sequence.eventHandler) as EventHandlerEditor; EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(block.eventHandler) as EventHandlerEditor;
eventHandlerEditor.DrawInspectorGUI(); eventHandlerEditor.DrawInspectorGUI();
DestroyImmediate(eventHandlerEditor); DestroyImmediate(eventHandlerEditor);
} }
@ -339,32 +343,32 @@ namespace Fungus
protected void OnSelectEventHandler(object obj) protected void OnSelectEventHandler(object obj)
{ {
SetEventHandlerOperation operation = obj as SetEventHandlerOperation; SetEventHandlerOperation operation = obj as SetEventHandlerOperation;
Sequence sequence = operation.sequence; Block block = operation.block;
System.Type selectedType = operation.eventHandlerType; System.Type selectedType = operation.eventHandlerType;
if (sequence == null) if (block == null)
{ {
return; return;
} }
Undo.RecordObject(sequence, "Set Start Event"); Undo.RecordObject(block, "Set Event Handler");
if (sequence.eventHandler != null) if (block.eventHandler != null)
{ {
Undo.DestroyObjectImmediate(sequence.eventHandler); Undo.DestroyObjectImmediate(block.eventHandler);
} }
if (selectedType != null) if (selectedType != null)
{ {
EventHandler newHandler = Undo.AddComponent(sequence.gameObject, selectedType) as EventHandler; EventHandler newHandler = Undo.AddComponent(block.gameObject, selectedType) as EventHandler;
newHandler.parentSequence = sequence; newHandler.parentBlock = block;
sequence.eventHandler = newHandler; block.eventHandler = newHandler;
} }
} }
protected virtual void UpdateIndentLevels(Sequence sequence) protected virtual void UpdateIndentLevels(Block block)
{ {
int indentLevel = 0; int indentLevel = 0;
foreach(Command command in sequence.commandList) foreach(Command command in block.commandList)
{ {
if (command == null) if (command == null)
{ {
@ -384,77 +388,77 @@ namespace Fungus
} }
} }
static public void SequenceField(SerializedProperty property, GUIContent label, GUIContent nullLabel, FungusScript fungusScript) static public void BlockField(SerializedProperty property, GUIContent label, GUIContent nullLabel, Flowchart flowchart)
{ {
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }
Sequence sequence = property.objectReferenceValue as Sequence; Block block = property.objectReferenceValue as Block;
// Build dictionary of child sequences // Build dictionary of child blocks
List<GUIContent> sequenceNames = new List<GUIContent>(); List<GUIContent> blockNames = new List<GUIContent>();
int selectedIndex = 0; int selectedIndex = 0;
sequenceNames.Add(nullLabel); blockNames.Add(nullLabel);
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>(true); Block[] blocks = flowchart.GetComponentsInChildren<Block>(true);
for (int i = 0; i < sequences.Length; ++i) for (int i = 0; i < blocks.Length; ++i)
{ {
sequenceNames.Add(new GUIContent(sequences[i].sequenceName)); blockNames.Add(new GUIContent(blocks[i].blockName));
if (sequence == sequences[i]) if (block == blocks[i])
{ {
selectedIndex = i + 1; selectedIndex = i + 1;
} }
} }
selectedIndex = EditorGUILayout.Popup(label, selectedIndex, sequenceNames.ToArray()); selectedIndex = EditorGUILayout.Popup(label, selectedIndex, blockNames.ToArray());
if (selectedIndex == 0) if (selectedIndex == 0)
{ {
sequence = null; // Option 'None' block = null; // Option 'None'
} }
else else
{ {
sequence = sequences[selectedIndex - 1]; block = blocks[selectedIndex - 1];
} }
property.objectReferenceValue = sequence; property.objectReferenceValue = block;
} }
static public Sequence SequenceField(Rect position, GUIContent nullLabel, FungusScript fungusScript, Sequence sequence) static public Block BlockField(Rect position, GUIContent nullLabel, Flowchart flowchart, Block block)
{ {
if (fungusScript == null) if (flowchart == null)
{ {
return null; return null;
} }
Sequence result = sequence; Block result = block;
// Build dictionary of child sequences // Build dictionary of child blocks
List<GUIContent> sequenceNames = new List<GUIContent>(); List<GUIContent> blockNames = new List<GUIContent>();
int selectedIndex = 0; int selectedIndex = 0;
sequenceNames.Add(nullLabel); blockNames.Add(nullLabel);
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>(); Block[] blocks = flowchart.GetComponentsInChildren<Block>();
for (int i = 0; i < sequences.Length; ++i) for (int i = 0; i < blocks.Length; ++i)
{ {
sequenceNames.Add(new GUIContent(sequences[i].name)); blockNames.Add(new GUIContent(blocks[i].name));
if (sequence == sequences[i]) if (block == blocks[i])
{ {
selectedIndex = i + 1; selectedIndex = i + 1;
} }
} }
selectedIndex = EditorGUI.Popup(position, selectedIndex, sequenceNames.ToArray()); selectedIndex = EditorGUI.Popup(position, selectedIndex, blockNames.ToArray());
if (selectedIndex == 0) if (selectedIndex == 0)
{ {
result = null; // Option 'None' result = null; // Option 'None'
} }
else else
{ {
result = sequences[selectedIndex - 1]; result = blocks[selectedIndex - 1];
} }
return result; return result;
@ -507,13 +511,13 @@ namespace Fungus
void ShowCommandMenu() void ShowCommandMenu()
{ {
Sequence sequence = target as Sequence; Block block = target as Block;
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
// Use index of last selected command in list, or end of list if nothing selected. // Use index of last selected command in list, or end of list if nothing selected.
int index = -1; int index = -1;
foreach (Command command in fungusScript.selectedCommands) foreach (Command command in flowchart.selectedCommands)
{ {
if (command.commandIndex + 1 > index) if (command.commandIndex + 1 > index)
{ {
@ -522,7 +526,7 @@ namespace Fungus
} }
if (index == -1) if (index == -1)
{ {
index = sequence.commandList.Count; index = block.commandList.Count;
} }
GenericMenu commandMenu = new GenericMenu(); GenericMenu commandMenu = new GenericMenu();
@ -537,7 +541,7 @@ namespace Fungus
{ {
AddCommandOperation commandOperation = new AddCommandOperation(); AddCommandOperation commandOperation = new AddCommandOperation();
commandOperation.sequence = sequence; commandOperation.block = block;
commandOperation.commandType = keyPair.Key; commandOperation.commandType = keyPair.Key;
commandOperation.index = index; commandOperation.index = index;
@ -592,41 +596,41 @@ namespace Fungus
{ {
AddCommandOperation commandOperation = obj as AddCommandOperation; AddCommandOperation commandOperation = obj as AddCommandOperation;
Sequence sequence = commandOperation.sequence; Block block = commandOperation.block;
if (sequence == null) if (block == null)
{ {
return; return;
} }
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
Command newCommand = Undo.AddComponent(sequence.gameObject, commandOperation.commandType) as Command; Command newCommand = Undo.AddComponent(block.gameObject, commandOperation.commandType) as Command;
sequence.GetFungusScript().AddSelectedCommand(newCommand); block.GetFlowchart().AddSelectedCommand(newCommand);
newCommand.parentSequence = sequence; newCommand.parentBlock = block;
newCommand.commandId = fungusScript.NextCommandId(); newCommand.commandId = flowchart.NextCommandId();
// Let command know it has just been added to the sequence // Let command know it has just been added to the block
newCommand.OnCommandAdded(sequence); newCommand.OnCommandAdded(block);
Undo.RecordObject(sequence, "Set command type"); Undo.RecordObject(block, "Set command type");
if (commandOperation.index < sequence.commandList.Count - 1) if (commandOperation.index < block.commandList.Count - 1)
{ {
sequence.commandList.Insert(commandOperation.index, newCommand); block.commandList.Insert(commandOperation.index, newCommand);
} }
else else
{ {
sequence.commandList.Add(newCommand); block.commandList.Add(newCommand);
} }
} }
public virtual void ShowContextMenu() public virtual void ShowContextMenu()
{ {
Sequence sequence = target as Sequence; Block block = target as Block;
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }
@ -636,7 +640,7 @@ namespace Fungus
bool showDelete = false; bool showDelete = false;
bool showPaste = false; bool showPaste = false;
if (fungusScript.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
showCut = true; showCut = true;
showCopy = true; showCopy = true;
@ -698,20 +702,20 @@ namespace Fungus
protected void SelectAll() protected void SelectAll()
{ {
Sequence sequence = target as Sequence; Block block = target as Block;
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
if (fungusScript == null || if (flowchart == null ||
fungusScript.selectedSequence == null) flowchart.selectedBlock == null)
{ {
return; return;
} }
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
Undo.RecordObject(fungusScript, "Select All"); Undo.RecordObject(flowchart, "Select All");
foreach (Command command in fungusScript.selectedSequence.commandList) foreach (Command command in flowchart.selectedBlock.commandList)
{ {
fungusScript.AddSelectedCommand(command); flowchart.AddSelectedCommand(command);
} }
Repaint(); Repaint();
@ -719,17 +723,17 @@ namespace Fungus
protected void SelectNone() protected void SelectNone()
{ {
Sequence sequence = target as Sequence; Block block = target as Block;
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
if (fungusScript == null || if (flowchart == null ||
fungusScript.selectedSequence == null) flowchart.selectedBlock == null)
{ {
return; return;
} }
Undo.RecordObject(fungusScript, "Select None"); Undo.RecordObject(flowchart, "Select None");
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
Repaint(); Repaint();
} }
@ -742,11 +746,11 @@ namespace Fungus
protected void Copy() protected void Copy()
{ {
Sequence sequence = target as Sequence; Block block = target as Block;
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
if (fungusScript == null || if (flowchart == null ||
fungusScript.selectedSequence == null) flowchart.selectedBlock == null)
{ {
return; return;
} }
@ -755,9 +759,9 @@ namespace Fungus
commandCopyBuffer.Clear(); commandCopyBuffer.Clear();
// Scan through all commands in execution order to see if each needs to be copied // Scan through all commands in execution order to see if each needs to be copied
foreach (Command command in fungusScript.selectedSequence.commandList) foreach (Command command in flowchart.selectedBlock.commandList)
{ {
if (fungusScript.selectedCommands.Contains(command)) if (flowchart.selectedCommands.Contains(command))
{ {
System.Type type = command.GetType(); System.Type type = command.GetType();
Command newCommand = Undo.AddComponent(commandCopyBuffer.gameObject, type) as Command; Command newCommand = Undo.AddComponent(commandCopyBuffer.gameObject, type) as Command;
@ -772,26 +776,26 @@ namespace Fungus
protected void Paste() protected void Paste()
{ {
Sequence sequence = target as Sequence; Block block = target as Block;
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
if (fungusScript == null || if (flowchart == null ||
fungusScript.selectedSequence == null) flowchart.selectedBlock == null)
{ {
return; return;
} }
CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance(); CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance();
// Find where to paste commands in sequence (either at end or after last selected command) // Find where to paste commands in block (either at end or after last selected command)
int pasteIndex = fungusScript.selectedSequence.commandList.Count; int pasteIndex = flowchart.selectedBlock.commandList.Count;
if (fungusScript.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
for (int i = 0; i < fungusScript.selectedSequence.commandList.Count; ++i) for (int i = 0; i < flowchart.selectedBlock.commandList.Count; ++i)
{ {
Command command = fungusScript.selectedSequence.commandList[i]; Command command = flowchart.selectedBlock.commandList[i];
foreach (Command selectedCommand in fungusScript.selectedCommands) foreach (Command selectedCommand in flowchart.selectedCommands)
{ {
if (command == selectedCommand) if (command == selectedCommand)
{ {
@ -807,19 +811,19 @@ namespace Fungus
// because this does a deep copy of the command properties. // because this does a deep copy of the command properties.
if (ComponentUtility.CopyComponent(command)) if (ComponentUtility.CopyComponent(command))
{ {
if (ComponentUtility.PasteComponentAsNew(fungusScript.gameObject)) if (ComponentUtility.PasteComponentAsNew(flowchart.gameObject))
{ {
Command[] commands = fungusScript.GetComponents<Command>(); Command[] commands = flowchart.GetComponents<Command>();
Command pastedCommand = commands.Last<Command>(); Command pastedCommand = commands.Last<Command>();
if (pastedCommand != null) if (pastedCommand != null)
{ {
pastedCommand.commandId = fungusScript.NextCommandId(); pastedCommand.commandId = flowchart.NextCommandId();
fungusScript.selectedSequence.commandList.Insert(pasteIndex++, pastedCommand); flowchart.selectedBlock.commandList.Insert(pasteIndex++, pastedCommand);
} }
} }
// This stops the user pasting the command manually into another game object. // This stops the user pasting the command manually into another game object.
ComponentUtility.CopyComponent(fungusScript.transform); ComponentUtility.CopyComponent(flowchart.transform);
} }
} }
@ -828,26 +832,26 @@ namespace Fungus
protected void Delete() protected void Delete()
{ {
Sequence sequence = target as Sequence; Block block = target as Block;
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
if (fungusScript == null || if (flowchart == null ||
fungusScript.selectedSequence == null) flowchart.selectedBlock == null)
{ {
return; return;
} }
int lastSelectedIndex = 0; int lastSelectedIndex = 0;
for (int i = fungusScript.selectedSequence.commandList.Count - 1; i >= 0; --i) for (int i = flowchart.selectedBlock.commandList.Count - 1; i >= 0; --i)
{ {
Command command = fungusScript.selectedSequence.commandList[i]; Command command = flowchart.selectedBlock.commandList[i];
foreach (Command selectedCommand in fungusScript.selectedCommands) foreach (Command selectedCommand in flowchart.selectedCommands)
{ {
if (command == selectedCommand) if (command == selectedCommand)
{ {
command.OnCommandRemoved(sequence); command.OnCommandRemoved(block);
Undo.RecordObject(fungusScript.selectedSequence, "Delete"); Undo.RecordObject(flowchart.selectedBlock, "Delete");
fungusScript.selectedSequence.commandList.RemoveAt(i); flowchart.selectedBlock.commandList.RemoveAt(i);
Undo.DestroyObjectImmediate(command); Undo.DestroyObjectImmediate(command);
lastSelectedIndex = i; lastSelectedIndex = i;
break; break;
@ -855,13 +859,13 @@ namespace Fungus
} }
} }
Undo.RecordObject(fungusScript, "Delete"); Undo.RecordObject(flowchart, "Delete");
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
if (lastSelectedIndex < fungusScript.selectedSequence.commandList.Count) if (lastSelectedIndex < flowchart.selectedBlock.commandList.Count)
{ {
Command nextCommand = fungusScript.selectedSequence.commandList[lastSelectedIndex]; Command nextCommand = flowchart.selectedBlock.commandList[lastSelectedIndex];
sequence.GetFungusScript().AddSelectedCommand(nextCommand); block.GetFlowchart().AddSelectedCommand(nextCommand);
} }
Repaint(); Repaint();
@ -869,20 +873,20 @@ namespace Fungus
protected void SelectPrevious() protected void SelectPrevious()
{ {
Sequence sequence = target as Sequence; Block block = target as Block;
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
int firstSelectedIndex = fungusScript.selectedSequence.commandList.Count; int firstSelectedIndex = flowchart.selectedBlock.commandList.Count;
bool firstSelectedCommandFound = false; bool firstSelectedCommandFound = false;
if (fungusScript.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
for (int i = 0; i < fungusScript.selectedSequence.commandList.Count; i++) for (int i = 0; i < flowchart.selectedBlock.commandList.Count; i++)
{ {
Command commandInSequence = fungusScript.selectedSequence.commandList[i]; Command commandInBlock = flowchart.selectedBlock.commandList[i];
foreach (Command selectedCommand in fungusScript.selectedCommands) foreach (Command selectedCommand in flowchart.selectedCommands)
{ {
if (commandInSequence == selectedCommand) if (commandInBlock == selectedCommand)
{ {
if (!firstSelectedCommandFound) if (!firstSelectedCommandFound)
{ {
@ -900,37 +904,38 @@ namespace Fungus
} }
if (firstSelectedIndex > 0) if (firstSelectedIndex > 0)
{ {
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
fungusScript.AddSelectedCommand(fungusScript.selectedSequence.commandList[firstSelectedIndex-1]); flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[firstSelectedIndex-1]);
} }
Repaint(); Repaint();
} }
protected void SelectNext() protected void SelectNext()
{ {
Sequence sequence = target as Sequence; Block block = target as Block;
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
int lastSelectedIndex = -1; int lastSelectedIndex = -1;
if (fungusScript.selectedCommands.Count > 0) if (flowchart.selectedCommands.Count > 0)
{ {
for (int i = 0; i < fungusScript.selectedSequence.commandList.Count; i++) for (int i = 0; i < flowchart.selectedBlock.commandList.Count; i++)
{ {
Command commandInSequence = fungusScript.selectedSequence.commandList[i]; Command commandInBlock = flowchart.selectedBlock.commandList[i];
foreach (Command selectedCommand in fungusScript.selectedCommands) foreach (Command selectedCommand in flowchart.selectedCommands)
{ {
if (commandInSequence == selectedCommand) if (commandInBlock == selectedCommand)
{ {
lastSelectedIndex = i; lastSelectedIndex = i;
} }
} }
} }
} }
if (lastSelectedIndex < fungusScript.selectedSequence.commandList.Count-1) if (lastSelectedIndex < flowchart.selectedBlock.commandList.Count-1)
{ {
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
fungusScript.AddSelectedCommand(fungusScript.selectedSequence.commandList[lastSelectedIndex+1]); flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[lastSelectedIndex+1]);
} }
Repaint(); Repaint();

0
Assets/Fungus/FungusScript/Editor/SequenceEditor.cs.meta → Assets/Fungus/Flowchart/Editor/SequenceEditor.cs.meta

66
Assets/Fungus/FungusScript/Editor/SequenceInspector.cs → Assets/Fungus/Flowchart/Editor/SequenceInspector.cs

@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
using UnityEditor; using UnityEditor;
using System.Collections; using System.Collections;
@ -6,68 +7,69 @@ namespace Fungus
{ {
/** /**
* Temp hidden object which lets us use the entire inspector window to inspect * Temp hidden object which lets us use the entire inspector window to inspect
* the sequence command list. * the block command list.
*/ */
public class SequenceInspector : ScriptableObject public class BlockInspector : ScriptableObject
{ {
public Sequence sequence; [FormerlySerializedAs("sequence")]
public Block block;
} }
/** /**
* Custom editor for the temp hidden object. * Custom editor for the temp hidden object.
*/ */
[CustomEditor (typeof(SequenceInspector), true)] [CustomEditor (typeof(BlockInspector), true)]
public class SequenceInspectorEditor : Editor public class BlockInspectorEditor : Editor
{ {
protected Vector2 sequenceScrollPos; protected Vector2 blockScrollPos;
protected Vector2 commandScrollPos; protected Vector2 commandScrollPos;
protected bool resize = false; protected bool resize = false;
protected float topPanelHeight = 50; protected float topPanelHeight = 50;
public override void OnInspectorGUI () public override void OnInspectorGUI ()
{ {
SequenceInspector sequenceInspector = target as SequenceInspector; BlockInspector blockInspector = target as BlockInspector;
Sequence sequence = sequenceInspector.sequence; Block block = blockInspector.block;
if (sequence == null) if (block == null)
{ {
return; return;
} }
FungusScript fungusScript = sequence.GetFungusScript(); Flowchart flowchart = block.GetFlowchart();
SequenceEditor sequenceEditor = Editor.CreateEditor(sequence) as SequenceEditor; BlockEditor blockEditor = Editor.CreateEditor(block) as BlockEditor;
sequenceEditor.DrawSequenceName(fungusScript); blockEditor.DrawBlockName(flowchart);
// Using a custom rect area to get the correct 5px indent for the scroll views // Using a custom rect area to get the correct 5px indent for the scroll views
Rect sequenceRect = new Rect(5, topPanelHeight, Screen.width - 6, Screen.height); Rect blockRect = new Rect(5, topPanelHeight, Screen.width - 6, Screen.height);
GUILayout.BeginArea(sequenceRect); GUILayout.BeginArea(blockRect);
sequenceScrollPos = GUILayout.BeginScrollView(sequenceScrollPos, GUILayout.Height(fungusScript.sequenceViewHeight)); blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.blockViewHeight));
sequenceEditor.DrawSequenceGUI(fungusScript); blockEditor.DrawBlockGUI(flowchart);
GUILayout.EndScrollView(); GUILayout.EndScrollView();
Command inspectCommand = null; Command inspectCommand = null;
if (fungusScript.selectedCommands.Count == 1) if (flowchart.selectedCommands.Count == 1)
{ {
inspectCommand = fungusScript.selectedCommands[0]; inspectCommand = flowchart.selectedCommands[0];
} }
if (Application.isPlaying && if (Application.isPlaying &&
inspectCommand != null && inspectCommand != null &&
inspectCommand.parentSequence != sequence) inspectCommand.parentBlock != block)
{ {
GUILayout.EndArea(); GUILayout.EndArea();
Repaint(); Repaint();
DestroyImmediate(sequenceEditor); DestroyImmediate(blockEditor);
return; return;
} }
ResizeScrollView(fungusScript); ResizeScrollView(flowchart);
GUILayout.Space(7); GUILayout.Space(7);
sequenceEditor.DrawButtonToolbar(); blockEditor.DrawButtonToolbar();
commandScrollPos = GUILayout.BeginScrollView(commandScrollPos); commandScrollPos = GUILayout.BeginScrollView(commandScrollPos);
@ -84,7 +86,7 @@ namespace Fungus
// Draw the resize bar after everything else has finished drawing // Draw the resize bar after everything else has finished drawing
// This is mainly to avoid incorrect indenting. // This is mainly to avoid incorrect indenting.
Rect resizeRect = new Rect(0, topPanelHeight + fungusScript.sequenceViewHeight + 1, Screen.width, 4f); Rect resizeRect = new Rect(0, topPanelHeight + flowchart.blockViewHeight + 1, Screen.width, 4f);
GUI.color = new Color(0.64f, 0.64f, 0.64f); GUI.color = new Color(0.64f, 0.64f, 0.64f);
GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture); GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
resizeRect.height = 1; resizeRect.height = 1;
@ -96,12 +98,12 @@ namespace Fungus
Repaint(); Repaint();
DestroyImmediate(sequenceEditor); DestroyImmediate(blockEditor);
} }
private void ResizeScrollView(FungusScript fungusScript) private void ResizeScrollView(Flowchart flowchart)
{ {
Rect cursorChangeRect = new Rect(0, fungusScript.sequenceViewHeight + 1, Screen.width, 4f); Rect cursorChangeRect = new Rect(0, flowchart.blockViewHeight + 1, Screen.width, 4f);
EditorGUIUtility.AddCursorRect(cursorChangeRect, MouseCursor.ResizeVertical); EditorGUIUtility.AddCursorRect(cursorChangeRect, MouseCursor.ResizeVertical);
@ -112,15 +114,15 @@ namespace Fungus
if (resize) if (resize)
{ {
Undo.RecordObject(fungusScript, "Resize view"); Undo.RecordObject(flowchart, "Resize view");
fungusScript.sequenceViewHeight = Event.current.mousePosition.y; flowchart.blockViewHeight = Event.current.mousePosition.y;
} }
// Make sure sequence view is always visible // Make sure block view is always visible
float height = fungusScript.sequenceViewHeight; float height = flowchart.blockViewHeight;
height = Mathf.Max(200, height); height = Mathf.Max(200, height);
height = Mathf.Min(Screen.height - 200,height); height = Mathf.Min(Screen.height - 200,height);
fungusScript.sequenceViewHeight = height; flowchart.blockViewHeight = height;
// Stop resizing if mouse is outside inspector window. // Stop resizing if mouse is outside inspector window.
// This isn't standard Unity UI behavior but it is robust and safe. // This isn't standard Unity UI behavior but it is robust and safe.

0
Assets/Fungus/FungusScript/Editor/SequenceInspector.cs.meta → Assets/Fungus/Flowchart/Editor/SequenceInspector.cs.meta

4
Assets/Fungus/FungusScript/Editor/SetVariableEditor.cs → Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs

@ -32,8 +32,8 @@ namespace Fungus
SetVariable t = target as SetVariable; SetVariable t = target as SetVariable;
FungusScript fungusScript = t.GetFungusScript(); Flowchart flowchart = t.GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }

0
Assets/Fungus/FungusScript/Editor/SetVariableEditor.cs.meta → Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs.meta

22
Assets/Fungus/FungusScript/Editor/VariableEditor.cs → Assets/Fungus/Flowchart/Editor/VariableEditor.cs

@ -34,7 +34,7 @@ namespace Fungus
static public void VariableField(SerializedProperty property, static public void VariableField(SerializedProperty property,
GUIContent label, GUIContent label,
FungusScript fungusScript, Flowchart flowchart,
Func<Variable, bool> filter, Func<Variable, bool> filter,
Func<string, int, string[], int> drawer = null) Func<string, int, string[], int> drawer = null)
{ {
@ -44,7 +44,7 @@ namespace Fungus
variableKeys.Add("<None>"); variableKeys.Add("<None>");
variableObjects.Add(null); variableObjects.Add(null);
List<Variable> variables = fungusScript.variables; List<Variable> variables = flowchart.variables;
int index = 0; int index = 0;
int selectedIndex = 0; int selectedIndex = 0;
@ -71,10 +71,10 @@ namespace Fungus
} }
} }
FungusScript[] fsList = GameObject.FindObjectsOfType<FungusScript>(); Flowchart[] fsList = GameObject.FindObjectsOfType<Flowchart>();
foreach (FungusScript fs in fsList) foreach (Flowchart fs in fsList)
{ {
if (fs == fungusScript) if (fs == flowchart)
{ {
continue; continue;
} }
@ -139,7 +139,7 @@ namespace Fungus
VariableEditor.VariableField(property, VariableEditor.VariableField(property,
label, label,
FungusScriptWindow.GetFungusScript(), FlowchartWindow.GetFlowchart(),
compare, compare,
(s,t,u) => (EditorGUI.Popup(position, s, t, u))); (s,t,u) => (EditorGUI.Popup(position, s, t, u)));
@ -187,17 +187,17 @@ namespace Fungus
popupRect.width = popupWidth; popupRect.width = popupWidth;
} }
FungusScript fungusScript = property.serializedObject.targetObject as FungusScript; Flowchart flowchart = property.serializedObject.targetObject as Flowchart;
if (fungusScript == null) if (flowchart == null)
{ {
Command command = property.serializedObject.targetObject as Command; Command command = property.serializedObject.targetObject as Command;
if (command != null) if (command != null)
{ {
fungusScript = command.GetFungusScript(); flowchart = command.GetFlowchart();
} }
} }
if (fungusScript != null) if (flowchart != null)
{ {
T selectedVariable = referenceProp.objectReferenceValue as T; T selectedVariable = referenceProp.objectReferenceValue as T;
@ -209,7 +209,7 @@ namespace Fungus
int index = 0; int index = 0;
int selectedIndex = 0; int selectedIndex = 0;
foreach (Variable v in fungusScript.variables) foreach (Variable v in flowchart.variables)
{ {
if (v == null) if (v == null)
{ {

0
Assets/Fungus/FungusScript/Editor/VariableEditor.cs.meta → Assets/Fungus/Flowchart/Editor/VariableEditor.cs.meta

16
Assets/Fungus/FungusScript/Editor/VariableListAdaptor.cs → Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs

@ -111,23 +111,23 @@ namespace Fungus
return; return;
} }
FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); Flowchart flowchart = FlowchartWindow.GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }
// Highlight if an active or selected command is referencing this variable // Highlight if an active or selected command is referencing this variable
bool highlight = false; bool highlight = false;
if (fungusScript.selectedSequence != null) if (flowchart.selectedBlock != null)
{ {
if (Application.isPlaying && fungusScript.selectedSequence.IsExecuting()) if (Application.isPlaying && flowchart.selectedBlock.IsExecuting())
{ {
highlight = fungusScript.selectedSequence.activeCommand.HasReference(variable); highlight = flowchart.selectedBlock.activeCommand.HasReference(variable);
} }
else if (!Application.isPlaying && fungusScript.selectedCommands.Count > 0) else if (!Application.isPlaying && flowchart.selectedCommands.Count > 0)
{ {
foreach (Command selectedCommand in fungusScript.selectedCommands) foreach (Command selectedCommand in flowchart.selectedCommands)
{ {
if (selectedCommand.HasReference(variable)) if (selectedCommand.HasReference(variable))
{ {
@ -157,7 +157,7 @@ namespace Fungus
key = EditorGUI.TextField(rects[1], variable.key); key = EditorGUI.TextField(rects[1], variable.key);
SerializedProperty keyProp = variableObject.FindProperty("key"); SerializedProperty keyProp = variableObject.FindProperty("key");
keyProp.stringValue = fungusScript.GetUniqueVariableKey(key, variable); keyProp.stringValue = flowchart.GetUniqueVariableKey(key, variable);
SerializedProperty defaultProp = variableObject.FindProperty("value"); SerializedProperty defaultProp = variableObject.FindProperty("value");
EditorGUI.PropertyField(rects[2], defaultProp, new GUIContent("")); EditorGUI.PropertyField(rects[2], defaultProp, new GUIContent(""));

0
Assets/Fungus/FungusScript/Editor/VariableListAdaptor.cs.meta → Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs.meta

0
Assets/Fungus/FungusScript/Resources.meta → Assets/Fungus/Flowchart/Resources.meta

4
Assets/Fungus/FungusScript/Resources/FungusScript.prefab → Assets/Fungus/Flowchart/Resources/Flowchart.prefab

@ -12,7 +12,7 @@ GameObject:
- 114: {fileID: 11467182} - 114: {fileID: 11467182}
- 114: {fileID: 11417010} - 114: {fileID: 11417010}
m_Layer: 0 m_Layer: 0
m_Name: FungusScript m_Name: Flowchart
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -64,7 +64,7 @@ MonoBehaviour:
y: -340 y: -340
width: 926 width: 926
height: 840 height: 840
selectedSequence: {fileID: 11467182} selectedSequence: {fileID: 0}
selectedCommands: [] selectedCommands: []
variables: [] variables: []
description: description:

0
Assets/Fungus/FungusScript/Resources/FungusScript.prefab.meta → Assets/Fungus/Flowchart/Resources/Flowchart.prefab.meta

0
Assets/Fungus/FungusScript/Scripts.meta → Assets/Fungus/Flowchart/Scripts.meta

58
Assets/Fungus/FungusScript/Scripts/Sequence.cs → Assets/Fungus/Flowchart/Scripts/Block.cs

@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -6,14 +7,15 @@ using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
[ExecuteInEditMode] [ExecuteInEditMode]
[RequireComponent(typeof(FungusScript))] [RequireComponent(typeof(Flowchart))]
[AddComponentMenu("")] [AddComponentMenu("")]
public class Sequence : Node public class Block : Node
{ {
public string sequenceName = "New Sequence"; [FormerlySerializedAs("sequenceName")]
public string blockName = "New Block";
[TextArea(2, 5)] [TextArea(2, 5)]
[Tooltip("Description text to display under the sequence node")] [Tooltip("Description text to display under the block node")]
public string description = ""; public string description = "";
[Tooltip("Slow down execution in the editor to make it easier to visualise program flow")] [Tooltip("Slow down execution in the editor to make it easier to visualise program flow")]
@ -42,12 +44,12 @@ namespace Fungus
protected virtual void Awake() protected virtual void Awake()
{ {
// Give each child command a reference back to its parent sequence // Give each child command a reference back to its parent block
// and tell each command its index in the list. // and tell each command its index in the list.
int index = 0; int index = 0;
foreach (Command command in commandList) foreach (Command command in commandList)
{ {
command.parentSequence = this; command.parentBlock = this;
command.commandIndex = index++; command.commandIndex = index++;
} }
} }
@ -71,20 +73,20 @@ namespace Fungus
} }
#endif #endif
public virtual FungusScript GetFungusScript() public virtual Flowchart GetFlowchart()
{ {
FungusScript fungusScript = GetComponent<FungusScript>(); Flowchart flowchart = GetComponent<Flowchart>();
if (fungusScript == null) if (flowchart == null)
{ {
// Legacy support for earlier system where Sequences were children of the FungusScript // Legacy support for earlier system where Blocks were children of the Flowchart
if (transform.parent != null) if (transform.parent != null)
{ {
fungusScript = transform.parent.GetComponent<FungusScript>(); flowchart = transform.parent.GetComponent<Flowchart>();
} }
} }
return fungusScript; return flowchart;
} }
public virtual bool HasError() public virtual bool HasError()
@ -102,8 +104,8 @@ namespace Fungus
public virtual bool IsExecuting() public virtual bool IsExecuting()
{ {
FungusScript fungusScript = GetFungusScript(); Flowchart flowchart = GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return false; return false;
} }
@ -138,7 +140,7 @@ namespace Fungus
executionCount++; executionCount++;
} }
FungusScript fungusScript = GetFungusScript(); Flowchart flowchart = GetFlowchart();
// Skip disabled commands, comments and labels // Skip disabled commands, comments and labels
while (commandIndex < commandList.Count && while (commandIndex < commandList.Count &&
@ -166,20 +168,20 @@ namespace Fungus
} }
else else
{ {
if (fungusScript.gameObject.activeInHierarchy) if (flowchart.gameObject.activeInHierarchy)
{ {
// Auto select a command in some situations // Auto select a command in some situations
if ((fungusScript.selectedCommands.Count == 0 && commandIndex == 0) || if ((flowchart.selectedCommands.Count == 0 && commandIndex == 0) ||
(fungusScript.selectedCommands.Count == 1 && fungusScript.selectedCommands[0].commandIndex == previousActiveCommandIndex)) (flowchart.selectedCommands.Count == 1 && flowchart.selectedCommands[0].commandIndex == previousActiveCommandIndex))
{ {
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
fungusScript.AddSelectedCommand(nextCommand); flowchart.AddSelectedCommand(nextCommand);
} }
if (runSlowInEditor && if (runSlowInEditor &&
nextCommand.RunSlowInEditor()) nextCommand.RunSlowInEditor())
{ {
StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.runSlowDuration)); StartCoroutine(ExecuteAfterDelay(nextCommand, flowchart.runSlowDuration));
} }
else else
{ {
@ -200,27 +202,27 @@ namespace Fungus
public virtual void Stop() public virtual void Stop()
{ {
FungusScript fungusScript = GetFungusScript(); Flowchart flowchart = GetFlowchart();
if (fungusScript == null) if (flowchart == null)
{ {
return; return;
} }
activeCommand = null; activeCommand = null;
fungusScript.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
} }
public virtual List<Sequence> GetConnectedSequences() public virtual List<Block> GetConnectedBlocks()
{ {
List<Sequence> connectedSequences = new List<Sequence>(); List<Block> connectedBlocks = new List<Block>();
foreach (Command command in commandList) foreach (Command command in commandList)
{ {
if (command != null) if (command != null)
{ {
command.GetConnectedSequences(ref connectedSequences); command.GetConnectedBlocks(ref connectedBlocks);
} }
} }
return connectedSequences; return connectedBlocks;
} }
public virtual System.Type GetPreviousActiveCommandType() public virtual System.Type GetPreviousActiveCommandType()

0
Assets/Fungus/FungusScript/Scripts/Sequence.cs.meta → Assets/Fungus/Flowchart/Scripts/Block.cs.meta

64
Assets/Fungus/FungusScript/Scripts/Command.cs → Assets/Fungus/Flowchart/Scripts/Command.cs

@ -44,32 +44,32 @@ namespace Fungus
public int commandIndex; public int commandIndex;
/** /**
* Reference to the Sequence object that this command belongs to. * Reference to the Block object that this command belongs to.
* This reference is only populated at runtime and in the editor when the * This reference is only populated at runtime and in the editor when the
* sequence is selected. * block is selected.
*/ */
[NonSerialized] [NonSerialized]
public Sequence parentSequence; public Block parentBlock;
public virtual FungusScript GetFungusScript() public virtual Flowchart GetFlowchart()
{ {
FungusScript fungusScript = GetComponent<FungusScript>(); Flowchart flowchart = GetComponent<Flowchart>();
if (fungusScript == null && if (flowchart == null &&
transform.parent != null) transform.parent != null)
{ {
fungusScript = transform.parent.GetComponent<FungusScript>(); flowchart = transform.parent.GetComponent<Flowchart>();
} }
return fungusScript; return flowchart;
} }
public virtual bool IsExecuting() public virtual bool IsExecuting()
{ {
if (parentSequence == null) if (parentBlock == null)
{ {
return false; return false;
} }
return (parentSequence.activeCommand == this); return (parentBlock.activeCommand == this);
} }
public virtual void Execute() public virtual void Execute()
@ -85,56 +85,56 @@ namespace Fungus
public virtual void Continue(int nextCommandIndex) public virtual void Continue(int nextCommandIndex)
{ {
OnExit(); OnExit();
if (parentSequence != null) if (parentBlock != null)
{ {
parentSequence.ExecuteCommand(nextCommandIndex); parentBlock.ExecuteCommand(nextCommandIndex);
} }
} }
public virtual void Stop() public virtual void Stop()
{ {
OnExit(); OnExit();
if (parentSequence != null) if (parentBlock != null)
{ {
parentSequence.Stop(); parentBlock.Stop();
} }
} }
public virtual void ExecuteSequence(Sequence s) public virtual void ExecuteBlock(Block s)
{ {
OnExit(); OnExit();
if (parentSequence != null) if (parentBlock != null)
{ {
FungusScript fungusScript = parentSequence.GetFungusScript(); Flowchart flowchart = parentBlock.GetFlowchart();
// Record the currently selected sequence because Stop() will clear it. // Record the currently selected block because Stop() will clear it.
Sequence selectedSequence = fungusScript.selectedSequence; Block selectedBlock = flowchart.selectedBlock;
parentSequence.Stop(); parentBlock.Stop();
if (fungusScript != null) if (flowchart != null)
{ {
// If the executing sequence is currently selected then follow the execution // If the executing block is currently selected then follow the execution
// onto the next sequence in the inspector. // onto the next block in the inspector.
if (selectedSequence == parentSequence) if (selectedBlock == parentBlock)
{ {
fungusScript.selectedSequence = s; flowchart.selectedBlock = s;
} }
fungusScript.ExecuteSequence(s); flowchart.ExecuteBlock(s);
} }
} }
} }
/** /**
* Called when the new command is added to a sequence in the editor. * Called when the new command is added to a block in the editor.
*/ */
public virtual void OnCommandAdded(Sequence parentSequence) public virtual void OnCommandAdded(Block parentBlock)
{} {}
/** /**
* Called when the command is deleted from a sequence in the editor. * Called when the command is deleted from a block in the editor.
*/ */
public virtual void OnCommandRemoved(Sequence parentSequence) public virtual void OnCommandRemoved(Block parentBlock)
{} {}
public virtual void OnEnter() public virtual void OnEnter()
@ -146,7 +146,7 @@ namespace Fungus
public virtual void OnReset() public virtual void OnReset()
{} {}
public virtual void GetConnectedSequences(ref List<Sequence> connectedSequences) public virtual void GetConnectedBlocks(ref List<Block> connectedBlocks)
{} {}
public virtual bool HasReference(Variable variable) public virtual bool HasReference(Variable variable)
@ -189,7 +189,7 @@ namespace Fungus
} }
/** /**
* Adds a delay between commands if the 'Run Slow In Editor' sequence option is enabled. * Adds a delay between commands if the 'Run Slow In Editor' option is enabled.
*/ */
public virtual bool RunSlowInEditor() public virtual bool RunSlowInEditor()
{ {

0
Assets/Fungus/FungusScript/Scripts/Command.cs.meta → Assets/Fungus/Flowchart/Scripts/Command.cs.meta

4
Assets/Fungus/FungusScript/Scripts/CommandCopyBuffer.cs → Assets/Fungus/Flowchart/Scripts/CommandCopyBuffer.cs

@ -1,11 +1,11 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
namespace Fungus namespace Fungus
{ {
[AddComponentMenu("")] [AddComponentMenu("")]
public class CommandCopyBuffer : Sequence public class CommandCopyBuffer : Block
{ {
protected static CommandCopyBuffer instance; protected static CommandCopyBuffer instance;

0
Assets/Fungus/FungusScript/Scripts/CommandCopyBuffer.cs.meta → Assets/Fungus/Flowchart/Scripts/CommandCopyBuffer.cs.meta

0
Assets/Fungus/FungusScript/Scripts/Commands.meta → Assets/Fungus/Flowchart/Scripts/Commands.meta

4
Assets/Fungus/FungusScript/Scripts/Commands/Break.cs → Assets/Fungus/Flowchart/Scripts/Commands/Break.cs

@ -14,9 +14,9 @@ namespace Fungus
public override void OnEnter() public override void OnEnter()
{ {
// Find next End statement at -1 relative indent level // Find next End statement at -1 relative indent level
for (int i = commandIndex + 1; i < parentSequence.commandList.Count; ++i) for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i)
{ {
End endCommand = parentSequence.commandList[i] as End; End endCommand = parentBlock.commandList[i] as End;
if (endCommand != null && if (endCommand != null &&
endCommand.indentLevel == indentLevel - 1) endCommand.indentLevel == indentLevel - 1)

0
Assets/Fungus/FungusScript/Scripts/Commands/Break.cs.meta → Assets/Fungus/Flowchart/Scripts/Commands/Break.cs.meta

22
Assets/Fungus/FungusScript/Scripts/Commands/Call.cs → Assets/Fungus/Flowchart/Scripts/Commands/Call.cs

@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -7,18 +8,19 @@ namespace Fungus
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Call", "Call",
"Execute another sequence in the same Fungus Script.")] "Execute another block in the same Flowchart.")]
[AddComponentMenu("")] [AddComponentMenu("")]
public class Call : Command public class Call : Command
{ {
[Tooltip("Sequence to execute")] [FormerlySerializedAs("targetSequence")]
public Sequence targetSequence; [Tooltip("Block to execute")]
public Block targetBlock;
public override void OnEnter() public override void OnEnter()
{ {
if (targetSequence != null) if (targetBlock != null)
{ {
ExecuteSequence(targetSequence); ExecuteBlock(targetBlock);
} }
else else
{ {
@ -26,22 +28,22 @@ namespace Fungus
} }
} }
public override void GetConnectedSequences(ref List<Sequence> connectedSequences) public override void GetConnectedBlocks(ref List<Block> connectedBlocks)
{ {
if (targetSequence != null) if (targetBlock != null)
{ {
connectedSequences.Add(targetSequence); connectedBlocks.Add(targetBlock);
} }
} }
public override string GetSummary() public override string GetSummary()
{ {
if (targetSequence == null) if (targetBlock == null)
{ {
return "<Continue>"; return "<Continue>";
} }
return targetSequence.sequenceName; return targetBlock.blockName;
} }
public override Color GetButtonColor() public override Color GetButtonColor()

0
Assets/Fungus/FungusScript/Scripts/Commands/Call.cs.meta → Assets/Fungus/Flowchart/Scripts/Commands/Call.cs.meta

0
Assets/Fungus/FungusScript/Scripts/Commands/Comment.cs → Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs

0
Assets/Fungus/FungusScript/Scripts/Commands/Comment.cs.meta → Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs.meta

0
Assets/Fungus/FungusScript/Scripts/Commands/Condition.cs → Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs

0
Assets/Fungus/FungusScript/Scripts/Commands/Condition.cs.meta → Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs.meta

6
Assets/Fungus/FungusScript/Scripts/Commands/DebugLog.cs → Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs

@ -1,4 +1,4 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
namespace Fungus namespace Fungus
@ -22,8 +22,8 @@ namespace Fungus
public override void OnEnter () public override void OnEnter ()
{ {
FungusScript fungusScript = GetFungusScript(); Flowchart flowchart = GetFlowchart();
string message = fungusScript.SubstituteVariables(logMessage.Value); string message = flowchart.SubstituteVariables(logMessage.Value);
switch (logType) switch (logType)
{ {

0
Assets/Fungus/FungusScript/Scripts/Commands/DebugLog.cs.meta → Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs.meta

4
Assets/Fungus/FungusScript/Scripts/Commands/DeleteSaveKey.cs → Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs

@ -21,10 +21,10 @@ namespace Fungus
return; return;
} }
FungusScript fungusScript = GetFungusScript(); Flowchart flowchart = GetFlowchart();
// Prepend the current save profile (if any) // Prepend the current save profile (if any)
string prefsKey = SetSaveProfile.saveProfile + "_" + fungusScript.SubstituteVariables(key); string prefsKey = SetSaveProfile.saveProfile + "_" + flowchart.SubstituteVariables(key);
PlayerPrefs.DeleteKey(prefsKey); PlayerPrefs.DeleteKey(prefsKey);

0
Assets/Fungus/FungusScript/Scripts/Commands/DeleteSaveKey.cs.meta → Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs.meta

0
Assets/Fungus/FungusScript/Scripts/Commands/Destroy.cs → Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs

0
Assets/Fungus/FungusScript/Scripts/Commands/Destroy.cs.meta → Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs.meta

8
Assets/Fungus/FungusScript/Scripts/Commands/Else.cs → Assets/Fungus/Flowchart/Scripts/Commands/Else.cs

@ -12,13 +12,13 @@ namespace Fungus
{ {
public override void OnEnter() public override void OnEnter()
{ {
if (parentSequence == null) if (parentBlock == null)
{ {
return; return;
} }
// Stop if this is the last command in the list // Stop if this is the last command in the list
if (commandIndex >= parentSequence.commandList.Count - 1) if (commandIndex >= parentBlock.commandList.Count - 1)
{ {
Stop(); Stop();
return; return;
@ -26,9 +26,9 @@ namespace Fungus
// Find the next End command at the same indent level as this Else command // Find the next End command at the same indent level as this Else command
int indent = indentLevel; int indent = indentLevel;
for (int i = commandIndex + 1; i < parentSequence.commandList.Count; ++i) for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i)
{ {
Command command = parentSequence.commandList[i]; Command command = parentBlock.commandList[i];
if (command.indentLevel == indent) if (command.indentLevel == indent)
{ {

0
Assets/Fungus/FungusScript/Scripts/Commands/Else.cs.meta → Assets/Fungus/Flowchart/Scripts/Commands/Else.cs.meta

10
Assets/Fungus/FungusScript/Scripts/Commands/ElseIf.cs → Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs

@ -8,14 +8,14 @@ namespace Fungus
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Else If", "Else If",
"Marks the start of a sequence block to be executed when the preceding If statement is False and the test expression is true.")] "Marks the start of a command block to be executed when the preceding If statement is False and the test expression is true.")]
[AddComponentMenu("")] [AddComponentMenu("")]
public class ElseIf : If public class ElseIf : If
{ {
public override void OnEnter() public override void OnEnter()
{ {
System.Type previousCommandType = parentSequence.GetPreviousActiveCommandType(); System.Type previousCommandType = parentBlock.GetPreviousActiveCommandType();
if (previousCommandType == typeof(If) || if (previousCommandType == typeof(If) ||
previousCommandType == typeof(ElseIf) ) previousCommandType == typeof(ElseIf) )
@ -29,7 +29,7 @@ namespace Fungus
// but will also jump to a following Else command. // but will also jump to a following Else command.
// Stop if this is the last command in the list // Stop if this is the last command in the list
if (commandIndex >= parentSequence.commandList.Count - 1) if (commandIndex >= parentBlock.commandList.Count - 1)
{ {
Stop(); Stop();
return; return;
@ -37,9 +37,9 @@ namespace Fungus
// Find the next End command at the same indent level as this Else If command // Find the next End command at the same indent level as this Else If command
int indent = indentLevel; int indent = indentLevel;
for (int i = commandIndex + 1; i < parentSequence.commandList.Count; ++i) for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i)
{ {
Command command = parentSequence.commandList[i]; Command command = parentBlock.commandList[i];
if (command.indentLevel == indent) if (command.indentLevel == indent)
{ {

0
Assets/Fungus/FungusScript/Scripts/Commands/ElseIf.cs.meta → Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs.meta

2
Assets/Fungus/FungusScript/Scripts/Commands/End.cs → Assets/Fungus/Flowchart/Scripts/Commands/End.cs

@ -20,7 +20,7 @@ namespace Fungus
{ {
for (int i = commandIndex - 1; i >= 0; --i) for (int i = commandIndex - 1; i >= 0; --i)
{ {
System.Type commandType = parentSequence.commandList[i].GetType(); System.Type commandType = parentBlock.commandList[i].GetType();
if (commandType == typeof(While)) if (commandType == typeof(While))
{ {
Continue(i); Continue(i);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save