1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Consolidate HoverClickSounds constructors

As suggested in review, merge both HoverClickSounds constructors into
one accepting optional arguments. Due to existing usages the parameter
is added as second and supplied by name in ModButton.
This commit is contained in:
Bartłomiej Dach 2019-09-01 13:10:11 +02:00
parent 658e0edc3e
commit c4dc34eefd
2 changed files with 7 additions and 13 deletions

View File

@ -20,24 +20,18 @@ namespace osu.Game.Graphics.UserInterface
private SampleChannel sampleClick;
private readonly MouseButton[] buttons;
/// <summary>
/// Creates an instance that adds sounds on hover and left click only.
/// </summary>
/// <param name="sampleSet">Set of click samples to play.</param>
public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal)
: this(new[] { MouseButton.Left }, sampleSet)
{
}
/// <summary>
/// Creates an instance that adds sounds on hover and on click for any of the buttons specified.
/// </summary>
/// <param name="buttons">Array of button codes which should trigger the click sound.</param>
/// <param name="sampleSet">Set of click samples to play.</param>
public HoverClickSounds(MouseButton[] buttons, HoverSampleSet sampleSet = HoverSampleSet.Normal)
/// <param name="buttons">
/// Array of button codes which should trigger the click sound.
/// If this optional parameter is omitted or set to <code>null</code>, the click sound will also be added on left click.
/// </param>
public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal, MouseButton[] buttons = null)
: base(sampleSet)
{
this.buttons = buttons;
this.buttons = buttons ?? new[] { MouseButton.Left };
}
protected override bool OnMouseUp(MouseUpEvent e)

View File

@ -283,7 +283,7 @@ namespace osu.Game.Overlays.Mods
Anchor = Anchor.TopCentre,
Font = OsuFont.GetFont(size: 18)
},
new HoverClickSounds(new[] { MouseButton.Left, MouseButton.Right })
new HoverClickSounds(buttons: new[] { MouseButton.Left, MouseButton.Right })
};
Mod = mod;