mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Add some sanity to request/drawable creation logic
This commit is contained in:
parent
a51e64b2d1
commit
1ae0eff6ad
@ -39,7 +39,6 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
this.type = type;
|
||||
this.includeWeight = includeWeight;
|
||||
this.user.BindTo(user);
|
||||
this.user.ValueChanged += user_ValueChanged;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
@ -87,6 +86,16 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(APIAccess api, RulesetStore rulesets)
|
||||
{
|
||||
this.api = api;
|
||||
this.rulesets = rulesets;
|
||||
|
||||
user.ValueChanged += user_ValueChanged;
|
||||
user.TriggerChange();
|
||||
}
|
||||
|
||||
private void user_ValueChanged(User newUser)
|
||||
{
|
||||
visiblePages = 0;
|
||||
@ -96,13 +105,6 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
showMore();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(APIAccess api, RulesetStore rulesets)
|
||||
{
|
||||
this.api = api;
|
||||
this.rulesets = rulesets;
|
||||
}
|
||||
|
||||
private void showMore()
|
||||
{
|
||||
var req = new GetUserScoresRequest(user.Value.Id, type, visiblePages++ * 5);
|
||||
@ -118,17 +120,29 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
showMoreButton.FadeTo(scores.Count == 5 ? 1 : 0);
|
||||
showMoreLoading.Hide();
|
||||
|
||||
if (scores.Any())
|
||||
{
|
||||
if (!scores.Any()) return;
|
||||
|
||||
missing.Hide();
|
||||
|
||||
foreach (OnlineScore score in scores)
|
||||
{
|
||||
var drawableScore = type == ScoreType.Recent ? (DrawableScore)new DrawableTotalScore(score) : new DrawablePerformanceScore(score, includeWeight ? Math.Pow(0.95, scoreContainer.Count) : (double?)null);
|
||||
DrawableScore drawableScore;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
drawableScore = new DrawablePerformanceScore(score, includeWeight ? Math.Pow(0.95, scoreContainer.Count) : (double?)null);
|
||||
break;
|
||||
case ScoreType.Recent:
|
||||
drawableScore = new DrawableTotalScore(score);
|
||||
break;
|
||||
}
|
||||
|
||||
drawableScore.RelativeSizeAxes = Axes.X;
|
||||
drawableScore.Height = 60;
|
||||
|
||||
scoreContainer.Add(drawableScore);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
api.Queue(req);
|
||||
|
Loading…
Reference in New Issue
Block a user