From 43a8aabccfbd185ae84e02344c77e685a9816fe5 Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 14 Nov 2016 15:46:18 +0000 Subject: [PATCH] Renamed save commands --- .../{LoadFlowchart.cs => LoadGame.cs} | 10 +-- ...LoadFlowchart.cs.meta => LoadGame.cs.meta} | 0 .../{SaveFlowchart.cs => SavePoint.cs} | 10 +-- ...aveFlowchart.cs.meta => SavePoint.cs.meta} | 0 ...eFlowchartEditor.cs => SavePointEditor.cs} | 16 ++-- ...Editor.cs.meta => SavePointEditor.cs.meta} | 0 Assets/FungusExamples/SaveGame/SceneA.unity | 85 +++++++++++++++++-- ProjectSettings/EditorBuildSettings.asset | 4 +- 8 files changed, 98 insertions(+), 27 deletions(-) rename Assets/Fungus/Scripts/Commands/{LoadFlowchart.cs => LoadGame.cs} (73%) rename Assets/Fungus/Scripts/Commands/{LoadFlowchart.cs.meta => LoadGame.cs.meta} (100%) rename Assets/Fungus/Scripts/Commands/{SaveFlowchart.cs => SavePoint.cs} (84%) rename Assets/Fungus/Scripts/Commands/{SaveFlowchart.cs.meta => SavePoint.cs.meta} (100%) rename Assets/Fungus/Scripts/Editor/{SaveFlowchartEditor.cs => SavePointEditor.cs} (67%) rename Assets/Fungus/Scripts/Editor/{SaveFlowchartEditor.cs.meta => SavePointEditor.cs.meta} (100%) diff --git a/Assets/Fungus/Scripts/Commands/LoadFlowchart.cs b/Assets/Fungus/Scripts/Commands/LoadGame.cs similarity index 73% rename from Assets/Fungus/Scripts/Commands/LoadFlowchart.cs rename to Assets/Fungus/Scripts/Commands/LoadGame.cs index 5800344f..ed661912 100644 --- a/Assets/Fungus/Scripts/Commands/LoadFlowchart.cs +++ b/Assets/Fungus/Scripts/Commands/LoadGame.cs @@ -2,15 +2,13 @@ // It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) using UnityEngine; -using UnityEngine.SceneManagement; -using System.Collections.Generic; namespace Fungus { [CommandInfo("Variable", - "Load Flowchart", - "Loads a previously saved Flowchart state. The original scene is loaded and the resume block is executed.")] - public class LoadFlowchart : Command + "Load Game", + "Loads a previously saved game. The original scene is loaded and the resume block is executed.")] + public class LoadGame : Command { [SerializeField] protected IntegerData saveSlot = new IntegerData(0); @@ -20,7 +18,7 @@ namespace Fungus { var saveManager = FungusManager.Instance.SaveManager; - saveManager.Load(0); + saveManager.Load(saveSlot.Value); } public override string GetSummary() diff --git a/Assets/Fungus/Scripts/Commands/LoadFlowchart.cs.meta b/Assets/Fungus/Scripts/Commands/LoadGame.cs.meta similarity index 100% rename from Assets/Fungus/Scripts/Commands/LoadFlowchart.cs.meta rename to Assets/Fungus/Scripts/Commands/LoadGame.cs.meta diff --git a/Assets/Fungus/Scripts/Commands/SaveFlowchart.cs b/Assets/Fungus/Scripts/Commands/SavePoint.cs similarity index 84% rename from Assets/Fungus/Scripts/Commands/SaveFlowchart.cs rename to Assets/Fungus/Scripts/Commands/SavePoint.cs index 20ff7240..bb9c67da 100644 --- a/Assets/Fungus/Scripts/Commands/SaveFlowchart.cs +++ b/Assets/Fungus/Scripts/Commands/SavePoint.cs @@ -8,13 +8,13 @@ using System.Collections.Generic; namespace Fungus { [CommandInfo("Variable", - "Save Flowchart", - "Saves the current Flowchart variable state to be loaded again in future.")] - public class SaveFlowchart : Command + "Save Point", + "Creates a save point which can be saved to persistant storage and loaded again later.")] + public class SavePoint : Command { [SerializeField] protected Block resumeBlock; - [SerializeField] protected bool saveImmediately; + [SerializeField] protected bool saveNow; #region Public members @@ -24,7 +24,7 @@ namespace Fungus saveManager.PopulateSaveBuffer(GetFlowchart(), resumeBlock.BlockName); - if (saveImmediately) + if (saveNow) { saveManager.Save(); } diff --git a/Assets/Fungus/Scripts/Commands/SaveFlowchart.cs.meta b/Assets/Fungus/Scripts/Commands/SavePoint.cs.meta similarity index 100% rename from Assets/Fungus/Scripts/Commands/SaveFlowchart.cs.meta rename to Assets/Fungus/Scripts/Commands/SavePoint.cs.meta diff --git a/Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs b/Assets/Fungus/Scripts/Editor/SavePointEditor.cs similarity index 67% rename from Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs rename to Assets/Fungus/Scripts/Editor/SavePointEditor.cs index 1fb9565f..a7b84753 100644 --- a/Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs +++ b/Assets/Fungus/Scripts/Editor/SavePointEditor.cs @@ -7,11 +7,11 @@ using Fungus; namespace Fungus.EditorUtils { - [CustomEditor(typeof(SaveFlowchart))] - public class SaveFlowchartEditor : CommandEditor + [CustomEditor(typeof(SavePoint))] + public class SavePointEditor : CommandEditor { protected SerializedProperty resumeBlockProp; - protected SerializedProperty saveImmediatelyProp; + protected SerializedProperty saveNowProp; protected virtual void OnEnable() { @@ -19,7 +19,7 @@ namespace Fungus.EditorUtils return; resumeBlockProp = serializedObject.FindProperty("resumeBlock"); - saveImmediatelyProp = serializedObject.FindProperty("saveImmediately"); + saveNowProp = serializedObject.FindProperty("saveNow"); } public override void DrawCommandGUI() @@ -33,10 +33,10 @@ namespace Fungus.EditorUtils serializedObject.Update(); BlockEditor.BlockField(resumeBlockProp, - new GUIContent("Resume Block", "Block to call when save data is loaded again"), - new GUIContent(""), - flowchart); - EditorGUILayout.PropertyField(saveImmediatelyProp); + new GUIContent("Resume Block", "Block to call when save data is loaded again"), + new GUIContent(""), + flowchart); + EditorGUILayout.PropertyField(saveNowProp); serializedObject.ApplyModifiedProperties(); } diff --git a/Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs.meta b/Assets/Fungus/Scripts/Editor/SavePointEditor.cs.meta similarity index 100% rename from Assets/Fungus/Scripts/Editor/SaveFlowchartEditor.cs.meta rename to Assets/Fungus/Scripts/Editor/SavePointEditor.cs.meta diff --git a/Assets/FungusExamples/SaveGame/SceneA.unity b/Assets/FungusExamples/SaveGame/SceneA.unity index 07c45bae..6112856c 100644 --- a/Assets/FungusExamples/SaveGame/SceneA.unity +++ b/Assets/FungusExamples/SaveGame/SceneA.unity @@ -103,6 +103,9 @@ GameObject: - 114: {fileID: 27697869} - 114: {fileID: 27697868} - 114: {fileID: 27697873} + - 114: {fileID: 27697874} + - 114: {fileID: 27697875} + - 114: {fileID: 27697876} m_Layer: 0 m_Name: Flowchart m_TagString: Untagged @@ -175,6 +178,8 @@ MonoBehaviour: eventHandler: {fileID: 27697869} commandList: - {fileID: 27697868} + - {fileID: 27697874} + - {fileID: 27697876} --- !u!114 &27697871 MonoBehaviour: m_ObjectHideFlags: 0 @@ -195,12 +200,14 @@ MonoBehaviour: zoom: 1 scrollViewRect: serializedVersion: 2 - x: -343 - y: -340 - width: 1114 - height: 859 - selectedBlocks: [] - selectedCommands: [] + x: -350 + y: -350 + width: 1121 + height: 869 + selectedBlocks: + - {fileID: 27697870} + selectedCommands: + - {fileID: 27697876} variables: - {fileID: 27697873} description: @@ -240,6 +247,72 @@ MonoBehaviour: scope: 0 key: Count value: 0 +--- !u!114 &27697874 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 27697867} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fb77d0ce495044f6e9feb91b31798e8c, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 2 + indentLevel: 0 + variable: {fileID: 27697873} + setOperator: 2 + booleanData: + booleanRef: {fileID: 0} + booleanVal: 0 + integerData: + integerRef: {fileID: 0} + integerVal: 1 + floatData: + floatRef: {fileID: 0} + floatVal: 0 + stringData: + stringRef: {fileID: 0} + stringVal: +--- !u!114 &27697875 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 27697867} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} + m_Name: + m_EditorClassIdentifier: + nodeRect: + serializedVersion: 2 + x: 224 + y: 74 + width: 120 + height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 + itemId: 4 + blockName: New Block + description: + eventHandler: {fileID: 0} + commandList: [] +--- !u!114 &27697876 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 27697867} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0b115619cb83b4d6ab8047d0e9407403, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 5 + indentLevel: 0 + resumeBlock: {fileID: 27697875} + saveNow: 0 --- !u!1 &132834842 GameObject: m_ObjectHideFlags: 0 diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index bbb972d6..20ed1e07 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -6,6 +6,6 @@ EditorBuildSettings: serializedVersion: 2 m_Scenes: - enabled: 1 - path: Assets/FungusExamples/Sherlock/TheExperiment.unity + path: Assets/FungusExamples/SaveGame/Menu.unity - enabled: 1 - path: Assets/Tests/Lua/SceneB.unity + path: Assets/FungusExamples/SaveGame/SceneA.unity