1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 12:22:56 +08:00

Inverse and xmldoc ShearedToggleButton sample allowance bool

This commit is contained in:
Dean Herbert 2023-08-18 17:05:25 +09:00
parent c811546868
commit fc2fac577f
2 changed files with 13 additions and 9 deletions

View File

@ -14,7 +14,11 @@ namespace osu.Game.Graphics.UserInterface
private Sample? sampleOff;
private Sample? sampleOn;
protected virtual bool PlayClickSampleOnly => false;
/// <summary>
/// Sheared toggle buttons by default play two samples when toggled: a click and a toggle (on/off).
/// Sometimes this might be too much. Setting this to <c>false</c> will silence the toggle sound.
/// </summary>
protected virtual bool PlayToggleSamples => true;
/// <summary>
/// Whether this button is currently toggled to an active state.
@ -70,13 +74,13 @@ namespace osu.Game.Graphics.UserInterface
{
sampleClick?.Play();
if (PlayClickSampleOnly)
return;
if (Active.Value)
sampleOn?.Play();
else
sampleOff?.Play();
if (PlayToggleSamples)
{
if (Active.Value)
sampleOn?.Play();
else
sampleOff?.Play();
}
}
}
}

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Mods
{
public partial class AddPresetButton : ShearedToggleButton, IHasPopover
{
protected override bool PlayClickSampleOnly => true;
protected override bool PlayToggleSamples => false;
[Resolved]
private OsuColour colours { get; set; } = null!;