2018-04-13 17:19:50 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Overlays.Dialog;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
|
|
|
|
public class DialogOverlay : OsuFocusedOverlayContainer
|
|
|
|
|
{
|
|
|
|
|
private readonly Container dialogContainer;
|
|
|
|
|
private PopupDialog currentDialog;
|
|
|
|
|
|
2018-07-02 13:22:37 +08:00
|
|
|
|
public DialogOverlay()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
Child = dialogContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Width = 0.4f;
|
|
|
|
|
Anchor = Anchor.BottomCentre;
|
|
|
|
|
Origin = Anchor.BottomCentre;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public void Push(PopupDialog dialog)
|
|
|
|
|
{
|
|
|
|
|
if (dialog == currentDialog) return;
|
|
|
|
|
|
|
|
|
|
currentDialog?.Hide();
|
|
|
|
|
currentDialog = dialog;
|
|
|
|
|
|
|
|
|
|
dialogContainer.Add(currentDialog);
|
|
|
|
|
|
|
|
|
|
currentDialog.Show();
|
|
|
|
|
currentDialog.StateChanged += state => onDialogOnStateChanged(dialog, state);
|
|
|
|
|
State = Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-21 15:47:05 +08:00
|
|
|
|
protected override bool PlaySamplesOnStateChange => false;
|
|
|
|
|
|
2018-07-02 13:22:37 +08:00
|
|
|
|
protected override bool BlockPassThroughKeyboard => true;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
|
|
|
|
{
|
|
|
|
|
if (v != Visibility.Hidden) return;
|
|
|
|
|
|
|
|
|
|
//handle the dialog being dismissed.
|
|
|
|
|
dialog.Delay(PopupDialog.EXIT_DURATION).Expire();
|
|
|
|
|
|
|
|
|
|
if (dialog == currentDialog)
|
|
|
|
|
State = Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
|
|
|
|
this.FadeIn(PopupDialog.ENTER_DURATION, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
|
|
|
|
|
2018-07-02 13:22:37 +08:00
|
|
|
|
if (currentDialog?.State == Visibility.Visible)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-02 13:22:37 +08:00
|
|
|
|
currentDialog.Hide();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|