1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 03:07:26 +08:00
osu-lazer/osu.Game/Screens/Menu/Disclaimer.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

228 lines
8.1 KiB
C#
Raw Normal View History

// 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-04-13 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
2021-07-01 19:23:12 +08:00
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
2017-02-18 13:16:46 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens;
2017-02-18 13:16:46 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Screens.Menu
{
public partial class Disclaimer : StartupScreen
{
private SpriteIcon icon;
2017-02-18 13:16:46 +08:00
private Color4 iconColour;
private LinkFlowContainer textFlow;
private LinkFlowContainer supportFlow;
2018-04-13 17:19:50 +08:00
private Drawable heart;
private const float icon_y = -85;
private const float icon_size = 30;
2019-07-09 17:06:49 +08:00
private readonly OsuScreen nextScreen;
private readonly Bindable<APIUser> currentUser = new Bindable<APIUser>();
2020-03-11 01:35:49 +08:00
private FillFlowContainer fill;
private readonly List<ITextPart> expendableText = new List<ITextPart>();
2021-07-01 19:23:12 +08:00
2019-07-09 17:06:49 +08:00
public Disclaimer(OsuScreen nextScreen = null)
2017-02-18 13:16:46 +08:00
{
2019-07-09 17:06:49 +08:00
this.nextScreen = nextScreen;
2017-02-18 13:16:46 +08:00
ValidForResume = false;
}
2018-04-13 17:19:50 +08:00
[Resolved]
private IAPIProvider api { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2019-01-23 19:52:00 +08:00
InternalChildren = new Drawable[]
2017-02-18 13:16:46 +08:00
{
icon = new SpriteIcon
2017-02-18 13:16:46 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2021-07-01 19:23:12 +08:00
Icon = OsuIcon.Logo,
Size = new Vector2(icon_size),
Y = icon_y,
},
2020-03-11 01:35:49 +08:00
fill = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
2020-03-11 01:35:49 +08:00
Y = icon_y,
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
Children = new Drawable[]
{
textFlow = new LinkFlowContainer
{
2021-07-02 11:16:45 +08:00
Width = 680,
AutoSizeAxes = Axes.Y,
TextAnchor = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Spacing = new Vector2(0, 2),
},
}
2021-07-01 19:23:12 +08:00
},
supportFlow = new LinkFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
TextAnchor = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Padding = new MarginPadding(20),
Alpha = 0,
Spacing = new Vector2(0, 2),
},
2017-02-18 13:16:46 +08:00
};
textFlow.AddText("this is osu!", t => t.Font = t.Font.With(Typeface.Torus, 30, FontWeight.Regular));
2021-07-01 19:23:12 +08:00
expendableText.Add(textFlow.AddText("lazer", t =>
2021-07-01 19:23:12 +08:00
{
t.Font = t.Font.With(Typeface.Torus, 30, FontWeight.Regular);
t.Colour = colours.PinkLight;
}));
2021-07-02 11:21:28 +08:00
static void formatRegular(SpriteText t) => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular);
static void formatSemiBold(SpriteText t) => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.SemiBold);
textFlow.NewParagraph();
2021-07-02 11:21:28 +08:00
textFlow.AddText("the next ", formatRegular);
2021-07-01 19:23:12 +08:00
textFlow.AddText("major update", t =>
{
t.Font = t.Font.With(Typeface.Torus, 20, FontWeight.SemiBold);
t.Colour = colours.Pink;
});
expendableText.Add(textFlow.AddText(" coming to osu!", formatRegular));
2021-07-02 11:21:28 +08:00
textFlow.AddText(".", formatRegular);
2021-07-02 11:21:28 +08:00
textFlow.NewParagraph();
2021-07-01 19:23:12 +08:00
textFlow.NewParagraph();
textFlow.NewParagraph();
iconColour = colours.Yellow;
2019-03-03 02:13:38 +08:00
// manually transfer the user once, but only do the final bind in LoadComplete to avoid thread woes (API scheduler could run while this screen is still loading).
// the manual transfer is here to ensure all text content is loaded ahead of time as this is very early in the game load process and we want to avoid stutters.
currentUser.Value = api.LocalUser.Value;
2019-03-03 02:13:38 +08:00
currentUser.BindValueChanged(e =>
{
2019-03-19 15:10:28 +08:00
supportFlow.Children.ForEach(d => d.FadeOut().Expire());
2019-03-03 02:13:38 +08:00
if (e.NewValue.IsSupporter)
{
2021-07-02 11:21:28 +08:00
supportFlow.AddText("Eternal thanks to you for supporting osu!", formatSemiBold);
}
else
{
2021-07-02 11:21:28 +08:00
supportFlow.AddText("Consider becoming an ", formatSemiBold);
supportFlow.AddLink("osu!supporter", "https://osu.ppy.sh/home/support", formatSemiBold);
supportFlow.AddText(" to help support osu!'s development", formatSemiBold);
}
supportFlow.AddIcon(FontAwesome.Solid.Heart, t =>
{
heart = t;
2020-03-11 01:35:49 +08:00
t.Padding = new MarginPadding { Left = 5, Top = 3 };
2021-07-02 11:21:28 +08:00
t.Font = t.Font.With(size: 20);
t.Origin = Anchor.Centre;
t.Colour = colours.Pink;
2022-06-17 16:06:06 +08:00
Schedule(() => heart?.FlashColour(Color4.White, 750, Easing.OutQuint).Loop());
});
2019-03-19 15:10:28 +08:00
if (supportFlow.IsPresent)
supportFlow.FadeInFromZero(500);
2019-03-03 02:13:38 +08:00
}, true);
2017-02-18 13:16:46 +08:00
}
2018-04-13 17:19:50 +08:00
protected override void LoadComplete()
{
base.LoadComplete();
2019-07-09 17:06:49 +08:00
if (nextScreen != null)
LoadComponentAsync(nextScreen);
((IBindable<APIUser>)currentUser).BindTo(api.LocalUser);
}
2018-04-13 17:19:50 +08:00
public override void OnSuspending(ScreenTransitionEvent e)
{
base.OnSuspending(e);
// Once this screen has finished being displayed, we don't want to unnecessarily handle user change events.
currentUser.UnbindAll();
}
public override void OnEntering(ScreenTransitionEvent e)
{
base.OnEntering(e);
2018-04-13 17:19:50 +08:00
2020-03-11 01:35:49 +08:00
icon.RotateTo(10);
icon.FadeOut();
icon.ScaleTo(0.5f);
icon.Delay(500).FadeIn(500).ScaleTo(1, 500, Easing.OutQuint);
2021-07-05 23:52:39 +08:00
using (BeginDelayedSequence(3000))
2020-03-11 01:35:49 +08:00
{
icon.FadeColour(iconColour, 200, Easing.OutQuint);
icon.MoveToY(icon_y * 1.3f, 500, Easing.OutCirc)
.RotateTo(-360, 520, Easing.OutQuint)
.Then()
.MoveToY(icon_y, 160, Easing.InQuart)
.FadeColour(Color4.White, 160);
2021-07-01 19:23:12 +08:00
using (BeginDelayedSequence(520 + 160))
{
fill.MoveToOffset(new Vector2(0, 15), 160, Easing.OutQuart);
Schedule(() => expendableText.SelectMany(t => t.Drawables).ForEach(t =>
{
t.FadeOut(100);
t.ScaleTo(new Vector2(0, 1), 100, Easing.OutQuart);
}));
2021-07-01 19:23:12 +08:00
}
2020-03-11 01:35:49 +08:00
}
supportFlow.FadeOut().Delay(2000).FadeIn(500);
2020-03-11 01:35:49 +08:00
double delay = 500;
foreach (var c in textFlow.Children)
c.FadeTo(0.001f).Delay(delay += 20).FadeIn(500);
2019-01-23 19:52:00 +08:00
this
.FadeInFromZero(500)
.Then(5500)
.FadeOut(250)
.ScaleTo(0.9f, 250, Easing.InQuint)
2022-06-24 20:25:23 +08:00
.Finally(_ =>
{
if (nextScreen != null)
this.Push(nextScreen);
});
}
}
}