mirror of
https://github.com/ppy/osu.git
synced 2025-03-02 03:33:21 +08:00
Replace manual usages of AudioFilter
with new ducking methods
This commit is contained in:
parent
a56751511e
commit
0d11b2b91c
@ -7,11 +7,11 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Audio.Effects;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Collections
|
||||
@ -21,11 +21,12 @@ namespace osu.Game.Collections
|
||||
private const double enter_duration = 500;
|
||||
private const double exit_duration = 200;
|
||||
|
||||
private AudioFilter lowPassFilter = null!;
|
||||
|
||||
protected override string PopInSampleName => @"UI/overlay-big-pop-in";
|
||||
protected override string PopOutSampleName => @"UI/overlay-big-pop-out";
|
||||
|
||||
[Resolved]
|
||||
private MusicController? musicController { get; set; }
|
||||
|
||||
public ManageCollectionsDialog()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
@ -110,19 +111,14 @@ namespace osu.Game.Collections
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
lowPassFilter = new AudioFilter(audio.TrackMixer)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override bool IsPresent => base.IsPresent
|
||||
// Safety for low pass filter potentially getting stuck in applied state due to
|
||||
// transforms on `this` causing children to no longer be updated.
|
||||
|| lowPassFilter.IsAttached;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
lowPassFilter.CutoffTo(300, 100, Easing.OutCubic);
|
||||
musicController?.Duck(100, 1f);
|
||||
|
||||
this.FadeIn(enter_duration, Easing.OutQuint);
|
||||
this.ScaleTo(0.9f).Then().ScaleTo(1f, enter_duration, Easing.OutQuint);
|
||||
}
|
||||
@ -131,7 +127,7 @@ namespace osu.Game.Collections
|
||||
{
|
||||
base.PopOut();
|
||||
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, 100, Easing.InCubic);
|
||||
musicController?.Unduck(100);
|
||||
|
||||
this.FadeOut(exit_duration, Easing.OutQuint);
|
||||
this.ScaleTo(0.9f, exit_duration);
|
||||
|
@ -10,7 +10,6 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Audio.Effects;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
@ -48,6 +47,9 @@ namespace osu.Game.Overlays.Dialog
|
||||
|
||||
private partial class DangerousConfirmContainer : HoldToConfirmContainer
|
||||
{
|
||||
[Resolved]
|
||||
private MusicController musicController { get; set; }
|
||||
|
||||
public DangerousConfirmContainer()
|
||||
: base(isDangerousAction: true)
|
||||
{
|
||||
@ -56,7 +58,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
private Sample tickSample;
|
||||
private Sample confirmSample;
|
||||
private double lastTickPlaybackTime;
|
||||
private AudioFilter lowPassFilter = null!;
|
||||
private bool mouseDown;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -64,8 +65,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
{
|
||||
tickSample = audio.Samples.Get(@"UI/dialog-dangerous-tick");
|
||||
confirmSample = audio.Samples.Get(@"UI/dialog-dangerous-select");
|
||||
|
||||
AddInternal(lowPassFilter = new AudioFilter(audio.SampleMixer));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -76,13 +75,13 @@ namespace osu.Game.Overlays.Dialog
|
||||
|
||||
protected override void AbortConfirm()
|
||||
{
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
|
||||
musicController?.Unduck();
|
||||
base.AbortConfirm();
|
||||
}
|
||||
|
||||
protected override void Confirm()
|
||||
{
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
|
||||
musicController?.Duck();
|
||||
confirmSample?.Play();
|
||||
base.Confirm();
|
||||
}
|
||||
@ -126,8 +125,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
|
||||
if (Clock.CurrentTime - lastTickPlaybackTime < 30) return;
|
||||
|
||||
lowPassFilter.CutoffTo((int)(progress.NewValue * AudioFilter.MAX_LOWPASS_CUTOFF * 0.5));
|
||||
|
||||
var channel = tickSample.GetChannel();
|
||||
|
||||
channel.Frequency.Value = 1 + progress.NewValue * 0.5f;
|
||||
|
@ -10,9 +10,7 @@ using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input.Bindings;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Audio.Effects;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -23,15 +21,13 @@ namespace osu.Game.Overlays
|
||||
protected override string PopInSampleName => "UI/dialog-pop-in";
|
||||
protected override string PopOutSampleName => "UI/dialog-pop-out";
|
||||
|
||||
private AudioFilter lowPassFilter;
|
||||
[Resolved]
|
||||
private MusicController musicController { get; set; }
|
||||
|
||||
public PopupDialog CurrentDialog { get; private set; }
|
||||
|
||||
public override bool IsPresent => Scheduler.HasPendingTasks
|
||||
|| dialogContainer.Children.Count > 0
|
||||
// Safety for low pass filter potentially getting stuck in applied state due to
|
||||
// transforms on `this` causing children to no longer be updated.
|
||||
|| lowPassFilter.IsAttached;
|
||||
|| dialogContainer.Children.Count > 0;
|
||||
|
||||
public DialogOverlay()
|
||||
{
|
||||
@ -49,12 +45,6 @@ namespace osu.Game.Overlays
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
AddInternal(lowPassFilter = new AudioFilter(audio.TrackMixer));
|
||||
}
|
||||
|
||||
public void Push(PopupDialog dialog)
|
||||
{
|
||||
if (dialog == CurrentDialog || dialog.State.Value == Visibility.Hidden) return;
|
||||
@ -105,13 +95,13 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
lowPassFilter.CutoffTo(300, 100, Easing.OutCubic);
|
||||
musicController.Duck(100, 1f);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, 100, Easing.InCubic);
|
||||
musicController.Unduck(100);
|
||||
|
||||
// PopOut gets called initially, but we only want to hide dialog when we have been loaded and are present.
|
||||
if (IsLoaded && CurrentDialog?.State.Value == Visibility.Visible)
|
||||
|
Loading…
Reference in New Issue
Block a user