2017-02-28 12:59:36 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-02-28 12:59:36 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Overlays.Dialog;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-06-29 01:18:12 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-02-28 12:59:36 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2017-06-29 01:18:12 +08:00
|
|
|
|
public class DialogOverlay : OsuFocusedOverlayContainer
|
2017-02-28 12:59:36 +08:00
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly Container dialogContainer;
|
2017-02-28 12:59:36 +08:00
|
|
|
|
private PopupDialog currentDialog;
|
|
|
|
|
|
|
|
|
|
public void Push(PopupDialog dialog)
|
|
|
|
|
{
|
2017-03-02 16:08:00 +08:00
|
|
|
|
if (dialog == currentDialog) return;
|
|
|
|
|
|
|
|
|
|
currentDialog?.Hide();
|
2017-02-28 12:59:36 +08:00
|
|
|
|
currentDialog = dialog;
|
2017-03-02 16:41:33 +08:00
|
|
|
|
|
|
|
|
|
dialogContainer.Add(currentDialog);
|
|
|
|
|
|
|
|
|
|
currentDialog.Show();
|
2017-09-04 08:10:04 +08:00
|
|
|
|
currentDialog.StateChanged += state => onDialogOnStateChanged(dialog, state);
|
2017-03-02 16:41:33 +08:00
|
|
|
|
State = Visibility.Visible;
|
2017-03-02 16:08:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 15:40:53 +08:00
|
|
|
|
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
2017-03-02 16:08:00 +08:00
|
|
|
|
{
|
|
|
|
|
if (v != Visibility.Hidden) return;
|
|
|
|
|
|
|
|
|
|
//handle the dialog being dismissed.
|
2017-07-17 21:51:21 +08:00
|
|
|
|
dialog.Delay(PopupDialog.EXIT_DURATION).Expire();
|
2017-03-02 16:41:33 +08:00
|
|
|
|
|
2017-03-02 16:08:00 +08:00
|
|
|
|
if (dialog == currentDialog)
|
|
|
|
|
State = Visibility.Hidden;
|
2017-02-28 12:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
2017-07-23 02:50:25 +08:00
|
|
|
|
this.FadeIn(PopupDialog.ENTER_DURATION, Easing.OutQuint);
|
2017-02-28 12:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
2017-07-23 02:50:25 +08:00
|
|
|
|
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
|
2017-02-28 12:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 14:09:36 +08:00
|
|
|
|
public DialogOverlay()
|
2017-02-28 12:59:36 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-03-02 06:41:00 +08:00
|
|
|
|
new Container
|
2017-02-28 12:59:36 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.5f),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
dialogContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|