1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-29 05:29:59 +08:00

Inverse and xmldoc ShearedToggleButton sample allowance bool

This commit is contained in:
Dean Herbert
2023-08-18 17:05:25 +09:00
Unverified
parent c811546868
commit fc2fac577f
2 changed files with 13 additions and 9 deletions
@@ -14,7 +14,11 @@ namespace osu.Game.Graphics.UserInterface
private Sample? sampleOff; private Sample? sampleOff;
private Sample? sampleOn; 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> /// <summary>
/// Whether this button is currently toggled to an active state. /// Whether this button is currently toggled to an active state.
@@ -70,13 +74,13 @@ namespace osu.Game.Graphics.UserInterface
{ {
sampleClick?.Play(); sampleClick?.Play();
if (PlayClickSampleOnly) if (PlayToggleSamples)
return; {
if (Active.Value)
if (Active.Value) sampleOn?.Play();
sampleOn?.Play(); else
else sampleOff?.Play();
sampleOff?.Play(); }
} }
} }
} }
+1 -1
View File
@@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Mods
{ {
public partial class AddPresetButton : ShearedToggleButton, IHasPopover public partial class AddPresetButton : ShearedToggleButton, IHasPopover
{ {
protected override bool PlayClickSampleOnly => true; protected override bool PlayToggleSamples => false;
[Resolved] [Resolved]
private OsuColour colours { get; set; } = null!; private OsuColour colours { get; set; } = null!;