From af1e97b7c73fb476c9208051d8f47fa9aa579837 Mon Sep 17 00:00:00 2001 From: Susko3 <16479013+Susko3@users.noreply.github.com> Date: Wed, 8 Dec 2021 09:49:36 +0100 Subject: [PATCH] Move playing text added samples to private helper and fix it never playing the last sample `RNG.Next` is exclusive of the upper bound, meaning that the last sample would never be played. --- osu.Game/Graphics/UserInterface/OsuTextBox.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTextBox.cs b/osu.Game/Graphics/UserInterface/OsuTextBox.cs index 96319b9fdd..145e51b05a 100644 --- a/osu.Game/Graphics/UserInterface/OsuTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTextBox.cs @@ -86,6 +86,8 @@ namespace osu.Game.Graphics.UserInterface protected override Color4 SelectionColour => selectionColour; + private void playTextAddedSample() => textAddedSamples[RNG.Next(0, textAddedSamples.Length)]?.Play(); + protected override void OnUserTextAdded(string added) { base.OnUserTextAdded(added); @@ -93,7 +95,7 @@ namespace osu.Game.Graphics.UserInterface if (added.Any(char.IsUpper) && AllowUniqueCharacterSamples) capsTextAddedSample?.Play(); else - textAddedSamples[RNG.Next(0, 3)]?.Play(); + playTextAddedSample(); } protected override void OnUserTextRemoved(string removed)