mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +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:
commit
fc22b8584a
@ -2,6 +2,8 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
@ -17,6 +19,11 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
private Box overlay;
|
private Box overlay;
|
||||||
|
|
||||||
|
private readonly BindableDouble audioVolume = new BindableDouble(1);
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private AudioManager audio { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user