osu/osu.Game/Screens/Menu/Disclaimer.cs

218 lines
8.5 KiB
C#

// 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.
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens;
using osu.Framework.Utils;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
using osuTK;
using osuTK.Graphics;
using osu.Game.Users;
namespace osu.Game.Screens.Menu
{
public class Disclaimer : StartupScreen
{
private SpriteIcon icon;
private Color4 iconColour;
private LinkFlowContainer textFlow;
private LinkFlowContainer supportFlow;
private Drawable heart;
private const float icon_y = -85;
private const float icon_size = 30;
private readonly OsuScreen nextScreen;
private readonly Bindable<User> currentUser = new Bindable<User>();
private FillFlowContainer fill;
public Disclaimer(OsuScreen nextScreen = null)
{
this.nextScreen = nextScreen;
ValidForResume = false;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, IAPIProvider api)
{
InternalChildren = new Drawable[]
{
icon = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.Solid.Flask,
Size = new Vector2(icon_size),
Y = icon_y,
},
fill = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Y = icon_y,
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),
LayoutDuration = 2000,
LayoutEasing = Easing.OutQuint
},
supportFlow = new LinkFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
TextAnchor = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Alpha = 0,
Spacing = new Vector2(0, 2),
},
}
}
};
textFlow.AddText("This project is an ongoing ", t => t.Font = t.Font.With(Typeface.Torus, 30, FontWeight.Light));
textFlow.AddText("work in progress", t => t.Font = t.Font.With(Typeface.Torus, 30, FontWeight.SemiBold));
textFlow.NewParagraph();
static void format(SpriteText t) => t.Font = OsuFont.GetFont(size: 15, weight: FontWeight.SemiBold);
textFlow.AddParagraph(getRandomTip(), t => t.Font = t.Font.With(Typeface.Torus, 20, FontWeight.SemiBold));
textFlow.NewParagraph();
textFlow.NewParagraph();
iconColour = colours.Yellow;
currentUser.BindTo(api.LocalUser);
currentUser.BindValueChanged(e =>
{
supportFlow.Children.ForEach(d => d.FadeOut().Expire());
if (e.NewValue.IsSupporter)
{
supportFlow.AddText("Eternal thanks to 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.Solid.Heart, t =>
{
t.Padding = new MarginPadding { Left = 5, Top = 3 };
t.Font = t.Font.With(size: 12);
t.Origin = Anchor.Centre;
t.Colour = colours.Pink;
}).First();
if (IsLoaded)
animateHeart();
if (supportFlow.IsPresent)
supportFlow.FadeInFromZero(500);
}, true);
}
protected override void LoadComplete()
{
base.LoadComplete();
if (nextScreen != null)
LoadComponentAsync(nextScreen);
}
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
icon.RotateTo(10);
icon.FadeOut();
icon.ScaleTo(0.5f);
icon.Delay(500).FadeIn(500).ScaleTo(1, 500, Easing.OutQuint);
using (BeginDelayedSequence(3000, true))
{
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);
fill.Delay(520 + 160).MoveToOffset(new Vector2(0, 15), 160, Easing.OutQuart);
}
supportFlow.FadeOut().Delay(2000).FadeIn(500);
double delay = 500;
foreach (var c in textFlow.Children)
c.FadeTo(0.001f).Delay(delay += 20).FadeIn(500);
animateHeart();
this
.FadeInFromZero(500)
.Then(5500)
.FadeOut(250)
.ScaleTo(0.9f, 250, Easing.InQuint)
.Finally(d =>
{
if (nextScreen != null)
this.Push(nextScreen);
});
}
private string getRandomTip()
{
string[] tips =
{
"You can press Ctrl-T anywhere in the game to toggle the toolbar!",
"You can press Ctrl-O anywhere in the game to access options!",
"All settings are dynamic and take effect in real-time. Try pausing and changing the skin while playing!",
"New features are coming online every update. Make sure to stay up-to-date!",
"If you find the UI too large or small, try adjusting UI scale in settings!",
"Try adjusting the \"Screen Scaling\" mode to change your gameplay or UI area, even in fullscreen!",
"For now, osu!direct is available to all users on lazer. You can access it anywhere using Ctrl-D!",
"Seeking in replays is available by dragging on the difficulty bar at the bottom of the screen!",
"Multithreading support means that even with low \"FPS\" your input and judgements will be accurate!",
"Try scrolling down in the mod select panel to find a bunch of new fun mods!",
"Most of the web content (profiles, rankings, etc.) are available natively in-game from the icons on the toolbar!",
"Get more details, hide or delete a beatmap by right-clicking on its panel at song select!",
"All delete operations are temporary until exiting. Restore accidentally deleted content from the maintenance settings!",
"Check out the \"timeshift\" multiplayer system, which has local permanent leaderboards and playlist support!",
"Toggle advanced frame / thread statistics with Ctrl-F11!",
"Take a look under the hood at performance counters and enable verbose performance logging with Ctrl-F2!",
};
return tips[RNG.Next(0, tips.Length)];
}
private void animateHeart()
{
heart.FlashColour(Color4.White, 750, Easing.OutQuint).Loop();
}
}
}