string GetBackupDisplayString(BackupAIData 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); }
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(); } if (!bIsDrawingEditingTeams) { VarietyNS.DrawRect = Global.GetScreenSpaceRectTransform(VarietyNumberBox); TeamworkNS.DrawRect = Global.GetScreenSpaceRectTransform(TeamworkNumberBox); MusicNS.DrawRect = Global.GetScreenSpaceRectTransform(MusicNumberBox); FlowNS.DrawRect = Global.GetScreenSpaceRectTransform(FlowNumberBox); FormNS.DrawRect = Global.GetScreenSpaceRectTransform(FormNumberBox); GeneralNS.DrawRect = Global.GetScreenSpaceRectTransform(GeneralNumberBox); VarietyNS.Draw(); TeamworkNS.Draw(); MusicNS.Draw(); FlowNS.Draw(); FormNS.Draw(); GeneralNS.Draw(); TotalScoreUI.GetComponent <Text>().text = CurrentTotalScore.ToString("0.00"); } } }
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("AIBackup")) { BackupAIData backup = new BackupAIData(); try { FileStream BackupFile = new FileStream(filename, FileMode.Open); backup.Data = AIData.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(BackupAIData b1, BackupAIData 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); } } }