mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Improve the loading animation and use it in multiple places
- Supersedes https://github.com/ppy/osu/pull/926. - [ ] Depends on https://github.com/ppy/osu-framework/pull/817.
This commit is contained in:
@ -80,8 +80,8 @@ namespace osu.Game.Screens.Select
|
||||
lookup.Success += res =>
|
||||
{
|
||||
if (beatmap != requestedBeatmap)
|
||||
//the beatmap has been changed since we started the lookup.
|
||||
return;
|
||||
//the beatmap has been changed since we started the lookup.
|
||||
return;
|
||||
|
||||
requestedBeatmap.Metrics = res;
|
||||
Schedule(() => updateMetrics(res));
|
||||
@ -89,6 +89,7 @@ namespace osu.Game.Screens.Select
|
||||
lookup.Failure += e => updateMetrics(null);
|
||||
|
||||
api.Queue(lookup);
|
||||
loading.Show();
|
||||
}
|
||||
|
||||
updateMetrics(requestedBeatmap.Metrics, false);
|
||||
@ -104,6 +105,9 @@ namespace osu.Game.Screens.Select
|
||||
var hasRatings = metrics?.Ratings.Any() ?? false;
|
||||
var hasRetriesFails = (metrics?.Retries.Any() ?? false) && metrics.Fails.Any();
|
||||
|
||||
if (failOnMissing)
|
||||
loading.Hide();
|
||||
|
||||
if (hasRatings)
|
||||
{
|
||||
var ratings = metrics.Ratings.ToList();
|
||||
@ -320,11 +324,13 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
loading = new LoadingAnimation()
|
||||
};
|
||||
}
|
||||
|
||||
private APIAccess api;
|
||||
private readonly LoadingAnimation loading;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colour, APIAccess api)
|
||||
|
@ -12,6 +12,7 @@ using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
@ -25,6 +26,8 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
public Action<Score> ScoreSelected;
|
||||
|
||||
private LoadingAnimation loading;
|
||||
|
||||
private IEnumerable<Score> scores;
|
||||
public IEnumerable<Score> Scores
|
||||
{
|
||||
@ -86,6 +89,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
},
|
||||
},
|
||||
},
|
||||
loading = new LoadingAnimation()
|
||||
};
|
||||
}
|
||||
|
||||
@ -117,6 +121,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
}
|
||||
|
||||
private GetScoresRequest getScoresRequest;
|
||||
|
||||
private void updateScores()
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
@ -126,8 +131,14 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
if (api == null || Beatmap == null) return;
|
||||
|
||||
loading.Show();
|
||||
|
||||
getScoresRequest = new GetScoresRequest(Beatmap);
|
||||
getScoresRequest.Success += r => Scores = r.Scores;
|
||||
getScoresRequest.Success += r =>
|
||||
{
|
||||
Scores = r.Scores;
|
||||
loading.Hide();
|
||||
};
|
||||
api.Queue(getScoresRequest);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user