diff --git a/Controls/TransparentLabel.cs b/Controls/TransparentLabel.cs index 7f84bfa28..ecb44c750 100644 --- a/Controls/TransparentLabel.cs +++ b/Controls/TransparentLabel.cs @@ -31,7 +31,7 @@ public TransparentLabel() { public Image RoundIcon { get; set; } public bool UseShareCode { get; set; } public int SecondProgress { get; set; } - public int SecondProgressLines { get; set; } + public int OverlaySetting { get; set; } public void Draw(Graphics g) { if (!this.DrawVisible) { return; } if (this.PlatformIcon != null) { @@ -86,8 +86,11 @@ public void Draw(Graphics g) { } if (!string.IsNullOrEmpty(this.Text)) { - if (this.Name.Equals("lblPlayers")) { - if (this.SecondProgress > 0 && this.SecondProgressLines > 0) this.FillRoundedRectangleF(g, new Pen(this.GetComplementaryColor(brFore.Color, 95)), new SolidBrush(this.GetComplementaryColor(brFore.Color, 95)), this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width * this.SecondProgress / 60f, this.ClientRectangle.Height * this.SecondProgressLines, 4f); + if ((this.Name.Equals("lblPlayers") && (this.OverlaySetting == 0 || this.OverlaySetting == 1 || this.OverlaySetting == 4 || this.OverlaySetting == 5)) || + (this.Name.Equals("lblFastest") && this.OverlaySetting == 2) || + (this.Name.Equals("lblFinals") && this.OverlaySetting == 3) || + (this.Name.Equals("lblDuration") && this.OverlaySetting == 6)) { + if (this.SecondProgress > 0) this.FillRoundedRectangleF(g, new Pen(this.GetComplementaryColor(brFore.Color, 95)), new SolidBrush(this.GetComplementaryColor(brFore.Color, 95)), this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width * this.SecondProgress / 60f, this.ClientRectangle.Height * 2, 4f); } this.DrawOutlineText(g, this.ClientRectangle, null, brFore, this.Font.FontFamily, this.Font.Style, this.Font.Size * this.GetFontSizeFactor(), this.Text, stringFormat); } diff --git a/Entities/Multilingual.cs b/Entities/Multilingual.cs index f220f42a1..a90e2c154 100644 --- a/Entities/Multilingual.cs +++ b/Entities/Multilingual.cs @@ -313,6 +313,7 @@ public static class Multilingual { {"settings_color_round_name_based_on_round_type", "Color round name based on round type (Ctrl + R)"}, {"settings_auto_change_profile", "Automatically change to linked profile (Ctrl + Shift + Z)"}, {"settings_shade_the_flag_image", "Shading the server's flag image to display"}, + {"settings_diaplay_current_time", "Display the current time while waiting"}, {"settings_custom_overlay_font", "Custom Overlay Font"}, {"settings_select_font", "Select Font"}, {"settings_reset_font", "Reset Font"}, @@ -739,6 +740,7 @@ public static class Multilingual { {"settings_color_round_name_based_on_round_type", "Colorer la manche selon son type (Ctrl + R)"}, {"settings_auto_change_profile", "Passer automatiquement sur le profil lié (Ctrl + Shift + Z)"}, {"settings_shade_the_flag_image", "Ombrage de l'image du drapeau du serveur à afficher"}, + {"settings_diaplay_current_time", "Affiche l'heure actuelle en attendant"}, {"settings_custom_overlay_font", "Police d'écriture"}, {"settings_select_font", "Changer"}, {"settings_reset_font", "Réinitialiser"}, @@ -1165,6 +1167,7 @@ public static class Multilingual { {"settings_color_round_name_based_on_round_type", "라운드 유형별 색상 배지 표시 (Ctrl + R)"}, {"settings_auto_change_profile", "연동된 프로필로 자동 변경 (Ctrl + Shift + Z)"}, {"settings_shade_the_flag_image", "서버의 국기 이미지를 음영 처리해서 표시"}, + {"settings_diaplay_current_time", "대기하는 동안 현재 시간을 표시"}, {"settings_custom_overlay_font", "사용자 정의 글꼴"}, {"settings_select_font", "글꼴 선택"}, {"settings_reset_font", "글꼴 초기화"}, @@ -1592,6 +1595,7 @@ public static class Multilingual { {"settings_color_round_name_based_on_round_type", "ラウンドタイプ別に色を変更する (Ctrl + R)"}, {"settings_auto_change_profile", "リンク先のプロファイルに自動で変更する (Ctrl + Shift + Z)"}, {"settings_shade_the_flag_image", "サーバーの旗のイメージを網掛けして表示します"}, + {"settings_diaplay_current_time", "待機中に現在時刻を表示します"}, {"settings_custom_overlay_font", "カスタムフォント"}, {"settings_select_font", "フォント選択"}, {"settings_reset_font", "リセット"}, @@ -2018,6 +2022,7 @@ public static class Multilingual { {"settings_color_round_name_based_on_round_type", "按照关卡类型显示颜色 (Ctrl + R)"}, {"settings_auto_change_profile", "自动改变为链接的个人资料 (Ctrl + Shift + Z)"}, {"settings_shade_the_flag_image", "对要显示的服务器标志图像进行着色"}, + {"settings_diaplay_current_time", "等待时显示当前时间"}, {"settings_custom_overlay_font", "自定义浮窗字体"}, {"settings_select_font", "选择字体"}, {"settings_reset_font", "重置字体"}, @@ -2444,6 +2449,7 @@ public static class Multilingual { {"settings_color_round_name_based_on_round_type", "按照關卡類型顯示顏色 (Ctrl + R)"}, {"settings_auto_change_profile", "自動改變為鏈接的個人資料 (Ctrl + Shift + Z)"}, {"settings_shade_the_flag_image", "對要顯示的服務器標誌圖像進行著色"}, + {"settings_diaplay_current_time", "等待時顯示當前時間"}, {"settings_custom_overlay_font", "自定義浮窗字體"}, {"settings_select_font", "選擇字體"}, {"settings_reset_font", "重置字體"}, diff --git a/Entities/UserSettings.cs b/Entities/UserSettings.cs index e5d47abbc..9c3bdbaeb 100644 --- a/Entities/UserSettings.cs +++ b/Entities/UserSettings.cs @@ -42,6 +42,7 @@ public class UserSettings { public bool ColorByRoundType { get; set; } public bool AutoChangeProfile { get; set; } public bool ShadeTheFlagImage { get; set; } + public bool DisplayCurrentTime { get; set; } public int PreviousWins { get; set; } public int WinsFilter { get; set; } public int FastestFilter { get; set; } diff --git a/Views/Overlay.cs b/Views/Overlay.cs index ccb6fd06f..04f9481bd 100644 --- a/Views/Overlay.cs +++ b/Views/Overlay.cs @@ -572,54 +572,83 @@ private void UpdateTimer() { } } } - private void SetQualifyChanceLabel(StatSummary levelInfo) { - int qualifySwitchCount = this.switchCount; - if (!this.StatsForm.CurrentSettings.SwitchBetweenQualify) { - qualifySwitchCount = this.StatsForm.CurrentSettings.OnlyShowGold ? 1 : 0; - } - float qualifyChance; - string qualifyChanceDisplay; - string qualifyDisplay; - switch (qualifySwitchCount % 2) { - case 0: - this.lblQualifyChance.Text = $"{Multilingual.GetWord("overlay_qualify_chance")} :"; - qualifyChance = levelInfo.TotalQualify * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); - qualifyChanceDisplay = this.StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {qualifyChance:0.0}%"; - qualifyDisplay = $"{levelInfo.TotalQualify}{(levelInfo.TotalPlays < 100000 ? " / " + levelInfo.TotalPlays : Multilingual.GetWord("overlay_inning"))}"; - this.lblQualifyChance.TextRight = $"{qualifyDisplay}{qualifyChanceDisplay}"; - break; - case 1: - this.lblQualifyChance.Text = $"{Multilingual.GetWord("overlay_qualify_gold")} :"; - qualifyChance = levelInfo.TotalGolds * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); - qualifyChanceDisplay = this.StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {qualifyChance:0.0}%"; - qualifyDisplay = $"{levelInfo.TotalGolds}{(levelInfo.TotalPlays < 100000 ? " / " + levelInfo.TotalPlays : Multilingual.GetWord("overlay_inning"))}"; - this.lblQualifyChance.TextRight = $"{qualifyDisplay}{qualifyChanceDisplay}"; - break; + private void SetFinalsLabel(StatSummary levelInfo, int overlaySetting) { + if (this.StatsForm.CurrentSettings.DisplayCurrentTime && !Stats.IsPrePlaying && overlaySetting == 3) { + this.lblFinals.OverlaySetting = overlaySetting; + this.lblFinals.SecondProgress = DateTime.Now.Second; + this.lblFinals.Text = $"{Multilingual.GetWord("overlay_current_time")} :"; + this.lblFinals.TextRight = $"{DateTime.Now:HH\\:mm\\:ss}"; + } else { + this.lblFinals.SecondProgress = 0; + this.lblFinals.Text = $"{Multilingual.GetWord("overlay_finals")} :"; + string finalText = $"{levelInfo.TotalFinals}{(levelInfo.TotalShows < 100000 ? " / " + levelInfo.TotalShows : Multilingual.GetWord("overlay_inning"))}"; + float finalChance = levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows); + string finalChanceDisplay = this.StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : finalText.Length > 9 ? $" - {finalChance:0}%" : $" - {finalChance:0.0}%"; + this.lblFinals.TextRight = $"{finalText}{finalChanceDisplay}"; } } - private void SetFastestLabel(StatSummary levelInfo, LevelType type) { - int fastestSwitchCount = this.switchCount; - if (!this.StatsForm.CurrentSettings.SwitchBetweenLongest) { - fastestSwitchCount = this.StatsForm.CurrentSettings.OnlyShowLongest ? 0 - : this.levelException == 1 ? 1 : this.levelException == 2 ? 2 : type.FastestLabel(); + private void SetQualifyChanceLabel(StatSummary levelInfo, int overlaySetting) { + if (this.StatsForm.CurrentSettings.DisplayCurrentTime && !Stats.IsPrePlaying && (overlaySetting == 1 || overlaySetting == 5)) { + this.lblQualifyChance.OverlaySetting = overlaySetting; + this.lblQualifyChance.Text = ""; + this.lblQualifyChance.TextRight = $@"{DateTime.Now.ToString(Multilingual.GetWord("level_date_format"))}"; + } else { + int qualifySwitchCount = this.switchCount; + if (!this.StatsForm.CurrentSettings.SwitchBetweenQualify) { + qualifySwitchCount = this.StatsForm.CurrentSettings.OnlyShowGold ? 1 : 0; + } + float qualifyChance; + string qualifyChanceDisplay; + string qualifyDisplay; + switch (qualifySwitchCount % 2) { + case 0: + this.lblQualifyChance.Text = $"{Multilingual.GetWord("overlay_qualify_chance")} :"; + qualifyChance = levelInfo.TotalQualify * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); + qualifyChanceDisplay = this.StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {qualifyChance:0.0}%"; + qualifyDisplay = $"{levelInfo.TotalQualify}{(levelInfo.TotalPlays < 100000 ? " / " + levelInfo.TotalPlays : Multilingual.GetWord("overlay_inning"))}"; + this.lblQualifyChance.TextRight = $"{qualifyDisplay}{qualifyChanceDisplay}"; + break; + case 1: + this.lblQualifyChance.Text = $"{Multilingual.GetWord("overlay_qualify_gold")} :"; + qualifyChance = levelInfo.TotalGolds * 100f / (levelInfo.TotalPlays == 0 ? 1 : levelInfo.TotalPlays); + qualifyChanceDisplay = this.StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : $" - {qualifyChance:0.0}%"; + qualifyDisplay = $"{levelInfo.TotalGolds}{(levelInfo.TotalPlays < 100000 ? " / " + levelInfo.TotalPlays : Multilingual.GetWord("overlay_inning"))}"; + this.lblQualifyChance.TextRight = $"{qualifyDisplay}{qualifyChanceDisplay}"; + break; + } } - switch (fastestSwitchCount % ((levelInfo.BestScore.HasValue && this.levelException != 1) ? 3 : 2)) { - case 0: - this.lblFastest.Text = $"{Multilingual.GetWord("overlay_longest")} :"; - this.lblFastest.TextRight = levelInfo.LongestFinish.HasValue ? $"{levelInfo.LongestFinish:m\\:ss\\.ff}" : "-"; - break; - case 1: - this.lblFastest.Text = $"{Multilingual.GetWord("overlay_fastest")} :"; - this.lblFastest.TextRight = levelInfo.BestFinish.HasValue ? $"{levelInfo.BestFinish:m\\:ss\\.ff}" : "-"; - break; - case 2: - this.lblFastest.Text = $"{Multilingual.GetWord("overlay_best_score")} :"; - this.lblFastest.TextRight = $"{levelInfo.BestScore}"; - break; + } + private void SetFastestLabel(StatSummary levelInfo, LevelType type, int overlaySetting) { + if (this.StatsForm.CurrentSettings.DisplayCurrentTime && !Stats.IsPrePlaying && (overlaySetting == 2)) { + this.lblFastest.OverlaySetting = overlaySetting; + this.lblFastest.SecondProgress = DateTime.Now.Second; + this.lblFastest.Text = $"{Multilingual.GetWord("overlay_current_time")} :"; + this.lblFastest.TextRight = $"{DateTime.Now:HH\\:mm\\:ss}"; + } else { + this.lblFastest.SecondProgress = 0; + int fastestSwitchCount = this.switchCount; + if (!this.StatsForm.CurrentSettings.SwitchBetweenLongest) { + fastestSwitchCount = this.StatsForm.CurrentSettings.OnlyShowLongest ? 0 + : this.levelException == 1 ? 1 : this.levelException == 2 ? 2 : type.FastestLabel(); + } + switch (fastestSwitchCount % ((levelInfo.BestScore.HasValue && this.levelException != 1) ? 3 : 2)) { + case 0: + this.lblFastest.Text = $"{Multilingual.GetWord("overlay_longest")} :"; + this.lblFastest.TextRight = levelInfo.LongestFinish.HasValue ? $"{levelInfo.LongestFinish:m\\:ss\\.ff}" : "-"; + break; + case 1: + this.lblFastest.Text = $"{Multilingual.GetWord("overlay_fastest")} :"; + this.lblFastest.TextRight = levelInfo.BestFinish.HasValue ? $"{levelInfo.BestFinish:m\\:ss\\.ff}" : "-"; + break; + case 2: + this.lblFastest.Text = $"{Multilingual.GetWord("overlay_best_score")} :"; + this.lblFastest.TextRight = $"{levelInfo.BestScore}"; + break; + } } } - private void SetPlayersLabel() { - if (!Stats.IsPrePlaying && !this.StatsForm.CurrentSettings.HideRoundInfo) { + private void SetPlayersLabel(int overlaySetting) { + if (this.StatsForm.CurrentSettings.DisplayCurrentTime && !Stats.IsPrePlaying && (overlaySetting == 0 || overlaySetting == 1 || overlaySetting == 4 || overlaySetting == 5)) { this.lblPlayers.Image = null; this.lblPlayersPs.DrawVisible = false; this.lblPlayersXbox.DrawVisible = false; @@ -627,13 +656,11 @@ private void SetPlayersLabel() { this.lblPlayersPc.DrawVisible = false; this.lblCountryIcon.DrawVisible = false; this.lblPingIcon.DrawVisible = false; - this.lblPlayers.SecondProgressLines = this.StatsForm.CurrentSettings.HideRoundInfo ? 0 : this.StatsForm.CurrentSettings.HideTimeInfo ? 1 : 2; + this.lblPlayers.OverlaySetting = overlaySetting; this.lblPlayers.SecondProgress = DateTime.Now.Second; this.lblPlayers.Text = $"{Multilingual.GetWord("overlay_current_time")} :"; - //this.lblPlayers.Text = $@"{DateTime.Now.ToString(Multilingual.GetWord("level_date_format"))}"; this.lblPlayers.TextRight = $"{DateTime.Now:HH\\:mm\\:ss}"; } else { - this.lblPlayers.SecondProgressLines = 0; this.lblPlayers.SecondProgress = 0; int playersSwitchCount = this.switchCount; if (!this.StatsForm.CurrentSettings.SwitchBetweenPlayers) { @@ -713,20 +740,141 @@ private void SetPlayersLabel() { } } } - private void SetStreakInfo(StatSummary levelInfo) { - int streakSwitchCount = this.switchCount; - if (!this.StatsForm.CurrentSettings.SwitchBetweenStreaks) { - streakSwitchCount = this.StatsForm.CurrentSettings.OnlyShowFinalStreak ? 1 : 0; + private void SetStreakLabel(StatSummary levelInfo, int overlaySetting) { + if (this.StatsForm.CurrentSettings.DisplayCurrentTime && !Stats.IsPrePlaying && (overlaySetting == 3)) { + this.lblStreak.OverlaySetting = overlaySetting; + this.lblStreak.Text = ""; + this.lblStreak.TextRight = $@"{DateTime.Now.ToString(Multilingual.GetWord("level_date_format"))}"; + } else { + int streakSwitchCount = this.switchCount; + if (!this.StatsForm.CurrentSettings.SwitchBetweenStreaks) { + streakSwitchCount = this.StatsForm.CurrentSettings.OnlyShowFinalStreak ? 1 : 0; + } + switch (streakSwitchCount % 2) { + case 0: + this.lblStreak.Text = $"{Multilingual.GetWord("overlay_streak")} :"; + this.lblStreak.TextRight = $"{levelInfo.CurrentStreak}{Multilingual.GetWord("overlay_streak_suffix")} ({Multilingual.GetWord("overlay_best")}{levelInfo.BestStreak}{Multilingual.GetWord("overlay_streak_suffix")})"; + break; + case 1: + this.lblStreak.Text = $"{Multilingual.GetWord("overlay_streak_finals")} :"; + this.lblStreak.TextRight = $"{levelInfo.CurrentFinalStreak}{Multilingual.GetWord("overlay_inning")} ({Multilingual.GetWord("overlay_best")}{levelInfo.BestFinalStreak}{Multilingual.GetWord("overlay_inning")})"; + break; + } } - switch (streakSwitchCount % 2) { - case 0: - this.lblStreak.Text = $"{Multilingual.GetWord("overlay_streak")} :"; - this.lblStreak.TextRight = $"{levelInfo.CurrentStreak}{Multilingual.GetWord("overlay_streak_suffix")} ({Multilingual.GetWord("overlay_best")}{levelInfo.BestStreak}{Multilingual.GetWord("overlay_streak_suffix")})"; - break; - case 1: - this.lblStreak.Text = $"{Multilingual.GetWord("overlay_streak_finals")} :"; - this.lblStreak.TextRight = $"{levelInfo.CurrentFinalStreak}{Multilingual.GetWord("overlay_inning")} ({Multilingual.GetWord("overlay_best")}{levelInfo.BestFinalStreak}{Multilingual.GetWord("overlay_inning")})"; - break; + } + private void SetDurationLabel(LevelStats level, LevelType levelType, int overlaySetting) { + if (this.StatsForm.CurrentSettings.DisplayCurrentTime && !Stats.IsPrePlaying && (overlaySetting == 0 || overlaySetting == 2 || overlaySetting == 4)) { + this.lblDuration.OverlaySetting = overlaySetting; + this.lblDuration.SecondProgress = 0; + this.lblDuration.Text = ""; + this.lblDuration.TextRight = $@"{DateTime.Now.ToString(Multilingual.GetWord("level_date_format"))}"; + } else if (this.StatsForm.CurrentSettings.DisplayCurrentTime && !Stats.IsPrePlaying && overlaySetting == 6) { + this.lblDuration.OverlaySetting = overlaySetting; + this.lblDuration.SecondProgress = DateTime.Now.Second; + this.lblDuration.Text = $"{Multilingual.GetWord("overlay_current_time")} :"; + this.lblDuration.TextRight = $"{DateTime.Now:HH\\:mm\\:ss}"; + } else { + this.lblDuration.SecondProgress = 0; + if (this.lastRound.UseShareCode && this.lastRound.CreativeTimeLimitSeconds == 0) { + this.lastRound.CreativeTimeLimitSeconds = this.StatsForm.GetTimeLimitSecondsFromShareCode(this.lastRound.ShowNameId, levelType); + } + DateTime start = this.lastRound.Start; + DateTime end = this.lastRound.End; + if (this.lastRound.UseShareCode) { + this.lblDuration.Text = this.lastRound.CreativeTimeLimitSeconds > 0 ? $"{Multilingual.GetWord("overlay_duration")} ({TimeSpan.FromSeconds(this.lastRound.CreativeTimeLimitSeconds):m\\:ss}) :" + : $"{Multilingual.GetWord("overlay_duration")} :"; + } else { + if ((("main_show".Equals(this.lastRound.ShowNameId) || level.IsCreative) || (!level.IsCreative && level.IsFinal)) && level.TimeLimitSeconds > 0) { + this.lblDuration.Text = $"{Multilingual.GetWord("overlay_duration")} ({TimeSpan.FromSeconds(level.TimeLimitSeconds):m\\:ss}) :"; + } else if (("squads_2player_template".Equals(this.lastRound.ShowNameId) || "squads_4player".Equals(this.lastRound.ShowNameId)) && level.TimeLimitSecondsForSquad > 0) { + this.lblDuration.Text = $"{Multilingual.GetWord("overlay_duration")} ({TimeSpan.FromSeconds(level.TimeLimitSecondsForSquad):m\\:ss}) :"; + } else { + this.lblDuration.Text = $"{Multilingual.GetWord("overlay_duration")} :"; + } + } + + if (end != DateTime.MinValue) { + if (this.lastRound.UseShareCode) { + if (this.lastRound.CreativeTimeLimitSeconds > 0) { + this.lblDuration.TextRight = $"{TimeSpan.FromSeconds(this.lastRound.CreativeTimeLimitSeconds) - (end - start):m\\:ss\\.ff}"; + } else { + this.lblDuration.TextRight = $"{end - start:m\\:ss\\.ff}"; + } + } else { + if ((("main_show".Equals(this.lastRound.ShowNameId) || level.IsCreative) || (!level.IsCreative && level.IsFinal)) && level.TimeLimitSeconds > 0) { + this.lblDuration.TextRight = $"{TimeSpan.FromSeconds(level.TimeLimitSeconds) - (end - start):m\\:ss\\.ff}"; + } else if (("squads_2player_template".Equals(this.lastRound.ShowNameId) || "squads_4player".Equals(this.lastRound.ShowNameId)) && level.TimeLimitSecondsForSquad > 0) { + this.lblDuration.TextRight = $"{TimeSpan.FromSeconds(level.TimeLimitSecondsForSquad) - (end - start):m\\:ss\\.ff}"; + } else { + this.lblDuration.TextRight = $"{end - start:m\\:ss\\.ff}"; + } + } + } else if (this.lastRound.Playing && Stats.IsPlaying) { + if (this.lastRound.UseShareCode) { + if (this.lastRound.CreativeTimeLimitSeconds > 0) { + this.lblDuration.TextRight = $"{TimeSpan.FromSeconds(this.lastRound.CreativeTimeLimitSeconds) - (DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start)):m\\:ss}"; + } else { + this.lblDuration.TextRight = $"{DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start):m\\:ss}"; + } + } else { + if ((("main_show".Equals(this.lastRound.ShowNameId) || level.IsCreative) || (!level.IsCreative && level.IsFinal)) && level.TimeLimitSeconds > 0) { + this.lblDuration.TextRight = $"{(TimeSpan.FromSeconds(level.TimeLimitSeconds)) - (DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start)):m\\:ss}"; + } else if (("squads_2player_template".Equals(this.lastRound.ShowNameId) || "squads_4player".Equals(this.lastRound.ShowNameId)) && level.TimeLimitSecondsForSquad > 0) { + this.lblDuration.TextRight = $"{(TimeSpan.FromSeconds(level.TimeLimitSecondsForSquad)) - (DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start)):m\\:ss}"; + } else { + this.lblDuration.TextRight = $"{DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start):m\\:ss}"; + } + } + } else { + this.lblDuration.TextRight = "-"; + } + } + } + private void SetFinishLabel(StatSummary levelInfo, LevelType levelType, int overlaySetting) { + if (this.StatsForm.CurrentSettings.DisplayCurrentTime && !Stats.IsPrePlaying && overlaySetting == 6) { + this.lblFinish.OverlaySetting = overlaySetting; + this.lblFinish.Text = ""; + this.lblFinish.TextRight = $@"{DateTime.Now.ToString(Multilingual.GetWord("level_date_format"))}"; + } else { + this.lblFinish.Text = Stats.IsQueued ? $"{Multilingual.GetWord("overlay_queued_players")} :" : $"{Multilingual.GetWord("overlay_finish")} :"; + if (Stats.IsQueued) { + this.lblFinish.TextRight = Stats.QueuedPlayers.ToString(); + this.lblFinish.ForeColor = this.ForeColor; + } else { + DateTime start = this.lastRound.Start; + DateTime? finish = this.lastRound.Finish; + if (finish.HasValue) { + TimeSpan time = finish.GetValueOrDefault(start) - start; + if (this.lastRound.Crown) { + this.lblFinish.TextRight = $"{Multilingual.GetWord("overlay_position_win")}! {time:m\\:ss\\.ff}"; + } else { + if (levelType == LevelType.Survival) { + this.lblFinish.TextRight = this.lastRound.Position > 0 ? $"{this.lastRound.Position} {Multilingual.GetWord("overlay_position_survived")}! {time:m\\:ss\\.ff}" : $"{time:m\\:ss\\.ff}"; + } else if (levelType == LevelType.Logic || levelType == LevelType.Hunt || levelType == LevelType.Team || levelType == LevelType.Invisibeans) { + this.lblFinish.TextRight = this.lastRound.Position > 0 ? $"{Multilingual.GetWord("overlay_position_qualified")}! {time:m\\:ss\\.ff}" : $"{time:m\\:ss\\.ff}"; + } else { + this.lblFinish.TextRight = this.lastRound.Position > 0 ? $"# {Multilingual.GetWord("overlay_position_prefix")}{this.lastRound.Position}{Multilingual.GetWord("overlay_position_suffix")} - {time:m\\:ss\\.ff}" : $"{time:m\\:ss\\.ff}"; + } + } + + if (levelType == LevelType.CreativeRace || levelType == LevelType.Race || levelType == LevelType.Hunt || levelType == LevelType.Invisibeans || this.levelException == 1) { + if (time < levelInfo.BestFinish.GetValueOrDefault(TimeSpan.MaxValue) && time > levelInfo.BestFinishOverall.GetValueOrDefault(TimeSpan.MaxValue)) { + this.lblFinish.ForeColor = Color.LightGreen; + } else if (time < levelInfo.BestFinishOverall.GetValueOrDefault(TimeSpan.MaxValue)) { + this.lblFinish.ForeColor = Color.Gold; + } + } else if (time > levelInfo.LongestFinish && time < levelInfo.LongestFinishOverall) { + this.lblFinish.ForeColor = Color.LightGreen; + } else if (time > levelInfo.LongestFinishOverall) { + this.lblFinish.ForeColor = Color.Gold; + } + } else if (this.lastRound.Playing && Stats.IsPlaying) { + this.lblFinish.TextRight = start > DateTime.UtcNow ? $"{DateTime.UtcNow - startTime:m\\:ss}" : $"{DateTime.UtcNow - start:m\\:ss}"; + } else { + this.lblFinish.TextRight = "-"; + this.lblFinish.ForeColor = this.ForeColor; + } + } } } private void UpdateInfo() { @@ -747,6 +895,7 @@ private void UpdateInfo() { this.lblProfile.Location = new Point(this.flippedImage ? 125 : this.drawWidth - (145 + this.GetOverlayProfileOffset(this.lblProfile.Text)), 9); if (this.lastRound != null && !string.IsNullOrEmpty(this.lastRound.Name)) { + int overlaySetting = (this.StatsForm.CurrentSettings.HideWinsInfo ? 4 : 0) + (this.StatsForm.CurrentSettings.HideRoundInfo ? 2 : 0) + (this.StatsForm.CurrentSettings.HideTimeInfo ? 1 : 0); string roundName = this.lastRound.VerifiedName(); this.levelException = 0; if (roundName == "round_pixelperfect_almond" || roundName == "round_hoverboardsurvival_s4_show" || roundName == "round_hoverboardsurvival2_almond" || roundName == "round_snowy_scrap" || roundName == "round_jinxed" || roundName == "round_rocknroll" || roundName == "round_conveyor_arena") { @@ -816,24 +965,16 @@ private void UpdateInfo() { : $"{levelInfo.TotalWins}{winChanceDisplay}"; } - this.lblFinals.Text = $"{Multilingual.GetWord("overlay_finals")} :"; - string finalText = $"{levelInfo.TotalFinals}{(levelInfo.TotalShows < 100000 ? " / " + levelInfo.TotalShows : Multilingual.GetWord("overlay_inning"))}"; - float finalChance = levelInfo.TotalFinals * 100f / (levelInfo.TotalShows == 0 ? 1 : levelInfo.TotalShows); - string finalChanceDisplay = this.StatsForm.CurrentSettings.HideOverlayPercentages ? string.Empty : finalText.Length > 9 ? $" - {finalChance:0}%" : $" - {finalChance:0.0}%"; - this.lblFinals.TextRight = $"{finalText}{finalChanceDisplay}"; - - this.SetQualifyChanceLabel(levelInfo); - this.SetFastestLabel(levelInfo, levelType); - this.SetPlayersLabel(); - this.SetStreakInfo(levelInfo); + this.SetFinalsLabel(levelInfo, overlaySetting); + this.SetQualifyChanceLabel(levelInfo, overlaySetting); + this.SetPlayersLabel(overlaySetting); + this.SetFastestLabel(levelInfo, levelType, overlaySetting); + this.SetStreakLabel(levelInfo, overlaySetting); + if (this.isTimeToSwitch) { this.switchCount++; } - DateTime start = this.lastRound.Start; - DateTime end = this.lastRound.End; - DateTime? finish = this.lastRound.Finish; - if (this.lastRound.Playing != this.startedPlaying) { if (this.lastRound.Playing) { this.startTime = DateTime.UtcNow; @@ -841,101 +982,8 @@ private void UpdateInfo() { this.startedPlaying = this.lastRound.Playing; } - this.lblFinish.Text = Stats.IsQueued ? $"{Multilingual.GetWord("overlay_queued_players")} :" : $"{Multilingual.GetWord("overlay_finish")} :"; - if (Stats.IsQueued) { - this.lblFinish.TextRight = Stats.QueuedPlayers.ToString(); - this.lblFinish.ForeColor = this.ForeColor; - } else { - if (finish.HasValue) { - TimeSpan time = finish.GetValueOrDefault(start) - start; - if (this.lastRound.Crown) { - this.lblFinish.TextRight = $"{Multilingual.GetWord("overlay_position_win")}! {time:m\\:ss\\.ff}"; - } else { - if (levelType == LevelType.Survival) { - this.lblFinish.TextRight = this.lastRound.Position > 0 ? $"{this.lastRound.Position} {Multilingual.GetWord("overlay_position_survived")}! {time:m\\:ss\\.ff}" : $"{time:m\\:ss\\.ff}"; - } else if (levelType == LevelType.Logic || levelType == LevelType.Hunt || levelType == LevelType.Team || levelType == LevelType.Invisibeans) { - this.lblFinish.TextRight = this.lastRound.Position > 0 ? $"{Multilingual.GetWord("overlay_position_qualified")}! {time:m\\:ss\\.ff}" : $"{time:m\\:ss\\.ff}"; - } else { - this.lblFinish.TextRight = this.lastRound.Position > 0 ? $"# {Multilingual.GetWord("overlay_position_prefix")}{this.lastRound.Position}{Multilingual.GetWord("overlay_position_suffix")} - {time:m\\:ss\\.ff}" : $"{time:m\\:ss\\.ff}"; - } - } - - if (levelType == LevelType.CreativeRace || levelType == LevelType.Race || levelType == LevelType.Hunt || levelType == LevelType.Invisibeans || this.levelException == 1) { - if (time < levelInfo.BestFinish.GetValueOrDefault(TimeSpan.MaxValue) && time > levelInfo.BestFinishOverall.GetValueOrDefault(TimeSpan.MaxValue)) { - this.lblFinish.ForeColor = Color.LightGreen; - } else if (time < levelInfo.BestFinishOverall.GetValueOrDefault(TimeSpan.MaxValue)) { - this.lblFinish.ForeColor = Color.Gold; - } - } else if (time > levelInfo.LongestFinish && time < levelInfo.LongestFinishOverall) { - this.lblFinish.ForeColor = Color.LightGreen; - } else if (time > levelInfo.LongestFinishOverall) { - this.lblFinish.ForeColor = Color.Gold; - } - } else if (this.lastRound.Playing && Stats.IsPlaying) { - this.lblFinish.TextRight = start > DateTime.UtcNow ? $"{DateTime.UtcNow - startTime:m\\:ss}" : $"{DateTime.UtcNow - start:m\\:ss}"; - } else { - this.lblFinish.TextRight = "-"; - this.lblFinish.ForeColor = this.ForeColor; - } - } - - if (this.lastRound.UseShareCode && this.lastRound.CreativeTimeLimitSeconds == 0) { - this.lastRound.CreativeTimeLimitSeconds = this.StatsForm.GetTimeLimitSecondsFromShareCode(this.lastRound.ShowNameId, levelType); - } - - if (!Stats.IsPrePlaying && !this.StatsForm.CurrentSettings.HideRoundInfo) { - this.lblDuration.Text = ""; - this.lblDuration.TextRight = $@"{DateTime.Now.ToString(Multilingual.GetWord("level_date_format"))}"; - } else { - if (this.lastRound.UseShareCode) { - this.lblDuration.Text = this.lastRound.CreativeTimeLimitSeconds > 0 ? $"{Multilingual.GetWord("overlay_duration")} ({TimeSpan.FromSeconds(this.lastRound.CreativeTimeLimitSeconds):m\\:ss}) :" - : $"{Multilingual.GetWord("overlay_duration")} :"; - } else { - if ((("main_show".Equals(this.lastRound.ShowNameId) || level.IsCreative) || (!level.IsCreative && level.IsFinal)) && level.TimeLimitSeconds > 0) { - this.lblDuration.Text = $"{Multilingual.GetWord("overlay_duration")} ({TimeSpan.FromSeconds(level.TimeLimitSeconds):m\\:ss}) :"; - } else if (("squads_2player_template".Equals(this.lastRound.ShowNameId) || "squads_4player".Equals(this.lastRound.ShowNameId)) && level.TimeLimitSecondsForSquad > 0) { - this.lblDuration.Text = $"{Multilingual.GetWord("overlay_duration")} ({TimeSpan.FromSeconds(level.TimeLimitSecondsForSquad):m\\:ss}) :"; - } else { - this.lblDuration.Text = $"{Multilingual.GetWord("overlay_duration")} :"; - } - } - - if (end != DateTime.MinValue) { - if (this.lastRound.UseShareCode) { - if (this.lastRound.CreativeTimeLimitSeconds > 0) { - this.lblDuration.TextRight = $"{TimeSpan.FromSeconds(this.lastRound.CreativeTimeLimitSeconds) - (end - start):m\\:ss\\.ff}"; - } else { - this.lblDuration.TextRight = $"{end - start:m\\:ss\\.ff}"; - } - } else { - if ((("main_show".Equals(this.lastRound.ShowNameId) || level.IsCreative) || (!level.IsCreative && level.IsFinal)) && level.TimeLimitSeconds > 0) { - this.lblDuration.TextRight = $"{TimeSpan.FromSeconds(level.TimeLimitSeconds) - (end - start):m\\:ss\\.ff}"; - } else if (("squads_2player_template".Equals(this.lastRound.ShowNameId) || "squads_4player".Equals(this.lastRound.ShowNameId)) && level.TimeLimitSecondsForSquad > 0) { - this.lblDuration.TextRight = $"{TimeSpan.FromSeconds(level.TimeLimitSecondsForSquad) - (end - start):m\\:ss\\.ff}"; - } else { - this.lblDuration.TextRight = $"{end - start:m\\:ss\\.ff}"; - } - } - } else if (this.lastRound.Playing && Stats.IsPlaying) { - if (this.lastRound.UseShareCode) { - if (this.lastRound.CreativeTimeLimitSeconds > 0) { - this.lblDuration.TextRight = $"{TimeSpan.FromSeconds(this.lastRound.CreativeTimeLimitSeconds) - (DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start)):m\\:ss}"; - } else { - this.lblDuration.TextRight = $"{DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start):m\\:ss}"; - } - } else { - if ((("main_show".Equals(this.lastRound.ShowNameId) || level.IsCreative) || (!level.IsCreative && level.IsFinal)) && level.TimeLimitSeconds > 0) { - this.lblDuration.TextRight = $"{(TimeSpan.FromSeconds(level.TimeLimitSeconds)) - (DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start)):m\\:ss}"; - } else if (("squads_2player_template".Equals(this.lastRound.ShowNameId) || "squads_4player".Equals(this.lastRound.ShowNameId)) && level.TimeLimitSecondsForSquad > 0) { - this.lblDuration.TextRight = $"{(TimeSpan.FromSeconds(level.TimeLimitSecondsForSquad)) - (DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start)):m\\:ss}"; - } else { - this.lblDuration.TextRight = $"{DateTime.UtcNow - (start > DateTime.UtcNow ? startTime : start):m\\:ss}"; - } - } - } else { - this.lblDuration.TextRight = "-"; - } - } + this.SetFinishLabel(levelInfo, levelType, overlaySetting); + this.SetDurationLabel(level, levelType, overlaySetting); } this.Invalidate(); } diff --git a/Views/Settings.Designer.cs b/Views/Settings.Designer.cs index e12ec36b6..b6b0b1bcd 100644 --- a/Views/Settings.Designer.cs +++ b/Views/Settings.Designer.cs @@ -64,6 +64,7 @@ private void InitializeComponent() this.chkColorByRoundType = new MetroFramework.Controls.MetroCheckBox(); this.chkAutoChangeProfile = new MetroFramework.Controls.MetroCheckBox(); this.chkShadeTheFlagImage = new MetroFramework.Controls.MetroCheckBox(); + this.chkDisplayCurrentTime = new MetroFramework.Controls.MetroCheckBox(); this.lblCycleTimeSecondsTag = new MetroFramework.Controls.MetroLabel(); this.lblCycleTimeSeconds = new MetroFramework.Controls.MetroLabel(); this.txtCycleTimeSeconds = new MetroFramework.Controls.MetroTextBox(); @@ -215,7 +216,7 @@ private void InitializeComponent() // this.lblOverlayFont.AutoSize = true; this.lblOverlayFont.FontWeight = MetroFramework.MetroLabelWeight.Regular; - this.lblOverlayFont.Location = new System.Drawing.Point(21, 661); + this.lblOverlayFont.Location = new System.Drawing.Point(21, 690); this.lblOverlayFont.Name = "lblOverlayFont"; this.lblOverlayFont.Size = new System.Drawing.Size(133, 19); this.lblOverlayFont.TabIndex = 27; @@ -224,7 +225,7 @@ private void InitializeComponent() // btnSelectFont // this.btnSelectFont.Cursor = System.Windows.Forms.Cursors.Hand; - this.btnSelectFont.Location = new System.Drawing.Point(169, 660); + this.btnSelectFont.Location = new System.Drawing.Point(169, 689); this.btnSelectFont.Margin = new System.Windows.Forms.Padding(2); this.btnSelectFont.Name = "btnSelectFont"; this.btnSelectFont.Size = new System.Drawing.Size(96, 25); @@ -236,7 +237,7 @@ private void InitializeComponent() // btnResetOverlayFont // this.btnResetOverlayFont.Cursor = System.Windows.Forms.Cursors.Hand; - this.btnResetOverlayFont.Location = new System.Drawing.Point(269, 660); + this.btnResetOverlayFont.Location = new System.Drawing.Point(269, 689); this.btnResetOverlayFont.Margin = new System.Windows.Forms.Padding(2); this.btnResetOverlayFont.Name = "btnResetOverlayFont"; this.btnResetOverlayFont.Size = new System.Drawing.Size(96, 25); @@ -248,7 +249,7 @@ private void InitializeComponent() // grpOverlayFontExample // this.grpOverlayFontExample.Controls.Add(this.lblOverlayFontExample); - this.grpOverlayFontExample.Location = new System.Drawing.Point(21, 685); + this.grpOverlayFontExample.Location = new System.Drawing.Point(21, 714); this.grpOverlayFontExample.Margin = new System.Windows.Forms.Padding(2); this.grpOverlayFontExample.Name = "grpOverlayFontExample"; this.grpOverlayFontExample.Padding = new System.Windows.Forms.Padding(2); @@ -624,6 +625,18 @@ private void InitializeComponent() this.chkShadeTheFlagImage.Text = "Shade the flag image"; this.chkShadeTheFlagImage.UseSelectable = true; // + // chkDisplayCurrentTime + // + this.chkDisplayCurrentTime.AutoSize = true; + this.chkDisplayCurrentTime.Cursor = System.Windows.Forms.Cursors.Hand; + this.chkDisplayCurrentTime.FontSize = MetroFramework.MetroCheckBoxSize.Medium; + this.chkDisplayCurrentTime.Location = new System.Drawing.Point(21, 639); + this.chkDisplayCurrentTime.Name = "chkDisplayCurrentTime"; + this.chkDisplayCurrentTime.Size = new System.Drawing.Size(255, 19); + this.chkDisplayCurrentTime.TabIndex = 28; + this.chkDisplayCurrentTime.Text = "Display the current time while waiting"; + this.chkDisplayCurrentTime.UseSelectable = true; + // // lblCycleTimeSecondsTag // this.lblCycleTimeSecondsTag.AutoSize = true; @@ -646,9 +659,6 @@ private void InitializeComponent() // // txtCycleTimeSeconds // - // - // - // this.txtCycleTimeSeconds.CustomButton.Image = null; this.txtCycleTimeSeconds.CustomButton.Location = new System.Drawing.Point(4, 1); this.txtCycleTimeSeconds.CustomButton.Name = ""; @@ -1209,6 +1219,7 @@ private void InitializeComponent() this.panelOverlay.Controls.Add(this.btnResetOverlayFont); this.panelOverlay.Controls.Add(this.chkAutoChangeProfile); this.panelOverlay.Controls.Add(this.chkShadeTheFlagImage); + this.panelOverlay.Controls.Add(this.chkDisplayCurrentTime); this.panelOverlay.Controls.Add(this.chkColorByRoundType); this.panelOverlay.Controls.Add(this.chkPlayerByConsoleType); this.panelOverlay.Controls.Add(this.chkOverlayOnTop); @@ -1675,6 +1686,7 @@ private void InitializeComponent() private MetroFramework.Controls.MetroCheckBox chkColorByRoundType; private MetroFramework.Controls.MetroCheckBox chkAutoChangeProfile; private MetroFramework.Controls.MetroCheckBox chkShadeTheFlagImage; + private MetroFramework.Controls.MetroCheckBox chkDisplayCurrentTime; private MetroFramework.Controls.MetroComboBox cboFastestFilter; private MetroFramework.Controls.MetroLabel lblFastestFilter; private MetroFramework.Controls.MetroComboBox cboQualifyFilter; diff --git a/Views/Settings.cs b/Views/Settings.cs index 90ee3bd14..23c10933a 100644 --- a/Views/Settings.cs +++ b/Views/Settings.cs @@ -89,6 +89,7 @@ private void Settings_Load(object sender, EventArgs e) { this.chkColorByRoundType.Checked = this.CurrentSettings.ColorByRoundType; this.chkAutoChangeProfile.Checked = this.CurrentSettings.AutoChangeProfile; this.chkShadeTheFlagImage.Checked = this.CurrentSettings.ShadeTheFlagImage; + this.chkDisplayCurrentTime.Checked = this.CurrentSettings.DisplayCurrentTime; this.chkHideWinsInfo.Checked = this.CurrentSettings.HideWinsInfo; this.chkHideRoundInfo.Checked = this.CurrentSettings.HideRoundInfo; this.chkHideTimeInfo.Checked = this.CurrentSettings.HideTimeInfo; @@ -403,6 +404,7 @@ private void btnSave_Click(object sender, EventArgs e) { this.CurrentSettings.ColorByRoundType = this.chkColorByRoundType.Checked; this.CurrentSettings.AutoChangeProfile = this.chkAutoChangeProfile.Checked; this.CurrentSettings.ShadeTheFlagImage = this.chkShadeTheFlagImage.Checked; + this.CurrentSettings.DisplayCurrentTime = this.chkDisplayCurrentTime.Checked; if (this.chkHideRoundInfo.Checked && this.chkHideTimeInfo.Checked && this.chkHideWinsInfo.Checked) { this.chkHideWinsInfo.Checked = false; } @@ -857,6 +859,7 @@ private void ChangeLanguage(int lang) { this.chkColorByRoundType.Text = Multilingual.GetWord("settings_color_round_name_based_on_round_type"); this.chkAutoChangeProfile.Text = Multilingual.GetWord("settings_auto_change_profile"); this.chkShadeTheFlagImage.Text = Multilingual.GetWord("settings_shade_the_flag_image"); + this.chkDisplayCurrentTime.Text = Multilingual.GetWord("settings_diaplay_current_time"); this.lblCycleTimeSecondsTag.Text = Multilingual.GetWord("settings_sec"); this.lblCycleTimeSeconds.Text = Multilingual.GetWord("settings_cycle_time"); this.chkOnlyShowFinalStreak.Text = Multilingual.GetWord("settings_final_streak_only"); diff --git a/Views/Stats.cs b/Views/Stats.cs index f7411eaa4..35622aafd 100644 --- a/Views/Stats.cs +++ b/Views/Stats.cs @@ -1908,6 +1908,12 @@ private void UpdateDatabaseVersion() { this.CurrentSettings.Version = 52; this.SaveUserSettings(); } + + if (this.CurrentSettings.Version == 52) { + this.CurrentSettings.DisplayCurrentTime = true; + this.CurrentSettings.Version = 53; + this.SaveUserSettings(); + } } private UserSettings GetDefaultSettings() { return new UserSettings { @@ -1952,6 +1958,7 @@ private UserSettings GetDefaultSettings() { ColorByRoundType = false, AutoChangeProfile = false, ShadeTheFlagImage = false, + DisplayCurrentTime = false, PreviousWins = 0, WinsFilter = 1, QualifyFilter = 1, @@ -1982,7 +1989,7 @@ private UserSettings GetDefaultSettings() { WinPerDayGraphStyle = 0, ShowChangelog = true, Visible = true, - Version = 52 + Version = 53 }; } private bool IsFinalWithCreativeLevel(string levelId) {