1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 22:07:28 +08:00
osu-lazer/osu.Game/Screens/Menu/Disclaimer.cs

183 lines
6.3 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
using System;
using System.Linq;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
2018-04-13 17:19:50 +08:00
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
using osu.Game.Overlays;
using osu.Game.Users;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Screens.Menu
{
public class Disclaimer : OsuScreen
{
private Intro intro;
private SpriteIcon icon;
2018-04-13 17:19:50 +08:00
private Color4 iconColour;
private LinkFlowContainer textFlow;
private LinkFlowContainer supportFlow;
2018-04-13 17:19:50 +08:00
public override bool HideOverlaysOnEnter => true;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
2018-04-13 17:19:50 +08:00
public override bool CursorVisible => false;
private Drawable heart;
private const float icon_y = -85;
private const float icon_size = 30;
2019-03-03 02:13:38 +08:00
private readonly Bindable<User> currentUser = new Bindable<User>();
2018-04-13 17:19:50 +08:00
public Disclaimer()
{
ValidForResume = false;
}
2018-04-13 17:19:50 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colours, IAPIProvider api)
{
2019-01-23 19:52:00 +08:00
InternalChildren = new Drawable[]
2018-04-13 17:19:50 +08:00
{
icon = new SpriteIcon
2018-04-13 17:19:50 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.fa_warning,
Size = new Vector2(icon_size),
Y = icon_y,
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Y = icon_y + icon_size,
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
Children = new Drawable[]
{
textFlow = new LinkFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
TextAnchor = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Spacing = new Vector2(0, 2),
},
supportFlow = new LinkFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
TextAnchor = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
2019-03-19 15:11:22 +08:00
Alpha = 0,
Spacing = new Vector2(0, 2),
},
}
2018-04-13 17:19:50 +08:00
}
};
textFlow.AddText("This is an ", t => t.Font = t.Font.With(Typeface.Exo, 30, FontWeight.Light));
textFlow.AddText("early development build", t => t.Font = t.Font.With(Typeface.Exo, 30, FontWeight.SemiBold));
textFlow.AddParagraph("Things may not work as expected", t => t.Font = t.Font.With(size: 20));
textFlow.NewParagraph();
2019-03-02 12:25:59 +08:00
Action<SpriteText> format = t => t.Font = OsuFont.GetFont(size: 15, weight: FontWeight.SemiBold);
textFlow.AddParagraph("Detailed bug reports are welcomed via github issues.", format);
textFlow.NewParagraph();
textFlow.AddText("Visit ", format);
2019-02-28 12:31:40 +08:00
textFlow.AddLink("discord.gg/ppy", "https://discord.gg/ppy", creationParameters: format);
textFlow.AddText(" to help out or follow progress!", format);
textFlow.NewParagraph();
textFlow.NewParagraph();
textFlow.NewParagraph();
iconColour = colours.Yellow;
2019-03-03 02:13:38 +08:00
currentUser.BindTo(api.LocalUser);
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)
{
supportFlow.AddText("Thank you for supporting osu!", format);
}
else
{
supportFlow.AddText("Consider becoming an ", format);
supportFlow.AddLink("osu!supporter", "https://osu.ppy.sh/home/support", creationParameters: format);
supportFlow.AddText(" to help support the game", format);
}
heart = supportFlow.AddIcon(FontAwesome.fa_heart, t =>
{
t.Padding = new MarginPadding { Left = 5 };
t.Font = t.Font.With(size: 12);
t.Origin = Anchor.Centre;
t.Colour = colours.Pink;
}).First();
if (IsLoaded)
animateHeart();
2019-03-19 15:10:28 +08:00
if (supportFlow.IsPresent)
supportFlow.FadeInFromZero(500);
2019-03-03 02:13:38 +08:00
}, true);
2018-04-13 17:19:50 +08:00
}
private void animateHeart()
{
heart.FlashColour(Color4.White, 750, Easing.OutQuint).Loop();
}
protected override void LoadComplete()
2018-04-13 17:19:50 +08:00
{
base.LoadComplete();
2018-04-13 17:19:50 +08:00
LoadComponentAsync(intro = new Intro());
}
2019-01-23 19:52:00 +08:00
public override void OnEntering(IScreen last)
2018-04-13 17:19:50 +08:00
{
base.OnEntering(last);
icon.Delay(1000).FadeColour(iconColour, 200, Easing.OutQuint);
icon.Delay(1000)
.MoveToY(icon_y * 1.1f, 160, Easing.OutCirc)
.RotateTo(-10, 160, Easing.OutCirc)
.Then()
.MoveToY(icon_y, 160, Easing.InCirc)
.RotateTo(0, 160, Easing.InCirc);
supportFlow.FadeOut().Delay(2000).FadeIn(500);
animateHeart();
2018-04-13 17:19:50 +08:00
2019-01-23 19:52:00 +08:00
this
2018-04-13 17:19:50 +08:00
.FadeInFromZero(500)
.Then(5500)
.FadeOut(250)
.ScaleTo(0.9f, 250, Easing.InQuint)
2019-01-23 19:52:00 +08:00
.Finally(d => this.Push(intro));
2018-04-13 17:19:50 +08:00
}
}
}