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

slots int

Properties

LastError

Error text of the last failed call (null after a success).

public string LastError { get; }

Property Value

string

LastStatus

Status of the last Load(int, out ProfileData).

public SaveLoadStatus LastStatus { get; }

Property Value

SaveLoadStatus

SlotCount

Number of slots offered (slot pickers show this many).

public int SlotCount { get; }

Property Value

int

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

slot int
text string

Returns

string

Delete(int)

Deletes a slot (the player asked for it). Returns false on failure.

public bool Delete(int slot)

Parameters

slot int

Returns

bool

DeleteText(int)

Removes a slot.

protected abstract void DeleteText(int slot)

Parameters

slot int

Exists(int)

Whether slot holds data.

public bool Exists(int slot)

Parameters

slot int

Returns

bool

HasText(int)

Whether a slot holds text.

protected abstract bool HasText(int slot)

Parameters

slot int

Returns

bool

Load(int, out ProfileData)

Reads a slot. data is set for Loaded and Migrated.

public SaveLoadStatus Load(int slot, out ProfileData data)

Parameters

slot int
data ProfileData

Returns

SaveLoadStatus

ReadText(int)

Reads the raw text of a slot, or null when it is empty.

protected abstract string ReadText(int slot)

Parameters

slot int

Returns

string

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

slot int
data ProfileData

Returns

bool

Valid(int)

Whether slot is a valid slot number.

protected bool Valid(int slot)

Parameters

slot int

Returns

bool

WriteText(int, string)

Writes the raw text of a slot.

protected abstract void WriteText(int slot, string text)

Parameters

slot int
text string