diff --git a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs new file mode 100644 index 0000000000..b34e54b301 --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs @@ -0,0 +1,50 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Framework.Bindables; +using osu.Game.Screens.Select.Leaderboards; +using osu.Framework.Graphics.Sprites; + +namespace osu.Game.Overlays.BeatmapSet.Scores +{ + public class NoScoresPlaceholder : Container + { + public readonly Bindable Scope = new Bindable(); + + private readonly SpriteText text; + + public NoScoresPlaceholder() + { + AutoSizeAxes = Axes.Both; + Child = text = new SpriteText + { + Font = OsuFont.GetFont(), + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Scope.BindValueChanged(scope => text.Text = getText(scope.NewValue), true); + } + + private string getText(BeatmapLeaderboardScope scope) + { + switch (scope) + { + default: + case BeatmapLeaderboardScope.Global: + return @"No scores yet. Maybe should try setting some?"; + + case BeatmapLeaderboardScope.Friend: + return @"None of your friends has set a score on this map yet!"; + + case BeatmapLeaderboardScope.Country: + return @"No one from your country has set a score on this map yet!"; + } + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index bc5daa39a0..62ec9ca609 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -35,6 +35,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly LoadingAnimation loadingAnimation; private readonly FillFlowContainer modFilter; private readonly LeaderboardModSelector modSelector; + private readonly NoScoresPlaceholder noScoresPlaceholder; [Resolved] private IAPIProvider api { get; set; } @@ -125,6 +126,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(0, spacing), Children = new Drawable[] { + noScoresPlaceholder = new NoScoresPlaceholder + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Alpha = 0, + Scope = { BindTarget = scope } + }, topScoresContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -204,6 +212,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Scores = null; + noScoresPlaceholder.Hide(); + updateModFilterVisibility(); if (hasNoLeaderboard) @@ -215,6 +225,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { loadingAnimation.Hide(); Scores = scores; + + if (!scores.Scores.Any()) + noScoresPlaceholder.Show(); }; api.Queue(getScoresRequest); }