1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:47:29 +08:00

Hook up input manager

This commit is contained in:
Dan Balasescu 2024-04-04 17:25:05 +09:00 committed by Dean Herbert
parent ef40197713
commit 39337f5189
No known key found for this signature in database

View File

@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Mania.UI
receptorGridDimensions.Add(new Dimension(GridSizeMode.AutoSize));
}
receptorGridContent.Add(new InputReceptor());
receptorGridContent.Add(new InputReceptor { Action = { BindTarget = column.Action } });
receptorGridDimensions.Add(new Dimension());
first = false;
@ -72,8 +72,15 @@ namespace osu.Game.Rulesets.Mania.UI
public partial class InputReceptor : CompositeDrawable
{
public readonly IBindable<ManiaAction> Action = new Bindable<ManiaAction>();
private readonly Box highlightOverlay;
[Resolved]
private ManiaInputManager? inputManager { get; set; }
private bool isPressed;
public InputReceptor()
{
RelativeSizeAxes = Axes.Both;
@ -105,29 +112,43 @@ namespace osu.Game.Rulesets.Mania.UI
protected override bool OnTouchDown(TouchDownEvent e)
{
updateHighlight(true);
updateButton(true);
return true;
}
protected override void OnTouchUp(TouchUpEvent e)
{
updateHighlight(false);
updateButton(false);
}
protected override bool OnMouseDown(MouseDownEvent e)
{
updateHighlight(true);
updateButton(true);
return true;
}
protected override void OnMouseUp(MouseUpEvent e)
{
updateHighlight(false);
updateButton(false);
}
private void updateHighlight(bool enabled)
private void updateButton(bool press)
{
highlightOverlay.FadeTo(enabled ? 0.1f : 0, enabled ? 80 : 400, Easing.OutQuint);
if (press == isPressed)
return;
isPressed = press;
if (press)
{
inputManager?.KeyBindingContainer?.TriggerPressed(Action.Value);
highlightOverlay.FadeTo(0.1f, 80, Easing.OutQuint);
}
else
{
inputManager?.KeyBindingContainer?.TriggerReleased(Action.Value);
highlightOverlay.FadeTo(0, 400, Easing.OutQuint);
}
}
}