string GetBackupDisplayString(BackupDiffData bd) { if (bd.Data == null) { Debug.Log(String.Format(" {0}, {1}, {2} ", bd != null, bd != null && bd.Data != null, bd != null && bd.Data != null ? (int)bd.Data.Pool : 0)); } 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("DiffBackup")) { BackupDiffData backup = new BackupDiffData(); try { FileStream BackupFile = new FileStream(filename, FileMode.Open); backup.Data = DiffData.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(BackupDiffData b1, BackupDiffData 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); } } }
new void OnGUI() { if (bIsChoosingBackup) { DrawBackupList(); } else { if (bBackupLoaded) { if (CurBackupData != null) { GUIStyle BackupTextStyle = new GUIStyle("label"); BackupTextStyle.fontSize = 20; 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 * .25f, Screen.width * .3f, Screen.height * .1f), "Send Backup Data")) { SendResultsToHeadJudger((int)CurData.Division, (int)CurData.Round, (int)CurData.Pool, CurData.Team); bInputingConsec = false; } if (GUI.Button(new Rect(Screen.width * .42f, Screen.height * .25f, Screen.width * .51f, Screen.height * .1f), "Exit Backup mode and discard changes")) { bBackupLoaded = false; CurBackupData = null; bInputingConsec = false; } } } else { base.OnGUI(); } if (!bIsDrawingEditingTeams) { if (bInputingConsec) { NumberlineUI.SetActive(false); NoneButtonUI.gameObject.SetActive(true); PlusButtonUI.gameObject.SetActive(true); GUIStyle ButtonStyle = new GUIStyle("button"); ButtonStyle.fontSize = 30; } else { NumberlineUI.SetActive(true); NoneButtonUI.gameObject.SetActive(false); PlusButtonUI.gameObject.SetActive(false); } for (int i = 0; i < GetNumScoreBlocks(); ++i) { string ConsecStr = " / "; switch (ConsecScores[i]) { case -1: ConsecStr += "-"; break; case 0: ConsecStr += "None"; break; case 1: ConsecStr += "+"; break; } string BlockLabelString = (i + 1).ToString() + ConsecStr; LabelList[i].GetComponent <Text>().text = BlockLabelString; NSArray[i].DrawRect = Global.GetScreenSpaceRectTransform(NumberBoxesList[i]); NSArray[i].Draw(); } if (bInputingDiffScore) { string ScoreString = CurrentDiffScore.ToString("0.0"); GUIStyle NewStyle = new GUIStyle("label"); NewStyle.fontSize = 50; NewStyle.normal.textColor = Color.red; Vector2 StrSize = NewStyle.CalcSize(new GUIContent(ScoreString)); GUI.Label(new Rect(Mathf.Clamp(MousePos.x - StrSize.x / 2f, 0, Screen.width - StrSize.x), MousePos.y - Screen.height * .15f, StrSize.x, StrSize.y), ScoreString, NewStyle); } } } }