mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 15:17:44 +08:00
Migrate MusicController
to Live<T>
to fix broken migrations instead
This commit is contained in:
parent
081d87fe6d
commit
baa64d1486
@ -72,7 +72,7 @@ namespace osu.Game.Overlays
|
|||||||
private AudioFilter audioDuckFilter = null!;
|
private AudioFilter audioDuckFilter = null!;
|
||||||
|
|
||||||
private readonly Bindable<RandomSelectAlgorithm> randomSelectAlgorithm = new Bindable<RandomSelectAlgorithm>();
|
private readonly Bindable<RandomSelectAlgorithm> randomSelectAlgorithm = new Bindable<RandomSelectAlgorithm>();
|
||||||
private readonly List<BeatmapSetInfo> previousRandomSets = new List<BeatmapSetInfo>();
|
private readonly List<Live<BeatmapSetInfo>> previousRandomSets = new List<Live<BeatmapSetInfo>>();
|
||||||
private int randomHistoryDirection;
|
private int randomHistoryDirection;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -249,19 +249,19 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
queuedDirection = TrackChangeDirection.Prev;
|
queuedDirection = TrackChangeDirection.Prev;
|
||||||
|
|
||||||
BeatmapSetInfo? playableSet;
|
Live<BeatmapSetInfo>? playableSet;
|
||||||
|
|
||||||
if (Shuffle.Value)
|
if (Shuffle.Value)
|
||||||
playableSet = getNextRandom(-1, allowProtectedTracks);
|
playableSet = getNextRandom(-1, allowProtectedTracks);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playableSet = getBeatmapSets().AsEnumerable().TakeWhile(i => !i.Equals(current?.BeatmapSetInfo)).LastOrDefault(s => !s.Protected || allowProtectedTracks)
|
playableSet = getBeatmapSets().TakeWhile(i => !i.Value.Equals(current?.BeatmapSetInfo)).LastOrDefault(s => !s.Value.Protected || allowProtectedTracks)
|
||||||
?? getBeatmapSets().AsEnumerable().LastOrDefault(s => !s.Protected || allowProtectedTracks);
|
?? getBeatmapSets().LastOrDefault(s => !s.Value.Protected || allowProtectedTracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playableSet != null)
|
if (playableSet != null)
|
||||||
{
|
{
|
||||||
changeBeatmap(beatmaps.GetWorkingBeatmap(playableSet.Beatmaps.First()));
|
changeBeatmap(beatmaps.GetWorkingBeatmap(playableSet.Value.Beatmaps.First()));
|
||||||
restartTrack();
|
restartTrack();
|
||||||
return PreviousTrackResult.Previous;
|
return PreviousTrackResult.Previous;
|
||||||
}
|
}
|
||||||
@ -345,19 +345,19 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
queuedDirection = TrackChangeDirection.Next;
|
queuedDirection = TrackChangeDirection.Next;
|
||||||
|
|
||||||
BeatmapSetInfo? playableSet;
|
Live<BeatmapSetInfo>? playableSet;
|
||||||
|
|
||||||
if (Shuffle.Value)
|
if (Shuffle.Value)
|
||||||
playableSet = getNextRandom(1, allowProtectedTracks);
|
playableSet = getNextRandom(1, allowProtectedTracks);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playableSet = getBeatmapSets().AsEnumerable().SkipWhile(i => !i.Equals(current?.BeatmapSetInfo))
|
playableSet = getBeatmapSets().SkipWhile(i => !i.Value.Equals(current?.BeatmapSetInfo))
|
||||||
.Where(i => !i.Protected || allowProtectedTracks)
|
.Where(i => !i.Value.Protected || allowProtectedTracks)
|
||||||
.ElementAtOrDefault(1)
|
.ElementAtOrDefault(1)
|
||||||
?? getBeatmapSets().AsEnumerable().FirstOrDefault(i => !i.Protected || allowProtectedTracks);
|
?? getBeatmapSets().FirstOrDefault(i => !i.Value.Protected || allowProtectedTracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
var playableBeatmap = playableSet?.Beatmaps.FirstOrDefault();
|
var playableBeatmap = playableSet?.Value.Beatmaps.FirstOrDefault();
|
||||||
|
|
||||||
if (playableBeatmap != null)
|
if (playableBeatmap != null)
|
||||||
{
|
{
|
||||||
@ -369,11 +369,11 @@ namespace osu.Game.Overlays
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BeatmapSetInfo? getNextRandom(int direction, bool allowProtectedTracks)
|
private Live<BeatmapSetInfo>? getNextRandom(int direction, bool allowProtectedTracks)
|
||||||
{
|
{
|
||||||
BeatmapSetInfo result;
|
Live<BeatmapSetInfo> result;
|
||||||
|
|
||||||
var possibleSets = getBeatmapSets().AsEnumerable().Where(s => !s.Protected || allowProtectedTracks).ToArray();
|
var possibleSets = getBeatmapSets().Where(s => !s.Value.Protected || allowProtectedTracks).ToArray();
|
||||||
|
|
||||||
if (possibleSets.Length == 0)
|
if (possibleSets.Length == 0)
|
||||||
return null;
|
return null;
|
||||||
@ -432,7 +432,9 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private TrackChangeDirection? queuedDirection;
|
private TrackChangeDirection? queuedDirection;
|
||||||
|
|
||||||
private IQueryable<BeatmapSetInfo> getBeatmapSets() => realm.Realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending);
|
private IEnumerable<Live<BeatmapSetInfo>> getBeatmapSets() => realm.Realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending)
|
||||||
|
.AsEnumerable()
|
||||||
|
.Select(s => new RealmLive<BeatmapSetInfo>(s, realm));
|
||||||
|
|
||||||
private void changeBeatmap(WorkingBeatmap newWorking)
|
private void changeBeatmap(WorkingBeatmap newWorking)
|
||||||
{
|
{
|
||||||
@ -459,8 +461,8 @@ namespace osu.Game.Overlays
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// figure out the best direction based on order in playlist.
|
// figure out the best direction based on order in playlist.
|
||||||
int last = getBeatmapSets().AsEnumerable().TakeWhile(b => !b.Equals(current.BeatmapSetInfo)).Count();
|
int last = getBeatmapSets().TakeWhile(b => !b.Value.Equals(current.BeatmapSetInfo)).Count();
|
||||||
int next = getBeatmapSets().AsEnumerable().TakeWhile(b => !b.Equals(newWorking.BeatmapSetInfo)).Count();
|
int next = getBeatmapSets().TakeWhile(b => !b.Value.Equals(newWorking.BeatmapSetInfo)).Count();
|
||||||
|
|
||||||
direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next;
|
direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user