// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics.Containers; namespace osu.Game.Screens.Play.HUD { /// /// Keeps track of key press counts for a current play session, exposing bindable counts which can /// be used for display purposes. /// public partial class InputCountController : CompositeComponent { public readonly Bindable IsCounting = new BindableBool(true); public event Action? OnNewTrigger; private readonly Container triggers; public IReadOnlyList Triggers => triggers; public InputCountController() { InternalChild = triggers = new Container(); } public void Add(InputTrigger trigger) { triggers.Add(trigger); trigger.IsCounting.BindTo(IsCounting); OnNewTrigger?.Invoke(trigger); } public void AddRange(IEnumerable inputTriggers) => inputTriggers.ForEach(Add); public override bool HandleNonPositionalInput => true; public override bool HandlePositionalInput => true; } }