mirror of
https://github.com/ppy/osu.git
synced 2024-11-08 09:27:32 +08:00
74a58fb674
To implement different different sources of input for KeyCounter, it is now possible to create a Trigger class (to inherit) instead of inheriting KeyCounter. This eases the creation of more input sources (like for tests) while allowing to implement different UI variants. That way, if another variant of the key counter needs to implemented (for whathever reason), this can be done by only inheriting KeyCounter and changing how things are arranged visually.
38 lines
824 B
C#
38 lines
824 B
C#
// 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.
|
|
|
|
#nullable disable
|
|
|
|
using osu.Framework.Input.Events;
|
|
using osuTK.Input;
|
|
|
|
namespace osu.Game.Screens.Play
|
|
{
|
|
public partial class KeyCounterKeyboard : KeyCounter.Trigger
|
|
{
|
|
public Key Key { get; }
|
|
|
|
public KeyCounterKeyboard(Key key)
|
|
: base(key.ToString())
|
|
{
|
|
Key = key;
|
|
}
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
|
{
|
|
if (e.Key == Key)
|
|
Lit();
|
|
|
|
return base.OnKeyDown(e);
|
|
}
|
|
|
|
protected override void OnKeyUp(KeyUpEvent e)
|
|
{
|
|
if (e.Key == Key)
|
|
Unlit();
|
|
|
|
base.OnKeyUp(e);
|
|
}
|
|
}
|
|
}
|