Fix background dim application to avoid overdraw, transition smoother

This commit is contained in:
Dean Herbert 2020-10-20 15:03:12 +09:00
parent fd4bab85cf
commit 4e57751ca1
2 changed files with 10 additions and 11 deletions

View File

@ -5,16 +5,14 @@ using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Screens.Backgrounds;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -31,16 +29,13 @@ namespace osu.Game.Screens.Play
Alpha = 0f; Alpha = 0f;
} }
public BackgroundScreenBeatmap DimmableBackground { get; set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, IBindable<WorkingBeatmap> beatmap) private void load(OsuColour colours, IBindable<WorkingBeatmap> beatmap)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f),
},
warningContent = new FillFlowContainer warningContent = new FillFlowContainer
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -88,10 +83,11 @@ namespace osu.Game.Screens.Play
protected override void PopIn() protected override void PopIn()
{ {
this.FadeIn(500, Easing.InQuint) this.TransformBindableTo(trackVolumeOnEpilepsyWarning, 0.25, FADE_DURATION);
.TransformBindableTo(trackVolumeOnEpilepsyWarning, 0.25, 500, Easing.InQuint);
warningContent.FadeIn(500, Easing.InQuint); DimmableBackground?.FadeColour(OsuColour.Gray(0.5f), FADE_DURATION, Easing.OutQuint);
this.FadeIn(FADE_DURATION, Easing.OutQuint);
} }
protected override void PopOut() protected override void PopOut()

View File

@ -167,6 +167,9 @@ namespace osu.Game.Screens.Play
{ {
base.OnEntering(last); base.OnEntering(last);
if (epilepsyWarning != null)
epilepsyWarning.DimmableBackground = Background;
content.ScaleTo(0.7f); content.ScaleTo(0.7f);
Background?.FadeColour(Color4.White, 800, Easing.OutQuint); Background?.FadeColour(Color4.White, 800, Easing.OutQuint);