2019-01-24 16:43:03 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-12-04 19:33:29 +08:00
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2018-12-04 19:33:29 +08:00
|
|
|
using osu.Framework.Allocation;
|
2020-10-22 13:19:12 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-12-04 19:33:29 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-04-02 13:51:28 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2018-12-04 19:33:29 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-01-23 19:52:00 +08:00
|
|
|
using osu.Framework.Screens;
|
2020-12-25 22:37:14 +08:00
|
|
|
using osu.Framework.Threading;
|
2018-12-04 19:33:29 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Overlays.AccountCreation;
|
|
|
|
using osuTK;
|
2018-12-06 10:58:09 +08:00
|
|
|
using osuTK.Graphics;
|
2018-12-04 19:33:29 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
{
|
2020-10-22 13:19:12 +08:00
|
|
|
public partial class AccountCreationOverlay : OsuFocusedOverlayContainer
|
2018-12-04 19:33:29 +08:00
|
|
|
{
|
|
|
|
private const float transition_time = 400;
|
|
|
|
|
2018-12-06 11:38:11 +08:00
|
|
|
private ScreenWelcome welcomeScreen;
|
|
|
|
|
2018-12-04 19:33:29 +08:00
|
|
|
public AccountCreationOverlay()
|
|
|
|
{
|
|
|
|
Size = new Vector2(620, 450);
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
}
|
|
|
|
|
2020-10-22 13:19:12 +08:00
|
|
|
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
|
|
|
|
2018-12-04 19:33:29 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 08:06:39 +08:00
|
|
|
private void load(IAPIProvider api)
|
2018-12-04 19:33:29 +08:00
|
|
|
{
|
2020-10-22 13:19:12 +08:00
|
|
|
apiState.BindTo(api.State);
|
|
|
|
apiState.BindValueChanged(apiStateChanged, true);
|
2018-12-04 19:33:29 +08:00
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Radius = 5,
|
|
|
|
Colour = Color4.Black.Opacity(0.2f),
|
|
|
|
},
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = 10,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
Alpha = 0.6f,
|
|
|
|
},
|
|
|
|
new DelayedLoadWrapper(new AccountCreationBackground(), 0),
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 0.6f,
|
|
|
|
AutoSizeDuration = transition_time,
|
|
|
|
AutoSizeEasing = Easing.OutQuint,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
Alpha = 0.9f,
|
|
|
|
},
|
2019-02-15 16:01:51 +08:00
|
|
|
new ScreenStack(welcomeScreen = new ScreenWelcome())
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2018-12-04 19:33:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
{
|
|
|
|
this.FadeIn(transition_time, Easing.OutQuint);
|
2018-12-06 11:38:11 +08:00
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
if (welcomeScreen.GetChildScreen() != null)
|
2018-12-06 11:38:11 +08:00
|
|
|
welcomeScreen.MakeCurrent();
|
2020-12-25 22:37:14 +08:00
|
|
|
|
|
|
|
// there might be a stale scheduled hide from a previous API state change.
|
|
|
|
// cancel it here so that the overlay is not hidden again after one frame.
|
|
|
|
scheduledHide?.Cancel();
|
|
|
|
scheduledHide = null;
|
2018-12-04 19:33:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
{
|
|
|
|
base.PopOut();
|
|
|
|
this.FadeOut(100);
|
|
|
|
}
|
|
|
|
|
2020-12-25 22:37:14 +08:00
|
|
|
private ScheduledDelegate scheduledHide;
|
|
|
|
|
|
|
|
private void apiStateChanged(ValueChangedEvent<APIState> state)
|
2018-12-04 19:33:29 +08:00
|
|
|
{
|
2020-10-22 13:19:12 +08:00
|
|
|
switch (state.NewValue)
|
2018-12-04 19:33:29 +08:00
|
|
|
{
|
|
|
|
case APIState.Offline:
|
|
|
|
case APIState.Failing:
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
2018-12-04 19:33:29 +08:00
|
|
|
case APIState.Connecting:
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
2018-12-04 19:33:29 +08:00
|
|
|
case APIState.Online:
|
2020-12-25 22:37:14 +08:00
|
|
|
scheduledHide?.Cancel();
|
|
|
|
scheduledHide = Schedule(Hide);
|
2018-12-04 19:33:29 +08:00
|
|
|
break;
|
|
|
|
}
|
2020-12-25 22:37:14 +08:00
|
|
|
}
|
2018-12-04 19:33:29 +08:00
|
|
|
}
|
|
|
|
}
|