private void SetFastestLabel(StatSummary levelInfo, LevelType type) { int fastestSwitchCount = switchCount; if (!StatsForm.CurrentSettings.SwitchBetweenLongest) { fastestSwitchCount = StatsForm.CurrentSettings.OnlyShowLongest ? 0 : type.FastestLabel(); } switch (fastestSwitchCount % (levelInfo.BestScore.HasValue ? 3 : 2)) { case 0: lblFastest.Text = "LONGEST:"; lblFastest.TextRight = levelInfo.LongestFinish.HasValue ? $"{levelInfo.LongestFinish:m\\:ss\\.ff}" : "-"; break; case 1: lblFastest.Text = "FASTEST:"; lblFastest.TextRight = levelInfo.BestFinish.HasValue ? $"{levelInfo.BestFinish:m\\:ss\\.ff}" : "-"; break; case 2: lblFastest.Text = "HIGH SCORE:"; lblFastest.TextRight = levelInfo.BestScore.Value.ToString(); break; } }
private void SetWinInfo(StatSummary levelInfo) { int winSwitchCount = switchCount; float winChance; string winChanceDisplay; string allWinsDisplay; if (StatsForm.CurrentSettings.PreviousWins > 0) { allWinsDisplay = $"{levelInfo.TotalWins} ({levelInfo.AllWins + StatsForm.CurrentSettings.PreviousWins})"; } else if (StatsForm.CurrentSettings.FilterType != 0) { allWinsDisplay = $"{levelInfo.TotalWins} ({levelInfo.AllWins})"; } else { allWinsDisplay = $"{levelInfo.TotalWins}"; } if (winSwitchCount % 2 == 0) { winChance = levelInfo.TotalWins * 100f / (levelInfo.TotalFinals == 0 ? 1 : levelInfo.TotalFinals); winChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $"{levelInfo.TotalFinals} - {winChance:0.0}%"; } else { winChance = levelInfo.TotalWins * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows); winChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $"{levelInfo.TotalShows} - {winChance:0.0}%"; } lblWins.TextRight = $"{allWinsDisplay} / {winChanceDisplay}"; }
private void SetQualifyChanceLabel(StatSummary levelInfo) { int qualifySwitchCount = switchCount; if (!StatsForm.CurrentSettings.SwitchBetweenQualify) { qualifySwitchCount = StatsForm.CurrentSettings.OnlyShowGold ? 1 : 0; } float qualifyChance; string qualifyChanceDisplay; switch (qualifySwitchCount % 2) { case 0: lblQualifyChance.Text = "QUALIFY:"; qualifyChance = levelInfo.TotalQualify * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); qualifyChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {qualifyChance:0.0}%"; lblQualifyChance.TextRight = $"{levelInfo.TotalQualify} / {levelInfo.TotalPlays}{qualifyChanceDisplay}"; break; case 1: lblQualifyChance.Text = "GOLD:"; qualifyChance = levelInfo.TotalGolds * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); qualifyChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {qualifyChance:0.0}%"; lblQualifyChance.TextRight = $"{levelInfo.TotalGolds} / {levelInfo.TotalPlays}{qualifyChanceDisplay}"; break; } }
private void SetStreakInfo(StatSummary levelInfo) { int streakSwitchCount = switchCount; if (!StatsForm.CurrentSettings.SwitchBetweenStreaks) { streakSwitchCount = StatsForm.CurrentSettings.OnlyShowFinalStreak ? 1 : 0; } switch (streakSwitchCount % 2) { case 0: lblStreak.Text = "WIN STREAK:"; lblStreak.TextRight = $"{levelInfo.CurrentStreak} ({levelInfo.BestStreak})"; break; case 1: lblStreak.Text = "FINAL STREAK:"; lblStreak.TextRight = $"{levelInfo.CurrentFinalStreak} ({levelInfo.BestFinalStreak})"; break; } }
private void SetQualifyChanceLabel(StatSummary levelInfo) { if (!StatsForm.CurrentSettings.SwitchBetweenQualify) { return; } float qualifyChance; switch (switchCount % 2) { case 0: lblQualifyChance.Text = "QUALIFY:"; qualifyChance = (float)levelInfo.TotalQualify * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); lblQualifyChance.TextRight = $"{levelInfo.TotalQualify} / {levelInfo.TotalPlays} - {qualifyChance:0.0}%"; break; case 1: lblQualifyChance.Text = "GOLD:"; qualifyChance = (float)levelInfo.TotalGolds * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); lblQualifyChance.TextRight = $"{levelInfo.TotalGolds} / {levelInfo.TotalPlays} - {qualifyChance:0.0}%"; break; } }
private void UpdateInfo() { if (StatsForm == null) { return; } lock (StatsForm.CurrentRound) { bool hasCurrentRound = StatsForm.CurrentRound != null && StatsForm.CurrentRound.Count > 0; if (hasCurrentRound && (lastRound == null || Stats.InShow || Stats.EndedShow)) { if (Stats.EndedShow) { Stats.EndedShow = false; } lastRound = StatsForm.CurrentRound[StatsForm.CurrentRound.Count - 1]; } lblFilter.Text = StatsForm.GetCurrentFilter(); if (lastRound != null && !string.IsNullOrEmpty(lastRound.Name)) { string roundName = lastRound.VerifiedName(); lblName.Text = $"ROUND {lastRound.Round}:"; if (StatsForm.StatLookup.TryGetValue(roundName, out var level)) { roundName = level.Name.ToUpper(); } if (roundName.StartsWith("round_", StringComparison.OrdinalIgnoreCase)) { roundName = roundName.Substring(6).Replace('_', ' ').ToUpper(); } if (roundName.Length > 15) { roundName = roundName.Substring(0, 15); } StatSummary levelInfo = StatsForm.GetLevelInfo(roundName); lblName.TextRight = roundName; float winChance = levelInfo.TotalWins * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows); string winChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {winChance:0.0}%"; if (StatsForm.CurrentSettings.PreviousWins > 0) { lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins + StatsForm.CurrentSettings.PreviousWins}){winChanceDisplay}"; } else if (StatsForm.CurrentSettings.FilterType != 0) { lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins}){winChanceDisplay}"; } else { lblWins.TextRight = $"{levelInfo.TotalWins}{winChanceDisplay}"; } float finalChance = levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows); string finalText = $"{levelInfo.TotalFinals} / {levelInfo.TotalShows}"; string finalChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : finalText.Length > 9 ? $" - {finalChance:0}%" : $" - {finalChance:0.0}%"; lblFinals.TextRight = $"{finalText}{finalChanceDisplay}"; SetQualifyChanceLabel(levelInfo); LevelType levelType = (level?.Type).GetValueOrDefault(); SetFastestLabel(levelInfo, levelType); SetPlayersLabel(); SetStreakInfo(levelInfo); if (isTimeToSwitch) { switchCount++; } DateTime Start = lastRound.Start; DateTime End = lastRound.End; DateTime?Finish = lastRound.Finish; if (lastRound.Playing != startedPlaying) { if (lastRound.Playing) { startTime = DateTime.UtcNow; } startedPlaying = lastRound.Playing; } if (Finish.HasValue) { TimeSpan Time = Finish.GetValueOrDefault(End) - Start; if (lastRound.Position > 0) { lblFinish.TextRight = $"# {lastRound.Position} - {Time:m\\:ss\\.ff}"; } else { lblFinish.TextRight = $"{Time:m\\:ss\\.ff}"; } if (levelType == LevelType.Race || levelType == LevelType.Hunt || roundName == "ROCK'N'ROLL" || roundName == "SNOWY SCRAP") { if (Time < levelInfo.BestFinish.GetValueOrDefault(TimeSpan.MaxValue) && Time > levelInfo.BestFinishOverall.GetValueOrDefault(TimeSpan.MaxValue)) { lblFinish.ForeColor = Color.LightGreen; } else if (Time < levelInfo.BestFinishOverall.GetValueOrDefault(TimeSpan.MaxValue)) { lblFinish.ForeColor = Color.Gold; } } else if (Time > levelInfo.LongestFinish && Time < levelInfo.LongestFinishOverall) { lblFinish.ForeColor = Color.LightGreen; } else if (Time > levelInfo.LongestFinishOverall) { lblFinish.ForeColor = Color.Gold; } } else if (lastRound.Playing) { if (Start > DateTime.UtcNow) { lblFinish.TextRight = $"{DateTime.UtcNow - startTime:m\\:ss}"; } else { lblFinish.TextRight = $"{DateTime.UtcNow - Start:m\\:ss}"; } } else { lblFinish.TextRight = "-"; lblFinish.ForeColor = Color.White; } if (lastRound.GameDuration > 0) { lblDuration.Text = $"TIME ({TimeSpan.FromSeconds(lastRound.GameDuration):m\\:ss}):"; } else { lblDuration.Text = "TIME:"; } if (End != DateTime.MinValue) { lblDuration.TextRight = $"{End - Start:m\\:ss\\.ff}"; } else if (lastRound.Playing) { if (Start > DateTime.UtcNow) { lblDuration.TextRight = $"{DateTime.UtcNow - startTime:m\\:ss}"; } else { lblDuration.TextRight = $"{DateTime.UtcNow - Start:m\\:ss}"; } } else { lblDuration.TextRight = "-"; } } Invalidate(); } if (StatsForm.CurrentSettings.UseNDI) { SendNDI(); } }
private void UpdateInfo() { if (StatsForm == null) { return; } lock (StatsForm.CurrentRound) { bool hasCurrentRound = StatsForm.CurrentRound != null && StatsForm.CurrentRound.Count > 0; if (hasCurrentRound && (lastRound == null || Stats.InShow || Stats.EndedShow)) { if (Stats.EndedShow) { Stats.EndedShow = false; } lastRound = StatsForm.CurrentRound[StatsForm.CurrentRound.Count - 1]; } StatSummary levelInfo = StatsForm.GetLevelInfo(lastRound?.Name); lblFilter.Text = levelInfo.CurrentFilter; if (lastRound != null) { lblName.Text = $"ROUND {lastRound.Round}:"; lblName.TextRight = LevelStats.ALL.TryGetValue(lastRound.Name, out var level) ? level.Name.ToUpper() : string.Empty; float winChance = (float)levelInfo.TotalWins * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows); string winChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {winChance:0.0}%"; if (StatsForm.CurrentSettings.PreviousWins > 0) { lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins + StatsForm.CurrentSettings.PreviousWins}){winChanceDisplay}"; } else if (StatsForm.CurrentSettings.FilterType != 0) { lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins}){winChanceDisplay}"; } else { lblWins.TextRight = $"{levelInfo.TotalWins}{winChanceDisplay}"; } float finalChance = (float)levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows); string finalText = $"{levelInfo.TotalFinals} / {levelInfo.TotalShows}"; string finalChanceDisplay = StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : finalText.Length > 9 ? $" - {finalChance:0}%" : $" - {finalChance:0.0}%"; lblFinals.TextRight = $"{finalText}{finalChanceDisplay}"; lblStreak.TextRight = $"{levelInfo.CurrentStreak} (BEST {levelInfo.BestStreak})"; SetQualifyChanceLabel(levelInfo); SetFastestLabel(levelInfo, level); SetPlayersLabel(); if (isTimeToSwitch) { switchCount++; } DateTime Start = lastRound.Start; DateTime End = lastRound.End; DateTime?Finish = lastRound.Finish; if (lastRound.Playing != startedPlaying) { if (lastRound.Playing) { startTime = DateTime.UtcNow; } startedPlaying = lastRound.Playing; } if (Finish.HasValue) { if (lastRound.Position > 0) { lblFinish.TextRight = $"# {lastRound.Position} - {Finish.GetValueOrDefault(End) - Start:m\\:ss\\.ff}"; } else { lblFinish.TextRight = $"{Finish.GetValueOrDefault(End) - Start:m\\:ss\\.ff}"; } } else if (lastRound.Playing) { if (Start > DateTime.UtcNow) { lblFinish.TextRight = $"{DateTime.UtcNow - startTime:m\\:ss}"; } else { lblFinish.TextRight = $"{DateTime.UtcNow - Start:m\\:ss}"; } } else { lblFinish.TextRight = "-"; } if (End != DateTime.MinValue) { lblDuration.TextRight = (End - Start).ToString("m\\:ss\\.ff"); } else if (lastRound.Playing) { if (Start > DateTime.UtcNow) { lblDuration.TextRight = (DateTime.UtcNow - startTime).ToString("m\\:ss"); } else { lblDuration.TextRight = (DateTime.UtcNow - Start).ToString("m\\:ss"); } } else { lblDuration.TextRight = "-"; } } this.Invalidate(); } if (StatsForm.CurrentSettings.UseNDI) { SendNDI(); } }
private void UpdateInfo() { if (StatsForm == null) { return; } lock (StatsForm.CurrentRound) { bool hasCurrentRound = StatsForm.CurrentRound != null && StatsForm.CurrentRound.Count > 0; if (hasCurrentRound && (lastRound == null || Stats.InShow || Stats.EndedShow)) { if (Stats.EndedShow) { Stats.EndedShow = false; } lastRound = StatsForm.CurrentRound[StatsForm.CurrentRound.Count - 1]; } StatSummary levelInfo = StatsForm.GetLevelInfo(lastRound?.Name); lblFilter.Text = levelInfo.CurrentFilter; if (lastRound != null) { lblName.Text = $"ROUND {lastRound.Round}:"; string displayName = string.Empty; LevelStats.DisplayNameLookup.TryGetValue(lastRound.Name, out displayName); lblName.TextRight = displayName.ToUpper(); lblPlayers.TextRight = lastRound.Players.ToString(); float winChance = (float)levelInfo.TotalWins * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows); if (StatsForm.CurrentSettings.PreviousWins > 0) { lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins + StatsForm.CurrentSettings.PreviousWins}) - {winChance:0.0}%"; } else if (StatsForm.CurrentSettings.FilterType != 0) { lblWins.TextRight = $"{levelInfo.TotalWins} ({levelInfo.AllWins}) - {winChance:0.0}%"; } else { lblWins.TextRight = $"{levelInfo.TotalWins} - {winChance:0.0}%"; } float finalChance = (float)levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows); lblFinalChance.TextRight = $"{levelInfo.TotalFinals} - {finalChance:0.0}%"; lblStreak.TextRight = $"{levelInfo.CurrentStreak} (BEST {levelInfo.BestStreak})"; if ((labelToShow % 2) == 0) { lblQualifyChance.Text = "QUALIFY:"; float qualifyChance = (float)levelInfo.TotalQualify * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); lblQualifyChance.TextRight = $"{levelInfo.TotalQualify} / {levelInfo.TotalPlays} - {qualifyChance:0.0}%"; } else { lblQualifyChance.Text = "GOLD:"; float qualifyChance = (float)levelInfo.TotalGolds * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); lblQualifyChance.TextRight = $"{levelInfo.TotalGolds} / {levelInfo.TotalPlays} - {qualifyChance:0.0}%"; } int modCount = levelInfo.BestScore.HasValue ? 3 : 2; if ((labelToShow % modCount) == 1) { lblFastest.Text = "FASTEST:"; lblFastest.TextRight = levelInfo.BestFinish.HasValue ? $"{levelInfo.BestFinish:m\\:ss\\.ff}" : "-"; } else if ((labelToShow % modCount) == 2) { lblFastest.Text = "HIGH SCORE:"; lblFastest.TextRight = levelInfo.BestScore.Value.ToString(); } else { lblFastest.Text = "LONGEST:"; lblFastest.TextRight = levelInfo.LongestFinish.HasValue ? $"{levelInfo.LongestFinish:m\\:ss\\.ff}" : "-"; } DateTime Start = lastRound.Start; DateTime End = lastRound.End; DateTime?Finish = lastRound.Finish; if (lastRound.Playing != startedPlaying) { if (lastRound.Playing) { startTime = DateTime.UtcNow; } startedPlaying = lastRound.Playing; } if (Finish.HasValue) { if (lastRound.Position > 0) { lblFinish.TextRight = $"# {lastRound.Position} - {Finish.GetValueOrDefault(End) - Start:m\\:ss\\.ff}"; } else { lblFinish.TextRight = $"{Finish.GetValueOrDefault(End) - Start:m\\:ss\\.ff}"; } } else if (lastRound.Playing) { if (Start > DateTime.UtcNow) { lblFinish.TextRight = $"{DateTime.UtcNow - startTime:m\\:ss}"; } else { lblFinish.TextRight = $"{DateTime.UtcNow - Start:m\\:ss}"; } } else { lblFinish.TextRight = "-"; } if (End != DateTime.MinValue) { lblDuration.TextRight = (End - Start).ToString("m\\:ss"); } else if (lastRound.Playing) { if (Start > DateTime.UtcNow) { lblDuration.TextRight = (DateTime.UtcNow - startTime).ToString("m\\:ss"); } else { lblDuration.TextRight = (DateTime.UtcNow - Start).ToString("m\\:ss"); } } else { lblDuration.TextRight = "-"; } } } if (StatsForm.CurrentSettings.UseNDI) { SendNDI(); } }
public StatSummary GetLevelInfo(string name) { StatSummary summary = new StatSummary(); summary.CurrentFilter = menuAllStats.Checked ? "All" : menuSeasonStats.Checked ? "Season" : menuWeekStats.Checked ? "Week" : menuDayStats.Checked ? "Day" : "Session"; LevelStats levelDetails = null; summary.AllWins = 0; summary.TotalShows = 0; summary.TotalPlays = 0; summary.TotalWins = 0; summary.TotalFinals = 0; int lastShow = -1; for (int i = 0; i < AllStats.Count; i++) { RoundInfo info = AllStats[i]; TimeSpan finishTime = info.Finish.GetValueOrDefault(info.End) - info.Start; bool hasLevelDetails = StatLookup.TryGetValue(info.Name, out levelDetails); bool isCurrentLevel = name.Equals(info.Name, StringComparison.OrdinalIgnoreCase); bool isInQualifyFilter = CurrentSettings.QualifyFilter == 0 || (CurrentSettings.QualifyFilter == 1 && IsInStatsFilter(info) && IsInPartyFilter(info)) || (CurrentSettings.QualifyFilter == 2 && IsInStatsFilter(info)) || (CurrentSettings.QualifyFilter == 3 && IsInPartyFilter(info)); bool isInFastestFilter = CurrentSettings.FastestFilter == 0 || (CurrentSettings.FastestFilter == 1 && IsInStatsFilter(info) && IsInPartyFilter(info)) || (CurrentSettings.FastestFilter == 2 && IsInStatsFilter(info)) || (CurrentSettings.FastestFilter == 3 && IsInPartyFilter(info)); bool isInWinsFilter = CurrentSettings.WinsFilter == 3 || (CurrentSettings.WinsFilter == 0 && IsInStatsFilter(info) && IsInPartyFilter(info)) || (CurrentSettings.WinsFilter == 1 && IsInStatsFilter(info)) || (CurrentSettings.WinsFilter == 2 && IsInPartyFilter(info)); if (info.ShowID != lastShow) { lastShow = info.ShowID; if (isInWinsFilter) { summary.TotalShows++; } } if (isCurrentLevel) { if (isInQualifyFilter) { summary.TotalPlays++; } if (isInFastestFilter) { if ((!hasLevelDetails || levelDetails.Type == LevelType.Team) && info.Score.HasValue && (!summary.BestScore.HasValue || info.Score.Value > summary.BestScore.Value)) { summary.BestScore = info.Score; } } } if (info.Qualified) { if (hasLevelDetails && levelDetails.Type == LevelType.Final) { summary.AllWins++; if (isInWinsFilter) { summary.TotalWins++; summary.TotalFinals++; } summary.CurrentStreak++; if (summary.CurrentStreak > summary.BestStreak) { summary.BestStreak = summary.CurrentStreak; } } if (isCurrentLevel) { if (isInQualifyFilter) { if (info.Tier == (int)QualifyTier.Gold) { summary.TotalGolds++; } summary.TotalQualify++; } if (isInFastestFilter) { if (finishTime.TotalSeconds > 1.1 && (!summary.BestFinish.HasValue || summary.BestFinish.Value > finishTime)) { summary.BestFinish = finishTime; } if (finishTime.TotalSeconds > 1.1 && info.Finish.HasValue && (!summary.LongestFinish.HasValue || summary.LongestFinish.Value < finishTime)) { summary.LongestFinish = finishTime; } } } } else { summary.CurrentStreak = 0; if (isInWinsFilter && hasLevelDetails && levelDetails.Type == LevelType.Final) { summary.TotalFinals++; } } } return(summary); }
public StatSummary GetLevelInfo(string name) { StatSummary summary = new StatSummary(); summary.CurrentFilter = menuAllStats.Checked ? "All" : menuSeasonStats.Checked ? "Season" : menuWeekStats.Checked ? "Week" : menuDayStats.Checked ? "Day" : "Session"; LevelStats levelDetails = null; AllWins = 0; for (int i = 0; i < AllStats.Count; i++) { RoundInfo info = AllStats[i]; TimeSpan finishTime = info.Finish.GetValueOrDefault(info.End) - info.Start; bool hasLevelDetails = StatLookup.TryGetValue(info.Name, out levelDetails); bool isCurrentLevel = name.Equals(info.Name, StringComparison.OrdinalIgnoreCase); if (isCurrentLevel) { if ((!hasLevelDetails || levelDetails.Type == LevelType.Team) && info.Score.HasValue && (!summary.BestScore.HasValue || info.Score.Value > summary.BestScore.Value)) { summary.BestScore = info.Score; } } if (info.Qualified) { if (hasLevelDetails && levelDetails.Type == LevelType.Final) { AllWins++; summary.CurrentStreak++; if (summary.CurrentStreak > summary.BestStreak) { summary.BestStreak = summary.CurrentStreak; } } if (isCurrentLevel) { if (finishTime.TotalSeconds > 1.1 && (!summary.BestFinish.HasValue || summary.BestFinish.Value > finishTime)) { summary.BestFinish = finishTime; } if (finishTime.TotalSeconds > 1.1 && info.Finish.HasValue && (!summary.LongestFinish.HasValue || summary.LongestFinish.Value < finishTime)) { summary.LongestFinish = finishTime; } } } else { summary.CurrentStreak = 0; } } if (StatLookup.TryGetValue(name, out levelDetails)) { summary.TotalPlays = levelDetails.Stats.Count; for (int i = 0; i < summary.TotalPlays; i++) { RoundInfo info = levelDetails.Stats[i]; if (info.Qualified) { summary.TotalQualify++; } } } return(summary); }