2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-11-13 22:35:50 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2023-03-07 15:28:54 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2023-02-22 23:03:44 +08:00
|
|
|
|
public partial class KeyCounterActionTrigger<T> : InputTrigger
|
2018-04-13 17:19:50 +08:00
|
|
|
|
where T : struct
|
|
|
|
|
{
|
|
|
|
|
public T Action { get; }
|
|
|
|
|
|
2023-02-14 07:49:57 +08:00
|
|
|
|
public KeyCounterActionTrigger(T action)
|
2019-02-28 12:31:40 +08:00
|
|
|
|
: base($"B{(int)(object)action + 1}")
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Action = action;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-12 14:41:53 +08:00
|
|
|
|
public bool OnPressed(T action, bool forwards)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-13 22:35:50 +08:00
|
|
|
|
if (!EqualityComparer<T>.Default.Equals(action, Action))
|
2019-09-12 14:41:53 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
2023-02-17 07:15:03 +08:00
|
|
|
|
Activate(forwards);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-22 12:22:34 +08:00
|
|
|
|
public void OnReleased(T action, bool forwards)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-13 22:35:50 +08:00
|
|
|
|
if (!EqualityComparer<T>.Default.Equals(action, Action))
|
2020-01-22 12:22:34 +08:00
|
|
|
|
return;
|
2019-09-12 14:41:53 +08:00
|
|
|
|
|
2023-02-17 07:15:03 +08:00
|
|
|
|
Deactivate(forwards);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|