1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 23:27:25 +08:00

Flash dialog popup when attempting to exit editor while exit is being blocked

This commit is contained in:
Dean Herbert 2023-09-28 15:15:09 +09:00
parent fc38b2c024
commit 7908b36b39
2 changed files with 31 additions and 1 deletions

View File

@ -3,6 +3,9 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -28,6 +31,9 @@ namespace osu.Game.Overlays.Dialog
private readonly Vector2 ringMinifiedSize = new Vector2(20f);
private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f);
private readonly Box flashLayer;
private Sample flashSample = null!;
private readonly Container content;
private readonly Container ring;
private readonly FillFlowContainer<PopupDialogButton> buttonsContainer;
@ -208,6 +214,13 @@ namespace osu.Game.Overlays.Dialog
AutoSizeAxes = Axes.Y,
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();
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
flashSample = audio.Samples.Get(@"UI/default-select-disabled");
}
/// <summary>
/// Programmatically clicks the first <see cref="PopupDialogOkButton"/>.
/// </summary>
@ -232,6 +251,14 @@ namespace osu.Game.Overlays.Dialog
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)
{
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 (dialogOverlay.CurrentDialog is PromptForSaveDialog)
if (dialogOverlay.CurrentDialog is PromptForSaveDialog saveDialog)
{
saveDialog.Flash();
return true;
}
if (isNewBeatmap || HasUnsavedChanges)
{