/// <summary> /// Choose a save slot. This slot will now act as the active save slot for /// any data transactions. /// </summary> /// <param name="index">The index of the save slot.</param> /// <returns>True if the slot exists. False otherwise.</returns> public static bool ChooseSlot(int index) { if (index < 0 || index >= slots.Count) { return(false); } activeSlot = slots[index]; return(true); }
/// <summary> /// Delete a save slot. /// </summary> /// <param name="filename">The name of the save file to delete.</param> public static void Delete(string filename) { SaveSlot file = slots.Find((SaveSlot slot) => slot.Name == filename); if (file != null) { file.DeleteFolder(); slots.Remove(file); } }
//------------------------------------------------------------------------- // Public Interface //------------------------------------------------------------------------- /// <summary> /// Saves game data for a certain save file out to disk. /// </summary> /// <param name="filename">The name of the save file to save.</param> public static bool Save(string filename) { SaveSlot file = slots.Find((SaveSlot slot) => slot.Name == filename); if (file != null) { return(file.Save()); } return(false); }
/// <summary> /// Choose a save slot. This slot will now act as the active save slot for /// any data transactions. /// </summary> /// <param name="filename">The name of the slot.</param> /// <returns>True if the slot exists. False otherwise.</returns> public static bool ChooseSlot(string filename) { SaveSlot slot = slots.Find((SaveSlot s) => s.Name == filename); if (slot != null) { activeSlot = slot; return(true); } return(false); }
/// <summary> /// Load the list of available save files. /// </summary> /// <returns>True if the list of save files was loaded successfully.</returns> public static bool LoadSlots() { string[] paths = Directory.GetDirectories(directory); foreach (string path in paths) { SaveSlot file = new SaveSlot(path); slots.Add(file); } return(true); }
/// <summary> /// Resets the Save Data system. /// </summary> /// <param name="ignoreFolders">Do not delete the physical folders.</param> public static void Reset(bool ignoreFolders = false) { activeSlot = null; if (!ignoreFolders) { foreach (SaveSlot slot in slots) { slot.DeleteFolder(); } } slots = new List <SaveSlot>(); }
/// <summary> /// Creates a new save slot. /// </summary> /// <param name="filename">The name of the save file to create.</param> public static void CreateSlot(string filename) { string path = IO.Path.Combine(Path, filename); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } SaveSlot file = new SaveSlot(path); slots.Add(file); }