mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Ensure all OsuFocusedOverlayContainers contribute to screen fading
This commit is contained in:
@ -110,6 +110,8 @@ namespace osu.Game
|
||||
|
||||
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
||||
|
||||
private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>();
|
||||
|
||||
// todo: move this to SongSelect once Screen has the ability to unsuspend.
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
||||
@ -128,6 +130,23 @@ namespace osu.Game
|
||||
|
||||
public void ToggleDirect() => direct.ToggleVisibility();
|
||||
|
||||
private void updateBlockingOverlayFade() =>
|
||||
screenContainer.FadeColour(visibleBlockingOverlays.Any() ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint);
|
||||
|
||||
public void AddBlockingOverlay(OverlayContainer overlay)
|
||||
{
|
||||
if (!visibleBlockingOverlays.Contains(overlay))
|
||||
visibleBlockingOverlays.Add(overlay);
|
||||
updateBlockingOverlayFade();
|
||||
}
|
||||
|
||||
public void RemoveBlockingOverlay(OverlayContainer overlay)
|
||||
{
|
||||
if (visibleBlockingOverlays.Contains(overlay))
|
||||
visibleBlockingOverlays.Remove(overlay);
|
||||
updateBlockingOverlayFade();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close all game-wide overlays.
|
||||
/// </summary>
|
||||
@ -598,20 +617,10 @@ namespace osu.Game
|
||||
}
|
||||
|
||||
private Task asyncLoadStream;
|
||||
private int visibleOverlayCount;
|
||||
|
||||
private void loadComponentSingleFile<T>(T d, Action<T> add)
|
||||
where T : Drawable
|
||||
{
|
||||
if (d is FocusedOverlayContainer focused)
|
||||
{
|
||||
focused.StateChanged += s =>
|
||||
{
|
||||
visibleOverlayCount += s == Visibility.Visible ? 1 : -1;
|
||||
screenContainer.FadeColour(visibleOverlayCount > 0 ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint);
|
||||
};
|
||||
}
|
||||
|
||||
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
|
||||
// with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile,
|
||||
// we could avoid the need for scheduling altogether.
|
||||
|
Reference in New Issue
Block a user