From a9600010bf41c501d7e64138c6015e259f2b88de Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 15 Nov 2016 12:52:00 +0000 Subject: [PATCH] Added save description field --- Assets/Fungus/Scripts/Commands/SavePoint.cs | 4 +++- Assets/Fungus/Scripts/Components/SaveManager.cs | 7 ++++--- Assets/Fungus/Scripts/SavePoints/SavePointData.cs | 2 ++ Assets/FungusExamples/SaveGame/SceneA.unity | 6 ++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Assets/Fungus/Scripts/Commands/SavePoint.cs b/Assets/Fungus/Scripts/Commands/SavePoint.cs index b1ce72e1..ef2c355d 100644 --- a/Assets/Fungus/Scripts/Commands/SavePoint.cs +++ b/Assets/Fungus/Scripts/Commands/SavePoint.cs @@ -14,6 +14,8 @@ namespace Fungus { [SerializeField] protected string saveKey; + [SerializeField] protected string description; + [SerializeField] protected bool saveNow; #region Public members @@ -22,7 +24,7 @@ namespace Fungus { var saveManager = FungusManager.Instance.SaveManager; - saveManager.PopulateSaveBuffer(GetFlowchart(), saveKey); + saveManager.PopulateSaveBuffer(GetFlowchart(), saveKey, description); if (saveNow) { diff --git a/Assets/Fungus/Scripts/Components/SaveManager.cs b/Assets/Fungus/Scripts/Components/SaveManager.cs index eec1513a..3067afcb 100644 --- a/Assets/Fungus/Scripts/Components/SaveManager.cs +++ b/Assets/Fungus/Scripts/Components/SaveManager.cs @@ -55,13 +55,14 @@ namespace Fungus return true; } - protected virtual string CreateSaveData(Flowchart flowchart, string saveKey) + protected virtual string CreateSaveData(Flowchart flowchart, string saveKey, string description) { var saveData = new SavePointData(); // Store the scene, flowchart and block to execute on resume saveData.SceneName = SceneManager.GetActiveScene().name; saveData.SaveKey = saveKey; + saveData.Description = description; var flowchartData = FlowchartData.Encode(flowchart); saveData.FlowchartData.Add(flowchartData); @@ -181,9 +182,9 @@ namespace Fungus PlayerPrefs.DeleteKey(key); } - public virtual void PopulateSaveBuffer(Flowchart flowchart, string saveKey) + public virtual void PopulateSaveBuffer(Flowchart flowchart, string saveKey, string description) { - saveBuffer = CreateSaveData(flowchart, saveKey); + saveBuffer = CreateSaveData(flowchart, saveKey, description); } #endregion diff --git a/Assets/Fungus/Scripts/SavePoints/SavePointData.cs b/Assets/Fungus/Scripts/SavePoints/SavePointData.cs index 184da366..f2939be0 100644 --- a/Assets/Fungus/Scripts/SavePoints/SavePointData.cs +++ b/Assets/Fungus/Scripts/SavePoints/SavePointData.cs @@ -7,12 +7,14 @@ namespace Fungus public class SavePointData { [SerializeField] protected string saveKey; + [SerializeField] protected string description; [SerializeField] protected string sceneName; [SerializeField] protected List flowchartData = new List(); #region Public methods public string SaveKey { get { return saveKey; } set { saveKey = value; } } + public string Description { get { return description; } set { description = value; } } public string SceneName { get { return sceneName; } set { sceneName = value; } } public List FlowchartData { get { return flowchartData; } set { flowchartData = value; } } diff --git a/Assets/FungusExamples/SaveGame/SceneA.unity b/Assets/FungusExamples/SaveGame/SceneA.unity index 61550ab3..af9061e1 100644 --- a/Assets/FungusExamples/SaveGame/SceneA.unity +++ b/Assets/FungusExamples/SaveGame/SceneA.unity @@ -213,8 +213,9 @@ MonoBehaviour: width: 1328 height: 909 selectedBlocks: - - {fileID: 27697883} - selectedCommands: [] + - {fileID: 27697870} + selectedCommands: + - {fileID: 27697876} variables: - {fileID: 27697873} description: @@ -312,6 +313,7 @@ MonoBehaviour: itemId: 5 indentLevel: 0 saveKey: save_1 + description: Entering the forest saveNow: 0 --- !u!114 &27697877 MonoBehaviour: