mirror of
https://github.com/ppy/osu
synced 2025-01-15 18:41:14 +00:00
Toggle mute/unmute keyboard shortcut
This commit is contained in:
parent
0ee9bcd70c
commit
9277586907
@ -76,6 +76,10 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
else
|
||||
volumeMeterMaster.Increase();
|
||||
return true;
|
||||
case GlobalAction.ToggleMute:
|
||||
Show();
|
||||
volumeMeterMaster.ToogleMute();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -18,6 +18,9 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
private readonly Box meterFill;
|
||||
public BindableDouble Bindable { get; } = new BindableDouble();
|
||||
|
||||
private double lastVolume;
|
||||
public bool IsMuted { get; private set; }
|
||||
|
||||
public VolumeMeter(string meterName)
|
||||
{
|
||||
Size = new Vector2(40, 180);
|
||||
@ -70,16 +73,19 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
|
||||
public double Volume
|
||||
{
|
||||
get { return Bindable.Value; }
|
||||
get => Bindable.Value;
|
||||
private set
|
||||
{
|
||||
Bindable.Value = value;
|
||||
if (value > 0)
|
||||
IsMuted = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Increase()
|
||||
{
|
||||
Volume += 0.05f;
|
||||
IsMuted = false;
|
||||
}
|
||||
|
||||
public void Decrease()
|
||||
@ -87,6 +93,14 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
Volume -= 0.05f;
|
||||
}
|
||||
|
||||
public void ToogleMute()
|
||||
{
|
||||
IsMuted = !IsMuted;
|
||||
if (IsMuted)
|
||||
lastVolume = Volume;
|
||||
Volume = IsMuted ? 0.0 : lastVolume;
|
||||
}
|
||||
|
||||
private void updateFill() => meterFill.ScaleTo(new Vector2(1, (float)Volume), 300, Easing.OutQuint);
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
|
@ -33,6 +33,7 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(new[] { InputKey.MouseWheelUp }, GlobalAction.IncreaseVolume),
|
||||
new KeyBinding(new[] { InputKey.Down }, GlobalAction.DecreaseVolume),
|
||||
new KeyBinding(new[] { InputKey.MouseWheelDown }, GlobalAction.DecreaseVolume),
|
||||
new KeyBinding(InputKey.F4, GlobalAction.ToggleMute),
|
||||
};
|
||||
|
||||
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
|
||||
@ -62,6 +63,8 @@ namespace osu.Game.Input.Bindings
|
||||
IncreaseVolume,
|
||||
[Description("Decrease Volume")]
|
||||
DecreaseVolume,
|
||||
[Description("Toggle mute")]
|
||||
ToggleMute,
|
||||
|
||||
// In-Game Keybindings
|
||||
[Description("Skip Cutscene")]
|
||||
|
Loading…
Reference in New Issue
Block a user