1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 12:53:11 +08:00

Merge pull request #24953 from peppy/flash-dialog-on-stuck

Flash dialog popup when attempting to exit editor while exit is being blocked
This commit is contained in:
Bartłomiej Dach 2023-09-28 11:04:38 +02:00 committed by GitHub
commit 90326f62a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -3,6 +3,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -28,6 +31,9 @@ namespace osu.Game.Overlays.Dialog
private readonly Vector2 ringMinifiedSize = new Vector2(20f); private readonly Vector2 ringMinifiedSize = new Vector2(20f);
private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f); private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f);
private readonly Box flashLayer;
private Sample flashSample = null!;
private readonly Container content; private readonly Container content;
private readonly Container ring; private readonly Container ring;
private readonly FillFlowContainer<PopupDialogButton> buttonsContainer; private readonly FillFlowContainer<PopupDialogButton> buttonsContainer;
@ -208,6 +214,13 @@ namespace osu.Game.Overlays.Dialog
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
}, },
flashLayer = new Box
{
Alpha = 0,
RelativeSizeAxes = Axes.Both,
Blending = BlendingParameters.Additive,
Colour = Color4Extensions.FromHex(@"221a21"),
},
}, },
}, },
}; };
@ -217,6 +230,12 @@ namespace osu.Game.Overlays.Dialog
Show(); Show();
} }
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
flashSample = audio.Samples.Get(@"UI/default-select-disabled");
}
/// <summary> /// <summary>
/// Programmatically clicks the first <see cref="PopupDialogOkButton"/>. /// Programmatically clicks the first <see cref="PopupDialogOkButton"/>.
/// </summary> /// </summary>
@ -232,6 +251,14 @@ namespace osu.Game.Overlays.Dialog
Scheduler.AddOnce(() => Buttons.OfType<T>().FirstOrDefault()?.TriggerClick()); Scheduler.AddOnce(() => Buttons.OfType<T>().FirstOrDefault()?.TriggerClick());
} }
public void Flash()
{
flashLayer.FadeInFromZero(80, Easing.OutQuint)
.Then()
.FadeOutFromOne(1500, Easing.OutQuint);
flashSample.Play();
}
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)
{ {
if (e.Repeat) return false; if (e.Repeat) return false;

View File

@ -714,8 +714,11 @@ namespace osu.Game.Screens.Edit
} }
// if the dialog is already displayed, block exiting until the user explicitly makes a decision. // if the dialog is already displayed, block exiting until the user explicitly makes a decision.
if (dialogOverlay.CurrentDialog is PromptForSaveDialog) if (dialogOverlay.CurrentDialog is PromptForSaveDialog saveDialog)
{
saveDialog.Flash();
return true; return true;
}
if (isNewBeatmap || HasUnsavedChanges) if (isNewBeatmap || HasUnsavedChanges)
{ {