Add filter effect to beatmap loading

This commit is contained in:
Jamie Taylor 2021-10-07 14:15:16 +09:00
parent 99fb86878e
commit 5c48340520
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C
1 changed files with 9 additions and 2 deletions

View File

@ -15,6 +15,7 @@
using osu.Framework.Input;
using osu.Framework.Screens;
using osu.Framework.Threading;
using osu.Game.Audio.Effects;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@ -63,6 +64,8 @@ public class PlayerLoader : ScreenWithBeatmapBackground
private readonly BindableDouble volumeAdjustment = new BindableDouble(1);
private Filter lpFilter;
protected bool BackgroundBrightnessReduction
{
set
@ -127,7 +130,7 @@ public PlayerLoader(Func<Player> createPlayer)
}
[BackgroundDependencyLoader]
private void load(SessionStatics sessionStatics)
private void load(SessionStatics sessionStatics, AudioManager audio)
{
muteWarningShownOnce = sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce);
batteryWarningShownOnce = sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce);
@ -159,7 +162,8 @@ private void load(SessionStatics sessionStatics)
new InputSettings()
}
},
idleTracker = new IdleTracker(750)
idleTracker = new IdleTracker(750),
lpFilter = new Filter(audio.TrackMixer)
});
if (Beatmap.Value.BeatmapInfo.EpilepsyWarning)
@ -191,6 +195,7 @@ public override void OnEntering(IScreen last)
epilepsyWarning.DimmableBackground = b;
});
lpFilter.CutoffTo(500, 100, Easing.OutCubic);
Beatmap.Value.Track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment);
content.ScaleTo(0.7f);
@ -229,6 +234,7 @@ public override void OnSuspending(IScreen next)
// stop the track before removing adjustment to avoid a volume spike.
Beatmap.Value.Track.Stop();
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
lpFilter.CutoffTo(lpFilter.MaxCutoff);
}
public override bool OnExiting(IScreen next)
@ -242,6 +248,7 @@ public override bool OnExiting(IScreen next)
BackgroundBrightnessReduction = false;
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
lpFilter.CutoffTo(lpFilter.MaxCutoff, 100, Easing.InCubic);
return base.OnExiting(next);
}