mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:02:55 +08:00
Hide background sprite when storyboard finishes loading
This commit is contained in:
parent
e947158969
commit
59998b507a
@ -58,20 +58,20 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
if (!Beatmap.Storyboard.HasDrawable)
|
||||
return;
|
||||
|
||||
if (Beatmap.Storyboard.ReplacesBackground)
|
||||
Sprite.Alpha = 0;
|
||||
|
||||
LoadComponentAsync(drawableStoryboard = new DrawableStoryboard(Beatmap.Storyboard, mods.Value)
|
||||
{
|
||||
Clock = storyboardClock
|
||||
}, s =>
|
||||
{
|
||||
if (Beatmap.Storyboard.ReplacesBackground)
|
||||
Sprite.FadeOut(BackgroundScreen.TRANSITION_LENGTH, Easing.InQuint);
|
||||
|
||||
storyboardContainer.FadeInFromZero(BackgroundScreen.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
storyboardContainer.Add(s);
|
||||
}, (loadCancellationSource = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
public void UnloadStoryboard(Action<DrawableStoryboard> scheduleStoryboardRemoval)
|
||||
public void UnloadStoryboard(Action<Action> scheduleStoryboardRemoval)
|
||||
{
|
||||
if (drawableStoryboard == null)
|
||||
return;
|
||||
@ -79,7 +79,13 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
loadCancellationSource.AsNonNull().Cancel();
|
||||
loadCancellationSource = null;
|
||||
|
||||
scheduleStoryboardRemoval(drawableStoryboard);
|
||||
DrawableStoryboard s = drawableStoryboard;
|
||||
|
||||
scheduleStoryboardRemoval(() =>
|
||||
{
|
||||
s.RemoveAndDisposeImmediately();
|
||||
Sprite.Alpha = 1f;
|
||||
});
|
||||
|
||||
drawableStoryboard = null;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
|
||||
namespace osu.Game.Screens
|
||||
{
|
||||
@ -35,6 +35,6 @@ namespace osu.Game.Screens
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ScheduleStoryboardDisposal(DrawableStoryboard storyboard) => Scheduler.AddDelayed(storyboard.RemoveAndDisposeImmediately, BackgroundScreen.TRANSITION_LENGTH);
|
||||
internal void ScheduleToTransitionEnd(Action action) => Scheduler.AddDelayed(action, BackgroundScreen.TRANSITION_LENGTH);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
Debug.Assert(backgroundScreenStack != null);
|
||||
|
||||
if (background is BeatmapBackgroundWithStoryboard storyboardBackground)
|
||||
storyboardBackground.UnloadStoryboard(backgroundScreenStack.ScheduleStoryboardDisposal);
|
||||
storyboardBackground.UnloadStoryboard(backgroundScreenStack.ScheduleToTransitionEnd);
|
||||
|
||||
base.OnSuspending(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user