Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qubqub committed Sep 5, 2023
1 parent 853f1bd commit f169e46
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 74 deletions.
14 changes: 11 additions & 3 deletions Controls/TransparentLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public TransparentLabel() {
public Color LevelTrueColor { get; set; }
public Image RoundIcon { get; set; }
public bool UseShareCode { get; set; }
public int SecondProgress { get; set; }
public void Draw(Graphics g) {
if (!this.DrawVisible) { return; }
if (this.PlatformIcon != null) {
Expand Down Expand Up @@ -84,6 +85,9 @@ public void Draw(Graphics g) {
}

if (!string.IsNullOrEmpty(this.Text)) {
if (this.Name.Equals("lblPlayers")) {
if (this.SecondProgress > 0) this.FillRoundedRectangleF(g, new Pen(this.GetComplementaryColor(brFore.Color, 127)), new SolidBrush(this.GetComplementaryColor(brFore.Color, 127)), this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width * this.SecondProgress / 60f, this.ClientRectangle.Height, 4f);
}
this.DrawOutlineText(g, this.ClientRectangle, null, brFore, this.Font.FontFamily, this.Font.Style, this.Font.Size * this.GetFontSizeFactor(), this.Text, stringFormat);
}

Expand Down Expand Up @@ -120,9 +124,9 @@ public void Draw(Graphics g) {
}
}
}
// private Color GetComplementaryColor(Color source, int alpha) {
// return Color.FromArgb(alpha, 255 - source.R, 255 - source.G, 255 - source.B);
// }
private Color GetComplementaryColor(Color source, int alpha) {
return Color.FromArgb(alpha, 255 - source.R, 255 - source.G, 255 - source.B);
}
private float GetFontSizeFactor() {
switch (this.Name) {
case "lblWins":
Expand All @@ -141,6 +145,10 @@ private float GetFontSizeFactor() {
return (Stats.CurrentLanguage == 0 || Stats.CurrentLanguage == 1) ? (this.TextRight.Length > 17 ? (1f - (((this.TextRight.Length * 3.3f) - 78 + (this.Text.Length * 3.3f)) / 100f)) : 1f) :
(Stats.CurrentLanguage == 2 || Stats.CurrentLanguage == 3) ? (this.TextRight.Length > 17 ? (1f - (((this.TextRight.Length * 3.3f) - 68 + (this.Text.Length * 3.3f)) / 100f)) : 1f) :
(Stats.CurrentLanguage == 4 || Stats.CurrentLanguage == 5) ? (this.TextRight.Length > 17 ? (1f - (((this.TextRight.Length * 3.3f) - 68 + (this.Text.Length * 3.3f)) / 100f)) : 1f) : 1f;
case "lblPlayers":
return (Stats.CurrentLanguage == 0 || Stats.CurrentLanguage == 1) ? (this.TextRight.Length > 7 ? (1f - (((this.TextRight.Length * 3.3f) - 62 + (this.Text.Length * 3.3f)) / 100f)) : 1f) :
(Stats.CurrentLanguage == 2 || Stats.CurrentLanguage == 3) ? (this.TextRight.Length > 7 ? (1f - (((this.TextRight.Length * 3.3f) - 52 + (this.Text.Length * 3.3f)) / 100f)) : 1f) :
(Stats.CurrentLanguage == 4 || Stats.CurrentLanguage == 5) ? (this.TextRight.Length > 7 ? (1f - (((this.TextRight.Length * 3.3f) - 52 + (this.Text.Length * 3.3f)) / 100f)) : 1f) : 1f;
case "lblDuration":
return (Stats.CurrentLanguage == 0 || Stats.CurrentLanguage == 1) ? (this.Text.Length > 14 ? (1f - ((this.TextRight.Length - 42 + (this.Text.Length * 2.5f)) / 100f)) : 1f) :
(Stats.CurrentLanguage == 2 || Stats.CurrentLanguage == 3) ? (this.Text.Length > 14 ? (1f - ((this.TextRight.Length - 42 + (this.Text.Length * 2.5f)) / 100f)) : 1f) :
Expand Down
6 changes: 6 additions & 0 deletions Entities/Multilingual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public static class Multilingual {
{"overlay_worst_score", "LOW SCORE"},
{"overlay_duration", "TIME"},
{"overlay_players", "PLAYERS"},
{"overlay_current_time", "CURRENT TIME"},
{"overlay_round_prefix", "ROUND "},
{"overlay_round_suffix", ""},
{"overlay_round_abbreviation_prefix", "R "},
Expand Down Expand Up @@ -787,6 +788,7 @@ public static class Multilingual {
{"overlay_worst_score", "PIRE SCORE"},
{"overlay_duration", "TEMPS"},
{"overlay_players", "JOUEURS"},
{"overlay_current_time", "HEURE ACTUELLE"},
{"overlay_round_prefix", "MANCHE "},
{"overlay_round_suffix", ""},
{"overlay_round_abbreviation_prefix", "M "},
Expand Down Expand Up @@ -1212,6 +1214,7 @@ public static class Multilingual {
{"overlay_worst_score", "최저 점수"},
{"overlay_duration", "시간"},
{"overlay_players", "인원"},
{"overlay_current_time", "현재 시간"},
{"overlay_round_prefix", ""},
{"overlay_round_suffix", " 라운드"},
{"overlay_round_abbreviation_prefix", ""},
Expand Down Expand Up @@ -1638,6 +1641,7 @@ public static class Multilingual {
{"overlay_worst_score", "ワーストスコア"},
{"overlay_duration", "時間"},
{"overlay_players", "人数"},
{"overlay_current_time", "現在の時刻"},
{"overlay_round_prefix", "ラウンド "},
{"overlay_round_suffix", ""},
{"overlay_round_abbreviation_prefix", "R "},
Expand Down Expand Up @@ -2063,6 +2067,7 @@ public static class Multilingual {
{"overlay_worst_score", "最低分"},
{"overlay_duration", "时间"},
{"overlay_players", "玩家"},
{"overlay_current_time", "当前时间"},
{"overlay_round_prefix", "回合 "},
{"overlay_round_suffix", ""},
{"overlay_round_abbreviation_prefix", "回合 "},
Expand Down Expand Up @@ -2488,6 +2493,7 @@ public static class Multilingual {
{"overlay_worst_score", "最低分"},
{"overlay_duration", "時間"},
{"overlay_players", "玩家"},
{"overlay_current_time", "當前時間"},
{"overlay_round_prefix", "回合 "},
{"overlay_round_suffix", ""},
{"overlay_round_abbreviation_prefix", "回合 "},
Expand Down
154 changes: 83 additions & 71 deletions Views/Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -619,83 +619,95 @@ private void SetFastestLabel(StatSummary levelInfo, LevelType type) {
}
}
private void SetPlayersLabel() {
int playersSwitchCount = this.switchCount;
if (!this.StatsForm.CurrentSettings.SwitchBetweenPlayers) {
playersSwitchCount = this.StatsForm.CurrentSettings.OnlyShowPing ? 1 : 0;
}
switch (playersSwitchCount % 2) {
case 0:
this.lblPlayers.TextRight = $"{this.lastRound?.Players}";
if (this.StatsForm.CurrentSettings.PlayerByConsoleType) {
this.lblPlayers.Image = Properties.Resources.player_icon;
this.lblPlayers.Text = @"ㅤ :";
int psCount = this.lastRound.PlayersPs4 + this.lastRound.PlayersPs5;
int xbCount = this.lastRound.PlayersXb1 + this.lastRound.PlayersXsx;
int swCount = this.lastRound.PlayersSw;
int pcCount = this.lastRound.PlayersPc;
this.lblPlayersPs.TextRight = (psCount == 0 ? "-" : $"{psCount}");
this.lblPlayersPs.Size = new Size((psCount > 9 ? 32 : 26), 16);
this.lblPlayersPs.DrawVisible = true;
this.lblPlayersXbox.TextRight = (xbCount == 0 ? "-" : $"{xbCount}");
this.lblPlayersXbox.Size = new Size((xbCount > 9 ? 32 : 26), 16);
this.lblPlayersXbox.DrawVisible = true;
this.lblPlayersSwitch.TextRight = (swCount == 0 ? "-" : $"{swCount}");
this.lblPlayersSwitch.Size = new Size((swCount > 9 ? 32 : 26), 16);
this.lblPlayersSwitch.DrawVisible = true;
this.lblPlayersPc.TextRight = (pcCount == 0 ? "-" : $"{pcCount}");
this.lblPlayersPc.Size = new Size((pcCount > 9 ? 32 : 26), 16);
this.lblPlayersPc.DrawVisible = true;
this.lblCountryIcon.DrawVisible = false;
this.lblPingIcon.DrawVisible = false;
} else {
if (!Stats.IsPrePlaying) {
this.lblPlayers.Image = null;
this.lblPlayersPs.DrawVisible = false;
this.lblPlayersXbox.DrawVisible = false;
this.lblPlayersSwitch.DrawVisible = false;
this.lblPlayersPc.DrawVisible = false;
this.lblCountryIcon.DrawVisible = false;
this.lblPingIcon.DrawVisible = false;
this.lblPlayers.SecondProgress = DateTime.Now.Second;
this.lblPlayers.Text = $"{Multilingual.GetWord("overlay_current_time")} :";
this.lblPlayers.TextRight = $"{DateTime.Now:HH\\:mm\\:ss}";
} else {
this.lblPlayers.SecondProgress = 0;
int playersSwitchCount = this.switchCount;
if (!this.StatsForm.CurrentSettings.SwitchBetweenPlayers) {
playersSwitchCount = this.StatsForm.CurrentSettings.OnlyShowPing ? 1 : 0;
}
switch (playersSwitchCount % 2) {
case 0:
this.lblPlayers.TextRight = $"{this.lastRound?.Players}";
if (this.StatsForm.CurrentSettings.PlayerByConsoleType) {
this.lblPlayers.Image = Properties.Resources.player_icon;
this.lblPlayers.Text = @"ㅤ :";
int psCount = this.lastRound.PlayersPs4 + this.lastRound.PlayersPs5;
int xbCount = this.lastRound.PlayersXb1 + this.lastRound.PlayersXsx;
int swCount = this.lastRound.PlayersSw;
int pcCount = this.lastRound.PlayersPc;
this.lblPlayersPs.TextRight = (psCount == 0 ? "-" : $"{psCount}");
this.lblPlayersPs.Size = new Size((psCount > 9 ? 32 : 26), 16);
this.lblPlayersPs.DrawVisible = true;
this.lblPlayersXbox.TextRight = (xbCount == 0 ? "-" : $"{xbCount}");
this.lblPlayersXbox.Size = new Size((xbCount > 9 ? 32 : 26), 16);
this.lblPlayersXbox.DrawVisible = true;
this.lblPlayersSwitch.TextRight = (swCount == 0 ? "-" : $"{swCount}");
this.lblPlayersSwitch.Size = new Size((swCount > 9 ? 32 : 26), 16);
this.lblPlayersSwitch.DrawVisible = true;
this.lblPlayersPc.TextRight = (pcCount == 0 ? "-" : $"{pcCount}");
this.lblPlayersPc.Size = new Size((pcCount > 9 ? 32 : 26), 16);
this.lblPlayersPc.DrawVisible = true;
this.lblCountryIcon.DrawVisible = false;
this.lblPingIcon.DrawVisible = false;
} else {
this.lblPlayers.Image = null;
this.lblPlayers.Text = $"{Multilingual.GetWord("overlay_players")} :";
this.lblPlayersPs.DrawVisible = false;
this.lblPlayersXbox.DrawVisible = false;
this.lblPlayersSwitch.DrawVisible = false;
this.lblPlayersPc.DrawVisible = false;
this.lblCountryIcon.DrawVisible = false;
this.lblPingIcon.DrawVisible = false;
}
break;
case 1:
this.lblPlayers.Image = null;
this.lblPlayers.Text = $"{Multilingual.GetWord("overlay_players")} :";
this.lblPlayersPs.DrawVisible = false;
this.lblPlayersXbox.DrawVisible = false;
this.lblPlayersSwitch.DrawVisible = false;
this.lblPlayersPc.DrawVisible = false;
this.lblCountryIcon.DrawVisible = false;
this.lblPingIcon.DrawVisible = false;
}
break;
case 1:
this.lblPlayers.Image = null;
this.lblPlayersPs.DrawVisible = false;
this.lblPlayersXbox.DrawVisible = false;
this.lblPlayersSwitch.DrawVisible = false;
this.lblPlayersPc.DrawVisible = false;

this.lblCountryIcon.DrawVisible = true;
this.lblPingIcon.DrawVisible = true;
if (Stats.IsBadPing) {
this.lblCountryIcon.ImageX = 49;
this.lblCountryIcon.Image = (Image)Properties.Resources.ResourceManager.GetObject($"country_{Stats.LastCountryAlpha2Code}{(this.StatsForm.CurrentSettings.ShadeTheFlagImage ? "_shiny" : "")}_icon");

this.lblPingIcon.ImageX = 40;
this.lblPingIcon.Image = Properties.Resources.ping_200_icon;
} else {
this.lblCountryIcon.Image = (Image)(Stats.IsPrePlaying && Stats.LastServerPing > 0 ? Properties.Resources.ResourceManager.GetObject($"country_{Stats.LastCountryAlpha2Code}{(this.StatsForm.CurrentSettings.ShadeTheFlagImage ? "_shiny" : "")}_icon") : null);
this.lblCountryIcon.ImageX = (Stats.IsPrePlaying && Stats.LastServerPing < 1000)
? (Stats.LastServerPing > 0 && 9 >= Stats.LastServerPing ? 39 :
Stats.LastServerPing >= 10 && 99 >= Stats.LastServerPing ? 30 :
Stats.LastServerPing >= 100 && 199 >= Stats.LastServerPing ? -2 :
Stats.LastServerPing >= 200 && 999 >= Stats.LastServerPing ? -5 : 0) : -12;

this.lblPingIcon.Image = (Stats.IsPrePlaying && Stats.LastServerPing > 99 && 200 > Stats.LastServerPing) ? Properties.Resources.ping_100_icon :
(Stats.IsPrePlaying && Stats.LastServerPing >= 200 ? Properties.Resources.ping_200_icon : null);
this.lblPingIcon.ImageX = (Stats.IsPrePlaying && Stats.LastServerPing >= 100 && 199 >= Stats.LastServerPing) ? -14 :
(Stats.IsPrePlaying && Stats.LastServerPing >= 200 && 999 >= Stats.LastServerPing) ? -16 :
(Stats.IsPrePlaying && Stats.LastServerPing > 999) ? -24 : 0;

if (!this.Font.FontFamily.Name.Equals(GetDefaultFontFamilies(0).Name)) {
this.lblCountryIcon.ImageX += 7;
this.lblPingIcon.ImageX += 7;
this.lblCountryIcon.DrawVisible = true;
this.lblPingIcon.DrawVisible = true;
if (Stats.IsBadPing) {
this.lblCountryIcon.ImageX = 49;
this.lblCountryIcon.Image = (Image)Properties.Resources.ResourceManager.GetObject($"country_{Stats.LastCountryAlpha2Code}{(this.StatsForm.CurrentSettings.ShadeTheFlagImage ? "_shiny" : "")}_icon");
this.lblPingIcon.ImageX = 40;
this.lblPingIcon.Image = Properties.Resources.ping_200_icon;
} else {
this.lblCountryIcon.Image = (Image)(Stats.IsPrePlaying && Stats.LastServerPing > 0 ? Properties.Resources.ResourceManager.GetObject($"country_{Stats.LastCountryAlpha2Code}{(this.StatsForm.CurrentSettings.ShadeTheFlagImage ? "_shiny" : "")}_icon") : null);
this.lblCountryIcon.ImageX = (Stats.IsPrePlaying && Stats.LastServerPing < 1000)
? (Stats.LastServerPing > 0 && 9 >= Stats.LastServerPing ? 39 :
Stats.LastServerPing >= 10 && 99 >= Stats.LastServerPing ? 30 :
Stats.LastServerPing >= 100 && 199 >= Stats.LastServerPing ? -2 :
Stats.LastServerPing >= 200 && 999 >= Stats.LastServerPing ? -5 : 0) : -12;

this.lblPingIcon.Image = (Stats.IsPrePlaying && Stats.LastServerPing > 99 && 200 > Stats.LastServerPing) ? Properties.Resources.ping_100_icon :
(Stats.IsPrePlaying && Stats.LastServerPing >= 200 ? Properties.Resources.ping_200_icon : null);
this.lblPingIcon.ImageX = (Stats.IsPrePlaying && Stats.LastServerPing >= 100 && 199 >= Stats.LastServerPing) ? -14 :
(Stats.IsPrePlaying && Stats.LastServerPing >= 200 && 999 >= Stats.LastServerPing) ? -16 :
(Stats.IsPrePlaying && Stats.LastServerPing > 999) ? -24 : 0;

if (!this.Font.FontFamily.Name.Equals(GetDefaultFontFamilies(0).Name)) {
this.lblCountryIcon.ImageX += 7;
this.lblPingIcon.ImageX += 7;
}
}
}

this.lblPlayers.Text = $"{Multilingual.GetWord("overlay_ping")} :";
this.lblPlayers.TextRight = (Stats.IsPrePlaying && Stats.LastServerPing > 0) ? $"{Stats.LastServerPing} ms" : "-";
break;
this.lblPlayers.Text = $"{Multilingual.GetWord("overlay_ping")} :";
this.lblPlayers.TextRight = (Stats.IsPrePlaying && Stats.LastServerPing > 0) ? $"{Stats.LastServerPing} ms" : "-";
break;
}
}
}
private void SetStreakInfo(StatSummary levelInfo) {
Expand Down

0 comments on commit f169e46

Please sign in to comment.