1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

Dim music volume when holding to confirm (#4907)

Dim music volume when holding to confirm

Co-authored-by: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com>
This commit is contained in:
Dean Herbert 2019-06-06 16:26:18 +09:00 committed by GitHub
commit fc22b8584a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers;
@ -17,6 +19,11 @@ namespace osu.Game.Overlays
{
private Box overlay;
private readonly BindableDouble audioVolume = new BindableDouble(1);
[Resolved]
private AudioManager audio { get; set; }
[BackgroundDependencyLoader]
private void load()
{
@ -33,7 +40,19 @@ namespace osu.Game.Overlays
}
};
Progress.ValueChanged += p => overlay.Alpha = (float)p.NewValue;
Progress.ValueChanged += p =>
{
audioVolume.Value = 1 - p.NewValue;
overlay.Alpha = (float)p.NewValue;
};
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, audioVolume);
}
protected override void Dispose(bool isDisposing)
{
audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, audioVolume);
base.Dispose(isDisposing);
}
}
}