From 5a931441d4fa32328451b29b3a047f324178ea89 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Tue, 31 Mar 2015 13:22:31 +0100 Subject: [PATCH] Merge branch 'Rename-core-classes' --- .../Fungus/Camera/Editor/CameraMenuItems.cs | 4 +- Assets/Fungus/Camera/Editor/ViewEditor.cs | 6 +- .../Camera/Scripts/Commands/FadeToView.cs | 4 +- .../Camera/Scripts/Commands/MoveToView.cs | 2 +- .../{FungusScript.meta => Flowchart.meta} | 0 .../{FungusScript => Flowchart}/Editor.meta | 0 .../Editor/AssetModProcessor.cs | 12 +- .../Editor/AssetModProcessor.cs.meta | 0 .../Editor/CallEditor.cs | 14 +- .../Editor/CallEditor.cs.meta | 0 .../Editor/CommandEditor.cs | 8 +- .../Editor/CommandEditor.cs.meta | 0 .../Editor/CommandListAdaptor.cs | 62 +- .../Editor/CommandListAdaptor.cs.meta | 0 .../Editor/CustomGUI.cs | Bin .../Editor/CustomGUI.cs.meta | 0 .../Editor/EditorExtensions.cs | 0 .../Editor/EditorExtensions.cs.meta | 0 .../Editor/EditorZoomArea.cs | 0 .../Editor/EditorZoomArea.cs.meta | 0 .../Editor/EventHandlerEditor.cs | 2 +- .../Editor/EventHandlerEditor.cs.meta | 0 .../Editor/FlowchartEditor.cs} | 34 +- .../Editor/FlowchartEditor.cs.meta} | 0 .../Editor/FlowchartMenuItems.cs} | 8 +- .../Editor/FlowchartMenuItems.cs.meta} | 0 .../Flowchart/Editor/FlowchartWindow.cs | 726 +++++ .../Editor/FlowchartWindow.cs.meta} | 0 .../Editor/FountainExporter.cs | 26 +- .../Editor/FountainExporter.cs.meta | 0 .../Editor/FungusEditorResources.cs | 0 .../Editor/FungusEditorResources.cs.meta | 0 .../Editor/GLDraw.cs | 0 .../Editor/GLDraw.cs.meta | 0 .../Editor/IfEditor.cs | 4 +- .../Editor/IfEditor.cs.meta | 0 .../Editor/JumpEditor.cs | 2 +- .../Editor/JumpEditor.cs.meta | 0 .../Editor/LabelEditor.cs | 10 +- .../Editor/LabelEditor.cs.meta | 0 .../Editor/Resources.meta | 0 .../Editor/Resources/Icons.meta | 0 .../Editor/Resources/Icons/ResizeHandle.png | Bin .../Resources/Icons/ResizeHandle.png.meta | 0 .../Editor/Resources/Icons/add.png | Bin .../Editor/Resources/Icons/add.png.meta | 0 .../Editor/Resources/Icons/delete.png | Bin .../Editor/Resources/Icons/delete.png.meta | 0 .../Editor/Resources/Icons/down.png | Bin .../Editor/Resources/Icons/down.png.meta | 0 .../Editor/Resources/Icons/duplicate.png | Bin .../Editor/Resources/Icons/duplicate.png.meta | 0 .../Editor/Resources/Icons/left.png | Bin .../Editor/Resources/Icons/left.png.meta | 0 .../Editor/Resources/Icons/right.png | Bin .../Editor/Resources/Icons/right.png.meta | 0 .../Editor/Resources/Icons/up.png | Bin .../Editor/Resources/Icons/up.png.meta | 0 .../Editor/SendEventEditor.cs | 6 +- .../Editor/SendEventEditor.cs.meta | 0 .../Editor/SequenceEditor.cs | 337 +-- .../Editor/SequenceEditor.cs.meta | 0 .../Editor/SequenceInspector.cs | 66 +- .../Editor/SequenceInspector.cs.meta | 0 .../Editor/SetVariableEditor.cs | 4 +- .../Editor/SetVariableEditor.cs.meta | 0 .../Editor/VariableEditor.cs | 22 +- .../Editor/VariableEditor.cs.meta | 0 .../Editor/VariableListAdaptor.cs | 16 +- .../Editor/VariableListAdaptor.cs.meta | 0 .../Resources.meta | 0 .../Resources/Flowchart.prefab} | 4 +- .../Resources/Flowchart.prefab.meta} | 0 .../{FungusScript => Flowchart}/Scripts.meta | 0 .../Scripts/Block.cs} | 58 +- .../Scripts/Block.cs.meta} | 0 .../Scripts/Command.cs | 64 +- .../Scripts/Command.cs.meta | 0 .../Scripts/CommandCopyBuffer.cs | 4 +- .../Scripts/CommandCopyBuffer.cs.meta | 0 .../Scripts/Commands.meta | 0 .../Scripts/Commands/Break.cs | 4 +- .../Scripts/Commands/Break.cs.meta | 0 .../Scripts/Commands/Call.cs | 22 +- .../Scripts/Commands/Call.cs.meta | 0 .../Scripts/Commands/Comment.cs | 0 .../Scripts/Commands/Comment.cs.meta | 0 .../Scripts/Commands/Condition.cs | 0 .../Scripts/Commands/Condition.cs.meta | 0 .../Scripts/Commands/DebugLog.cs | 6 +- .../Scripts/Commands/DebugLog.cs.meta | 0 .../Scripts/Commands/DeleteSaveKey.cs | 4 +- .../Scripts/Commands/DeleteSaveKey.cs.meta | 0 .../Scripts/Commands/Destroy.cs | 0 .../Scripts/Commands/Destroy.cs.meta | 0 .../Scripts/Commands/Else.cs | 8 +- .../Scripts/Commands/Else.cs.meta | 0 .../Scripts/Commands/ElseIf.cs | 10 +- .../Scripts/Commands/ElseIf.cs.meta | 0 .../Scripts/Commands/End.cs | 2 +- .../Scripts/Commands/End.cs.meta | 0 .../Scripts/Commands/EndIf.cs | 0 .../Scripts/Commands/EndIf.cs.meta | 0 .../Scripts/Commands/If.cs | 16 +- .../Scripts/Commands/If.cs.meta | 0 .../Scripts/Commands/Jump.cs | 2 +- .../Scripts/Commands/Jump.cs.meta | 0 .../Scripts/Commands/Label.cs | 0 .../Scripts/Commands/Label.cs.meta | 0 .../Scripts/Commands/LoadScene.cs | 0 .../Scripts/Commands/LoadScene.cs.meta | 0 .../Scripts/Commands/LoadVariable.cs | 4 +- .../Scripts/Commands/LoadVariable.cs.meta | 0 .../Scripts/Commands/RandomFloat.cs | 0 .../Scripts/Commands/RandomFloat.cs.meta | 0 .../Scripts/Commands/RandomInteger.cs | 0 .../Scripts/Commands/RandomInteger.cs.meta | 0 .../Scripts/Commands/Reset.cs | 4 +- .../Scripts/Commands/Reset.cs.meta | 0 .../Scripts/Commands/RunFlowchart.cs | 73 + .../Scripts/Commands/RunFlowchart.cs.meta} | 6 +- .../Scripts/Commands/SaveVariable.cs | 4 +- .../Scripts/Commands/SaveVariable.cs.meta | 0 .../Scripts/Commands/SendEvent.cs | 6 +- .../Scripts/Commands/SendEvent.cs.meta | 0 .../Scripts/Commands/SendMessage.cs | 14 +- .../Scripts/Commands/SendMessage.cs.meta | 0 .../Scripts/Commands/SetActive.cs | 0 .../Scripts/Commands/SetActive.cs.meta | 0 .../Scripts/Commands/SetSaveProfile.cs | 2 +- .../Scripts/Commands/SetSaveProfile.cs.meta | 0 .../Scripts/Commands/SetVariable.cs | 0 .../Scripts/Commands/SetVariable.cs.meta | 0 .../Scripts/Commands/Stop.cs | 2 +- .../Scripts/Commands/Stop.cs.meta | 0 .../Scripts/Commands/Wait.cs | 2 +- .../Scripts/Commands/Wait.cs.meta | 0 .../Scripts/Commands/While.cs | 4 +- .../Scripts/Commands/While.cs.meta | 0 .../Scripts/EventHandler.cs | 30 +- .../Scripts/EventHandler.cs.meta | 0 .../Scripts/EventHandlers.meta | 0 .../Scripts/EventHandlers/GameStarted.cs | 4 +- .../Scripts/EventHandlers/GameStarted.cs.meta | 0 .../Scripts/EventHandlers/KeyPressed.cs | 8 +- .../Scripts/EventHandlers/KeyPressed.cs.meta | 0 .../Scripts/EventHandlers/MessageReceived.cs | 4 +- .../EventHandlers/MessageReceived.cs.meta | 0 .../Scripts/EventHandlers/ObjectEnabled.cs | 4 +- .../EventHandlers/ObjectEnabled.cs.meta | 0 .../Scripts/Flowchart.cs} | 165 +- .../Scripts/Flowchart.cs.meta} | 0 .../Fungus/Flowchart/Scripts/FungusState.cs | 15 + .../Scripts/FungusState.cs.meta | 0 .../Scripts/Node.cs | 0 .../Scripts/Node.cs.meta | 0 .../Scripts/SceneLoader.cs | 4 +- .../Scripts/SceneLoader.cs.meta | 0 .../Scripts/StringFormatter.cs | 0 .../Scripts/StringFormatter.cs.meta | 0 .../Scripts/StringsParser.cs | 0 .../Scripts/StringsParser.cs.meta | 0 .../Scripts/Variable.cs | 4 +- .../Scripts/Variable.cs.meta | 0 .../Scripts/VariableTypes.meta | 0 .../Scripts/VariableTypes/BooleanVariable.cs | 0 .../VariableTypes/BooleanVariable.cs.meta | 0 .../Scripts/VariableTypes/ColorVariable.cs | 0 .../VariableTypes/ColorVariable.cs.meta | 0 .../Scripts/VariableTypes/FloatVariable.cs | 0 .../VariableTypes/FloatVariable.cs.meta | 0 .../VariableTypes/GameObjectVariable.cs | 0 .../VariableTypes/GameObjectVariable.cs.meta | 0 .../Scripts/VariableTypes/IntegerVariable.cs | 0 .../VariableTypes/IntegerVariable.cs.meta | 0 .../Scripts/VariableTypes/MaterialVariable.cs | 0 .../VariableTypes/MaterialVariable.cs.meta | 0 .../Scripts/VariableTypes/ObjectVariable.cs | 0 .../VariableTypes/ObjectVariable.cs.meta | 0 .../Scripts/VariableTypes/SpriteVariable.cs | 0 .../VariableTypes/SpriteVariable.cs.meta | 0 .../Scripts/VariableTypes/StringVariable.cs | 0 .../VariableTypes/StringVariable.cs.meta | 0 .../Scripts/VariableTypes/TextureVariable.cs | 0 .../VariableTypes/TextureVariable.cs.meta | 0 .../Scripts/VariableTypes/Vector2Variable.cs | 0 .../VariableTypes/Vector2Variable.cs.meta | 0 .../Scripts/VariableTypes/Vector3Variable.cs | 0 .../VariableTypes/Vector3Variable.cs.meta | 0 .../{FungusScript => Flowchart}/Sprites.meta | 0 .../Sprites/ScriptIcon.png | Bin .../Sprites/ScriptIcon.png.meta | 0 .../FungusScript/Editor/FungusScriptWindow.cs | 726 ----- .../Scripts/Commands/RunScript.cs | 60 - .../FungusScript/Scripts/FungusState.cs | 15 - .../Fungus/Narrative/Deprecated/AddOption.cs | 18 +- Assets/Fungus/Narrative/Deprecated/Choose.cs | 28 +- .../Deprecated/Editor/AddOptionEditor.cs | 10 +- Assets/Fungus/Narrative/Editor/MenuEditor.cs | 14 +- .../Narrative/Editor/MenuTimerEditor.cs | 14 +- .../Narrative/Editor/NarrativeMenuItems.cs | 16 +- .../Fungus/Narrative/Editor/PortraitEditor.cs | 2 +- Assets/Fungus/Narrative/Editor/StageEditor.cs | 2 +- .../Scripts/Commands/ControlStage.cs | 2 +- .../Fungus/Narrative/Scripts/Commands/Menu.cs | 28 +- .../Narrative/Scripts/Commands/MenuTimer.cs | 23 +- .../Narrative/Scripts/Commands/Portrait.cs | 2 +- .../Fungus/Narrative/Scripts/Commands/Say.cs | 6 +- Assets/Fungus/Narrative/Scripts/Dialog.cs | 8 +- Assets/Fungus/Narrative/Scripts/MenuDialog.cs | 24 +- .../Fungus/Sprite/Editor/SpriteMenuItems.cs | 10 +- Assets/Fungus/Sprite/Scripts/Clickable2D.cs | 4 +- Assets/Fungus/Sprite/Scripts/Draggable2D.cs | 2 +- .../Scripts/EventHandlers/DragCancelled.cs | 4 +- .../Scripts/EventHandlers/DragCompleted.cs | 4 +- .../Scripts/EventHandlers/DragEntered.cs | 4 +- .../Scripts/EventHandlers/DragExited.cs | 4 +- .../Scripts/EventHandlers/DragStarted.cs | 4 +- .../Scripts/EventHandlers/ObjectClicked.cs | 4 +- .../DragAndDrop/DragAndDrop.unity | 381 +-- .../JumpingPrax/JumpingPrax.unity | 254 +- .../Sherlock/TheExperiment.unity | 8 +- .../TheFacility/TheFacility.unity | 2628 ++--------------- .../FungusExamples/TheHunter/TheHunter.unity | 6 +- .../Usfxr/UsfxrAudioExample.unity | 80 +- .../Variables/Scenes/Variables.unity | 129 +- Assets/FungusExamples/iTween/iTween.unity | 182 +- 227 files changed, 2095 insertions(+), 4549 deletions(-) rename Assets/Fungus/{FungusScript.meta => Flowchart.meta} (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/AssetModProcessor.cs (67%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/AssetModProcessor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/CallEditor.cs (55%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/CallEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/CommandEditor.cs (95%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/CommandEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/CommandListAdaptor.cs (84%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/CommandListAdaptor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/CustomGUI.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/CustomGUI.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/EditorExtensions.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/EditorExtensions.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/EditorZoomArea.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/EditorZoomArea.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/EventHandlerEditor.cs (95%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/EventHandlerEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript/Editor/FungusScriptEditor.cs => Flowchart/Editor/FlowchartEditor.cs} (86%) rename Assets/Fungus/{FungusScript/Editor/FungusScriptEditor.cs.meta => Flowchart/Editor/FlowchartEditor.cs.meta} (100%) rename Assets/Fungus/{FungusScript/Editor/FungusScriptMenuItems.cs => Flowchart/Editor/FlowchartMenuItems.cs} (80%) rename Assets/Fungus/{FungusScript/Editor/FungusScriptMenuItems.cs.meta => Flowchart/Editor/FlowchartMenuItems.cs.meta} (100%) create mode 100755 Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs rename Assets/Fungus/{FungusScript/Editor/FungusScriptWindow.cs.meta => Flowchart/Editor/FlowchartWindow.cs.meta} (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/FountainExporter.cs (84%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/FountainExporter.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/FungusEditorResources.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/FungusEditorResources.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/GLDraw.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/GLDraw.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/IfEditor.cs (97%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/IfEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/JumpEditor.cs (95%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/JumpEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/LabelEditor.cs (84%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/LabelEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/ResizeHandle.png (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/ResizeHandle.png.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/add.png (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/add.png.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/delete.png (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/delete.png.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/down.png (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/down.png.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/duplicate.png (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/duplicate.png.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/left.png (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/left.png.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/right.png (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/right.png.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/up.png (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/Resources/Icons/up.png.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/SendEventEditor.cs (81%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/SendEventEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/SequenceEditor.cs (64%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/SequenceEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/SequenceInspector.cs (57%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/SequenceInspector.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/SetVariableEditor.cs (98%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/SetVariableEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/VariableEditor.cs (92%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/VariableEditor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/VariableListAdaptor.cs (90%) rename Assets/Fungus/{FungusScript => Flowchart}/Editor/VariableListAdaptor.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Resources.meta (100%) rename Assets/Fungus/{FungusScript/Resources/FungusScript.prefab => Flowchart/Resources/Flowchart.prefab} (97%) rename Assets/Fungus/{FungusScript/Resources/FungusScript.prefab.meta => Flowchart/Resources/Flowchart.prefab.meta} (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts.meta (100%) rename Assets/Fungus/{FungusScript/Scripts/Sequence.cs => Flowchart/Scripts/Block.cs} (71%) rename Assets/Fungus/{FungusScript/Scripts/Sequence.cs.meta => Flowchart/Scripts/Block.cs.meta} (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Command.cs (61%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Command.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/CommandCopyBuffer.cs (95%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/CommandCopyBuffer.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Break.cs (84%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Break.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Call.cs (52%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Call.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Comment.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Comment.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Condition.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Condition.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/DebugLog.cs (85%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/DebugLog.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/DeleteSaveKey.cs (85%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/DeleteSaveKey.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Destroy.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Destroy.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Else.cs (84%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Else.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/ElseIf.cs (77%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/ElseIf.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/End.cs (90%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/End.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/EndIf.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/EndIf.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/If.cs (90%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/If.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Jump.cs (93%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Jump.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Label.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Label.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/LoadScene.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/LoadScene.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/LoadVariable.cs (94%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/LoadVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/RandomFloat.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/RandomFloat.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/RandomInteger.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/RandomInteger.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Reset.cs (86%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Reset.cs.meta (100%) create mode 100644 Assets/Fungus/Flowchart/Scripts/Commands/RunFlowchart.cs rename Assets/Fungus/{FungusScript/Scripts/Commands/RunScript.cs.meta => Flowchart/Scripts/Commands/RunFlowchart.cs.meta} (52%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SaveVariable.cs (94%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SaveVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SendEvent.cs (90%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SendEvent.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SendMessage.cs (70%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SendMessage.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SetActive.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SetActive.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SetSaveProfile.cs (93%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SetSaveProfile.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SetVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/SetVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Stop.cs (85%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Stop.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Wait.cs (95%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/Wait.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/While.cs (89%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Commands/While.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandler.cs (63%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandler.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandlers.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandlers/GameStarted.cs (74%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandlers/GameStarted.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandlers/KeyPressed.cs (84%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandlers/KeyPressed.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandlers/MessageReceived.cs (70%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandlers/MessageReceived.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandlers/ObjectEnabled.cs (71%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/EventHandlers/ObjectEnabled.cs.meta (100%) rename Assets/Fungus/{FungusScript/Scripts/FungusScript.cs => Flowchart/Scripts/Flowchart.cs} (72%) rename Assets/Fungus/{FungusScript/Scripts/FungusScript.cs.meta => Flowchart/Scripts/Flowchart.cs.meta} (100%) create mode 100644 Assets/Fungus/Flowchart/Scripts/FungusState.cs rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/FungusState.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Node.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Node.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/SceneLoader.cs (97%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/SceneLoader.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/StringFormatter.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/StringFormatter.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/StringsParser.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/StringsParser.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Variable.cs (95%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/Variable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/BooleanVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/BooleanVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/ColorVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/ColorVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/FloatVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/FloatVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/GameObjectVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/GameObjectVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/IntegerVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/IntegerVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/MaterialVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/MaterialVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/ObjectVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/ObjectVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/SpriteVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/SpriteVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/StringVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/StringVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/TextureVariable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/TextureVariable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/Vector2Variable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/Vector2Variable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/Vector3Variable.cs (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Scripts/VariableTypes/Vector3Variable.cs.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Sprites.meta (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Sprites/ScriptIcon.png (100%) rename Assets/Fungus/{FungusScript => Flowchart}/Sprites/ScriptIcon.png.meta (100%) delete mode 100755 Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs delete mode 100644 Assets/Fungus/FungusScript/Scripts/Commands/RunScript.cs delete mode 100644 Assets/Fungus/FungusScript/Scripts/FungusState.cs diff --git a/Assets/Fungus/Camera/Editor/CameraMenuItems.cs b/Assets/Fungus/Camera/Editor/CameraMenuItems.cs index 05652132..927c799e 100644 --- a/Assets/Fungus/Camera/Editor/CameraMenuItems.cs +++ b/Assets/Fungus/Camera/Editor/CameraMenuItems.cs @@ -1,4 +1,4 @@ -using UnityEngine; +using UnityEngine; using UnityEditor; using System.Collections; @@ -10,7 +10,7 @@ namespace Fungus [MenuItem("Tools/Fungus/Create/View", false, 100)] static void CreateView() { - FungusScriptMenuItems.SpawnPrefab("View"); + FlowchartMenuItems.SpawnPrefab("View"); } } diff --git a/Assets/Fungus/Camera/Editor/ViewEditor.cs b/Assets/Fungus/Camera/Editor/ViewEditor.cs index 23652503..ea02909b 100644 --- a/Assets/Fungus/Camera/Editor/ViewEditor.cs +++ b/Assets/Fungus/Camera/Editor/ViewEditor.cs @@ -164,10 +164,10 @@ namespace Fungus bool highlight = Selection.activeGameObject == view.gameObject; - FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); - if (fungusScript != null) + Flowchart flowchart = FlowchartWindow.GetFlowchart(); + if (flowchart != null) { - foreach (Command command in fungusScript.selectedCommands) + foreach (Command command in flowchart.selectedCommands) { MoveToView moveToViewCommand = command as MoveToView; if (moveToViewCommand != null && diff --git a/Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs b/Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs index f0738f5a..0f1bc73e 100644 --- a/Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs +++ b/Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs @@ -6,7 +6,7 @@ namespace Fungus { [CommandInfo("Camera", "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("")] public class FadeToView : Command { @@ -14,7 +14,7 @@ namespace Fungus public float duration = 1f; [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")] public bool waitUntilFinished = true; diff --git a/Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs b/Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs index 8dff3505..19da879e 100644 --- a/Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs +++ b/Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs @@ -6,7 +6,7 @@ namespace Fungus { [CommandInfo("Camera", "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("")] public class MoveToView : Command { diff --git a/Assets/Fungus/FungusScript.meta b/Assets/Fungus/Flowchart.meta similarity index 100% rename from Assets/Fungus/FungusScript.meta rename to Assets/Fungus/Flowchart.meta diff --git a/Assets/Fungus/FungusScript/Editor.meta b/Assets/Fungus/Flowchart/Editor.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor.meta rename to Assets/Fungus/Flowchart/Editor.meta diff --git a/Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs b/Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs similarity index 67% rename from Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs rename to Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs index 621ff29d..9e1cec05 100644 --- a/Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs +++ b/Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs @@ -8,7 +8,7 @@ using System.Collections.Generic; 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 { @@ -30,13 +30,13 @@ namespace Fungus } // Reset these variables before save so that they won't cause a git conflict - FungusScript[] allFungusScripts = UnityEngine.Object.FindObjectsOfType(); - foreach (FungusScript fs in allFungusScripts) + Flowchart[] flowcharts = UnityEngine.Object.FindObjectsOfType(); + foreach (Flowchart f in flowcharts) { - if (!fs.saveSelection) + if (!f.saveSelection) { - fs.selectedSequence = null; - fs.ClearSelectedCommands(); + f.selectedBlock = null; + f.ClearSelectedCommands(); } } diff --git a/Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs.meta b/Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs.meta rename to Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/CallEditor.cs b/Assets/Fungus/Flowchart/Editor/CallEditor.cs similarity index 55% rename from Assets/Fungus/FungusScript/Editor/CallEditor.cs rename to Assets/Fungus/Flowchart/Editor/CallEditor.cs index a4f9e0df..0ea0bcae 100644 --- a/Assets/Fungus/FungusScript/Editor/CallEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/CallEditor.cs @@ -8,11 +8,11 @@ namespace Fungus [CustomEditor (typeof(Call))] public class CallEditor : CommandEditor { - protected SerializedProperty targetSequenceProp; + protected SerializedProperty targetBlockProp; protected virtual void OnEnable() { - targetSequenceProp = serializedObject.FindProperty("targetSequence"); + targetBlockProp = serializedObject.FindProperty("targetBlock"); } public override void DrawCommandGUI() @@ -21,16 +21,16 @@ namespace Fungus Call t = target as Call; - FungusScript fungusScript = t.GetFungusScript(); - if (fungusScript == null) + Flowchart flowchart = t.GetFlowchart(); + if (flowchart == null) { return; } - SequenceEditor.SequenceField(targetSequenceProp, - new GUIContent("Target Sequence", "Sequence to call"), + BlockEditor.BlockField(targetBlockProp, + new GUIContent("Target Block", "Block to call"), new GUIContent(""), - fungusScript); + flowchart); serializedObject.ApplyModifiedProperties(); } diff --git a/Assets/Fungus/FungusScript/Editor/CallEditor.cs.meta b/Assets/Fungus/Flowchart/Editor/CallEditor.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/CallEditor.cs.meta rename to Assets/Fungus/Flowchart/Editor/CallEditor.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/CommandEditor.cs b/Assets/Fungus/Flowchart/Editor/CommandEditor.cs similarity index 95% rename from Assets/Fungus/FungusScript/Editor/CommandEditor.cs rename to Assets/Fungus/Flowchart/Editor/CommandEditor.cs index f2e7e2db..877e97b2 100644 --- a/Assets/Fungus/FungusScript/Editor/CommandEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/CommandEditor.cs @@ -35,8 +35,8 @@ namespace Fungus return; } - FungusScript fungusScript = t.GetFungusScript(); - if (fungusScript == null) + Flowchart flowchart = t.GetFlowchart(); + if (flowchart == null) { return; } @@ -51,7 +51,7 @@ namespace Fungus if (t.enabled) { - if (fungusScript.colorCommands) + if (flowchart.colorCommands) { 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 // 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. serializedObject.Update(); SerializedProperty iterator = serializedObject.GetIterator(); diff --git a/Assets/Fungus/FungusScript/Editor/CommandEditor.cs.meta b/Assets/Fungus/Flowchart/Editor/CommandEditor.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/CommandEditor.cs.meta rename to Assets/Fungus/Flowchart/Editor/CommandEditor.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs b/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs similarity index 84% rename from Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs rename to Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs index 9f94b94a..692db510 100644 --- a/Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs @@ -81,22 +81,22 @@ namespace Fungus Command AddNewCommand() { - FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); - if (fungusScript == null) + Flowchart flowchart = FlowchartWindow.GetFlowchart(); + if (flowchart == null) { return null; } - Sequence sequence = fungusScript.selectedSequence; - if (sequence == null) + Block block = flowchart.selectedBlock; + if (block == null) { return null; } - Command newCommand = Undo.AddComponent(sequence.gameObject) as Command; - newCommand.commandId = fungusScript.NextCommandId(); - fungusScript.ClearSelectedCommands(); - fungusScript.AddSelectedCommand(newCommand); + Command newCommand = Undo.AddComponent(block.gameObject) as Command; + newCommand.commandId = flowchart.NextCommandId(); + flowchart.ClearSelectedCommands(); + flowchart.AddSelectedCommand(newCommand); return newCommand; } @@ -106,11 +106,11 @@ namespace Fungus Command command = _arrayProperty.GetArrayElementAtIndex(index).objectReferenceValue as Command; // Add the command as a new component - Sequence parentSequence = command.GetComponent(); + Block parentBlock = command.GetComponent(); System.Type type = command.GetType(); - Command newCommand = Undo.AddComponent(parentSequence.gameObject, type) as Command; - newCommand.commandId = newCommand.GetFungusScript().NextCommandId(); + Command newCommand = Undo.AddComponent(parentBlock.gameObject, type) as Command; + newCommand.commandId = newCommand.GetFlowchart().NextCommandId(); System.Reflection.FieldInfo[] fields = type.GetFields(); foreach (System.Reflection.FieldInfo field in fields) { @@ -161,8 +161,8 @@ namespace Fungus return; } - FungusScript fungusScript = command.GetFungusScript(); - if (fungusScript == null) + Flowchart flowchart = command.GetFlowchart(); + if (flowchart == null) { return; } @@ -195,7 +195,7 @@ namespace Fungus } bool commandIsSelected = false; - foreach (Command selectedCommand in fungusScript.selectedCommands) + foreach (Command selectedCommand in flowchart.selectedCommands) { if (selectedCommand == command) { @@ -244,37 +244,37 @@ namespace Fungus Event.current.button == 0 && 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 // Command key and shift key is not pressed if (!EditorGUI.actionKey && !Event.current.shift) { - fungusScript.selectedCommands.Remove(command); - fungusScript.ClearSelectedCommands(); + flowchart.selectedCommands.Remove(command); + flowchart.ClearSelectedCommands(); } // Command key pressed if (EditorGUI.actionKey) { - fungusScript.selectedCommands.Remove(command); + flowchart.selectedCommands.Remove(command); } // Shift key pressed if (Event.current.shift) { - fungusScript.ClearSelectedCommands(); + flowchart.ClearSelectedCommands(); if (pinShiftToTop) { for (int i = firstSelectedIndex; i < index+1; ++i) { - fungusScript.AddSelectedCommand(fungusScript.selectedSequence.commandList[i]); + flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[i]); } } else { 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 if (!Event.current.shift && !EditorGUI.actionKey && Event.current.button == 0) { - fungusScript.ClearSelectedCommands(); + flowchart.ClearSelectedCommands(); } - fungusScript.AddSelectedCommand(command); + flowchart.AddSelectedCommand(command); 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) { @@ -317,7 +317,7 @@ namespace Fungus { for (int i = firstSelectedIndex; i < lastSelectedIndex; ++i) { - fungusScript.AddSelectedCommand(fungusScript.selectedSequence.commandList[i]); + flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[i]); } } if (index == firstSelectedIndex) @@ -333,7 +333,7 @@ namespace Fungus } Color commandLabelColor = Color.white; - if (fungusScript.colorCommands) + if (flowchart.colorCommands) { commandLabelColor = command.GetButtonColor(); } diff --git a/Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs.meta b/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs.meta rename to Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/CustomGUI.cs b/Assets/Fungus/Flowchart/Editor/CustomGUI.cs similarity index 100% rename from Assets/Fungus/FungusScript/Editor/CustomGUI.cs rename to Assets/Fungus/Flowchart/Editor/CustomGUI.cs diff --git a/Assets/Fungus/FungusScript/Editor/CustomGUI.cs.meta b/Assets/Fungus/Flowchart/Editor/CustomGUI.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/CustomGUI.cs.meta rename to Assets/Fungus/Flowchart/Editor/CustomGUI.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/EditorExtensions.cs b/Assets/Fungus/Flowchart/Editor/EditorExtensions.cs similarity index 100% rename from Assets/Fungus/FungusScript/Editor/EditorExtensions.cs rename to Assets/Fungus/Flowchart/Editor/EditorExtensions.cs diff --git a/Assets/Fungus/FungusScript/Editor/EditorExtensions.cs.meta b/Assets/Fungus/Flowchart/Editor/EditorExtensions.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/EditorExtensions.cs.meta rename to Assets/Fungus/Flowchart/Editor/EditorExtensions.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/EditorZoomArea.cs b/Assets/Fungus/Flowchart/Editor/EditorZoomArea.cs similarity index 100% rename from Assets/Fungus/FungusScript/Editor/EditorZoomArea.cs rename to Assets/Fungus/Flowchart/Editor/EditorZoomArea.cs diff --git a/Assets/Fungus/FungusScript/Editor/EditorZoomArea.cs.meta b/Assets/Fungus/Flowchart/Editor/EditorZoomArea.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/EditorZoomArea.cs.meta rename to Assets/Fungus/Flowchart/Editor/EditorZoomArea.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/EventHandlerEditor.cs b/Assets/Fungus/Flowchart/Editor/EventHandlerEditor.cs similarity index 95% rename from Assets/Fungus/FungusScript/Editor/EventHandlerEditor.cs rename to Assets/Fungus/Flowchart/Editor/EventHandlerEditor.cs index d215c660..73c6a042 100644 --- a/Assets/Fungus/FungusScript/Editor/EventHandlerEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/EventHandlerEditor.cs @@ -31,7 +31,7 @@ namespace Fungus public virtual void DrawInspectorGUI() { // 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. serializedObject.Update(); SerializedProperty iterator = serializedObject.GetIterator(); diff --git a/Assets/Fungus/FungusScript/Editor/EventHandlerEditor.cs.meta b/Assets/Fungus/Flowchart/Editor/EventHandlerEditor.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/EventHandlerEditor.cs.meta rename to Assets/Fungus/Flowchart/Editor/EventHandlerEditor.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs b/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs similarity index 86% rename from Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs rename to Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs index 3019dfab..09585f73 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs @@ -9,12 +9,12 @@ using System.IO; namespace Fungus { - [CustomEditor (typeof(FungusScript))] - public class FungusScriptEditor : Editor + [CustomEditor (typeof(Flowchart))] + public class FlowchartEditor : Editor { protected class AddVariableInfo { - public FungusScript fungusScript; + public Flowchart flowchart; public System.Type variableType; } @@ -39,9 +39,9 @@ namespace Fungus { serializedObject.Update(); - FungusScript fungusScript = target as FungusScript; + Flowchart flowchart = target as Flowchart; - fungusScript.UpdateHideFlags(); + flowchart.UpdateHideFlags(); EditorGUILayout.PropertyField(descriptionProp); EditorGUILayout.PropertyField(colorCommandsProp); @@ -51,17 +51,17 @@ namespace Fungus GUILayout.BeginHorizontal(); 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."))) { - FountainExporter.ExportStrings(fungusScript); + FountainExporter.ExportStrings(flowchart); } if (GUILayout.Button(new GUIContent("Import Text", "Import story text from a file in .fountain format."))) { - FountainExporter.ImportStrings(fungusScript); + FountainExporter.ImportStrings(flowchart); } GUILayout.FlexibleSpace(); @@ -74,7 +74,7 @@ namespace Fungus { serializedObject.Update(); - FungusScript t = target as FungusScript; + Flowchart t = target as Flowchart; if (t.variables.Count == 0) { @@ -160,7 +160,7 @@ namespace Fungus } AddVariableInfo addVariableInfo = new AddVariableInfo(); - addVariableInfo.fungusScript = t; + addVariableInfo.flowchart = t; addVariableInfo.variableType = type; GUIContent typeName = new GUIContent(variableInfo.VariableType); @@ -179,7 +179,7 @@ namespace Fungus } AddVariableInfo info = new AddVariableInfo(); - info.fungusScript = t; + info.flowchart = t; info.variableType = type; GUIContent typeName = new GUIContent(variableInfo.Category + "/" + variableInfo.VariableType); @@ -202,13 +202,13 @@ namespace Fungus return; } - FungusScript fungusScript = addVariableInfo.fungusScript; + Flowchart flowchart = addVariableInfo.flowchart; System.Type variableType = addVariableInfo.variableType; - Undo.RecordObject(fungusScript, "Add Variable"); - Variable newVariable = fungusScript.gameObject.AddComponent(variableType) as Variable; - newVariable.key = fungusScript.GetUniqueVariableKey(""); - fungusScript.variables.Add(newVariable); + Undo.RecordObject(flowchart, "Add Variable"); + Variable newVariable = flowchart.gameObject.AddComponent(variableType) as Variable; + newVariable.key = flowchart.GetUniqueVariableKey(""); + flowchart.variables.Add(newVariable); } public static List FindAllDerivedTypes() diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs.meta b/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs.meta rename to Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs b/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs similarity index 80% rename from Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs rename to Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs index ab723947..0163904c 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs +++ b/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs @@ -6,12 +6,12 @@ using System.Collections; namespace Fungus { - public class FungusScriptMenuItems + public class FlowchartMenuItems { - [MenuItem("Tools/Fungus/Create/Fungus Script", false, 0)] - static void CreateFungusScript() + [MenuItem("Tools/Fungus/Create/Flowchart", false, 0)] + static void CreateFlowchart() { - SpawnPrefab("FungusScript"); + SpawnPrefab("Flowchart"); } public static GameObject SpawnPrefab(string prefabName) diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs.meta b/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs.meta rename to Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs.meta diff --git a/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs b/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs new file mode 100755 index 00000000..f6e4670f --- /dev/null +++ b/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 deleteList = new List(); + + protected List windowBlockMap = new List(); + + // 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(); + if (fungusState == null) + { + GameObject go = new GameObject("_FungusState"); + go.hideFlags = HideFlags.HideInHierarchy; + fungusState = go.AddComponent(); + } + + if (Selection.activeGameObject != null) + { + Flowchart fs = Selection.activeGameObject.GetComponent(); + 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(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 uniqueList = new List(); + List 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 connectedBlocks = new List(); + + 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() as BlockInspector; + blockInspector.hideFlags = HideFlags.DontSave; + } + + Selection.activeObject = blockInspector; + + EditorUtility.SetDirty(blockInspector); + } + } +} \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs.meta b/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs.meta rename to Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/FountainExporter.cs b/Assets/Fungus/Flowchart/Editor/FountainExporter.cs similarity index 84% rename from Assets/Fungus/FungusScript/Editor/FountainExporter.cs rename to Assets/Fungus/Flowchart/Editor/FountainExporter.cs index abcb6f9b..7af75535 100644 --- a/Assets/Fungus/FungusScript/Editor/FountainExporter.cs +++ b/Assets/Fungus/Flowchart/Editor/FountainExporter.cs @@ -1,4 +1,4 @@ -using UnityEditor; +using UnityEditor; using UnityEngine; using System.Collections; using System.Collections.Generic; @@ -17,15 +17,15 @@ namespace Fungus public class FountainExporter { - public static void ExportStrings(FungusScript fungusScript) + public static void ExportStrings(Flowchart flowchart) { - if (fungusScript == null) + if (flowchart == null) { return; } string path = EditorUtility.SaveFilePanel("Export strings", "", - fungusScript.name + ".txt", ""); + flowchart.name + ".txt", ""); if(path.Length == 0) { @@ -34,17 +34,17 @@ namespace Fungus // 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 += "\n"; - // In every sequence, write out Say & Menu text in order - Sequence[] sequences = fungusScript.GetComponentsInChildren(); - foreach (Sequence s in sequences) + // In every block, write out Say & Menu text in order + Block[] blocks = flowchart.GetComponentsInChildren(); + foreach (Block block in blocks) { // Check for any Say, Menu or Comment commands bool hasText = false; - foreach (Command c in s.commandList) + foreach (Command c in block.commandList) { System.Type t = c.GetType(); if (t == typeof(Say) || @@ -59,9 +59,9 @@ namespace Fungus 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)) { @@ -124,7 +124,7 @@ namespace Fungus File.WriteAllText(path, exportText); } - public static void ImportStrings(FungusScript fungusScript) + public static void ImportStrings(Flowchart flowchart) { string path = EditorUtility.OpenFilePanel("Import strings", "", ""); @@ -140,7 +140,7 @@ namespace Fungus // Build dict of commands Dictionary commandDict = new Dictionary(); - foreach (Command c in fungusScript.gameObject.GetComponentsInChildren()) + foreach (Command c in flowchart.gameObject.GetComponentsInChildren()) { commandDict.Add (c.commandId, c); } diff --git a/Assets/Fungus/FungusScript/Editor/FountainExporter.cs.meta b/Assets/Fungus/Flowchart/Editor/FountainExporter.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/FountainExporter.cs.meta rename to Assets/Fungus/Flowchart/Editor/FountainExporter.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/FungusEditorResources.cs b/Assets/Fungus/Flowchart/Editor/FungusEditorResources.cs similarity index 100% rename from Assets/Fungus/FungusScript/Editor/FungusEditorResources.cs rename to Assets/Fungus/Flowchart/Editor/FungusEditorResources.cs diff --git a/Assets/Fungus/FungusScript/Editor/FungusEditorResources.cs.meta b/Assets/Fungus/Flowchart/Editor/FungusEditorResources.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/FungusEditorResources.cs.meta rename to Assets/Fungus/Flowchart/Editor/FungusEditorResources.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/GLDraw.cs b/Assets/Fungus/Flowchart/Editor/GLDraw.cs similarity index 100% rename from Assets/Fungus/FungusScript/Editor/GLDraw.cs rename to Assets/Fungus/Flowchart/Editor/GLDraw.cs diff --git a/Assets/Fungus/FungusScript/Editor/GLDraw.cs.meta b/Assets/Fungus/Flowchart/Editor/GLDraw.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/GLDraw.cs.meta rename to Assets/Fungus/Flowchart/Editor/GLDraw.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/IfEditor.cs b/Assets/Fungus/Flowchart/Editor/IfEditor.cs similarity index 97% rename from Assets/Fungus/FungusScript/Editor/IfEditor.cs rename to Assets/Fungus/Flowchart/Editor/IfEditor.cs index 77015fd4..22822293 100644 --- a/Assets/Fungus/FungusScript/Editor/IfEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/IfEditor.cs @@ -33,8 +33,8 @@ namespace Fungus If t = target as If; - FungusScript fungusScript = t.GetFungusScript(); - if (fungusScript == null) + Flowchart flowchart = t.GetFlowchart(); + if (flowchart == null) { return; } diff --git a/Assets/Fungus/FungusScript/Editor/IfEditor.cs.meta b/Assets/Fungus/Flowchart/Editor/IfEditor.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/IfEditor.cs.meta rename to Assets/Fungus/Flowchart/Editor/IfEditor.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/JumpEditor.cs b/Assets/Fungus/Flowchart/Editor/JumpEditor.cs similarity index 95% rename from Assets/Fungus/FungusScript/Editor/JumpEditor.cs rename to Assets/Fungus/Flowchart/Editor/JumpEditor.cs index a654db8c..af7c3cc5 100644 --- a/Assets/Fungus/FungusScript/Editor/JumpEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/JumpEditor.cs @@ -23,7 +23,7 @@ namespace Fungus LabelEditor.LabelField(targetLabelProp, new GUIContent("Target Label", "Label to jump to"), - t.parentSequence); + t.parentBlock); serializedObject.ApplyModifiedProperties(); } diff --git a/Assets/Fungus/FungusScript/Editor/JumpEditor.cs.meta b/Assets/Fungus/Flowchart/Editor/JumpEditor.cs.meta similarity index 100% rename from Assets/Fungus/FungusScript/Editor/JumpEditor.cs.meta rename to Assets/Fungus/Flowchart/Editor/JumpEditor.cs.meta diff --git a/Assets/Fungus/FungusScript/Editor/LabelEditor.cs b/Assets/Fungus/Flowchart/Editor/LabelEditor.cs similarity index 84% rename from Assets/Fungus/FungusScript/Editor/LabelEditor.cs rename to Assets/Fungus/Flowchart/Editor/LabelEditor.cs index 4a8e75f8..e7f3ce06 100644 --- a/Assets/Fungus/FungusScript/Editor/LabelEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/LabelEditor.cs @@ -15,7 +15,7 @@ namespace Fungus static public void LabelField(SerializedProperty property, GUIContent labelText, - Sequence sequence) + Block block) { List labelKeys = new List(); List