Add back standard mouse bindings support and only handle mouse when inside the visible zone

This commit is contained in:
Dean Herbert 2022-07-22 18:07:10 +09:00
parent 4279ac866c
commit ec98693cca
2 changed files with 16 additions and 2 deletions

View File

@ -50,6 +50,8 @@ namespace osu.Game.Rulesets.Taiko
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
{
new KeyBinding(InputKey.MouseLeft, TaikoAction.LeftCentre),
new KeyBinding(InputKey.MouseRight, TaikoAction.LeftRim),
new KeyBinding(InputKey.D, TaikoAction.LeftRim),
new KeyBinding(InputKey.F, TaikoAction.LeftCentre),
new KeyBinding(InputKey.J, TaikoAction.RightCentre),

View File

@ -32,6 +32,8 @@ namespace osu.Game.Rulesets.Taiko.UI
private QuarterCircle leftCentre = null!;
private QuarterCircle rightCentre = null!;
private QuarterCircle leftRim = null!;
private QuarterCircle rightRim = null!;
[BackgroundDependencyLoader]
private void load(TaikoInputManager taikoInputManager, OsuColour colours)
@ -62,13 +64,13 @@ namespace osu.Game.Rulesets.Taiko.UI
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new QuarterCircle(TaikoAction.LeftRim, colours.YellowDark)
leftRim = new QuarterCircle(TaikoAction.LeftRim, colours.YellowDark)
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomRight,
X = -2,
},
new QuarterCircle(TaikoAction.RightRim, colours.YellowDark)
rightRim = new QuarterCircle(TaikoAction.RightRim, colours.YellowDark)
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomRight,
@ -106,12 +108,18 @@ namespace osu.Game.Rulesets.Taiko.UI
protected override bool OnMouseDown(MouseDownEvent e)
{
if (validMouse(e))
return false;
handleDown(e.Button, e.ScreenSpaceMousePosition);
return true;
}
protected override void OnMouseUp(MouseUpEvent e)
{
if (validMouse(e))
return;
handleUp(e.Button);
base.OnMouseUp(e);
}
@ -144,6 +152,10 @@ namespace osu.Game.Rulesets.Taiko.UI
trackedActions.Remove(source);
}
private bool validMouse(MouseButtonEvent e) =>
!leftRim.Contains(e.ScreenSpaceMouseDownPosition)
&& !rightRim.Contains(e.ScreenSpaceMouseDownPosition);
private TaikoAction getTaikoActionFromInput(Vector2 inputPosition)
{
bool centreHit = leftCentre.Contains(inputPosition) || rightCentre.Contains(inputPosition);