mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 20:03:21 +08:00
Fix music playlist being enumerated asynchronously
This commit is contained in:
parent
6fd5667ff4
commit
5ca93758dc
@ -75,8 +75,6 @@ namespace osu.Game.Overlays.Music
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
list.Items.BindTo(beatmapSets);
|
|
||||||
|
|
||||||
filter.Search.OnCommit = (sender, newText) =>
|
filter.Search.OnCommit = (sender, newText) =>
|
||||||
{
|
{
|
||||||
BeatmapInfo toSelect = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault();
|
BeatmapInfo toSelect = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault();
|
||||||
@ -87,7 +85,13 @@ namespace osu.Game.Overlays.Music
|
|||||||
beatmap.Value.Track.Restart();
|
beatmap.Value.Track.Restart();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
list.Items.BindTo(beatmapSets);
|
||||||
beatmap.BindValueChanged(working => list.SelectedSet.Value = working.NewValue.BeatmapSetInfo, true);
|
beatmap.BindValueChanged(working => list.SelectedSet.Value = working.NewValue.BeatmapSetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,16 @@ namespace osu.Game.Overlays
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; }
|
||||||
|
|
||||||
public IBindableList<BeatmapSetInfo> BeatmapSets => beatmapSets;
|
public IBindableList<BeatmapSetInfo> BeatmapSets
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (LoadState < LoadState.Ready)
|
||||||
|
throw new InvalidOperationException($"{nameof(BeatmapSets)} should not be accessed before the music controller is loaded.");
|
||||||
|
|
||||||
|
return beatmapSets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Point in time after which the current track will be restarted on triggering a "previous track" action.
|
/// Point in time after which the current track will be restarted on triggering a "previous track" action.
|
||||||
@ -54,16 +63,18 @@ namespace osu.Game.Overlays
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
beatmapSets.AddRange(beatmaps.GetAllUsableBeatmapSets().OrderBy(_ => RNG.Next()));
|
|
||||||
beatmaps.ItemAdded += handleBeatmapAdded;
|
beatmaps.ItemAdded += handleBeatmapAdded;
|
||||||
beatmaps.ItemRemoved += handleBeatmapRemoved;
|
beatmaps.ItemRemoved += handleBeatmapRemoved;
|
||||||
|
|
||||||
|
beatmapSets.AddRange(beatmaps.GetAllUsableBeatmapSets().OrderBy(_ => RNG.Next()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
beatmap.BindValueChanged(beatmapChanged, true);
|
beatmap.BindValueChanged(beatmapChanged, true);
|
||||||
mods.BindValueChanged(_ => ResetTrackAdjustments(), true);
|
mods.BindValueChanged(_ => ResetTrackAdjustments(), true);
|
||||||
base.LoadComplete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -82,11 +93,16 @@ namespace osu.Game.Overlays
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsPlaying => current?.Track.IsRunning ?? false;
|
public bool IsPlaying => current?.Track.IsRunning ?? false;
|
||||||
|
|
||||||
private void handleBeatmapAdded(BeatmapSetInfo set) =>
|
private void handleBeatmapAdded(BeatmapSetInfo set) => Schedule(() =>
|
||||||
Schedule(() => beatmapSets.Add(set));
|
{
|
||||||
|
if (!beatmapSets.Contains(set))
|
||||||
|
beatmapSets.Add(set);
|
||||||
|
});
|
||||||
|
|
||||||
private void handleBeatmapRemoved(BeatmapSetInfo set) =>
|
private void handleBeatmapRemoved(BeatmapSetInfo set) => Schedule(() =>
|
||||||
Schedule(() => beatmapSets.RemoveAll(s => s.ID == set.ID));
|
{
|
||||||
|
beatmapSets.RemoveAll(s => s.ID == set.ID);
|
||||||
|
});
|
||||||
|
|
||||||
private ScheduledDelegate seekDelegate;
|
private ScheduledDelegate seekDelegate;
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ namespace osu.Game.Overlays
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
public NowPlayingOverlay()
|
public NowPlayingOverlay()
|
||||||
{
|
{
|
||||||
Width = 400;
|
Width = 400;
|
||||||
@ -65,7 +68,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load()
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -182,15 +185,15 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
playlist.BeatmapSets.BindTo(musicController.BeatmapSets);
|
|
||||||
playlist.State.ValueChanged += s => playlistButton.FadeColour(s.NewValue == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.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);
|
beatmap.BindDisabledChanged(beatmapDisabledChanged, true);
|
||||||
|
|
||||||
musicController.TrackChanged += trackChanged;
|
musicController.TrackChanged += trackChanged;
|
||||||
|
Loading…
Reference in New Issue
Block a user