1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 04:05:35 +08:00

Tidy up DI and binding logic

This commit is contained in:
Dean Herbert 2022-06-16 17:26:43 +09:00
parent e7dcbddbeb
commit 6b30ee0950

View File

@ -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<Visibility> firstRunSetupVisibility = new Bindable<Visibility>();
[CanBeNull]
private IBindable<Visibility> 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);
}