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.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
|
|
|
|
using osu.Game.Overlays.Dialog;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2017-02-28 14:09:36 +08:00
|
|
|
|
public class DialogOverlay : FocusedOverlayContainer
|
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();
|
|
|
|
|
currentDialog.StateChanged += onDialogOnStateChanged;
|
|
|
|
|
State = Visibility.Visible;
|
2017-03-02 16:08:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onDialogOnStateChanged(OverlayContainer dialog, Visibility v)
|
|
|
|
|
{
|
|
|
|
|
if (v != Visibility.Hidden) return;
|
|
|
|
|
|
|
|
|
|
//handle the dialog being dismissed.
|
|
|
|
|
dialog.Delay(PopupDialog.EXIT_DURATION);
|
|
|
|
|
dialog.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-03-02 06:41:00 +08:00
|
|
|
|
FadeIn(PopupDialog.ENTER_DURATION, EasingTypes.OutQuint);
|
2017-02-28 12:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
2017-03-02 06:41:00 +08:00
|
|
|
|
FadeOut(PopupDialog.EXIT_DURATION, EasingTypes.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,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|