Class JsonFileSaveStore
- Namespace
- TDMaker.Unity.Campaign
- Assembly
- TDMaker.Unity.dll
Default store: one JSON file per slot under UnityEngine.Application.persistentDataPath (folder TDMakerSaves, files
slot1.json, slot2.json, ...). Writes go to a temporary file that then replaces the slot file, so a crash
mid-write leaves the previous save intact. An unreadable file is renamed to slotN.json.bak (or .bak2, ...)
and kept. Not for WebGL (use PlayerPrefsSaveStore, or CreateDefault(int, string)).
public sealed class JsonFileSaveStore : TextSaveStore, ISaveStore
- Inheritance
-
JsonFileSaveStore
- Implements
- Inherited Members
Constructors
JsonFileSaveStore(string, int, string)
Creates a store. folder null uses persistentDataPath/TDMakerSaves.
public JsonFileSaveStore(string folder = null, int slots = 3, string filePrefix = "slot")
Parameters
Fields
DefaultFolderName
Default folder name under UnityEngine.Application.persistentDataPath.
public const string DefaultFolderName = "TDMakerSaves"
Field Value
Properties
FilePrefix
File name stem (files are stem + slot number + .json).
public string FilePrefix { get; }
Property Value
Folder
Folder of the slot files.
public string Folder { get; }
Property Value
Methods
Backup(int, string)
Moves unreadable slot content out of the way, keeping it. Returns where it went (for the warning).
protected override string Backup(int slot, string text)
Parameters
Returns
DeleteText(int)
Removes a slot.
protected override void DeleteText(int slot)
Parameters
slotint
GetBackups(int)
Backup files of slot kept after unreadable loads (oldest first).
public List<string> GetBackups(int slot)
Parameters
slotint
Returns
HasText(int)
Whether a slot holds text.
protected override bool HasText(int slot)
Parameters
slotint
Returns
PathOf(int)
Path of the file of slot.
public string PathOf(int slot)
Parameters
slotint
Returns
ReadText(int)
Reads the raw text of a slot, or null when it is empty.
protected override string ReadText(int slot)
Parameters
slotint
Returns
WriteText(int, string)
Writes the raw text of a slot.
protected override void WriteText(int slot, string text)