mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Fix new mod select overlay dimming itself
This commit is contained in:
@ -127,14 +127,14 @@ namespace osu.Game.Graphics.Containers
|
|||||||
if (didChange)
|
if (didChange)
|
||||||
samplePopIn?.Play();
|
samplePopIn?.Play();
|
||||||
|
|
||||||
if (BlockScreenWideMouse && DimMainContent) game?.AddBlockingOverlay(this);
|
if (BlockScreenWideMouse && DimMainContent) game?.ShowBlockingOverlay(this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Visibility.Hidden:
|
case Visibility.Hidden:
|
||||||
if (didChange)
|
if (didChange)
|
||||||
samplePopOut?.Play();
|
samplePopOut?.Play();
|
||||||
|
|
||||||
if (BlockScreenWideMouse) game?.RemoveBlockingOverlay(this);
|
if (BlockScreenWideMouse) game?.HideBlockingOverlay(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
game?.RemoveBlockingOverlay(this);
|
game?.HideBlockingOverlay(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,7 @@ namespace osu.Game
|
|||||||
private readonly string[] args;
|
private readonly string[] args;
|
||||||
|
|
||||||
private readonly List<OsuFocusedOverlayContainer> focusedOverlays = new List<OsuFocusedOverlayContainer>();
|
private readonly List<OsuFocusedOverlayContainer> focusedOverlays = new List<OsuFocusedOverlayContainer>();
|
||||||
|
private readonly List<OverlayContainer> externalOverlays = new List<OverlayContainer>();
|
||||||
|
|
||||||
private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>();
|
private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>();
|
||||||
|
|
||||||
@ -186,19 +187,59 @@ namespace osu.Game
|
|||||||
private void updateBlockingOverlayFade() =>
|
private void updateBlockingOverlayFade() =>
|
||||||
ScreenContainer.FadeColour(visibleBlockingOverlays.Any() ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint);
|
ScreenContainer.FadeColour(visibleBlockingOverlays.Any() ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint);
|
||||||
|
|
||||||
public void AddBlockingOverlay(OverlayContainer overlay)
|
/// <summary>
|
||||||
|
/// Registers a blocking <see cref="OverlayContainer"/> that was not created by <see cref="OsuGame"/> itself for later use.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The goal of this method is to allow child screens, like <see cref="SongSelect"/> to register their own full-screen blocking overlays
|
||||||
|
/// with background dim.
|
||||||
|
/// In those cases, for the dim to work correctly, the overlays need to be added at the `OsuGame` level directly, rather as children of the screens.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// An <see cref="IDisposable"/> that should be disposed of when the <paramref name="overlayContainer"/> should be unregistered.
|
||||||
|
/// Disposing of this <see cref="IDisposable"/> will automatically expire the <paramref name="overlayContainer"/>.
|
||||||
|
/// </returns>
|
||||||
|
internal IDisposable RegisterBlockingOverlay(OverlayContainer overlayContainer)
|
||||||
|
{
|
||||||
|
if (overlayContainer.Parent != null)
|
||||||
|
throw new ArgumentException($@"Overlays registered via {nameof(RegisterBlockingOverlay)} should not be added to the scene graph.");
|
||||||
|
|
||||||
|
if (externalOverlays.Contains(overlayContainer))
|
||||||
|
throw new ArgumentException($@"{overlayContainer} has already been registered via {nameof(RegisterBlockingOverlay)} once.");
|
||||||
|
|
||||||
|
externalOverlays.Add(overlayContainer);
|
||||||
|
overlayContent.Add(overlayContainer);
|
||||||
|
return new InvokeOnDisposal(() => unregisterBlockingOverlay(overlayContainer));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Should be called when <paramref name="overlay"/> has been shown and should begin blocking background input.
|
||||||
|
/// </summary>
|
||||||
|
internal void ShowBlockingOverlay(OverlayContainer overlay)
|
||||||
{
|
{
|
||||||
if (!visibleBlockingOverlays.Contains(overlay))
|
if (!visibleBlockingOverlays.Contains(overlay))
|
||||||
visibleBlockingOverlays.Add(overlay);
|
visibleBlockingOverlays.Add(overlay);
|
||||||
updateBlockingOverlayFade();
|
updateBlockingOverlayFade();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveBlockingOverlay(OverlayContainer overlay) => Schedule(() =>
|
/// <summary>
|
||||||
|
/// Should be called when a blocking <paramref name="overlay"/> has been hidden and should stop blocking background input.
|
||||||
|
/// </summary>
|
||||||
|
internal void HideBlockingOverlay(OverlayContainer overlay) => Schedule(() =>
|
||||||
{
|
{
|
||||||
visibleBlockingOverlays.Remove(overlay);
|
visibleBlockingOverlays.Remove(overlay);
|
||||||
updateBlockingOverlayFade();
|
updateBlockingOverlayFade();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unregisters a blocking <see cref="OverlayContainer"/> that was not created by <see cref="OsuGame"/> itself.
|
||||||
|
/// </summary>
|
||||||
|
private void unregisterBlockingOverlay(OverlayContainer overlayContainer)
|
||||||
|
{
|
||||||
|
externalOverlays.Remove(overlayContainer);
|
||||||
|
overlayContainer.Expire();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Close all game-wide overlays.
|
/// Close all game-wide overlays.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -35,6 +35,7 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Game.Collections;
|
using osu.Game.Collections;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -116,9 +117,15 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private double audioFeedbackLastPlaybackTime;
|
private double audioFeedbackLastPlaybackTime;
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
private IDisposable modSelectOverlayRegistration;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private MusicController music { get; set; }
|
private MusicController music { get; set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private OsuGame game { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(AudioManager audio, IDialogOverlay dialog, OsuColour colours, ManageCollectionsDialog manageCollectionsDialog, DifficultyRecommender recommender)
|
private void load(AudioManager audio, IDialogOverlay dialog, OsuColour colours, ManageCollectionsDialog manageCollectionsDialog, DifficultyRecommender recommender)
|
||||||
{
|
{
|
||||||
@ -264,10 +271,13 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Footer = new Footer(),
|
Footer = new Footer(),
|
||||||
ModSelect = CreateModSelectOverlay()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// preload the mod select overlay for later use in `LoadComplete()`.
|
||||||
|
// therein it will be registered at the `OsuGame` level to properly function as a blocking overlay.
|
||||||
|
LoadComponent(ModSelect = CreateModSelectOverlay());
|
||||||
|
|
||||||
if (Footer != null)
|
if (Footer != null)
|
||||||
{
|
{
|
||||||
foreach (var (button, overlay) in CreateFooterButtons())
|
foreach (var (button, overlay) in CreateFooterButtons())
|
||||||
@ -301,6 +311,13 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
modSelectOverlayRegistration = game?.RegisterBlockingOverlay(ModSelect);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the buttons to be displayed in the footer.
|
/// Creates the buttons to be displayed in the footer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -700,6 +717,8 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
if (music != null)
|
if (music != null)
|
||||||
music.TrackChanged -= ensureTrackLooping;
|
music.TrackChanged -= ensureTrackLooping;
|
||||||
|
|
||||||
|
modSelectOverlayRegistration?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Reference in New Issue
Block a user