mirror of
https://github.com/osukey/osukey.git
synced 2025-05-03 04:37:30 +09:00
Add placeholder when there are no scores.
This commit is contained in:
parent
fe559f4b62
commit
a58bd72c6e
@ -18,13 +18,18 @@ using osu.Game.Rulesets.Scoring;
|
|||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Leaderboards
|
namespace osu.Game.Screens.Select.Leaderboards
|
||||||
{
|
{
|
||||||
public class Leaderboard : Container
|
public class Leaderboard : Container
|
||||||
{
|
{
|
||||||
|
private const double fade_duration = 200;
|
||||||
|
|
||||||
private readonly ScrollContainer scrollContainer;
|
private readonly ScrollContainer scrollContainer;
|
||||||
private FillFlowContainer<LeaderboardScore> scrollFlow;
|
private FillFlowContainer<LeaderboardScore> scrollFlow;
|
||||||
|
private Container placeholderContainer;
|
||||||
|
|
||||||
public Action<Score> ScoreSelected;
|
public Action<Score> ScoreSelected;
|
||||||
|
|
||||||
@ -40,13 +45,19 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
scores = value;
|
scores = value;
|
||||||
getScoresRequest?.Cancel();
|
getScoresRequest?.Cancel();
|
||||||
|
|
||||||
scrollFlow?.FadeOut(200);
|
placeholderContainer.FadeOut(fade_duration);
|
||||||
scrollFlow?.Expire();
|
scrollFlow?.FadeOut(fade_duration).Expire();
|
||||||
scrollFlow = null;
|
scrollFlow = null;
|
||||||
|
|
||||||
if (scores == null)
|
if (scores == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (scores.Count() == 0)
|
||||||
|
{
|
||||||
|
placeholderContainer.FadeIn(fade_duration);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// schedule because we may not be loaded yet (LoadComponentAsync complains).
|
// schedule because we may not be loaded yet (LoadComponentAsync complains).
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
@ -74,7 +85,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LeaderboardScope scope = LeaderboardScope.Global;
|
private LeaderboardScope scope;
|
||||||
public LeaderboardScope Scope
|
public LeaderboardScope Scope
|
||||||
{
|
{
|
||||||
get { return scope; }
|
get { return scope; }
|
||||||
@ -96,7 +107,36 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ScrollbarVisible = false,
|
ScrollbarVisible = false,
|
||||||
},
|
},
|
||||||
loading = new LoadingAnimation()
|
loading = new LoadingAnimation(),
|
||||||
|
placeholderContainer = new Container
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new SpriteIcon
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.fa_exclamation_circle,
|
||||||
|
Size = new Vector2(26),
|
||||||
|
Margin = new MarginPadding { Right = 10 },
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = @"No records yet!",
|
||||||
|
TextSize = 22,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,14 +173,16 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
{
|
{
|
||||||
if (!IsLoaded) return;
|
if (!IsLoaded) return;
|
||||||
|
|
||||||
|
Scores = null;
|
||||||
|
getScoresRequest?.Cancel();
|
||||||
|
|
||||||
if (Scope == LeaderboardScope.Local)
|
if (Scope == LeaderboardScope.Local)
|
||||||
{
|
{
|
||||||
// TODO: get local scores from wherever here.
|
// TODO: get local scores from wherever here.
|
||||||
|
Scores = Enumerable.Empty<Score>();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scores = null;
|
|
||||||
getScoresRequest?.Cancel();
|
|
||||||
|
|
||||||
if (api == null || Beatmap?.OnlineBeatmapID == null) return;
|
if (api == null || Beatmap?.OnlineBeatmapID == null) return;
|
||||||
|
|
||||||
loading.Show();
|
loading.Show();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user