mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:47:52 +08:00
Better handle the passing of Beatmap and updating of scores.
PresentScores was dangerous as it could potentially bring up unsafe threading scenarios. This ensures everything will work well in all cases.
This commit is contained in:
parent
a561611125
commit
3ae7d0cb98
@ -21,10 +21,18 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private OsuGame game;
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuGame game)
|
||||
private WorkingBeatmap beatmap;
|
||||
public WorkingBeatmap Beatmap
|
||||
{
|
||||
this.game = game;
|
||||
get
|
||||
{
|
||||
return beatmap;
|
||||
}
|
||||
set
|
||||
{
|
||||
beatmap = value;
|
||||
if (IsLoaded) Schedule(updateScores);
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapDetailArea()
|
||||
@ -47,6 +55,9 @@ namespace osu.Game.Screens.Select
|
||||
Leaderboard.Show();
|
||||
break;
|
||||
}
|
||||
|
||||
//for now let's always update scores.
|
||||
updateScores();
|
||||
},
|
||||
},
|
||||
content = new Container
|
||||
@ -69,15 +80,27 @@ namespace osu.Game.Screens.Select
|
||||
});
|
||||
}
|
||||
|
||||
private GetScoresRequest getScoresRequest;
|
||||
public void PresentScores(WorkingBeatmap beatmap)
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
if (game == null) return;
|
||||
base.LoadComplete();
|
||||
updateScores();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuGame game)
|
||||
{
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
private GetScoresRequest getScoresRequest;
|
||||
private void updateScores()
|
||||
{
|
||||
if (game == null || !IsLoaded) return;
|
||||
|
||||
Leaderboard.Scores = null;
|
||||
getScoresRequest?.Cancel();
|
||||
|
||||
if (beatmap?.BeatmapInfo == null) return;
|
||||
if (beatmap?.BeatmapInfo == null || !Leaderboard.IsPresent) return;
|
||||
|
||||
getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo);
|
||||
getScoresRequest.Success += r => Leaderboard.Scores = r.Scores;
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
beatmap?.Mods.BindTo(modSelect.SelectedMods);
|
||||
|
||||
beatmapDetails.PresentScores(beatmap);
|
||||
beatmapDetails.Beatmap = beatmap;
|
||||
|
||||
base.OnBeatmapChanged(beatmap);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user