Fix new mod select overlay dimming itself

This commit is contained in:
Bartłomiej Dach
2022-05-04 21:53:04 +02:00
parent 407db7ff9d
commit 1744d7e4f0
3 changed files with 66 additions and 6 deletions

View File

@ -35,6 +35,7 @@ using osu.Framework.Input.Bindings;
using osu.Game.Collections;
using osu.Game.Graphics.UserInterface;
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Game.Screens.Play;
using osu.Game.Database;
using osu.Game.Skinning;
@ -116,9 +117,15 @@ namespace osu.Game.Screens.Select
private double audioFeedbackLastPlaybackTime;
[CanBeNull]
private IDisposable modSelectOverlayRegistration;
[Resolved]
private MusicController music { get; set; }
[Resolved(CanBeNull = true)]
private OsuGame game { get; set; }
[BackgroundDependencyLoader(true)]
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(),
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)
{
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>
/// Creates the buttons to be displayed in the footer.
/// </summary>
@ -700,6 +717,8 @@ namespace osu.Game.Screens.Select
if (music != null)
music.TrackChanged -= ensureTrackLooping;
modSelectOverlayRegistration?.Dispose();
}
/// <summary>