1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-05 12:32:58 +08:00

Dim music volume when holding to confirm

This commit is contained in:
Dean Herbert 2019-06-04 18:37:26 +09:00
parent 76474987ef
commit 7d2a75b350

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);
}
}
}