new void OnGUI() { if (bIsChoosingBackup) { DrawBackupList(); } else { if (bBackupLoaded) { if (CurBackupData != null) { GUIStyle BackupTextStyle = new GUIStyle("label"); BackupTextStyle.fontSize = 30; GUI.Label(new Rect(Screen.width * .07f, Screen.height * .11f, Screen.width * .86f, Screen.height * .3f), "Backup data for: " + GetBackupDisplayString(CurBackupData), BackupTextStyle); if (GUI.Button(new Rect(Screen.width * .07f, Screen.height * .35f, Screen.width * .3f, Screen.height * .2f), "Send Backup Data")) { SendResultsToHeadJudger((int)CurData.Division, (int)CurData.Round, (int)CurData.Pool, CurData.Team); } if (GUI.Button(new Rect(Screen.width * .42f, Screen.height * .35f, Screen.width * .51f, Screen.height * .2f), "Exit Backup mode and discard changes")) { bBackupLoaded = false; CurBackupData = null; } } } else { base.OnGUI(); } } }
string GetBackupDisplayString(BackupExData bd) { TeamData td = Global.GetTeamData(bd.Data.Division, bd.Data.Round, bd.Data.Pool, bd.Data.Team); string TeamName = td != null ? td.PlayerNames : "Missing Team"; NameData JudgeNameData = NameDatabase.FindInDatabase(bd.Data.JudgeNameId); string JudgeName = JudgeNameData != null ? JudgeNameData.DisplayName : "Missing Judge"; string BackupStr = JudgeName + " " + bd.Data.Division.ToString() + " " + bd.Data.Round.ToString() + " " + (char)(bd.Data.Pool + 'A') + " | " + TeamName + " | " + bd.WrittenTime.ToString(); return(BackupStr); }
public override void RecoverAutosave() { base.RecoverAutosave(); BackupList.Clear(); string BackupPath = Application.persistentDataPath + "/Backup"; string[] Files = Directory.GetFiles(BackupPath); foreach (string filename in Files) { if (filename.Contains("ExBackup")) { BackupExData backup = new BackupExData(); try { FileStream BackupFile = new FileStream(filename, FileMode.Open); backup.Data = ExData.Load(BackupFile); backup.Filename = filename; BackupFile.Close(); } catch (System.Exception e) { Debug.Log("Load autosave exception: " + e.Message); } backup.WrittenTime = File.GetLastWriteTime(filename); BackupList.Add(backup); } } BackupList.Sort( delegate(BackupExData b1, BackupExData b2) { if (b1 == b2) { return(0); } else if (b1.WrittenTime < b2.WrittenTime) { return(1); } else { return(-1); } }); // Delete old backup files if (BackupList.Count > Global.MaxBackupFileCount) { for (int FileIndex = Global.MaxBackupFileCount; FileIndex < BackupList.Count; ++FileIndex) { try { File.Delete(BackupList[FileIndex].Filename); } catch (System.Exception e) { Debug.Log("Delete old backup files exception: " + e.Message); } } while (BackupList.Count > Global.MaxBackupFileCount) { BackupList.RemoveAt(Global.MaxBackupFileCount); } } }