mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 02:22:59 +08:00
Use alternative method of scheduling storyboard unload
This commit is contained in:
parent
96da7a07bb
commit
dbd4f26436
@ -1,12 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Threading;
|
|
||||||
using osu.Game.Screens.Backgrounds;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens
|
namespace osu.Game.Screens
|
||||||
{
|
{
|
||||||
@ -36,20 +33,5 @@ namespace osu.Game.Screens
|
|||||||
base.Push(screen);
|
base.Push(screen);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Schedules a delegate to run after 500ms, the time length of a background screen transition.
|
|
||||||
/// This is used in <see cref="BackgroundScreenDefault"/> to dispose of the storyboard once the background screen is completely off-screen.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Late storyboard disposals cannot be achieved with any local scheduler from <see cref="BackgroundScreenDefault"/> or any component inside it,
|
|
||||||
/// due to the screen becoming dead at the moment the transition finishes. And, on the frame that it is dead on, it will not receive an <see cref="Drawable.UpdateSubTree"/>,
|
|
||||||
/// therefore not guaranteeing to dispose the storyboard at any period of time close to the end of the transition.
|
|
||||||
/// This might require reconsideration framework-side, possibly exposing a "death" event in <see cref="Screen"/> or all <see cref="Drawable"/>s in general.
|
|
||||||
/// </remarks>
|
|
||||||
/// <param name="action">The delegate </param>
|
|
||||||
/// <returns></returns>
|
|
||||||
/// <seealso cref="BackgroundScreen.TRANSITION_LENGTH"/>
|
|
||||||
internal ScheduledDelegate ScheduleUntilTransitionEnd(Action action) => Scheduler.AddDelayed(action, BackgroundScreen.TRANSITION_LENGTH);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -36,6 +37,9 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private GameHost gameHost { get; set; }
|
||||||
|
|
||||||
protected virtual bool AllowStoryboardBackground => true;
|
protected virtual bool AllowStoryboardBackground => true;
|
||||||
|
|
||||||
public BackgroundScreenDefault(bool animateOnEnter = true)
|
public BackgroundScreenDefault(bool animateOnEnter = true)
|
||||||
@ -81,7 +85,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
Debug.Assert(backgroundScreenStack != null);
|
Debug.Assert(backgroundScreenStack != null);
|
||||||
|
|
||||||
if (background is BeatmapBackgroundWithStoryboard storyboardBackground)
|
if (background is BeatmapBackgroundWithStoryboard storyboardBackground)
|
||||||
storyboardUnloadDelegate = backgroundScreenStack.ScheduleUntilTransitionEnd(storyboardBackground.UnloadStoryboard);
|
storyboardUnloadDelegate = gameHost.UpdateThread.Scheduler.AddDelayed(storyboardBackground.UnloadStoryboard, TRANSITION_LENGTH);
|
||||||
|
|
||||||
base.OnSuspending(e);
|
base.OnSuspending(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user