Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Micdu70 committed Jul 16, 2024
1 parent 13d9822 commit 61f4ad8
Show file tree
Hide file tree
Showing 7 changed files with 2,234 additions and 2,225 deletions.
4,414 changes: 2,208 additions & 2,206 deletions Entities/LevelStats.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Entities/LogFileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ private void SetCountryCodeByIp(string ip) {
if (!string.IsNullOrEmpty(ci)) {
string[] countryInfo = ci.Split(';');
Stats.LastCountryAlpha2Code = countryInfo[0].ToLower();
Stats.LastCountryRegion = !string.Equals("unknown", countryInfo[1].ToLower()) ? countryInfo[1] : string.Empty;
Stats.LastCountryCity = !string.Equals("unknown", countryInfo[2].ToLower()) ? countryInfo[2] : string.Empty;
Stats.LastCountryRegion = !string.Equals(countryInfo[1].ToLower(), "unknown") ? countryInfo[1] : string.Empty;
Stats.LastCountryCity = !string.Equals(countryInfo[2].ToLower(), "unknown") ? countryInfo[2] : string.Empty;
} else {
string countryCode = Utils.GetCountryCode(ip);
Stats.LastCountryAlpha2Code = !string.IsNullOrEmpty(countryCode) ? countryCode.ToLower() : string.Empty;
Expand Down
2 changes: 1 addition & 1 deletion Entities/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private static string[] GetCountryCodeUsingIp2c(string host) {
using (ApiWebClient web = new ApiWebClient()) {
string resStr = Regex.Unescape(web.DownloadString($"{IP2C_ORG_URL}{host}"));
string[] resArr = resStr.Split(';');
if (string.Equals("1", resArr[0])) {
if (string.Equals(resArr[0], "1")) {
countryInfo[0] = resArr[1]; // alpha-2 code
countryInfo[1] = resArr[3]; // a full country name
}
Expand Down
4 changes: 2 additions & 2 deletions Views/LeaderboardDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ private void gridPlayerList_CellDoubleClick(object sender, DataGridViewCellEvent
}

private string ReplaceLevelIdInShuffleShow(string showId, string roundId) {
if (string.Equals("wle_mrs_shuffle_show_squads", showId)) { // Squads Scramble
if (string.Equals(showId, "wle_mrs_shuffle_show_squads")) { // Squads Scramble
if (roundId.StartsWith("wle_shuffle_") && roundId.IndexOf("_fp") != -1) {
roundId = roundId.Replace("_squads_", "_discover_");
} else if (roundId.StartsWith("wle_shuffle_squads_2_24_01_")) {
Expand All @@ -1214,7 +1214,7 @@ private string ReplaceLevelIdInShuffleShow(string showId, string roundId) {
}
}

if (string.Equals("no_elimination_show", showId) && (roundId.StartsWith("wle_main_filler_") || roundId.StartsWith("wle_main_opener_"))) {
if (string.Equals(showId, "no_elimination_show") && (roundId.StartsWith("wle_main_filler_") || roundId.StartsWith("wle_main_opener_"))) {
roundId = roundId.Replace("_noelim", "");
}
return roundId;
Expand Down
2 changes: 1 addition & 1 deletion Views/LevelDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ private void gridDetails_CellFormatting(object sender, DataGridViewCellFormattin
}
} else if (((Grid)sender).Columns[e.ColumnIndex].Name == "IsFinalIcon") {
if (info.IsCasualShow) {
((Grid)sender).Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = Multilingual.GetShowName("casual_show");
((Grid)sender).Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = string.Equals(info.ShowNameId, "no_elimination_explore") ? Multilingual.GetShowName("no_elimination_explore") : Multilingual.GetShowName("casual_show");
e.Value = Properties.Resources.casual_show_icon;
} else if (info.IsFinal || info.Qualified) {
((Grid)sender).Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = Multilingual.GetWord("level_detail_success_reaching_finals");
Expand Down
23 changes: 15 additions & 8 deletions Views/Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public sealed partial class Overlay : Form {
private LevelStats levelStats;
private LevelType levelType;
private BestRecordType recordType;
private Image roundIcon;
private StatSummary levelSummary;
private int drawWidth, drawHeight;
private bool startedPlaying;
Expand Down Expand Up @@ -579,7 +580,7 @@ private void UpdateTimer() {
}
}

private void SetRoundLabel(LevelStats level, LevelType type, string roundName, int setting) {
private void SetRoundLabel(Image roundIcon, LevelType type, string roundName, int setting) {
if (Stats.IsQueued && (setting == 1 || setting == 5)) {
this.lblRound.LevelColor = Color.Empty;
this.lblRound.LevelTrueColor = Color.Empty;
Expand All @@ -596,7 +597,7 @@ private void SetRoundLabel(LevelStats level, LevelType type, string roundName, i
this.lblRound.Text = $@"{Multilingual.GetWord("overlay_round_abbreviation_prefix")}{roundNum}{Multilingual.GetWord("overlay_round_abbreviation_suffix")} :";
this.lblRound.LevelColor = type == LevelType.Unknown ? type.LevelBackColor(false, false, 159) : (this.lastRound.UseShareCode ? type.LevelBackColor(false, this.lastRound.IsTeam, 159) : type.LevelBackColor(this.lastRound.IsFinal, this.lastRound.IsTeam, 223));
this.lblRound.LevelTrueColor = type == LevelType.Unknown ? type.LevelBackColor(false, false, 159) : type.LevelBackColor(false, this.lastRound.IsTeam, 159);
this.lblRound.RoundIcon = type == LevelType.Unknown ? Properties.Resources.round_unknown_icon : level.RoundBigIcon;
this.lblRound.RoundIcon = roundIcon;
if (this.lblRound.RoundIcon.Height != 23) {
float ratio = 23f / this.lblRound.RoundIcon.Height;
this.lblRound.ImageHeight = 23;
Expand Down Expand Up @@ -866,12 +867,17 @@ private void SetDurationLabel(LevelStats level, LevelType type, DateTime current
this.lblDuration.TickProgress = 0;
string showId = this.StatsForm.GetAlternateShowId(this.lastRound.ShowNameId);
int showType = (level == null) ? 0
: ((string.Equals(showId, "main_show") || string.Equals(showId, "invisibeans_mode") || level.IsCreative) && level.TimeLimitSeconds > 0) ? 1
: ((string.Equals(showId, "squads_2player_template") || string.Equals(showId, "squads_4player")) && level.TimeLimitSecondsForSquad > 0) ? 2 : 0;
int timeLimit = this.lastRound.IsCasualShow ? (type == LevelType.CreativeSurvival ? 180 : 0)
: (string.Equals(this.lastRound.ShowNameId, "no_elimination_explore") && level.TimeLimitSecondsForExploreClassic > 0) ? 3
: ((string.Equals(showId, "squads_2player_template") || string.Equals(showId, "squads_4player")) && level.TimeLimitSecondsForSquad > 0) ? 2
: ((string.Equals(showId, "main_show") || string.Equals(showId, "invisibeans_mode") || level.IsCreative) && level.TimeLimitSeconds > 0) ? 1 : 0;
int timeLimit = this.lastRound.IsCasualShow ? ((showType == 3) ? level.TimeLimitSecondsForExploreClassic : (type == LevelType.CreativeSurvival ? 180 : 0))
: this.lastRound.UseShareCode ? this.lastRound.CreativeTimeLimitSeconds
: (showType == 1) ? level.TimeLimitSeconds
: (showType == 2) ? level.TimeLimitSecondsForSquad : 0;
: (showType == 2) ? level.TimeLimitSecondsForSquad
: (showType == 1) ? level.TimeLimitSeconds : 0;

if (level != null && string.Equals(level.Id, "round_hoops") && string.Equals(showId, "squads_4player")) {
timeLimit = 300; // PLEASE FIX THE TIMER MEDIATONIC!!!
}

this.lblDuration.Text = timeLimit > 0 ? $"{Multilingual.GetWord("overlay_duration")} ({TimeSpan.FromSeconds(timeLimit):m\\:ss}) :" : $"{Multilingual.GetWord("overlay_duration")} :";

Expand Down Expand Up @@ -1022,6 +1028,7 @@ private void UpdateInfo() {

this.levelType = (this.levelStats?.Type).GetValueOrDefault(LevelType.Unknown);
this.recordType = (this.levelStats?.BestRecordType).GetValueOrDefault(BestRecordType.Fastest);
this.roundIcon = this.levelType != LevelType.Unknown ? this.levelStats.RoundBigIcon : Properties.Resources.round_unknown_big_icon;
this.levelSummary = this.StatsForm.GetLevelInfo(this.levelId, this.levelType, this.recordType, this.lastRound.UseShareCode);
}

Expand All @@ -1030,7 +1037,7 @@ private void UpdateInfo() {
this.SetWinsLabel(this.levelSummary, overlaySetting);
this.SetFinalsLabel(this.levelSummary, overlaySetting);
this.SetStreakLabel(this.levelSummary, overlaySetting);
this.SetRoundLabel(this.levelStats, this.levelType, this.levelName, overlaySetting);
this.SetRoundLabel(this.roundIcon, this.levelType, this.levelName, overlaySetting);
this.SetQualifyChanceLabel(this.levelSummary, overlaySetting);
this.SetFastestLabel(this.levelSummary, this.recordType, overlaySetting);
this.SetPlayersLabel(overlaySetting);
Expand Down
10 changes: 5 additions & 5 deletions Views/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ private void GenerateLevelStats() {
foreach (var level in this.UpcomingShowCache) {
if (!LevelStats.ALL.ContainsKey(level.LevelId)) {
LevelStats.ALL.Add(level.LevelId, new LevelStats(level.LevelId, level.ShareCode, level.DisplayName, level.LevelType, level.BestRecordType, level.IsCreative, level.IsFinal,
10, 0, 0, Properties.Resources.round_gauntlet_icon, Properties.Resources.round_gauntlet_big_icon));
10, 0, 0, 0, Properties.Resources.round_gauntlet_icon, Properties.Resources.round_gauntlet_big_icon));
}
}
}
Expand Down Expand Up @@ -4218,7 +4218,7 @@ private void LogFile_OnParsedLogLines(List<RoundInfo> round) {
roundName = roundName.StartsWith("round_") ? roundName.Substring(6).Replace('_', ' ')
: roundName.Replace('_', ' ');

LevelStats newLevel = new LevelStats(stat.Name, string.Empty, this.textInfo.ToTitleCase(roundName), LevelType.Unknown, BestRecordType.Fastest, false, false, 0, 0, 0, Properties.Resources.round_unknown_icon, Properties.Resources.round_unknown_big_icon);
LevelStats newLevel = new LevelStats(stat.Name, string.Empty, this.textInfo.ToTitleCase(roundName), LevelType.Unknown, BestRecordType.Fastest, false, false, 10, 0, 0, 0, Properties.Resources.round_unknown_icon, Properties.Resources.round_unknown_big_icon);
this.StatLookup.Add(stat.Name, newLevel);
this.StatDetails.Add(newLevel);
this.gridDetails.DataSource = null;
Expand Down Expand Up @@ -4630,14 +4630,14 @@ public string GetAlternateShowId(string showId) {
}

public string ReplaceLevelIdInShuffleShow(string showId, string roundId) {
if (string.Equals("no_elimination_show", showId) && (roundId.StartsWith("wle_main_filler_") || roundId.StartsWith("wle_main_opener_"))) {
if (string.Equals(showId, "no_elimination_show") && (roundId.StartsWith("wle_main_filler_") || roundId.StartsWith("wle_main_opener_"))) {
roundId = roundId.Replace("_noelim", "");
}
return roundId;
}

private bool IsCreativeShow(string showId) {
return showId.StartsWith("casual_show")
return string.Equals(showId, "casual_show")
|| showId.StartsWith("event_wle_")
|| showId.StartsWith("show_wle")
|| showId.StartsWith("wle_")
Expand Down Expand Up @@ -4817,7 +4817,7 @@ public StatSummary GetLevelInfo(string levelId, LevelType type, BestRecordType r

int lastShow = -1;
if (!this.StatLookup.TryGetValue(useShareCode ? type.UserCreativeLevelTypeId() : levelId, out LevelStats currentLevel)) {
currentLevel = new LevelStats(levelId, string.Empty, levelId, LevelType.Unknown, BestRecordType.Fastest, false, false, 0, 0, 0, Properties.Resources.round_unknown_icon, Properties.Resources.round_unknown_big_icon);
currentLevel = new LevelStats(levelId, string.Empty, levelId, LevelType.Unknown, BestRecordType.Fastest, false, false, 10, 0, 0, 0, Properties.Resources.round_unknown_icon, Properties.Resources.round_unknown_big_icon);
}

List<RoundInfo> roundInfo = useShareCode ? this.AllStats.FindAll(r => r.Profile == this.GetCurrentProfileId() && string.Equals(r.Name, levelId) && string.Equals(r.ShowNameId, type.UserCreativeLevelTypeId()))
Expand Down

0 comments on commit 61f4ad8

Please sign in to comment.