Class TextSaveStore
- Namespace
- TDMaker.Unity.Campaign
- Assembly
- TDMaker.Unity.dll
Shared logic of the text-based stores: JSON through ProfileSerializer, unreadable or newer content moved to a backup before the slot is treated as empty, and exceptions turned into results with a warning.
public abstract class TextSaveStore : ISaveStore
- Inheritance
-
TextSaveStore
- Implements
- Derived
- Inherited Members
Constructors
TextSaveStore(int)
Creates a store with slots slots (at least 1).
protected TextSaveStore(int slots)
Parameters
slotsint
Properties
LastError
Error text of the last failed call (null after a success).
public string LastError { get; }
Property Value
LastStatus
Status of the last Load(int, out ProfileData).
public SaveLoadStatus LastStatus { get; }
Property Value
SlotCount
Number of slots offered (slot pickers show this many).
public int SlotCount { 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 abstract string Backup(int slot, string text)
Parameters
Returns
Delete(int)
Deletes a slot (the player asked for it). Returns false on failure.
public bool Delete(int slot)
Parameters
slotint
Returns
DeleteText(int)
Removes a slot.
protected abstract void DeleteText(int slot)
Parameters
slotint
Exists(int)
Whether slot holds data.
public bool Exists(int slot)
Parameters
slotint
Returns
HasText(int)
Whether a slot holds text.
protected abstract bool HasText(int slot)
Parameters
slotint
Returns
Load(int, out ProfileData)
public SaveLoadStatus Load(int slot, out ProfileData data)
Parameters
slotintdataProfileData
Returns
ReadText(int)
Reads the raw text of a slot, or null when it is empty.
protected abstract string ReadText(int slot)
Parameters
slotint
Returns
Save(int, ProfileData)
Writes a slot (all or nothing where the storage allows it). Returns false on failure.
public bool Save(int slot, ProfileData data)
Parameters
slotintdataProfileData
Returns
Valid(int)
Whether slot is a valid slot number.
protected bool Valid(int slot)
Parameters
slotint
Returns
WriteText(int, string)
Writes the raw text of a slot.
protected abstract void WriteText(int slot, string text)