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;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
2023-06-26 15:32:04 +08:00
|
|
|
public partial class KeyCounterController : CompositeComponent
|
2023-06-15 03:13:35 +08:00
|
|
|
{
|
|
|
|
public readonly Bindable<bool> IsCounting = new BindableBool(true);
|
|
|
|
|
|
|
|
public event Action<InputTrigger>? OnNewTrigger;
|
|
|
|
|
|
|
|
private readonly Container<InputTrigger> triggers;
|
|
|
|
|
|
|
|
public IReadOnlyList<InputTrigger> Triggers => triggers;
|
|
|
|
|
|
|
|
public KeyCounterController()
|
|
|
|
{
|
|
|
|
InternalChild = triggers = new Container<InputTrigger>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Add(InputTrigger trigger)
|
|
|
|
{
|
|
|
|
triggers.Add(trigger);
|
|
|
|
trigger.IsCounting.BindTo(IsCounting);
|
|
|
|
OnNewTrigger?.Invoke(trigger);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void AddRange(IEnumerable<InputTrigger> inputTriggers) => inputTriggers.ForEach(Add);
|
2023-06-19 03:26:16 +08:00
|
|
|
public override bool HandleNonPositionalInput => true;
|
2023-06-15 03:13:35 +08:00
|
|
|
|
2023-06-19 03:26:16 +08:00
|
|
|
public override bool HandlePositionalInput => true;
|
2023-06-15 03:13:35 +08:00
|
|
|
}
|
|
|
|
}
|