Merge branch 'master' into flag-fit

This commit is contained in:
Dean Herbert 2020-10-26 14:19:32 +09:00
commit 7ed128e030
5 changed files with 56 additions and 33 deletions

View File

@ -6,6 +6,7 @@ using System.Linq;
using osu.Framework.Bindables;
using System.Collections.Generic;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
@ -38,20 +39,25 @@ namespace osu.Game.Rulesets.Osu.Mods
protected void ApplyTraceableState(DrawableHitObject drawable, ArmedState state)
{
if (!(drawable is DrawableOsuHitObject drawableOsu))
if (!(drawable is DrawableOsuHitObject))
return;
var h = drawableOsu.HitObject;
//todo: expose and hide spinner background somehow
switch (drawable)
{
case DrawableHitCircle circle:
// we only want to see the approach circle
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
circle.CirclePiece.Hide();
applyCirclePieceState(circle, circle.CirclePiece);
break;
case DrawableSliderTail sliderTail:
applyCirclePieceState(sliderTail);
break;
case DrawableSliderRepeat sliderRepeat:
// show only the repeat arrow
applyCirclePieceState(sliderRepeat, sliderRepeat.CirclePiece);
break;
case DrawableSlider slider:
@ -61,6 +67,13 @@ namespace osu.Game.Rulesets.Osu.Mods
}
}
private void applyCirclePieceState(DrawableOsuHitObject hitObject, IDrawable hitCircle = null)
{
var h = hitObject.HitObject;
using (hitObject.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
(hitCircle ?? hitObject).Hide();
}
private void applySliderState(DrawableSlider slider)
{
((PlaySliderBody)slider.Body.Drawable).AccentColour = slider.AccentColour.Value.Opacity(0);

View File

@ -265,6 +265,26 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddAssert($"epilepsy warning {(warning ? "present" : "absent")}", () => this.ChildrenOfType<EpilepsyWarning>().Any() == warning);
if (warning)
{
AddUntilStep("sound volume decreased", () => Beatmap.Value.Track.AggregateVolume.Value == 0.25);
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
}
}
[Test]
public void TestEpilepsyWarningEarlyExit()
{
AddStep("set epilepsy warning", () => epilepsyWarning = true);
AddStep("load dummy beatmap", () => ResetPlayer(false));
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddUntilStep("wait for epilepsy warning", () => loader.ChildrenOfType<EpilepsyWarning>().Single().Alpha > 0);
AddStep("exit early", () => loader.Exit());
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
}
private class TestPlayerLoaderContainer : Container

View File

@ -2,8 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -18,11 +16,7 @@ namespace osu.Game.Screens.Play
{
public class EpilepsyWarning : VisibilityContainer
{
public const double FADE_DURATION = 500;
private readonly BindableDouble trackVolumeOnEpilepsyWarning = new BindableDouble(1f);
private Track track;
public const double FADE_DURATION = 250;
public EpilepsyWarning()
{
@ -77,26 +71,15 @@ namespace osu.Game.Screens.Play
}
}
};
track = beatmap.Value.Track;
track.AddAdjustment(AdjustableProperty.Volume, trackVolumeOnEpilepsyWarning);
}
protected override void PopIn()
{
this.TransformBindableTo(trackVolumeOnEpilepsyWarning, 0.25, FADE_DURATION);
DimmableBackground?.FadeColour(OsuColour.Gray(0.5f), FADE_DURATION, Easing.OutQuint);
this.FadeIn(FADE_DURATION, Easing.OutQuint);
}
protected override void PopOut() => this.FadeOut(FADE_DURATION);
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
track?.RemoveAdjustment(AdjustableProperty.Volume, trackVolumeOnEpilepsyWarning);
}
}
}

View File

@ -55,6 +55,8 @@ namespace osu.Game.Screens.Play
private bool backgroundBrightnessReduction;
private readonly BindableDouble volumeAdjustment = new BindableDouble(1);
protected bool BackgroundBrightnessReduction
{
set
@ -169,6 +171,7 @@ namespace osu.Game.Screens.Play
if (epilepsyWarning != null)
epilepsyWarning.DimmableBackground = Background;
Beatmap.Value.Track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment);
content.ScaleTo(0.7f);
Background?.FadeColour(Color4.White, 800, Easing.OutQuint);
@ -197,6 +200,11 @@ namespace osu.Game.Screens.Play
cancelLoad();
BackgroundBrightnessReduction = false;
// we're moving to player, so a period of silence is upcoming.
// stop the track before removing adjustment to avoid a volume spike.
Beatmap.Value.Track.Stop();
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
}
public override bool OnExiting(IScreen next)
@ -208,6 +216,7 @@ namespace osu.Game.Screens.Play
Background.EnableUserDim.Value = false;
BackgroundBrightnessReduction = false;
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
return base.OnExiting(next);
}
@ -331,18 +340,16 @@ namespace osu.Game.Screens.Play
{
const double epilepsy_display_length = 3000;
pushSequence.Schedule(() =>
{
epilepsyWarning.State.Value = Visibility.Visible;
this.Delay(epilepsy_display_length).Schedule(() =>
pushSequence
.Schedule(() => epilepsyWarning.State.Value = Visibility.Visible)
.TransformBindableTo(volumeAdjustment, 0.25, EpilepsyWarning.FADE_DURATION, Easing.OutQuint)
.Delay(epilepsy_display_length)
.Schedule(() =>
{
epilepsyWarning.Hide();
epilepsyWarning.Expire();
});
});
pushSequence.Delay(epilepsy_display_length);
})
.Delay(EpilepsyWarning.FADE_DURATION);
}
pushSequence.Schedule(() =>

View File

@ -140,7 +140,7 @@ namespace osu.Game.Screens.Select.Carousel
LoadComponentAsync(beatmapContainer, loaded =>
{
// make sure the pooled target hasn't changed.
if (carouselBeatmapSet != Item)
if (beatmapContainer != loaded)
return;
Content.Child = loaded;