void InitJudgersNameIds() { ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool); if (RData != null) { for (int JudgeIndex = 0; JudgeIndex < AIJudges.Count; ++JudgeIndex) { if (AIJudges[JudgeIndex] != null && JudgeIndex < RData.AIJudgeIds.Count) { AIJudges[JudgeIndex].NameId = RData.AIJudgeIds[JudgeIndex]; } } for (int JudgeIndex = 0; JudgeIndex < ExJudges.Count; ++JudgeIndex) { if (ExJudges[JudgeIndex] != null && JudgeIndex < RData.ExJudgeIds.Count) { ExJudges[JudgeIndex].NameId = RData.ExJudgeIds[JudgeIndex]; } } for (int JudgeIndex = 0; JudgeIndex < DiffJudges.Count; ++JudgeIndex) { if (DiffJudges[JudgeIndex] != null && JudgeIndex < RData.DiffJudgeIds.Count) { DiffJudges[JudgeIndex].NameId = RData.DiffJudgeIds[JudgeIndex]; } } } }
// Update is called once per frame void Update() { if (!Input.GetMouseButton(0)) { if (MovingNameId != -1) { bool bMovedSuccess = false; Vector3 NewMousePos = new Vector3(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 0); for (int CatIndex = 0; CatIndex < 3; ++CatIndex) { if (JudgeRects[CatIndex].Contains(NewMousePos)) { bMovedSuccess = true; MoveTeamToJudgeCategory(MovingNameId, CatIndex); break; } } if (!bMovedSuccess) { ResultsData Data = TournamentData.FindResultsData((EDivision)DivisionCombo.GetSelectedItemIndex(), (ERound)RoundCombo.GetSelectedItemIndex(), (EPool)CurPoolButtonIndex); if (Data != null) { Data.AIJudgeIds.Remove(MovingNameId); Data.ExJudgeIds.Remove(MovingNameId); Data.DiffJudgeIds.Remove(MovingNameId); } } MovingNameId = -1; } } }
void MoveTeamToJudgeCategory(int PlayerId, int CategoryIndex) { ResultsData Data = TournamentData.FindResultsData((EDivision)DivisionCombo.GetSelectedItemIndex(), (ERound)RoundCombo.GetSelectedItemIndex(), (EPool)CurPoolButtonIndex); if (Data != null) { Data.AIJudgeIds.Remove(PlayerId); Data.ExJudgeIds.Remove(PlayerId); Data.DiffJudgeIds.Remove(PlayerId); switch ((ECategory)CategoryIndex) { case ECategory.AI: Data.AIJudgeIds.Add(PlayerId); break; case ECategory.Ex: Data.ExJudgeIds.Add(PlayerId); break; case ECategory.Diff: Data.DiffJudgeIds.Add(PlayerId); break; } } }
void WriteJudgeNamesXml(XmlWriter writer, int PoolIndex) { ResultsData RData = TournamentData.FindResultsData((EDivision)CurDivIndex, (ERound)CurRoundIndex, (EPool)PoolIndex); int ExCount = RData.ExJudgeIds.Count; for (int ExIndex = 0; ExIndex < ExCount; ++ExIndex) { string JudgeName = NameDatabase.FindInDatabase(RData.ExJudgeIds[ExIndex]).DisplayName; writer.WriteElementString("ns2:Ex" + (ExIndex + 1), JudgeName); } int AiCount = RData.AIJudgeIds.Count; for (int AiIndex = 0; AiIndex < AiCount; ++AiIndex) { string JudgeName = NameDatabase.FindInDatabase(RData.AIJudgeIds[AiIndex]).DisplayName; writer.WriteElementString("ns2:Ai" + (AiIndex + 1), JudgeName); } int DiffCount = RData.DiffJudgeIds.Count; for (int DiffIndex = 0; DiffIndex < DiffCount; ++DiffIndex) { string JudgeName = NameDatabase.FindInDatabase(RData.DiffJudgeIds[DiffIndex]).DisplayName; writer.WriteElementString("ns2:Diff" + (DiffIndex + 1), JudgeName); } }
public int GetCatIndexForGuid(string InGuid) { int InOrgIndex = GetJudgeIndexRaw(InGuid); if (bFestivalJudging) { ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurFestivalPool); if (RData != null) { for (int JudgeIndex = 0; JudgeIndex < AIJudges.Count; ++JudgeIndex) { NetworkJudgeData njd = AIJudges[JudgeIndex]; if (njd != null && njd.Guid == InGuid) { if (JudgeIndex < RData.AIJudgeIds.Count) { return(InOrgIndex); } else { return(InOrgIndex - RData.AIJudgeIds.Count); } } } for (int JudgeIndex = 0; JudgeIndex < ExJudges.Count; ++JudgeIndex) { NetworkJudgeData njd = ExJudges[JudgeIndex]; if (njd != null && njd.Guid == InGuid) { if (JudgeIndex < RData.ExJudgeIds.Count) { return(InOrgIndex); } else { return(InOrgIndex - RData.ExJudgeIds.Count); } } } for (int JudgeIndex = 0; JudgeIndex < DiffJudges.Count; ++JudgeIndex) { NetworkJudgeData njd = DiffJudges[JudgeIndex]; if (njd != null && njd.Guid == InGuid) { if (JudgeIndex < RData.DiffJudgeIds.Count) { return(InOrgIndex); } else { return(InOrgIndex - RData.DiffJudgeIds.Count); } } } } } return(InOrgIndex); }
public bool IsInSecondaryPool(string InGuid) { if (bFestivalJudging) { ResultsData JData = TournamentData.FindResultsData(CurDivision, CurRound, CurFestivalPool); if (JData != null) { for (int JudgeIndex = 0; JudgeIndex < AIJudges.Count; ++JudgeIndex) { NetworkJudgeData njd = AIJudges[JudgeIndex]; if (njd != null && njd.Guid == InGuid) { if (JudgeIndex < JData.AIJudgeIds.Count) { return(false); } else { return(true); } } } for (int JudgeIndex = 0; JudgeIndex < ExJudges.Count; ++JudgeIndex) { NetworkJudgeData njd = ExJudges[JudgeIndex]; if (njd != null && njd.Guid == InGuid) { if (JudgeIndex < JData.ExJudgeIds.Count) { return(false); } else { return(true); } } } for (int JudgeIndex = 0; JudgeIndex < DiffJudges.Count; ++JudgeIndex) { NetworkJudgeData njd = DiffJudges[JudgeIndex]; if (njd != null && njd.Guid == InGuid) { if (JudgeIndex < JData.DiffJudgeIds.Count) { return(false); } else { return(true); } } } } } return(false); }
public int GetJudgeNameId() { if (JudgeNameId != -1 && !bIsDataDirty) { return(JudgeNameId); } if (CurPool != EPool.None) { ResultsData Data = TournamentData.FindResultsData(CurDivision, CurRound, CurPool); JudgeNameId = Data.GetNameId(JudgerCategory, JudgeCategoryIndex); } return(JudgeNameId); }
void UpdateActiveJudgingJudgersCount() { int Count = 0; ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool); if (RData != null) { foreach (int id in RData.AIJudgeIds) { NetworkJudgeData NJData = GetJudgeDataFromNameId(RData, id); if (NJData != null && (NJData.bJudging || NJData.bEditing)) { ++Count; } } foreach (int id in RData.ExJudgeIds) { NetworkJudgeData NJData = GetJudgeDataFromNameId(RData, id); if (NJData != null && (NJData.bJudging || NJData.bEditing)) { ++Count; } } foreach (int id in RData.DiffJudgeIds) { NetworkJudgeData NJData = GetJudgeDataFromNameId(RData, id); if (NJData != null && (NJData.bJudging || NJData.bEditing)) { ++Count; } } if (Count != ActiveJudgingJudgers) { ActiveJudgingJudgers = Count; ++Global.CurDataState; UpdateFinishRoutineAndGoToNextTeam(); } } }
public bool SetAIResults(AIData InData) { if (InData.JudgeNameId == -1) { return(false); } ResultsData rd = TournamentData.FindResultsData(InData.Division, InData.Round, InData.Pool); int ResultIndex = -1; for (int i = 0; i < rd.AIJudgeIds.Count; ++i) { if (InData.JudgeNameId == rd.AIJudgeIds[i]) { ResultIndex = i; break; } } bool bNewScore = false; if (ResultIndex >= 0) { for (int DataIndex = 0; DataIndex <= ResultIndex; ++DataIndex) { if (DataIndex >= AIResults.Count) { AIResults.Add(new AIData()); } } if (!AIResults[ResultIndex].IsValid()) { bNewScore = true; } AIResults[ResultIndex] = InData; } return(bNewScore); }
void OnGUI() { float SelectButWidth = Screen.width * .25f; float SelectButHeight = Screen.height * .08f; float SelectY = Screen.height * .04f; DivisionCombo.Draw(new Rect(20, SelectY, SelectButWidth, SelectButHeight)); RoundCombo.Draw(new Rect(20 + SelectButWidth + Screen.width * .02f, SelectY, SelectButWidth, SelectButHeight)); ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool); float InfoY = Screen.height * .02f + SelectY + SelectButHeight; GUIStyle InfoStyle = new GUIStyle("label"); InfoStyle.fontSize = 30; GUIContent TimeDate = new GUIContent(DateTime.Now.ToString()); Vector2 TimeDateSize = InfoStyle.CalcSize(TimeDate); GUI.Label(new Rect(20, InfoY, TimeDateSize.x, TimeDateSize.y), TimeDate, InfoStyle); bool bValidDivisionRoundSettings = Global.AllData.AllDivisions.Length > (int)CurDivision && Global.AllData.AllDivisions[(int)CurDivision].Rounds.Length > (int)CurRound; if (bValidDivisionRoundSettings) { RoundData Round = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound]; int TotalSeconds = bJudging ? (int)(DateTime.Now - RoutineStartTime).TotalSeconds : 0; int Minutes = Mathf.FloorToInt(TotalSeconds / 60f); int Seconds = Mathf.FloorToInt(TotalSeconds) % 60; int RoundMinutes = Mathf.FloorToInt(Round.RoutineLengthMinutes); int RoundSeconds = Mathf.FloorToInt(Round.RoutineLengthMinutes * 60) % 60; GUIContent RoutineTime = new GUIContent(String.Format("{0}:{1:00} / {2}:{3:00}", Minutes, Seconds, RoundMinutes, RoundSeconds)); Vector2 TimeSize = InfoStyle.CalcSize(RoutineTime); GUI.Label(new Rect(Screen.width - 20 - TimeSize.x, InfoY, TimeSize.x, TimeSize.y), RoutineTime, InfoStyle); if (TotalSeconds > Round.RoutineLengthMinutes * 60 && !bRoutineTimeElapsed) { bRoutineTimeElapsed = true; // Send ready to livestream TeamData finishedTeam = Global.GetTeamData(CurDivision, CurRound, CurPool, CurTeam); SendRestMessageAsync(finishedTeam, LiveStream.TeamStates.Finished); } } if (bFestivalJudging) { float PoolButWidth = Screen.width * .09f; RoundData Round = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound]; GUIStyle SelectedStyle = new GUIStyle("button"); SelectedStyle.normal.textColor = Color.green; SelectedStyle.hover.textColor = Color.green; SelectedStyle.fontStyle = FontStyle.Bold; GUIStyle ButtonStyle = new GUIStyle("button"); if (GUI.Button(new Rect(20 + 2f * SelectButWidth + Screen.width * .1f, SelectY, PoolButWidth, SelectButHeight), "Pool: " + Round.Pools[(int)CurFestivalPool].PoolName, CurPool == CurFestivalPool ? SelectedStyle : ButtonStyle)) { SetCurrentPool(CurFestivalPool); InitJudgersNameIds(); ++Global.CurDataState; } if (GUI.Button(new Rect(20 + 2f * SelectButWidth + Screen.width * .12f + PoolButWidth, SelectY, PoolButWidth, SelectButHeight), "Pool: " + Round.Pools[(int)CurFestivalPool + 2].PoolName, CurPool == CurFestivalPool + 2 ? SelectedStyle : ButtonStyle)) { SetCurrentPool(CurFestivalPool + 2); InitJudgersNameIds(); ++Global.CurDataState; } if (GUI.Button(new Rect(20 + 2f * SelectButWidth + Screen.width * .14f + 2f * PoolButWidth, SelectY, PoolButWidth, SelectButHeight), "AI Scores", (CurPool > EPool.Max) ? SelectedStyle : ButtonStyle)) { EPool newPool = EPool.None; if (CurPool == EPool.A || CurPool == EPool.C) { newPool = EPool.PostScoresAC; } else if (CurPool == EPool.B || CurPool == EPool.D) { newPool = EPool.PostScoresBD; } else { switch (CurPool) { case EPool.PostScoresAC: newPool = EPool.PostScoresCA; break; case EPool.PostScoresCA: newPool = EPool.PostScoresAC; break; case EPool.PostScoresBD: newPool = EPool.PostScoresDB; break; case EPool.PostScoresDB: newPool = EPool.PostScoresBD; break; } } SetCurrentPool(newPool); InitJudgersNameIds(); ++Global.CurDataState; } } #region Teams if (!DivisionCombo.IsPicking && !RoundCombo.IsPicking && bValidDivisionRoundSettings) { Rect LeftRect = new Rect(20, Screen.height * .22f, Screen.width / 2 - 40, Screen.height * .5f); if (CurPool == EPool.None && !bFestivalJudging) { GUILayout.BeginArea(LeftRect); PoolsScrollPos = GUILayout.BeginScrollView(PoolsScrollPos); GUILayout.BeginVertical(); RoundData Round = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound]; if (Round.Pools.Count <= 2) { for (int PoolIndex = 0; PoolIndex < Round.Pools.Count; ++PoolIndex) { PoolData Pool = Round.Pools[PoolIndex]; string PoolText = ""; PoolText += Pool.PoolName + "\n"; for (int TeamIndex = 0; TeamIndex < Pool.Teams.Count; ++TeamIndex) { TeamData Team = Pool.Teams[TeamIndex].Data; PoolText += (TeamIndex + 1) + ". " + Team.PlayerNames + "\n"; } GUIStyle ButtonStyle = new GUIStyle("button"); GUIStyle PoolStyle = new GUIStyle("button"); PoolStyle.alignment = TextAnchor.UpperLeft; PoolStyle.normal.textColor = (EPool)PoolIndex == CurPool ? Color.green : ButtonStyle.normal.textColor; PoolStyle.hover.textColor = (EPool)PoolIndex == CurPool ? Color.green : ButtonStyle.hover.textColor; PoolStyle.fontStyle = (EPool)PoolIndex == CurPool ? FontStyle.Bold : ButtonStyle.fontStyle; Vector2 PoolTextSize = PoolStyle.CalcSize(new GUIContent(PoolText)); if (GUILayout.Button(PoolText, PoolStyle, GUILayout.Width(LeftRect.width * .9f), GUILayout.Height(PoolTextSize.y))) { SetCurrentPool((EPool)PoolIndex); InitJudgersNameIds(); ++Global.CurDataState; bFestivalJudging = false; } } } else if (Round.Pools.Count == 4) { for (int ButIndex = 0; ButIndex < 2; ++ButIndex) { string PoolText = ""; for (int PoolIndex = 0; PoolIndex < 2; ++PoolIndex) { PoolData Pool = Round.Pools[2 * PoolIndex + ButIndex]; PoolText += Pool.PoolName + "\n"; for (int TeamIndex = 0; TeamIndex < Pool.Teams.Count; ++TeamIndex) { TeamData Team = Pool.Teams[TeamIndex].Data; PoolText += (TeamIndex + 1) + ". " + Team.PlayerNames + "\n"; } PoolText += "\n"; } GUIStyle ButtonStyle = new GUIStyle("button"); GUIStyle PoolStyle = new GUIStyle("button"); PoolStyle.alignment = TextAnchor.UpperLeft; PoolStyle.normal.textColor = ButIndex == (int)CurPool ? Color.green : ButtonStyle.normal.textColor; PoolStyle.hover.textColor = ButIndex == (int)CurPool ? Color.green : ButtonStyle.hover.textColor; PoolStyle.fontStyle = ButIndex == (int)CurPool ? FontStyle.Bold : ButtonStyle.fontStyle; Vector2 PoolTextSize = PoolStyle.CalcSize(new GUIContent(PoolText)); if (GUILayout.Button(PoolText, PoolStyle, GUILayout.Width(LeftRect.width * .9f), GUILayout.Height(PoolTextSize.y))) { CurFestivalPool = (EPool)ButIndex; bFestivalJudging = true; } } } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); } else if (!bFestivalJudging || CurPool != EPool.None) { float LeftRectWidth = Screen.width * .45f; //new Rect(Screen.width - RightRectWidth - 20, AreaRect.y, RightRectWidth, Screen.height - AreaRect.y - 20); GUILayout.BeginArea(LeftRect); GUILayout.BeginVertical(); GUIStyle TeamStyle = new GUIStyle("button"); TeamStyle.fontSize = 17; TeamStyle.alignment = TextAnchor.MiddleLeft; GUIStyle BackStyle = new GUIStyle(TeamStyle); List <PoolData> Pools = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools; if (CurPool >= 0 && (int)CurPool < Pools.Count) { for (int TeamIndex = 0; TeamIndex < Pools[(int)CurPool].Teams.Count; ++TeamIndex) { TeamData Data = Pools[(int)CurPool].Teams[TeamIndex].Data; if (Data != null) { GUIContent TeamContent = new GUIContent((TeamIndex + 1) + ". " + Data.PlayerNames); Vector2 TeamSize = TeamStyle.CalcSize(TeamContent); TeamStyle.fontStyle = TeamIndex == CurTeam ? FontStyle.Bold : FontStyle.Normal; if (!bLockedForJudging) { TeamStyle.normal.textColor = TeamIndex == CurTeam ? Color.green : new GUIStyle("button").normal.textColor; TeamStyle.hover.textColor = TeamIndex == CurTeam ? Color.green : new GUIStyle("button").hover.textColor; } else { TeamStyle.normal.textColor = TeamIndex == CurTeam ? Color.green : Color.gray; TeamStyle.hover.textColor = TeamIndex == CurTeam ? Color.green : Color.gray; TeamStyle.active.textColor = TeamIndex == CurTeam ? Color.green : Color.gray; } if (GUILayout.Button(TeamContent, TeamStyle, GUILayout.Width(LeftRectWidth), GUILayout.Height(TeamSize.y))) { if (!bLockedForJudging) { CurTeam = TeamIndex; ++Global.CurDataState; } } } } } GUILayout.Space(Screen.height * .03f); GUIContent BackContent = new GUIContent("<- Back To Pool Selection"); Vector2 BackSize = BackStyle.CalcSize(BackContent); if (GUILayout.Button(BackContent, BackStyle, GUILayout.Width(LeftRectWidth), GUILayout.Height(BackSize.y))) { SetCurrentPool(EPool.None); CurTeam = -1; bFestivalJudging = false; } GUILayout.EndVertical(); GUILayout.EndArea(); // Ready Buttons if (CurTeam >= 0) { DrawControlButtons(); } } } else { SetCurrentPool(EPool.None); bFestivalJudging = false; } #endregion #region Judges if (CurPool != EPool.None && RData != null) { Rect RightRect = new Rect(Screen.width * .5f + 20, Screen.height * .22f, Screen.width / 2 - 40, Screen.height * .88f - 20); GUILayout.BeginArea(RightRect); GUILayout.BeginVertical(); GUIStyle CatHeaderStyle = new GUIStyle("label"); CatHeaderStyle.fontSize = 17; CatHeaderStyle.fontStyle = FontStyle.Bold; GUILayout.Label("AI Judges:", CatHeaderStyle); foreach (int id in RData.AIJudgeIds) { DrawJudgeLabel(RData, id); } GUILayout.Label("Ex Judges:", CatHeaderStyle); foreach (int id in RData.ExJudgeIds) { DrawJudgeLabel(RData, id); } GUILayout.Label("Diff Judges:", CatHeaderStyle); foreach (int id in RData.DiffJudgeIds) { DrawJudgeLabel(RData, id); } GUILayout.EndVertical(); GUILayout.EndArea(); } #endregion }
private void UpdateFinishRoutineAndGoToNextTeam() { if (bJudging && ActiveJudgingJudgers == 0) { ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool); if (RData != null) { int JudgesCount = 0; foreach (int id in RData.AIJudgeIds) { ++JudgesCount; } foreach (int id in RData.ExJudgeIds) { ++JudgesCount; } foreach (int id in RData.DiffJudgeIds) { ++JudgesCount; } TeamData TData = Global.GetTeamData(CurDivision, CurRound, CurPool, CurTeam); if (TData.RoutineScores.GetTotalValidScores() >= JudgesCount) { // If we got all results StopRoutine(); if (Global.IsValid(CurDivision, CurRound, CurPool, CurTeam)) { int curPoolTeamCount = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[(int)CurPool].Teams.Count; if (bFestivalJudging) { int cachedTeamIndex = CurTeam; int newPool = (int)CurPool + 2; if (newPool >= 4) { newPool = newPool % 4; if (newPool < Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools.Count) { int newPoolTeamCount = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[newPool].Teams.Count; if (cachedTeamIndex < newPoolTeamCount - 1) { CurPool = (EPool)newPool; InitJudgersNameIds(); CurTeam = cachedTeamIndex + 1; ++Global.CurDataState; } else if (cachedTeamIndex < curPoolTeamCount - 1) { CurTeam = cachedTeamIndex + 1; ++Global.CurDataState; } else { // End of pools } } } else { int newPoolTeamCount = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[newPool].Teams.Count; if (cachedTeamIndex >= newPoolTeamCount && cachedTeamIndex < curPoolTeamCount - 1) { CurTeam = cachedTeamIndex + 1; ++Global.CurDataState; } else if (cachedTeamIndex < newPoolTeamCount) { CurPool = (EPool)newPool; CurTeam = cachedTeamIndex; InitJudgersNameIds(); ++Global.CurDataState; } else { // End of Pools } } } else { if (CurTeam < curPoolTeamCount - 1) { ++CurTeam; ++Global.CurDataState; } } } } } } }
void OnGUI() { bool bRepaintUpdate = Event.current.ToString() == "Repaint"; if (GUI.Button(new Rect(Screen.width - 150, Screen.height - 150, 150, 150), "Save")) { Global.AllData.Save(); } float StartSelectY = 30; float SelectHeight = 30; DivisionCombo.Draw(new Rect(20, StartSelectY, Screen.width * .18f, SelectHeight)); RoundCombo.Draw(new Rect(20 + Screen.width * .2f, StartSelectY, Screen.width * .18f, SelectHeight)); GUILayout.BeginArea(new Rect(20 + Screen.width * .4f, StartSelectY, Screen.width - Screen.width * .4f - 40, SelectHeight)); GUILayout.BeginHorizontal(); List <PoolData> Pools = Global.AllData.AllDivisions[DivisionCombo.GetSelectedItemIndex()].Rounds[RoundCombo.GetSelectedItemIndex()].Pools; for (int PoolIndex = 0; PoolIndex < Pools.Count; ++PoolIndex) { DrawPoolButton("Pool: " + Pools[PoolIndex].PoolName, PoolIndex, SelectHeight); } GUILayout.EndHorizontal(); GUILayout.EndArea(); float RightRectStartY = Screen.height * .02f + SelectHeight + StartSelectY; Rect RightRect = new Rect(20, RightRectStartY, Screen.width * .3f, Screen.height - RightRectStartY - 20); Rect LeftRect = new Rect(RightRect.x + RightRect.width + Screen.width * .1f, RightRect.y, RightRect.width, Screen.height * .5f); if (CurPoolButtonIndex != -1) { ResultsData RData = TournamentData.FindResultsData((EDivision)DivisionCombo.GetSelectedItemIndex(), (ERound)RoundCombo.GetSelectedItemIndex(), (EPool)CurPoolButtonIndex); if (RData == null) { RData = new ResultsData((EDivision)DivisionCombo.GetSelectedItemIndex(), (ERound)RoundCombo.GetSelectedItemIndex(), (EPool)CurPoolButtonIndex); Pools[CurPoolButtonIndex].JudgersId = RData.Id; Global.AllData.ResultsList.Add(RData); } else if (Pools[CurPoolButtonIndex].JudgersId == -1) { if (RData.Id == -1) { RData.Id = ResultsData.GetUniqueId(); } Pools[CurPoolButtonIndex].JudgersId = RData.Id; } if (RData != null && Global.AllNameData.AllJudges != null) { GUILayout.BeginArea(RightRect); RightScroll = GUILayout.BeginScrollView(RightScroll); GUILayout.BeginVertical(); string NewFilterStr = GUILayout.TextField(JudgeFilterStr); if (NewFilterStr != JudgeFilterStr || AvailableJudges.Count == 0) { JudgeFilterStr = NewFilterStr; AvailableJudges.Clear(); foreach (NameData pd in Global.AllNameData.AllJudges) { if (!IsPlayingInPool(pd, RData) && !RData.ContainsPlayer(pd)) { AvailableJudges.Add(pd); } } FilterAvailableJudges(JudgeFilterStr, ref AvailableJudges); } GUILayout.Space(20); GUIStyle LabelStyle = new GUIStyle("label"); GUIStyle PlayerStyle = new GUIStyle("label"); PlayerStyle.alignment = TextAnchor.MiddleLeft; foreach (NameData nd in AvailableJudges) { bool bMoving = MovingNameId == nd.Id; PlayerStyle.normal.textColor = bMoving ? Color.grey : LabelStyle.normal.textColor; GUIContent PlayerCont = new GUIContent(nd.DisplayName); Vector2 PlayerSize = PlayerStyle.CalcSize(PlayerCont); if (GUILayout.RepeatButton(PlayerCont, PlayerStyle, GUILayout.Width(RightRect.width * .9f), GUILayout.Height(PlayerSize.y))) { MovingNameId = nd.Id; } } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); // Left Rect ------------ GUILayout.BeginArea(LeftRect); GUILayout.BeginVertical(); GUIStyle JudgeStyle = new GUIStyle("label"); JudgeStyle.alignment = TextAnchor.MiddleLeft; GUILayout.BeginVertical(); GUILayout.Label("AI Judges:", JudgeStyle); for (int PlayerIndex = 0; PlayerIndex < Mathf.Max(RData.AIJudgeIds.Count, 3); ++PlayerIndex) { int PlayerId = -1; bool bMoving = false; string PlayerStr = PlayerIndex < 3 ? (PlayerIndex + 1) + ". " : ""; if (PlayerIndex < RData.AIJudgeIds.Count) { PlayerId = RData.AIJudgeIds[PlayerIndex]; bMoving = PlayerId == MovingNameId; PlayerStr += NameDatabase.FindInDatabase(PlayerId).DisplayName; } JudgeStyle.normal.textColor = bMoving ? Color.grey : LabelStyle.normal.textColor; GUIContent JudgeCont = new GUIContent(PlayerStr); Vector2 JudgeSize = JudgeStyle.CalcSize(JudgeCont); if (GUILayout.RepeatButton(JudgeCont, JudgeStyle, GUILayout.Width(LeftRect.width * .6f), GUILayout.Height(JudgeSize.y)) && PlayerIndex < RData.AIJudgeIds.Count) { MovingNameId = PlayerId; } } GUILayout.EndVertical(); if (bRepaintUpdate) { JudgeRects[0] = GUILayoutUtility.GetLastRect(); JudgeRects[0].x = LeftRect.x; JudgeRects[0].y = LeftRect.y; } GUILayout.BeginVertical(); GUILayout.Label("Ex Judges:", JudgeStyle); for (int PlayerIndex = 0; PlayerIndex < Mathf.Max(RData.ExJudgeIds.Count, 3); ++PlayerIndex) { int PlayerId = -1; bool bMoving = false; string PlayerStr = PlayerIndex < 3 ? (PlayerIndex + 1) + ". " : ""; if (PlayerIndex < RData.ExJudgeIds.Count) { PlayerId = RData.ExJudgeIds[PlayerIndex]; bMoving = PlayerId == MovingNameId; PlayerStr += NameDatabase.FindInDatabase(PlayerId).DisplayName; } JudgeStyle.normal.textColor = bMoving ? Color.grey : LabelStyle.normal.textColor; GUIContent JudgeCont = new GUIContent(PlayerStr); Vector2 JudgeSize = JudgeStyle.CalcSize(JudgeCont); if (GUILayout.RepeatButton(JudgeCont, JudgeStyle, GUILayout.Width(LeftRect.width * .6f), GUILayout.Height(JudgeSize.y)) && PlayerIndex < RData.ExJudgeIds.Count) { MovingNameId = PlayerId; } } GUILayout.EndVertical(); if (bRepaintUpdate) { JudgeRects[1] = GUILayoutUtility.GetLastRect(); JudgeRects[1].x += LeftRect.x; JudgeRects[1].y += LeftRect.y; } GUILayout.BeginVertical(); GUILayout.Label("Diff Judges:", JudgeStyle); for (int PlayerIndex = 0; PlayerIndex < Mathf.Max(RData.DiffJudgeIds.Count, 3); ++PlayerIndex) { int PlayerId = -1; bool bMoving = false; string PlayerStr = PlayerIndex < 3 ? (PlayerIndex + 1) + ". " : ""; if (PlayerIndex < RData.DiffJudgeIds.Count) { PlayerId = RData.DiffJudgeIds[PlayerIndex]; bMoving = PlayerId == MovingNameId; PlayerStr += NameDatabase.FindInDatabase(PlayerId).DisplayName; } JudgeStyle.normal.textColor = bMoving ? Color.grey : LabelStyle.normal.textColor; GUIContent JudgeCont = new GUIContent(PlayerStr); Vector2 JudgeSize = JudgeStyle.CalcSize(JudgeCont); if (GUILayout.RepeatButton(JudgeCont, JudgeStyle, GUILayout.Width(LeftRect.width * .6f), GUILayout.Height(JudgeSize.y)) && PlayerIndex < RData.DiffJudgeIds.Count) { MovingNameId = PlayerId; } } GUILayout.EndVertical(); if (bRepaintUpdate) { JudgeRects[2] = GUILayoutUtility.GetLastRect(); JudgeRects[2].x += LeftRect.x; JudgeRects[2].y += LeftRect.y; } GUILayout.EndVertical(); GUILayout.EndArea(); if (MovingNameId != -1) { GUI.Label(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 500, 30), NameDatabase.FindInDatabase(MovingNameId).DisplayName); } } } float BottomRectX = RightRect.x + RightRect.width + 20; float BottomRectY = LeftRect.y + LeftRect.height; GUILayout.BeginArea(new Rect(BottomRectX, BottomRectY, Screen.width - BottomRectX - 170, Screen.height - BottomRectY - 20)); GUILayout.Label("All Judges Names"); AllJudgesTextScrollPos = GUILayout.BeginScrollView(AllJudgesTextScrollPos); string NewAllJudgesString = GUILayout.TextArea(AllJudgesString); if (NewAllJudgesString != AllJudgesString) { AllJudgesString = NewAllJudgesString; AvailableJudges.Clear(); Global.AllNameData.AllJudges.Clear(); StringReader reader = new StringReader(AllJudgesString); string line = null; while ((line = reader.ReadLine()) != null) { AddJudgersFromString(line); } Global.AllNameData.Save(); } GUILayout.EndScrollView(); GUILayout.EndArea(); }
void ExportScheduleToExcel() { if (CurDivIndex != -1 && CurRoundIndex != -1 && File.Exists(ExcelPath)) { StringWriter OutStr = new StringWriter(); OutStr.WriteLine((EDivision)(CurDivIndex) + " - " + (ERound)(CurRoundIndex) + "\t\tJudges"); List <PoolData> Pools = Global.AllData.AllDivisions[CurDivIndex].Rounds[CurRoundIndex].Pools; int PoolIndex = 0; foreach (PoolData pd in Pools) { OutStr.WriteLine("Pool " + pd.PoolName + "\t\tAI\tEx\tDiff"); ResultsData JData = TournamentData.FindResultsData((EDivision)CurDivIndex, (ERound)CurRoundIndex, (EPool)PoolIndex); int TeamNum = 0; foreach (TeamDataDisplay tdd in pd.Teams) { ++TeamNum; OutStr.Write(TeamNum + ": " + tdd.Data.PlayerNames + "\t\t"); if (JData != null) { int NameId = JData.GetNameId(ECategory.AI, TeamNum - 1); if (NameId != -1) { OutStr.Write(NameDatabase.FindInDatabase(NameId).DisplayName); } OutStr.Write("\t"); NameId = JData.GetNameId(ECategory.Ex, TeamNum - 1); if (NameId != -1) { OutStr.Write(NameDatabase.FindInDatabase(NameId).DisplayName); } OutStr.Write("\t"); NameId = JData.GetNameId(ECategory.Diff, TeamNum - 1); if (NameId != -1) { OutStr.Write(NameDatabase.FindInDatabase(NameId).DisplayName); } OutStr.WriteLine("\t"); } } OutStr.WriteLine(); ++PoolIndex; } int TempNum = 0; string TempFilePath = Application.persistentDataPath + "/TempExcelStr.txt"; if (File.Exists(TempFilePath)) { bool bDeletedFile = false; while (!bDeletedFile) { try { File.Delete(TempFilePath); bDeletedFile = true; } catch { TempFilePath = Application.persistentDataPath + "/TempExcelStr-" + TempNum++ + ".txt"; } } } StreamWriter TempFile = new StreamWriter(TempFilePath); TempFile.Write(OutStr.ToString()); TempFile.Close(); OutStr.Close(); TempFilePath = TempFilePath.Replace('/', '\\'); Process.Start(ExcelPath, "\"" + TempFilePath + "\""); } }