mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Improve visual display
This commit is contained in:
parent
933314d724
commit
ed17a1c990
@ -4,6 +4,8 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -24,8 +26,6 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
protected override double LoadDelay => 250;
|
|
||||||
|
|
||||||
public TopLocalRank(BeatmapInfo beatmap)
|
public TopLocalRank(BeatmapInfo beatmap)
|
||||||
: base(null)
|
: base(null)
|
||||||
{
|
{
|
||||||
@ -48,20 +48,23 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
fetchAndLoadTopScore();
|
fetchAndLoadTopScore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ScheduledDelegate scheduledRankUpdate;
|
||||||
|
|
||||||
private void fetchAndLoadTopScore()
|
private void fetchAndLoadTopScore()
|
||||||
{
|
{
|
||||||
var rank = fetchTopScore()?.Rank;
|
var rank = fetchTopScore()?.Rank;
|
||||||
|
scheduledRankUpdate = Schedule(() =>
|
||||||
|
{
|
||||||
|
Rank = rank;
|
||||||
|
|
||||||
// toggle the display of this drawable
|
// Required since presence is changed via IsPresent override
|
||||||
// we do not want empty space if there is no rank to be displayed
|
Invalidate(Invalidation.Presence);
|
||||||
if (rank.HasValue)
|
});
|
||||||
Show();
|
|
||||||
else
|
|
||||||
Hide();
|
|
||||||
|
|
||||||
Schedule(() => Rank = rank);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We're present if a rank is set, or if there is a pending rank update (IsPresent = true is required for the scheduler to run).
|
||||||
|
public override bool IsPresent => base.IsPresent && (Rank != null || scheduledRankUpdate?.Completed == false);
|
||||||
|
|
||||||
private ScoreInfo fetchTopScore()
|
private ScoreInfo fetchTopScore()
|
||||||
{
|
{
|
||||||
if (scores == null || beatmap == null || ruleset?.Value == null || api?.LocalUser.Value == null)
|
if (scores == null || beatmap == null || ruleset?.Value == null || api?.LocalUser.Value == null)
|
||||||
|
Loading…
Reference in New Issue
Block a user