public static void ConvertToSlotSystem(string name, TitleScreen.GameSetup.PlayerModes mode) { string text = PlayerPrefsFile.GetPath(name); if (mode == TitleScreen.GameSetup.PlayerModes.Multiplayer) { text += "MP"; } if (File.Exists(text)) { string localSlotPath = SaveSlotUtils.GetLocalSlotPath(mode, TitleScreen.GameSetup.Slots.Slot1); if (!Directory.Exists(localSlotPath)) { Directory.CreateDirectory(localSlotPath); } File.Move(text, localSlotPath + name); } if (CoopSteamCloud.ShouldUseCloud() && CoopSteamCloud.CloudFileExist(name)) { Debug.Log("Converting cloud file: '" + name + "' to slot system"); byte[] buffer = CoopSteamCloud.CloudLoad(name); CoopSteamCloud.CloudDelete(name); if (CoopSteamCloud.CloudSave(SaveSlotUtils.GetCloudSlotPath() + name, buffer)) { Debug.Log(name + " converted successfully"); } else { Debug.Log(name + " update failed"); } } }
public static string GetCloudSlotPath(TitleScreen.GameSetup.PlayerModes mode, TitleScreen.GameSetup.Slots slot) { return(string.Concat(new object[] { mode, "_", slot, "_" })); }
public static string GetLocalSlotPath(TitleScreen.GameSetup.PlayerModes mode, TitleScreen.GameSetup.Slots slot) { return(string.Concat(new object[] { SaveSlotUtils.GetUserPath(), mode, "/", slot, "/" })); }
public static void DeleteSlot(TitleScreen.GameSetup.PlayerModes mode, TitleScreen.GameSetup.Slots slot) { string localSlotPath = SaveSlotUtils.GetLocalSlotPath(mode, slot); if (Directory.Exists(localSlotPath)) { SaveSlotUtils.DeleteDirectory(localSlotPath); } string[] array = CoopSteamCloud.ListFiles(); string cloudSlotPath = SaveSlotUtils.GetCloudSlotPath(mode, slot); for (int i = 0; i < array.Length; i++) { if (array[i].StartsWith(cloudSlotPath)) { CoopSteamCloud.CloudDelete(array[i]); } } }
public static void SyncWithCloud(string name, TitleScreen.GameSetup.PlayerModes mode, TitleScreen.GameSetup.Slots slot) { string localSlotPath = SaveSlotUtils.GetLocalSlotPath(mode, slot); string path = localSlotPath + name; string filename = SaveSlotUtils.GetCloudSlotPath(mode, slot) + name; bool flag = File.Exists(path); bool flag2 = CoopSteamCloud.CloudFileExist(filename); long num = 0L; long num2 = 0L; if (flag2 && flag) { num = CoopSteamCloud.CloudTimestamp(filename); num2 = File.GetCreationTime(path).ToUnixTimestamp(); flag2 = (num > num2); flag = (num < num2); } if (flag2) { Debug.Log(string.Concat(new object[] { "Syncing ", mode, "/", slot, "/", name, " from cloud(", num, ") to local(", num2, ")" })); if (!Directory.Exists(localSlotPath)) { Directory.CreateDirectory(localSlotPath); } File.WriteAllBytes(path, CoopSteamCloud.CloudLoad(filename)); File.SetCreationTime(path, DateEx.UnixTimeStampToDateTime(num)); Debug.Log(string.Concat(new object[] { "Local file (", name, ") Creation Time: ", File.GetCreationTime(path).ToUnixTimestamp(), " - ", num, " = ", File.GetCreationTime(path).ToUnixTimestamp() - num, "?" })); } else if (flag) { byte[] buffer = File.ReadAllBytes(path); bool flag3 = CoopSteamCloud.CloudSave(filename, buffer); Debug.Log(string.Concat(new object[] { "Cloud file (", name, ") Creation time: ", CoopSteamCloud.CloudTimestamp(filename), " - ", File.GetCreationTime(path).ToUnixTimestamp(), " = ", CoopSteamCloud.CloudTimestamp(filename) - File.GetCreationTime(path).ToUnixTimestamp(), "?" })); } }