1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 23:23:30 +08:00

Made DialogOverlay use PopupDialog's direct valfixed last dialogs not expiring, DialogOverlay actually hides now, fixed an issue where multiple buttons could be pressed at once

This commit is contained in:
DrabWeb 2017-03-01 18:41:00 -04:00
parent d5d8352b62
commit befdf68abe
3 changed files with 44 additions and 31 deletions

View File

@ -18,8 +18,8 @@ namespace osu.Game.Overlays.Dialog
{
public class PopupDialog : FocusedOverlayContainer
{
private const float enter_duration = 500;
private const float exit_duration = 200;
public static readonly float ENTER_DURATION = 500;
public static readonly float EXIT_DURATION = 200;
private readonly Vector2 ringSize = new Vector2(100f);
private readonly Vector2 ringMinifiedSize = new Vector2(20f);
private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f);
@ -92,27 +92,35 @@ namespace osu.Game.Overlays.Dialog
Buttons[index].TriggerClick();
}
private bool triggeredButton = false; // used to make it so the user can't press multiple buttons at once with the keyboard
protected override bool OnKeyDown(Framework.Input.InputState state, Framework.Input.KeyDownEventArgs args)
{
if (args.Repeat) return false;
if (args.Key == Key.Enter)
if (!triggeredButton)
{
Buttons.OfType<PopupDialogOkButton>()?.FirstOrDefault()?.TriggerClick();
return true;
}
if (args.Key == Key.Enter)
{
Buttons.OfType<PopupDialogOkButton>()?.FirstOrDefault()?.TriggerClick();
triggeredButton = true;
return true;
}
// press button at number if 1-9 on number row or keypad are pressed
var k = args.Key;
if (k >= Key.Number1 && k <= Key.Number9)
{
pressButtonAtIndex(k - Key.Number1);
return true;
}
else if (k >= Key.Keypad1 && k <= Key.Keypad9)
{
pressButtonAtIndex(k - Key.Keypad1);
return true;
// press button at number if 1-9 on number row or keypad are pressed
var k = args.Key;
if (k >= Key.Number1 && k <= Key.Number9)
{
pressButtonAtIndex(k - Key.Number1);
triggeredButton = true;
return true;
}
else if (k >= Key.Keypad1 && k <= Key.Keypad9)
{
pressButtonAtIndex(k - Key.Keypad1);
triggeredButton = true;
return true;
}
}
return base.OnKeyDown(state, args);
@ -122,6 +130,8 @@ namespace osu.Game.Overlays.Dialog
{
base.PopIn();
triggeredButton = false;
// Reset various animations but only if the dialog animation fully completed
if (content.Alpha == 0)
{
@ -130,17 +140,17 @@ namespace osu.Game.Overlays.Dialog
ring.ResizeTo(ringMinifiedSize);
}
content.FadeIn(enter_duration, EasingTypes.OutQuint);
ring.ResizeTo(ringSize, enter_duration, EasingTypes.OutQuint);
buttonsContainer.TransformSpacingTo(Vector2.Zero, enter_duration, EasingTypes.OutQuint);
buttonsContainer.MoveToY(0, enter_duration, EasingTypes.OutQuint);
content.FadeIn(ENTER_DURATION, EasingTypes.OutQuint);
ring.ResizeTo(ringSize, ENTER_DURATION, EasingTypes.OutQuint);
buttonsContainer.TransformSpacingTo(Vector2.Zero, ENTER_DURATION, EasingTypes.OutQuint);
buttonsContainer.MoveToY(0, ENTER_DURATION, EasingTypes.OutQuint);
}
protected override void PopOut()
{
base.PopOut();
content.FadeOut(exit_duration, EasingTypes.InSine);
content.FadeOut(EXIT_DURATION, EasingTypes.InSine);
}
public PopupDialog()

View File

@ -15,7 +15,6 @@ namespace osu.Game.Overlays
{
private Container dialogContainer;
private PopupDialog currentDialog;
private Container darken;
public void Push(PopupDialog dialog)
{
@ -25,26 +24,30 @@ namespace osu.Game.Overlays
dialog.Show();
dialog.StateChanged += delegate (OverlayContainer c, Visibility v)
{
if (v == Visibility.Hidden && c == currentDialog)
State = Visibility.Hidden;
if (v == Visibility.Hidden)
{
c.Delay(PopupDialog.EXIT_DURATION);
c.Expire();
if (c == currentDialog)
State = Visibility.Hidden;
}
};
var lastDialog = currentDialog;
currentDialog = dialog;
lastDialog?.Hide();
lastDialog?.Expire();
}
protected override void PopIn()
{
base.PopIn();
darken.FadeIn(500, EasingTypes.OutQuint);
FadeIn(PopupDialog.ENTER_DURATION, EasingTypes.OutQuint);
}
protected override void PopOut()
{
base.PopOut();
darken.FadeOut(200, EasingTypes.InSine);
FadeOut(PopupDialog.EXIT_DURATION, EasingTypes.InSine);
}
public DialogOverlay()
@ -53,7 +56,7 @@ namespace osu.Game.Overlays
Children = new Drawable[]
{
darken = new Container
new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]

View File

@ -59,7 +59,7 @@ namespace osu.Game.Screens.Select
FilterControl filter;
[BackgroundDependencyLoader(permitNulls: true)]
private void load(BeatmapDatabase beatmaps, AudioManager audio, /*DialogOverlay dialog,*/ Framework.Game game,
private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, Framework.Game game,
OsuGame osuGame, OsuColour colours)
{
const float carousel_width = 640;
@ -144,7 +144,7 @@ namespace osu.Game.Screens.Select
database.BeatmapSetRemoved += onBeatmapSetRemoved;
trackManager = audio.Track;
//dialogOverlay = dialog;
dialogOverlay = dialog;
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");