1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Trigger touch on click key area

This commit is contained in:
pikokr 2021-12-28 22:35:45 +09:00
parent 59b4aea5f9
commit 62d6bb8c2e
2 changed files with 23 additions and 20 deletions

View File

@ -136,24 +136,6 @@ namespace osu.Game.Rulesets.Mania.UI
{
}
private ManiaInputManager.RulesetKeyBindingContainer rulesetKeyBindingContainer { get; set; }
private ManiaInputManager.RulesetKeyBindingContainer getRulesetKeyBindingContainer()
{
return rulesetKeyBindingContainer ??= ((ManiaInputManager)GetContainingInputManager()).GetKeyBindingContainer();
}
protected override bool OnTouchDown(TouchDownEvent e)
{
getRulesetKeyBindingContainer().TriggerPressed(Action.Value);
return base.OnTouchDown(e);
}
protected override void OnTouchUp(TouchUpEvent e)
{
getRulesetKeyBindingContainer().TriggerReleased(Action.Value);
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
// This probably shouldn't exist as is, but the columns in the stage are separated by a 1px border
=> DrawRectangle.Inflate(new Vector2(Stage.COLUMN_SPACING / 2, 0)).Contains(ToLocalSpace(screenSpacePos));

View File

@ -36,10 +36,31 @@ namespace osu.Game.Rulesets.Mania.UI.Components
RelativeSizeAxes = Axes.Both;
}
public class ChildContainer : Container
{
private ManiaInputManager.RulesetKeyBindingContainer keyBindingContainer { get; set; }
private ManiaInputManager.RulesetKeyBindingContainer getKeyBindingContainer()
{
return keyBindingContainer ??= ((ManiaInputManager)GetContainingInputManager()).GetKeyBindingContainer();
}
protected override bool OnTouchDown(TouchDownEvent e)
{
getKeyBindingContainer().TriggerPressed(((DefaultKeyArea)Parent).column.Action.Value);
return base.OnTouchDown(e);
}
protected override void OnTouchUp(TouchUpEvent e)
{
getKeyBindingContainer().TriggerReleased(((DefaultKeyArea)Parent).column.Action.Value);
}
}
[BackgroundDependencyLoader]
private void load(IScrollingInfo scrollingInfo)
{
InternalChild = directionContainer = new Container
InternalChild = directionContainer = new ChildContainer
{
RelativeSizeAxes = Axes.X,
Height = Stage.HIT_TARGET_POSITION,
@ -69,7 +90,7 @@ namespace osu.Game.Rulesets.Mania.UI.Components
AlwaysPresent = true
}
}
}
},
}
};