Browse Source

Added save description field

master
Christopher 8 years ago
parent
commit
a9600010bf
  1. 4
      Assets/Fungus/Scripts/Commands/SavePoint.cs
  2. 7
      Assets/Fungus/Scripts/Components/SaveManager.cs
  3. 2
      Assets/Fungus/Scripts/SavePoints/SavePointData.cs
  4. 6
      Assets/FungusExamples/SaveGame/SceneA.unity

4
Assets/Fungus/Scripts/Commands/SavePoint.cs

@ -14,6 +14,8 @@ namespace Fungus
{ {
[SerializeField] protected string saveKey; [SerializeField] protected string saveKey;
[SerializeField] protected string description;
[SerializeField] protected bool saveNow; [SerializeField] protected bool saveNow;
#region Public members #region Public members
@ -22,7 +24,7 @@ namespace Fungus
{ {
var saveManager = FungusManager.Instance.SaveManager; var saveManager = FungusManager.Instance.SaveManager;
saveManager.PopulateSaveBuffer(GetFlowchart(), saveKey); saveManager.PopulateSaveBuffer(GetFlowchart(), saveKey, description);
if (saveNow) if (saveNow)
{ {

7
Assets/Fungus/Scripts/Components/SaveManager.cs

@ -55,13 +55,14 @@ namespace Fungus
return true; return true;
} }
protected virtual string CreateSaveData(Flowchart flowchart, string saveKey) protected virtual string CreateSaveData(Flowchart flowchart, string saveKey, string description)
{ {
var saveData = new SavePointData(); var saveData = new SavePointData();
// Store the scene, flowchart and block to execute on resume // Store the scene, flowchart and block to execute on resume
saveData.SceneName = SceneManager.GetActiveScene().name; saveData.SceneName = SceneManager.GetActiveScene().name;
saveData.SaveKey = saveKey; saveData.SaveKey = saveKey;
saveData.Description = description;
var flowchartData = FlowchartData.Encode(flowchart); var flowchartData = FlowchartData.Encode(flowchart);
saveData.FlowchartData.Add(flowchartData); saveData.FlowchartData.Add(flowchartData);
@ -181,9 +182,9 @@ namespace Fungus
PlayerPrefs.DeleteKey(key); 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 #endregion

2
Assets/Fungus/Scripts/SavePoints/SavePointData.cs

@ -7,12 +7,14 @@ namespace Fungus
public class SavePointData public class SavePointData
{ {
[SerializeField] protected string saveKey; [SerializeField] protected string saveKey;
[SerializeField] protected string description;
[SerializeField] protected string sceneName; [SerializeField] protected string sceneName;
[SerializeField] protected List<FlowchartData> flowchartData = new List<FlowchartData>(); [SerializeField] protected List<FlowchartData> flowchartData = new List<FlowchartData>();
#region Public methods #region Public methods
public string SaveKey { get { return saveKey; } set { saveKey = value; } } 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 string SceneName { get { return sceneName; } set { sceneName = value; } }
public List<FlowchartData> FlowchartData { get { return flowchartData; } set { flowchartData = value; } } public List<FlowchartData> FlowchartData { get { return flowchartData; } set { flowchartData = value; } }

6
Assets/FungusExamples/SaveGame/SceneA.unity

@ -213,8 +213,9 @@ MonoBehaviour:
width: 1328 width: 1328
height: 909 height: 909
selectedBlocks: selectedBlocks:
- {fileID: 27697883} - {fileID: 27697870}
selectedCommands: [] selectedCommands:
- {fileID: 27697876}
variables: variables:
- {fileID: 27697873} - {fileID: 27697873}
description: description:
@ -312,6 +313,7 @@ MonoBehaviour:
itemId: 5 itemId: 5
indentLevel: 0 indentLevel: 0
saveKey: save_1 saveKey: save_1
description: Entering the forest
saveNow: 0 saveNow: 0
--- !u!114 &27697877 --- !u!114 &27697877
MonoBehaviour: MonoBehaviour:

Loading…
Cancel
Save