1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 02:32:55 +08:00

Add key binding for tap button

This commit is contained in:
Dean Herbert 2022-06-02 12:27:11 +09:00
parent 781a1527b1
commit 0c493dd359
3 changed files with 32 additions and 2 deletions

View File

@ -80,6 +80,7 @@ namespace osu.Game.Input.Bindings
new KeyBinding(new[] { InputKey.K }, GlobalAction.EditorNudgeRight),
new KeyBinding(new[] { InputKey.G }, GlobalAction.EditorCycleGridDisplayMode),
new KeyBinding(new[] { InputKey.F5 }, GlobalAction.EditorTestGameplay),
new KeyBinding(new[] { InputKey.T }, GlobalAction.EditorTapForBPM),
new KeyBinding(new[] { InputKey.Control, InputKey.H }, GlobalAction.EditorFlipHorizontally),
new KeyBinding(new[] { InputKey.Control, InputKey.J }, GlobalAction.EditorFlipVertically),
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.MouseWheelDown }, GlobalAction.EditorDecreaseDistanceSpacing),
@ -322,5 +323,8 @@ namespace osu.Game.Input.Bindings
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.DeselectAllMods))]
DeselectAllMods,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorTapForBPM))]
EditorTapForBPM,
}
}

View File

@ -174,6 +174,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString EditorTimingMode => new TranslatableString(getKey(@"editor_timing_mode"), @"Timing mode");
/// <summary>
/// "Tap for BPM"
/// </summary>
public static LocalisableString EditorTapForBPM => new TranslatableString(getKey(@"editor_tap_for_bpm"), @"Tap for BPM");
/// <summary>
/// "Cycle grid display mode"
/// </summary>

View File

@ -15,18 +15,21 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osuTK;
using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Screens.Edit.Timing
{
internal class TapButton : CircularContainer
internal class TapButton : CircularContainer, IKeyBindingHandler<GlobalAction>
{
public const float SIZE = 140;
@ -57,6 +60,8 @@ namespace osu.Game.Screens.Edit.Timing
private const int light_count = 6;
private readonly List<double> tapTimings = new List<double>();
[BackgroundDependencyLoader]
private void load()
{
@ -257,7 +262,23 @@ namespace osu.Game.Screens.Edit.Timing
base.OnMouseUp(e);
}
private readonly List<double> tapTimings = new List<double>();
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Action == GlobalAction.EditorTapForBPM && !e.Repeat)
{
// Direct through mouse handling to achieve animation
OnMouseDown(new MouseDownEvent(e.CurrentState, MouseButton.Left));
return true;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
if (e.Action == GlobalAction.EditorTapForBPM)
OnMouseUp(new MouseUpEvent(e.CurrentState, MouseButton.Left));
}
private void reset()
{