1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Improve results screen behaviour when changing selected score

This commit is contained in:
smoogipoo 2020-05-28 21:40:01 +09:00
parent ad99d85468
commit 47d5974f04
3 changed files with 21 additions and 12 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
@ -13,6 +14,8 @@ namespace osu.Game.Screens.Ranking
{
public class ReplayDownloadButton : DownloadTrackingComposite<ScoreInfo, ScoreManager>
{
public Bindable<ScoreInfo> Score => Model;
private DownloadButton button;
private ShakeContainer shakeContainer;

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -30,16 +31,17 @@ namespace osu.Game.Screens.Ranking
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
public readonly Bindable<ScoreInfo> SelectedScore = new Bindable<ScoreInfo>();
public readonly ScoreInfo Score;
private readonly bool allowRetry;
[Resolved(CanBeNull = true)]
private Player player { get; set; }
[Resolved]
private IAPIProvider api { get; set; }
public readonly ScoreInfo Score;
private readonly bool allowRetry;
private Drawable bottomPanel;
private ScorePanelList panels;
@ -47,6 +49,8 @@ namespace osu.Game.Screens.Ranking
{
Score = score;
this.allowRetry = allowRetry;
SelectedScore.Value = score;
}
[BackgroundDependencyLoader]
@ -66,7 +70,7 @@ namespace osu.Game.Screens.Ranking
Child = panels = new ScorePanelList
{
RelativeSizeAxes = Axes.Both,
SelectedScore = { Value = Score }
SelectedScore = { BindTarget = SelectedScore }
}
}
},
@ -95,7 +99,11 @@ namespace osu.Game.Screens.Ranking
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new ReplayDownloadButton(Score) { Width = 300 },
new ReplayDownloadButton(null)
{
Score = { BindTarget = SelectedScore },
Width = 300
},
}
}
}
@ -109,6 +117,9 @@ namespace osu.Game.Screens.Ranking
}
};
if (Score != null)
panels.AddScore(Score);
if (player != null && allowRetry)
{
buttons.Add(new RetryButton { Width = 300 });
@ -132,12 +143,7 @@ namespace osu.Game.Screens.Ranking
var req = FetchScores(scores => Schedule(() =>
{
foreach (var s in scores)
{
if (s.OnlineScoreID == Score.OnlineScoreID)
continue;
panels.AddScore(s);
}
}));
if (req != null)

View File

@ -25,7 +25,7 @@ namespace osu.Game.Screens.Ranking
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
{
var req = new GetScoresRequest(Score.Beatmap, Score.Ruleset);
req.Success += r => scoresCallback?.Invoke(r.Scores.Select(s => s.CreateScoreInfo(rulesets)));
req.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => s.OnlineScoreID != Score.OnlineScoreID).Select(s => s.CreateScoreInfo(rulesets)));
return req;
}
}