mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Defer playlist load to improve load time of the now playing overlay
This commit is contained in:
parent
a886000fbf
commit
d8d830db6e
@ -84,11 +84,6 @@ namespace osu.Game.Overlays
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
playlist = new PlaylistOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Y = player_height + 10,
|
||||
},
|
||||
playerContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -171,7 +166,7 @@ namespace osu.Game.Overlays
|
||||
Anchor = Anchor.CentreRight,
|
||||
Position = new Vector2(-bottom_black_area_height / 2, 0),
|
||||
Icon = FontAwesome.Solid.Bars,
|
||||
Action = () => playlist.ToggleVisibility(),
|
||||
Action = togglePlaylist
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -191,13 +186,35 @@ namespace osu.Game.Overlays
|
||||
};
|
||||
}
|
||||
|
||||
private void togglePlaylist()
|
||||
{
|
||||
if (playlist == null)
|
||||
{
|
||||
LoadComponentAsync(playlist = new PlaylistOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Y = player_height + 10,
|
||||
}, _ =>
|
||||
{
|
||||
dragContainer.Add(playlist);
|
||||
|
||||
playlist.BeatmapSets.BindTo(musicController.BeatmapSets);
|
||||
playlist.State.BindValueChanged(s => playlistButton.FadeColour(s.NewValue == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint), true);
|
||||
|
||||
togglePlaylist();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!beatmap.Disabled)
|
||||
playlist.ToggleVisibility();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
playlist.BeatmapSets.BindTo(musicController.BeatmapSets);
|
||||
playlist.State.BindValueChanged(s => playlistButton.FadeColour(s.NewValue == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint), true);
|
||||
|
||||
beatmap.BindDisabledChanged(beatmapDisabledChanged, true);
|
||||
|
||||
musicController.TrackChanged += trackChanged;
|
||||
@ -306,7 +323,7 @@ namespace osu.Game.Overlays
|
||||
private void beatmapDisabledChanged(bool disabled)
|
||||
{
|
||||
if (disabled)
|
||||
playlist.Hide();
|
||||
playlist?.Hide();
|
||||
|
||||
prevButton.Enabled.Value = !disabled;
|
||||
nextButton.Enabled.Value = !disabled;
|
||||
|
Loading…
Reference in New Issue
Block a user