mirror of https://github.com/ppy/osu
Revert 'Fix any and all migration attempts dying on MusicController'
This reverts commit 310eec69fc
.
Way to try and "fix" stuff and screw stuff up even harder instead, me.
Great job, well done.
This commit is contained in:
parent
270c4c4f12
commit
081d87fe6d
|
@ -1137,6 +1137,7 @@ protected override void LoadComplete()
|
||||||
loadComponentSingleFile(new MedalOverlay(), topMostOverlayContent.Add);
|
loadComponentSingleFile(new MedalOverlay(), topMostOverlayContent.Add);
|
||||||
|
|
||||||
loadComponentSingleFile(new BackgroundDataStoreProcessor(), Add);
|
loadComponentSingleFile(new BackgroundDataStoreProcessor(), Add);
|
||||||
|
loadComponentSingleFile(new DetachedBeatmapStore(), Add, true);
|
||||||
|
|
||||||
Add(difficultyRecommender);
|
Add(difficultyRecommender);
|
||||||
Add(externalLinkOpener = new ExternalLinkOpener());
|
Add(externalLinkOpener = new ExternalLinkOpener());
|
||||||
|
|
|
@ -377,10 +377,6 @@ private void load(ReadableKeyCombinationProvider keyCombinationProvider, Framewo
|
||||||
dependencies.Cache(previewTrackManager = new PreviewTrackManager(BeatmapManager.BeatmapTrackStore));
|
dependencies.Cache(previewTrackManager = new PreviewTrackManager(BeatmapManager.BeatmapTrackStore));
|
||||||
base.Content.Add(previewTrackManager);
|
base.Content.Add(previewTrackManager);
|
||||||
|
|
||||||
var detachedBeatmapStore = new DetachedBeatmapStore();
|
|
||||||
base.Content.Add(detachedBeatmapStore);
|
|
||||||
dependencies.CacheAs(detachedBeatmapStore);
|
|
||||||
|
|
||||||
base.Content.Add(MusicController = new MusicController());
|
base.Content.Add(MusicController = new MusicController());
|
||||||
dependencies.CacheAs(MusicController);
|
dependencies.CacheAs(MusicController);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
|
@ -63,7 +62,8 @@ public partial class MusicController : CompositeDrawable
|
||||||
|
|
||||||
public DrawableTrack CurrentTrack { get; private set; } = new DrawableTrack(new TrackVirtual(1000));
|
public DrawableTrack CurrentTrack { get; private set; } = new DrawableTrack(new TrackVirtual(1000));
|
||||||
|
|
||||||
private IBindableList<BeatmapSetInfo> detachedBeatmaps = null!;
|
[Resolved]
|
||||||
|
private RealmAccess realm { get; set; } = null!;
|
||||||
|
|
||||||
private BindableNumber<double> sampleVolume = null!;
|
private BindableNumber<double> sampleVolume = null!;
|
||||||
|
|
||||||
|
@ -76,15 +76,13 @@ public partial class MusicController : CompositeDrawable
|
||||||
private int randomHistoryDirection;
|
private int randomHistoryDirection;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, OsuConfigManager configManager, DetachedBeatmapStore detachedBeatmapStore, CancellationToken? cancellationToken)
|
private void load(AudioManager audio, OsuConfigManager configManager)
|
||||||
{
|
{
|
||||||
AddInternal(audioDuckFilter = new AudioFilter(audio.TrackMixer));
|
AddInternal(audioDuckFilter = new AudioFilter(audio.TrackMixer));
|
||||||
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, audioDuckVolume);
|
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, audioDuckVolume);
|
||||||
sampleVolume = audio.VolumeSample.GetBoundCopy();
|
sampleVolume = audio.VolumeSample.GetBoundCopy();
|
||||||
|
|
||||||
configManager.BindWith(OsuSetting.RandomSelectAlgorithm, randomSelectAlgorithm);
|
configManager.BindWith(OsuSetting.RandomSelectAlgorithm, randomSelectAlgorithm);
|
||||||
|
|
||||||
detachedBeatmaps = detachedBeatmapStore.GetDetachedBeatmaps(cancellationToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -257,8 +255,8 @@ private PreviousTrackResult prev(bool allowProtectedTracks)
|
||||||
playableSet = getNextRandom(-1, allowProtectedTracks);
|
playableSet = getNextRandom(-1, allowProtectedTracks);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playableSet = getBeatmapSets().TakeWhile(i => !i.Equals(current?.BeatmapSetInfo)).LastOrDefault(s => !s.Protected || allowProtectedTracks)
|
playableSet = getBeatmapSets().AsEnumerable().TakeWhile(i => !i.Equals(current?.BeatmapSetInfo)).LastOrDefault(s => !s.Protected || allowProtectedTracks)
|
||||||
?? getBeatmapSets().LastOrDefault(s => !s.Protected || allowProtectedTracks);
|
?? getBeatmapSets().AsEnumerable().LastOrDefault(s => !s.Protected || allowProtectedTracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playableSet != null)
|
if (playableSet != null)
|
||||||
|
@ -353,10 +351,10 @@ private bool next(bool allowProtectedTracks)
|
||||||
playableSet = getNextRandom(1, allowProtectedTracks);
|
playableSet = getNextRandom(1, allowProtectedTracks);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playableSet = getBeatmapSets().SkipWhile(i => !i.Equals(current?.BeatmapSetInfo))
|
playableSet = getBeatmapSets().AsEnumerable().SkipWhile(i => !i.Equals(current?.BeatmapSetInfo))
|
||||||
.Where(i => !i.Protected || allowProtectedTracks)
|
.Where(i => !i.Protected || allowProtectedTracks)
|
||||||
.ElementAtOrDefault(1)
|
.ElementAtOrDefault(1)
|
||||||
?? getBeatmapSets().FirstOrDefault(i => !i.Protected || allowProtectedTracks);
|
?? getBeatmapSets().AsEnumerable().FirstOrDefault(i => !i.Protected || allowProtectedTracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
var playableBeatmap = playableSet?.Beatmaps.FirstOrDefault();
|
var playableBeatmap = playableSet?.Beatmaps.FirstOrDefault();
|
||||||
|
@ -375,7 +373,7 @@ private bool next(bool allowProtectedTracks)
|
||||||
{
|
{
|
||||||
BeatmapSetInfo result;
|
BeatmapSetInfo result;
|
||||||
|
|
||||||
var possibleSets = getBeatmapSets().Where(s => !s.Protected || allowProtectedTracks).ToArray();
|
var possibleSets = getBeatmapSets().AsEnumerable().Where(s => !s.Protected || allowProtectedTracks).ToArray();
|
||||||
|
|
||||||
if (possibleSets.Length == 0)
|
if (possibleSets.Length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
@ -434,7 +432,7 @@ private void restartTrack()
|
||||||
|
|
||||||
private TrackChangeDirection? queuedDirection;
|
private TrackChangeDirection? queuedDirection;
|
||||||
|
|
||||||
private IEnumerable<BeatmapSetInfo> getBeatmapSets() => detachedBeatmaps.Where(s => !s.DeletePending);
|
private IQueryable<BeatmapSetInfo> getBeatmapSets() => realm.Realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending);
|
||||||
|
|
||||||
private void changeBeatmap(WorkingBeatmap newWorking)
|
private void changeBeatmap(WorkingBeatmap newWorking)
|
||||||
{
|
{
|
||||||
|
@ -461,8 +459,8 @@ private void changeBeatmap(WorkingBeatmap newWorking)
|
||||||
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().TakeWhile(b => !b.Equals(current.BeatmapSetInfo)).Count();
|
int last = getBeatmapSets().AsEnumerable().TakeWhile(b => !b.Equals(current.BeatmapSetInfo)).Count();
|
||||||
int next = getBeatmapSets().TakeWhile(b => !b.Equals(newWorking.BeatmapSetInfo)).Count();
|
int next = getBeatmapSets().AsEnumerable().TakeWhile(b => !b.Equals(newWorking.BeatmapSetInfo)).Count();
|
||||||
|
|
||||||
direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next;
|
direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue