1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Ensure notifications don't interrupt the first run setup process

This commit is contained in:
Dean Herbert 2022-04-19 17:40:35 +09:00
parent c562004fe9
commit 17eaa44af1
2 changed files with 31 additions and 6 deletions

View File

@ -74,6 +74,8 @@ namespace osu.Game.Overlays
private Container stackContainer = null!;
private Bindable<OverlayActivation>? overlayActivationMode;
public FirstRunSetupOverlay()
{
RelativeSizeAxes = Axes.Both;
@ -225,11 +227,7 @@ namespace osu.Game.Overlays
config.BindWith(OsuSetting.ShowFirstRunSetup, showFirstRunSetup);
if (showFirstRunSetup.Value)
{
// if we are valid for display, only do so after reaching the main menu.
performer.PerformFromScreen(_ => { Show(); }, new[] { typeof(MainMenu) });
}
if (showFirstRunSetup.Value) Show();
}
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
@ -258,6 +256,26 @@ namespace osu.Game.Overlays
return base.OnPressed(e);
}
public override void Show()
{
// if we are valid for display, only do so after reaching the main menu.
performer.PerformFromScreen(screen =>
{
MainMenu menu = (MainMenu)screen;
// Eventually I'd like to replace this with a better method that doesn't access the screen.
// Either this dialog would be converted to its own screen, or at very least be "hosted" by a screen pushed to the main menu.
// Alternatively, another method of disabling notifications could be added to `INotificationOverlay`.
if (menu != null)
{
overlayActivationMode = menu.OverlayActivationMode.GetBoundCopy();
overlayActivationMode.Value = OverlayActivation.UserTriggered;
}
base.Show();
}, new[] { typeof(MainMenu) });
}
protected override void PopIn()
{
base.PopIn();
@ -273,6 +291,13 @@ namespace osu.Game.Overlays
protected override void PopOut()
{
if (overlayActivationMode != null)
{
// If this is non-null we are guaranteed to have come from the main menu.
overlayActivationMode.Value = OverlayActivation.All;
overlayActivationMode = null;
}
if (currentStepIndex != null)
{
notificationOverlay.Post(new SimpleNotification

View File

@ -48,7 +48,7 @@ namespace osu.Game.Screens
/// </summary>
protected virtual OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
protected readonly Bindable<OverlayActivation> OverlayActivationMode;
public readonly Bindable<OverlayActivation> OverlayActivationMode;
IBindable<OverlayActivation> IOsuScreen.OverlayActivationMode => OverlayActivationMode;