1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 04:13:00 +08:00

Change to manual adjustment add/remove

This commit is contained in:
Bartłomiej Dach 2020-10-25 12:33:35 +01:00
parent 85e14f3f0c
commit 0542a45c43

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
@ -104,9 +106,6 @@ namespace osu.Game.Screens.Play
[Resolved]
private AudioManager audioManager { get; set; }
[Resolved]
private MusicController musicController { get; set; }
public PlayerLoader(Func<Player> createPlayer)
{
this.createPlayer = createPlayer;
@ -172,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);
@ -200,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)
@ -211,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);
}
@ -335,11 +341,8 @@ namespace osu.Game.Screens.Play
const double epilepsy_display_length = 3000;
pushSequence
.Schedule(() =>
{
musicController.CurrentTrack.VolumeTo(0.25, EpilepsyWarning.FADE_DURATION, Easing.OutQuint);
epilepsyWarning.State.Value = Visibility.Visible;
})
.Schedule(() => epilepsyWarning.State.Value = Visibility.Visible)
.TransformBindableTo(volumeAdjustment, 0.25, EpilepsyWarning.FADE_DURATION, Easing.OutQuint)
.Delay(epilepsy_display_length)
.Schedule(() =>
{
@ -359,10 +362,6 @@ namespace osu.Game.Screens.Play
// Note that this may change if the player we load requested a re-run.
ValidForResume = false;
// restore full volume immediately - there's a usually a period of silence at start of gameplay anyway.
// note that this is delayed slightly to avoid volume spikes just before push.
musicController.CurrentTrack.Delay(50).VolumeTo(1);
if (player.LoadedBeatmapSuccessfully)
this.Push(player);
else
@ -378,10 +377,6 @@ namespace osu.Game.Screens.Play
private void cancelLoad()
{
// in case the epilepsy warning is being displayed, restore full volume.
if (epilepsyWarning?.IsAlive == true)
musicController.CurrentTrack.VolumeTo(1, EpilepsyWarning.FADE_DURATION, Easing.OutQuint);
scheduledPushPlayer?.Cancel();
scheduledPushPlayer = null;
}