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

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

108 lines
3.7 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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Screens.Play
{
public partial class PlayerLoaderDisclaimer : CompositeDrawable
{
private readonly LocalisableString title;
private readonly LocalisableString content;
private Box background = null!;
public PlayerLoaderDisclaimer(LocalisableString title, LocalisableString content)
{
this.title = title;
this.content = content;
}
[BackgroundDependencyLoader]
2024-03-15 18:31:45 +08:00
private void load(OsuColour colours, OverlayColourProvider colourProvider)
{
2024-03-15 18:31:45 +08:00
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
2024-03-15 18:31:45 +08:00
Masking = true;
CornerRadius = 5;
InternalChildren = new Drawable[]
{
background = new Box
{
2024-03-15 18:31:45 +08:00
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background4,
Alpha = 0.1f,
},
2024-03-15 18:31:45 +08:00
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2024-03-15 18:31:45 +08:00
Padding = new MarginPadding(10),
Children = new Drawable[]
{
2024-03-15 18:31:45 +08:00
new Circle
{
2024-03-15 18:31:45 +08:00
Width = 7,
Height = 15,
Margin = new MarginPadding { Top = 2 },
Colour = colours.Orange1,
},
2024-03-15 18:31:45 +08:00
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2024-03-15 18:31:45 +08:00
Padding = new MarginPadding { Left = 12 },
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 2),
Children = new[]
{
new TextFlowContainer(t => t.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Text = title,
},
new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 16))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Text = content,
}
}
}
}
}
};
}
protected override bool OnHover(HoverEvent e)
{
updateFadeState();
// handle hover so that users can hover the disclaimer to delay load if they want to read it.
return true;
}
protected override void OnHoverLost(HoverLostEvent e)
{
updateFadeState();
base.OnHoverLost(e);
}
private void updateFadeState()
{
// Matches SettingsToolboxGroup
2024-03-16 13:18:42 +08:00
background.FadeTo(IsHovered ? 1 : 0.1f, 500, Easing.OutQuint);
}
}
}