1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-12 11:52:57 +08:00

Add audio feedback for invalid textbox input

This commit is contained in:
Jamie Taylor 2022-08-31 17:23:22 +09:00
parent cc9dc604a0
commit 212d76a11f
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C

View File

@ -53,6 +53,7 @@ namespace osu.Game.Graphics.UserInterface
TextAddCaps,
TextRemove,
TextConfirm,
TextInvalid,
CaretMove,
SelectCharacter,
SelectWord,
@ -95,6 +96,7 @@ namespace osu.Game.Graphics.UserInterface
{ FeedbackSampleType.TextAddCaps, new[] { audio.Samples.Get(@"Keyboard/key-caps") } },
{ FeedbackSampleType.TextRemove, new[] { audio.Samples.Get(@"Keyboard/key-delete") } },
{ FeedbackSampleType.TextConfirm, new[] { audio.Samples.Get(@"Keyboard/key-confirm") } },
{ FeedbackSampleType.TextInvalid, new[] { audio.Samples.Get(@"Keyboard/key-invalid") } },
{ FeedbackSampleType.CaretMove, new[] { audio.Samples.Get(@"Keyboard/key-movement") } },
{ FeedbackSampleType.SelectCharacter, new[] { audio.Samples.Get(@"Keyboard/select-char") } },
{ FeedbackSampleType.SelectWord, new[] { audio.Samples.Get(@"Keyboard/select-word") } },
@ -111,6 +113,9 @@ namespace osu.Game.Graphics.UserInterface
{
base.OnUserTextAdded(added);
if (!added.Any(CanAddCharacter))
return;
if (added.Any(char.IsUpper) && AllowUniqueCharacterSamples)
playSample(FeedbackSampleType.TextAddCaps);
else
@ -124,6 +129,13 @@ namespace osu.Game.Graphics.UserInterface
playSample(FeedbackSampleType.TextRemove);
}
protected override void NotifyInputError()
{
base.NotifyInputError();
playSample(FeedbackSampleType.TextInvalid);
}
protected override void OnTextCommitted(bool textChanged)
{
base.OnTextCommitted(textChanged);