1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 04:13:03 +08:00

Removed redudent code & converted use of OnDrag to OnMouseMove`

This commit is contained in:
Josh 2022-09-08 20:39:53 +08:00
parent b9afe6f4cf
commit 888d8b2817
No known key found for this signature in database
GPG Key ID: B8D8E955D50CAA2C

View File

@ -13,6 +13,7 @@ using osu.Game.Graphics;
using osuTK.Graphics; using osuTK.Graphics;
using osuTK; using osuTK;
using System.Collections.Generic; using System.Collections.Generic;
using osuTK.Input;
namespace osu.Game.Rulesets.Catch.UI namespace osu.Game.Rulesets.Catch.UI
{ {
@ -119,45 +120,29 @@ namespace osu.Game.Rulesets.Catch.UI
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
if (getTouchCatchActionFromInput(e.ScreenSpaceMousePosition) == TouchCatchAction.None) return handleDown(e.Button, e.ScreenSpaceMousePosition);
return false;
handleDown(e.Button, e.ScreenSpaceMousePosition);
return true;
} }
protected override void OnMouseUp(MouseUpEvent e) protected override void OnMouseUp(MouseUpEvent e)
{ {
if (getTouchCatchActionFromInput(e.ScreenSpaceMousePosition) == TouchCatchAction.None)
return;
handleUp(e.Button); handleUp(e.Button);
base.OnMouseUp(e); base.OnMouseUp(e);
} }
protected override bool OnDragStart(DragStartEvent e) protected override bool OnMouseMove(MouseMoveEvent e)
{ {
return true; TouchCatchAction touchCatchAction = getTouchCatchActionFromInput(e.ScreenSpaceMousePosition);
}
protected override void OnDrag(DragEvent e) // Loop through the buttons to avoid keeping a button pressed if both mouse buttons are pressed.
{ foreach (MouseButton i in e.PressedButtons)
// I'm not sure if this is posible but let's be safe trackedActions[i] = touchCatchAction;
if (!trackedActions.ContainsKey(e.Button))
trackedActions.Add(e.Button, TouchCatchAction.None);
trackedActions[e.Button] = getTouchCatchActionFromInput(e.ScreenSpaceMousePosition);
calculateActiveKeys(); calculateActiveKeys();
return true;
base.OnDrag(e);
} }
protected override void OnTouchMove(TouchMoveEvent e) protected override void OnTouchMove(TouchMoveEvent e)
{ {
// I'm not sure if this is posible but let's be safe
if (!trackedActions.ContainsKey(e.Touch.Source))
trackedActions.Add(e.Touch.Source, TouchCatchAction.None);
trackedActions[e.Touch.Source] = getTouchCatchActionFromInput(e.ScreenSpaceTouch.Position); trackedActions[e.Touch.Source] = getTouchCatchActionFromInput(e.ScreenSpaceTouch.Position);
calculateActiveKeys(); calculateActiveKeys();
@ -194,18 +179,20 @@ namespace osu.Game.Rulesets.Catch.UI
keyBindingContainer.TriggerReleased(CatchAction.Dash); keyBindingContainer.TriggerReleased(CatchAction.Dash);
} }
private void handleDown(object source, Vector2 position) private bool handleDown(object source, Vector2 position)
{ {
Show();
TouchCatchAction catchAction = getTouchCatchActionFromInput(position); TouchCatchAction catchAction = getTouchCatchActionFromInput(position);
// Not too sure how this can happen, but let's avoid throwing. if (catchAction == TouchCatchAction.None)
if (trackedActions.ContainsKey(source)) return false;
return;
Show();
trackedActions[source] = catchAction;
trackedActions.Add(source, catchAction);
calculateActiveKeys(); calculateActiveKeys();
return true;
} }
private void handleUp(object source) private void handleUp(object source)