1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:33:20 +08:00

Show and hide osu!taiko touch controls overlay based on most recent input type detected

This commit is contained in:
Aaron Hong 2022-03-11 04:43:57 -08:00
parent c33a661a49
commit 35053eaeba

View File

@ -35,12 +35,15 @@ namespace osu.Game.Rulesets.Taiko.UI
// A map of (Finger Index OnTouchDown -> Which Taiko action was pressed), so that the corresponding action can be released OnTouchUp is released even if the touch position moved
private Dictionary<TouchSource, TaikoAction> touchActions = new Dictionary<TouchSource, TaikoAction>(Enum.GetNames(typeof(TouchSource)).Length);
private Container visibleComponents;
public DrumTouchInputArea() {
RelativeSizeAxes = Axes.Both;
RelativePositionAxes = Axes.Both;
Children = new Drawable[]
{
new Container() {
visibleComponents = new Container() {
Alpha = 0.0f,
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both,
Anchor = Anchor.BottomCentre,
@ -81,6 +84,7 @@ namespace osu.Game.Rulesets.Taiko.UI
protected override bool OnMouseDown(MouseDownEvent e)
{
ShowTouchControls();
mouseAction = getTaikoActionFromInput(e.ScreenSpaceMouseDownPosition);
keyBindingContainer?.TriggerPressed(mouseAction);
return true;
@ -94,6 +98,7 @@ namespace osu.Game.Rulesets.Taiko.UI
protected override bool OnTouchDown(TouchDownEvent e)
{
ShowTouchControls();
TaikoAction taikoAction = getTaikoActionFromInput(e.ScreenSpaceTouchDownPosition);
touchActions.Add(e.Touch.Source, taikoAction);
keyBindingContainer?.TriggerPressed(touchActions[e.Touch.Source]);
@ -108,6 +113,21 @@ namespace osu.Game.Rulesets.Taiko.UI
base.OnTouchUp(e);
}
protected override bool OnKeyDown(KeyDownEvent e)
{
HideTouchControls();
return false;
}
public void ShowTouchControls() {
visibleComponents.Animate(components => components.FadeIn(500, Easing.OutQuint));
}
public void HideTouchControls() {
visibleComponents.Animate(components => components.FadeOut(2000, Easing.OutQuint));
}
private TaikoAction getTaikoActionFromInput(Vector2 inputPosition) {
bool centreHit = inputIsCenterHit(inputPosition);
bool leftSide = inputIsOnLeftSide(inputPosition);