osu/osu.Game/Screens/Play/KeyCounterAction.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1023 B
C#
Raw Normal View History

// 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 09:19:50 +00:00
2019-11-13 14:35:50 +00:00
using System.Collections.Generic;
namespace osu.Game.Screens.Play
{
public class KeyCounterAction<T> : KeyCounter
where T : struct
{
public T Action { get; }
2018-04-13 09:19:50 +00:00
2019-02-28 04:31:40 +00:00
public KeyCounterAction(T action)
: base($"B{(int)(object)action + 1}")
{
Action = action;
}
2018-04-13 09:19:50 +00:00
public bool OnPressed(T action, bool forwards)
{
2019-11-13 14:35:50 +00:00
if (!EqualityComparer<T>.Default.Equals(action, Action))
return false;
IsLit = true;
if (forwards)
Increment();
return false;
}
2018-04-13 09:19:50 +00:00
public void OnReleased(T action, bool forwards)
{
2019-11-13 14:35:50 +00:00
if (!EqualityComparer<T>.Default.Equals(action, Action))
return;
IsLit = false;
if (!forwards)
Decrement();
}
}
2018-01-05 11:21:19 +00:00
}