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
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Overlays.Dialog;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2017-02-28 06:09:36 +00:00
|
|
|
|
public class DialogOverlay : FocusedOverlayContainer
|
2017-02-28 04:59:36 +00:00
|
|
|
|
{
|
|
|
|
|
private Container dialogContainer;
|
|
|
|
|
private PopupDialog currentDialog;
|
|
|
|
|
|
|
|
|
|
public void Push(PopupDialog dialog)
|
|
|
|
|
{
|
|
|
|
|
State = Visibility.Visible;
|
|
|
|
|
|
|
|
|
|
dialogContainer.Add(dialog);
|
|
|
|
|
dialog.Show();
|
|
|
|
|
dialog.StateChanged += delegate (OverlayContainer c, Visibility v)
|
|
|
|
|
{
|
2017-03-01 22:41:00 +00:00
|
|
|
|
if (v == Visibility.Hidden)
|
|
|
|
|
{
|
|
|
|
|
c.Delay(PopupDialog.EXIT_DURATION);
|
|
|
|
|
c.Expire();
|
|
|
|
|
if (c == currentDialog)
|
|
|
|
|
State = Visibility.Hidden;
|
|
|
|
|
}
|
2017-02-28 04:59:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-02-28 06:09:36 +00:00
|
|
|
|
var lastDialog = currentDialog;
|
2017-02-28 04:59:36 +00:00
|
|
|
|
currentDialog = dialog;
|
2017-02-28 06:09:36 +00:00
|
|
|
|
lastDialog?.Hide();
|
2017-02-28 04:59:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
2017-03-01 22:41:00 +00:00
|
|
|
|
FadeIn(PopupDialog.ENTER_DURATION, EasingTypes.OutQuint);
|
2017-02-28 04:59:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
2017-03-01 22:41:00 +00:00
|
|
|
|
FadeOut(PopupDialog.EXIT_DURATION, EasingTypes.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,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|