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