1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 17:57:38 +08:00
osu-lazer/osu.Game/Overlays/DialogOverlay.cs

82 lines
2.4 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +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.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Dialog;
using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays
{
public class DialogOverlay : OsuFocusedOverlayContainer
{
private readonly Container dialogContainer;
private PopupDialog currentDialog;
public void Push(PopupDialog dialog)
{
if (dialog == currentDialog) return;
currentDialog?.Hide();
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;
}
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
{
if (v != Visibility.Hidden) return;
//handle the dialog being dismissed.
dialog.Delay(PopupDialog.EXIT_DURATION).Expire();
2017-03-02 16:41:33 +08:00
if (dialog == currentDialog)
State = Visibility.Hidden;
}
protected override void PopIn()
{
base.PopIn();
2017-07-23 02:50:25 +08:00
this.FadeIn(PopupDialog.ENTER_DURATION, Easing.OutQuint);
}
protected override void PopOut()
{
base.PopOut();
2017-07-23 02:50:25 +08:00
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
}
public DialogOverlay()
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f),
},
},
},
dialogContainer = new Container
{
RelativeSizeAxes = Axes.Both,
},
};
}
}
}