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:
commit
90326f62a7
@ -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;
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user