Fix beatmap background being disposed too early

Causes weird transitions on the music controller
This commit is contained in:
Dean Herbert 2017-08-25 13:04:32 +09:00
parent cf251b70c7
commit 67b3cbce2f
2 changed files with 8 additions and 12 deletions

View File

@ -152,14 +152,10 @@ private void load()
Beatmap.ValueChanged += b =>
{
// compare to last baetmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
// compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
if (lastBeatmap?.Track != b.Track)
{
// this disposal is done to stop the audio track.
// it may not be exactly what we want for cases beatmaps are reused, as it will
// trigger a fresh load of contained resources.
lastBeatmap?.Dispose();
lastBeatmap?.Track?.Dispose();
Audio.Track.AddItem(b.Track);
}

View File

@ -348,23 +348,23 @@ private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
playerContainer.Add(new AsyncLoadWrapper(new Background(beatmap)
{
OnLoadComplete = d =>
OnLoadComplete = newBackground =>
{
switch (direction)
{
case TransformDirection.Next:
d.Position = new Vector2(400, 0);
d.MoveToX(0, 500, Easing.OutCubic);
newBackground.Position = new Vector2(400, 0);
newBackground.MoveToX(0, 500, Easing.OutCubic);
currentBackground.MoveToX(-400, 500, Easing.OutCubic);
break;
case TransformDirection.Prev:
d.Position = new Vector2(-400, 0);
d.MoveToX(0, 500, Easing.OutCubic);
newBackground.Position = new Vector2(-400, 0);
newBackground.MoveToX(0, 500, Easing.OutCubic);
currentBackground.MoveToX(400, 500, Easing.OutCubic);
break;
}
currentBackground.Expire();
currentBackground = d;
currentBackground = newBackground;
}
})
{