mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Implement NoScoresPlaceholder
This commit is contained in:
parent
2dbee5da79
commit
4e90daf212
50
osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs
Normal file
50
osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<BeatmapLeaderboardScope> Scope = new Bindable<BeatmapLeaderboardScope>();
|
||||
|
||||
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!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user