2023-06-15 03:13:35 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2023-06-27 15:39:21 +08:00
|
|
|
using osu.Framework.Graphics;
|
2023-06-15 03:13:35 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
2023-06-26 15:47:33 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Keeps track of key press counts for a current play session, exposing bindable counts which can
|
|
|
|
/// be used for display purposes.
|
|
|
|
/// </summary>
|
2023-06-27 15:39:21 +08:00
|
|
|
public partial class InputCountController : Component
|
2023-06-15 03:13:35 +08:00
|
|
|
{
|
|
|
|
public readonly Bindable<bool> IsCounting = new BindableBool(true);
|
|
|
|
|
2023-06-27 15:35:59 +08:00
|
|
|
private readonly BindableList<InputTrigger> triggers = new BindableList<InputTrigger>();
|
2023-06-15 03:13:35 +08:00
|
|
|
|
2023-06-27 15:35:59 +08:00
|
|
|
public IBindableList<InputTrigger> Triggers => triggers;
|
2023-06-15 03:13:35 +08:00
|
|
|
|
2023-06-27 15:35:59 +08:00
|
|
|
public void AddRange(IEnumerable<InputTrigger> triggers) => triggers.ForEach(Add);
|
2023-06-15 03:13:35 +08:00
|
|
|
|
|
|
|
public void Add(InputTrigger trigger)
|
|
|
|
{
|
2023-06-27 15:35:59 +08:00
|
|
|
// Note that these triggers are not added to the hierarchy here. It is presumed they are added externally at a
|
|
|
|
// more correct location (ie. inside a RulesetInputManager).
|
2023-06-15 03:13:35 +08:00
|
|
|
triggers.Add(trigger);
|
|
|
|
trigger.IsCounting.BindTo(IsCounting);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|