1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 13:33:03 +08:00

Different version of epilepsy warning display

This commit is contained in:
Salman Ahmed 2020-10-20 00:32:44 +03:00
parent 95f52573f7
commit 6e4b28ed1e
2 changed files with 113 additions and 45 deletions

View File

@ -49,44 +49,6 @@ namespace osu.Game.Screens.Play
}
}
private class EpilepsyWarning : FillFlowContainer
{
public EpilepsyWarning(bool warning)
{
if (warning)
this.Show();
else
this.Hide();
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Vertical;
Children = new Drawable[]
{
new SpriteIcon
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Icon = FontAwesome.Solid.ExclamationTriangle,
Size = new Vector2(40),
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "This beatmap contains scenes with rapidly flashing colours.",
Font = OsuFont.GetFont(size: 20),
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Please take caution if you are affected by epilepsy.",
Font = OsuFont.GetFont(size: 20),
}
};
}
}
private readonly WorkingBeatmap beatmap;
private readonly Bindable<IReadOnlyList<Mod>> mods;
private readonly Drawable facade;
@ -201,12 +163,6 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding { Top = 20 },
Current = mods
},
new EpilepsyWarning(beatmap.BeatmapInfo.EpilepsyWarning)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 20 },
}
},
}
};

View File

@ -6,16 +6,21 @@ using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using osu.Framework.Screens;
using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Input;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
@ -84,6 +89,8 @@ namespace osu.Game.Screens.Play
private bool hideOverlays;
private bool epilepsyShown;
private InputManager inputManager;
private IdleTracker idleTracker;
@ -308,7 +315,27 @@ namespace osu.Game.Screens.Play
{
contentOut();
this.Delay(250).Schedule(() =>
if (true && !epilepsyShown)
{
EpilepsyWarning warning;
AddInternal(warning = new EpilepsyWarning
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
State = { Value = Visibility.Visible }
});
epilepsyShown = true;
this.Delay(2000).Schedule(() =>
{
warning.Hide();
warning.Expire();
});
}
this.Delay(epilepsyShown ? 2500 : 250).Schedule(() =>
{
if (!this.IsCurrentScreen()) return;
@ -398,5 +425,90 @@ namespace osu.Game.Screens.Play
}
#endregion
private class EpilepsyWarning : VisibilityContainer
{
private readonly BindableDouble trackVolumeOnEpilepsyWarning = new BindableDouble(1f);
private Track track;
private FillFlowContainer warningContent;
public EpilepsyWarning()
{
RelativeSizeAxes = Axes.Both;
Alpha = 0f;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, IBindable<WorkingBeatmap> beatmap)
{
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f),
},
warningContent = new FillFlowContainer
{
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.");
}),
}
}
};
track = beatmap.Value.Track;
track.AddAdjustment(AdjustableProperty.Volume, trackVolumeOnEpilepsyWarning);
}
protected override void PopIn()
{
this.FadeIn(500, Easing.InQuint)
.TransformBindableTo(trackVolumeOnEpilepsyWarning, 0.25, 500, Easing.InQuint);
warningContent.FadeIn(500, Easing.InQuint);
}
protected override void PopOut() => this.FadeOut(500, Easing.InQuint);
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
track?.RemoveAdjustment(AdjustableProperty.Volume, trackVolumeOnEpilepsyWarning);
}
}
}
}