diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 1fe446454c..d50768f43e 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -36,15 +36,10 @@ namespace osu.Game.Overlays [Resolved] private AudioManager audio { get; set; } - [Resolved(canBeNull: true)] - [CanBeNull] - private FirstRunSetupOverlay firstRunSetup { get; set; } + private readonly IBindable firstRunSetupVisibility = new Bindable(); - [CanBeNull] - private IBindable firstRunSetupState; - - [BackgroundDependencyLoader] - private void load() + [BackgroundDependencyLoader(true)] + private void load([CanBeNull] FirstRunSetupOverlay firstRunSetup) { X = WIDTH; Width = WIDTH; @@ -83,13 +78,16 @@ namespace osu.Game.Overlays } } }; + + if (firstRunSetup != null) + firstRunSetupVisibility.BindTo(firstRunSetup.State); } private ScheduledDelegate notificationsEnabler; private void updateProcessingMode() { - bool enabled = (OverlayActivationMode.Value == OverlayActivation.All && firstRunSetupState?.Value != Visibility.Visible) || State.Value == Visibility.Visible; + bool enabled = (OverlayActivationMode.Value == OverlayActivation.All && firstRunSetupVisibility?.Value != Visibility.Visible) || State.Value == Visibility.Visible; notificationsEnabler?.Cancel(); @@ -104,13 +102,8 @@ namespace osu.Game.Overlays { base.LoadComplete(); - State.ValueChanged += _ => updateProcessingMode(); - - firstRunSetupState = firstRunSetup?.State.GetBoundCopy(); - - if (firstRunSetupState != null) - firstRunSetupState.ValueChanged += _ => updateProcessingMode(); - + State.BindValueChanged(_ => updateProcessingMode()); + firstRunSetupVisibility.BindValueChanged(_ => updateProcessingMode()); OverlayActivationMode.BindValueChanged(_ => updateProcessingMode(), true); }