2020-10-20 05:48:02 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
2020-10-20 14:03:12 +08:00
|
|
|
using osu.Game.Screens.Backgrounds;
|
2020-10-20 05:48:02 +08:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
{
|
|
|
|
public class EpilepsyWarning : VisibilityContainer
|
|
|
|
{
|
2020-10-25 04:58:43 +08:00
|
|
|
public const double FADE_DURATION = 250;
|
2020-10-20 05:48:02 +08:00
|
|
|
|
|
|
|
public EpilepsyWarning()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
Alpha = 0f;
|
|
|
|
}
|
|
|
|
|
2021-01-04 17:32:23 +08:00
|
|
|
private BackgroundScreenBeatmap dimmableBackground;
|
|
|
|
|
|
|
|
public BackgroundScreenBeatmap DimmableBackground
|
|
|
|
{
|
|
|
|
get => dimmableBackground;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
dimmableBackground = value;
|
|
|
|
|
|
|
|
if (IsLoaded)
|
|
|
|
updateBackgroundFade();
|
|
|
|
}
|
|
|
|
}
|
2020-10-20 14:03:12 +08:00
|
|
|
|
2020-10-20 05:48:02 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours, IBindable<WorkingBeatmap> beatmap)
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-10-20 14:18:15 +08:00
|
|
|
new FillFlowContainer
|
2020-10-20 05:48:02 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new SpriteIcon
|
|
|
|
{
|
|
|
|
Colour = colours.Yellow,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Icon = FontAwesome.Solid.ExclamationTriangle,
|
|
|
|
Size = new Vector2(50),
|
|
|
|
},
|
|
|
|
new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 25))
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
TextAnchor = Anchor.Centre,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
}.With(tfc =>
|
|
|
|
{
|
|
|
|
tfc.AddText("This beatmap contains scenes with ");
|
|
|
|
tfc.AddText("rapidly flashing colours", s =>
|
|
|
|
{
|
|
|
|
s.Font = s.Font.With(weight: FontWeight.Bold);
|
|
|
|
s.Colour = colours.Yellow;
|
|
|
|
});
|
|
|
|
tfc.AddText(".");
|
|
|
|
|
|
|
|
tfc.NewParagraph();
|
|
|
|
tfc.AddText("Please take caution if you are affected by epilepsy.");
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
{
|
2021-01-04 17:32:23 +08:00
|
|
|
updateBackgroundFade();
|
2020-10-20 05:48:02 +08:00
|
|
|
|
2020-10-20 14:03:12 +08:00
|
|
|
this.FadeIn(FADE_DURATION, Easing.OutQuint);
|
2020-10-20 05:48:02 +08:00
|
|
|
}
|
|
|
|
|
2021-01-04 17:32:23 +08:00
|
|
|
private void updateBackgroundFade()
|
|
|
|
{
|
|
|
|
DimmableBackground?.FadeColour(OsuColour.Gray(0.5f), FADE_DURATION, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
|
2020-10-20 14:03:33 +08:00
|
|
|
protected override void PopOut() => this.FadeOut(FADE_DURATION);
|
2020-10-20 05:48:02 +08:00
|
|
|
}
|
|
|
|
}
|