/// <summary> /// Loads scores for the current map. /// /// This needs to be reworked heavily. I don't like this entire system of cancelling /// the token everywhere....................................... /// /// Lord help me. /// </summary> private Task InitiateScoreLoad(CancellationToken cancellationToken = default) => Task.Run(async() => { var section = Sections[ConfigManager.LeaderboardSection.Value]; cancellationToken.ThrowIfCancellationRequested(); section.IsFetching = true; NoScoresAvailableText.Visible = false; Donator.Visible = false; cancellationToken.ThrowIfCancellationRequested(); // Scroll to the top of the container and reset the height of the container // (removes the scroll wheel) section.ScrollTo(0, 1); section.ContentContainer.Height = section.Height; try { section.ClearScores(); cancellationToken.ThrowIfCancellationRequested(); await Task.Delay(400, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); var map = MapManager.Selected.Value; map.ClearScores(); var scores = section.FetchScores(); if (OnlineManager.CurrentGame == null) { map.Scores.Value = scores.Scores; } cancellationToken.ThrowIfCancellationRequested(); section.IsFetching = false; cancellationToken.ThrowIfCancellationRequested(); if (scores.Scores.Count == 0 && scores.PersonalBest == null) { NoScoresAvailableText.Text = section.GetNoScoresAvailableString(map); NoScoresAvailableText.Alpha = 0; NoScoresAvailableText.Visible = true; Donator.Alpha = 0; if (!OnlineManager.IsDonator && ConfigManager.LeaderboardSection.Value != LeaderboardType.Local) { Donator.Visible = true; NoScoresAvailableText.Y = -15; Donator.Y = NoScoresAvailableText.Y + NoScoresAvailableText.Height + 15; } else { NoScoresAvailableText.Y = 0; } Donator.ClearAnimations(); Donator.FadeTo(1, Easing.Linear, 150); NoScoresAvailableText.ClearAnimations(); NoScoresAvailableText.Animations.Add(new Animation(AnimationProperty.Alpha, Easing.Linear, 0, 1, 150)); } else { NoScoresAvailableText.Visible = false; Donator.Visible = false; } cancellationToken.ThrowIfCancellationRequested(); section.UpdateWithScores(map, scores, cancellationToken); } catch (Exception e) { section.IsFetching = true; NoScoresAvailableText.Visible = false; Donator.Visible = false; } });