mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Show and hide osu!taiko touch controls overlay based on most recent input type detected
This commit is contained in:
parent
c33a661a49
commit
35053eaeba
@ -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
|
// 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 Dictionary<TouchSource, TaikoAction> touchActions = new Dictionary<TouchSource, TaikoAction>(Enum.GetNames(typeof(TouchSource)).Length);
|
||||||
|
|
||||||
|
private Container visibleComponents;
|
||||||
|
|
||||||
public DrumTouchInputArea() {
|
public DrumTouchInputArea() {
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
RelativePositionAxes = Axes.Both;
|
RelativePositionAxes = Axes.Both;
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Container() {
|
visibleComponents = new Container() {
|
||||||
|
Alpha = 0.0f,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RelativePositionAxes = Axes.Both,
|
RelativePositionAxes = Axes.Both,
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
@ -81,6 +84,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
{
|
{
|
||||||
|
ShowTouchControls();
|
||||||
mouseAction = getTaikoActionFromInput(e.ScreenSpaceMouseDownPosition);
|
mouseAction = getTaikoActionFromInput(e.ScreenSpaceMouseDownPosition);
|
||||||
keyBindingContainer?.TriggerPressed(mouseAction);
|
keyBindingContainer?.TriggerPressed(mouseAction);
|
||||||
return true;
|
return true;
|
||||||
@ -94,6 +98,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
protected override bool OnTouchDown(TouchDownEvent e)
|
protected override bool OnTouchDown(TouchDownEvent e)
|
||||||
{
|
{
|
||||||
|
ShowTouchControls();
|
||||||
TaikoAction taikoAction = getTaikoActionFromInput(e.ScreenSpaceTouchDownPosition);
|
TaikoAction taikoAction = getTaikoActionFromInput(e.ScreenSpaceTouchDownPosition);
|
||||||
touchActions.Add(e.Touch.Source, taikoAction);
|
touchActions.Add(e.Touch.Source, taikoAction);
|
||||||
keyBindingContainer?.TriggerPressed(touchActions[e.Touch.Source]);
|
keyBindingContainer?.TriggerPressed(touchActions[e.Touch.Source]);
|
||||||
@ -108,6 +113,21 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
base.OnTouchUp(e);
|
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) {
|
private TaikoAction getTaikoActionFromInput(Vector2 inputPosition) {
|
||||||
bool centreHit = inputIsCenterHit(inputPosition);
|
bool centreHit = inputIsCenterHit(inputPosition);
|
||||||
bool leftSide = inputIsOnLeftSide(inputPosition);
|
bool leftSide = inputIsOnLeftSide(inputPosition);
|
||||||
|
Loading…
Reference in New Issue
Block a user