diff --git a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs index 3efd7f4099..b94f9df70c 100644 --- a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs +++ b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs @@ -37,16 +37,16 @@ namespace osu.Game.Screens.Select.Leaderboards scrollFlow.Clear(); i = 0; - foreach(var s in scores) + foreach (var s in scores) { - var ls = new LeaderboardScore(s, 1 + i++) + var ls = new LeaderboardScore(s, 1 + i) { AlwaysPresent = true, State = Visibility.Hidden, }; scrollFlow.Add(ls); - ls.Delay((i - 1) * 50, true); + ls.Delay(i++ * 50, true); ls.Show(); } @@ -54,23 +54,6 @@ namespace osu.Game.Screens.Select.Leaderboards } } - protected override void Update() - { - base.Update(); - - var fadeStart = scrollContainer.DrawHeight - 10; - fadeStart += scrollContainer.IsScrolledToEnd() ? 70 : 0; - - foreach (var s in scrollFlow.Children) - { - var topY = scrollContainer.ScrollContent.DrawPosition.Y + s.DrawPosition.Y; - var bottomY = topY + 70; - - s.ColourInfo = ColourInfo.GradientVertical(Color4.White.Opacity(System.Math.Min((fadeStart - topY) / 70, 1)), - Color4.White.Opacity(System.Math.Min((fadeStart - bottomY) / 70, 1))); - } - } - public Leaderboard() { Children = new Drawable[] @@ -92,5 +75,22 @@ namespace osu.Game.Screens.Select.Leaderboards }, }; } + + protected override void Update() + { + base.Update(); + + var fadeStart = scrollContainer.DrawHeight - 10; + fadeStart += scrollContainer.IsScrolledToEnd() ? 70 : 0; + + foreach (var s in scrollFlow.Children) + { + var topY = scrollContainer.ScrollContent.DrawPosition.Y + s.DrawPosition.Y; + var bottomY = topY + 70; + + s.ColourInfo = ColourInfo.GradientVertical(Color4.White.Opacity(System.Math.Min((fadeStart - topY) / 70, 1)), + Color4.White.Opacity(System.Math.Min((fadeStart - bottomY) / 70, 1))); + } + } } } diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index 2ed5de9ab4..c9788c6361 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Select.Leaderboards private Container flagBadgeContainer; private FillFlowContainer modsContainer; - public readonly int Index; + public readonly int Rank; public readonly Score Score; private Visibility state; @@ -112,10 +112,10 @@ namespace osu.Game.Screens.Select.Leaderboards base.OnHoverLost(state); } - public LeaderboardScore(Score score, int i) + public LeaderboardScore(Score score, int rank) { Score = score; - Index = i; + Rank = rank; RelativeSizeAxes = Axes.X; Height = height; @@ -124,6 +124,8 @@ namespace osu.Game.Screens.Select.Leaderboards flag.Width = 30; flag.RelativeSizeAxes = Axes.Y; + const float rank_width = 30; + Children = new Drawable[] { new Container @@ -138,7 +140,7 @@ namespace osu.Game.Screens.Select.Leaderboards Origin = Anchor.CentreLeft, Font = @"Exo2.0-MediumItalic", TextSize = 22, - Text = Index.ToString(), + Text = Rank.ToString(), }, }, }, diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 841f8eda7f..c5c8543e6b 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -58,20 +58,21 @@ namespace osu.Game.Screens.Select { beatmap?.Mods.BindTo(modSelect.SelectedMods); + updateLeaderboard(beatmap); + + base.OnBeatmapChanged(beatmap); + } + + private void updateLeaderboard(WorkingBeatmap beatmap) + { leaderboard.Scores = null; getScoresRequest?.Cancel(); - if (beatmap != null) - { - getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo); - getScoresRequest.Success += res => - { - leaderboard.Scores = res.Scores; - }; - Game.API.Queue(getScoresRequest); - } + if (beatmap?.BeatmapInfo == null) return; - base.OnBeatmapChanged(beatmap); + getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo); + getScoresRequest.Success += r => leaderboard.Scores = r.Scores; + Game.API.Queue(getScoresRequest); } protected override void OnResuming(Screen last)