1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Column Touch area & highlighting on start

This commit is contained in:
pikokr 2021-12-30 17:37:14 +09:00
parent dec1f31749
commit 4cb8272d14
2 changed files with 60 additions and 23 deletions

View File

@ -44,6 +44,63 @@ namespace osu.Game.Rulesets.Mania.UI
private readonly GameplaySampleTriggerSource sampleTriggerSource;
public class ColumnTouchInputArea : Container
{
private Column column => (Column)Parent;
private Container hintContainer;
public ColumnTouchInputArea()
{
RelativeSizeAxes = Axes.X;
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
Height = 100;
InternalChild = hintContainer = new Container
{
RelativeSizeAxes = Axes.Both,
BorderColour = Color4.Red,
BorderThickness = 5,
Masking = true,
};
}
protected override void LoadComplete()
{
hintContainer.Delay(1000).FadeOutFromOne(500, Easing.OutSine);
}
private ManiaInputManager.RulesetKeyBindingContainer keyBindingContainer { get; set; }
private ManiaInputManager.RulesetKeyBindingContainer getKeyBindingContainer()
{
return keyBindingContainer ??= (ManiaInputManager.RulesetKeyBindingContainer)((ManiaInputManager)GetContainingInputManager()).KeyBindingContainer;
}
protected override bool OnTouchDown(TouchDownEvent e)
{
getKeyBindingContainer().TriggerPressed(column.Action.Value);
return base.OnTouchDown(e);
}
protected override bool OnMouseDown(MouseDownEvent e)
{
getKeyBindingContainer().TriggerPressed(column.Action.Value);
return base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseUpEvent e)
{
getKeyBindingContainer().TriggerReleased(column.Action.Value);
}
protected override void OnTouchUp(TouchUpEvent e)
{
getKeyBindingContainer().TriggerReleased(column.Action.Value);
}
}
public Column(int index)
{
Index = index;
@ -68,7 +125,8 @@ namespace osu.Game.Rulesets.Mania.UI
RelativeSizeAxes = Axes.Both
},
background,
TopLevelContainer = new Container { RelativeSizeAxes = Axes.Both }
TopLevelContainer = new Container { RelativeSizeAxes = Axes.Both },
new ColumnTouchInputArea()
};
hitPolicy = new OrderedHitPolicy(HitObjectContainer);

View File

@ -36,31 +36,10 @@ 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.RulesetKeyBindingContainer)((ManiaInputManager)GetContainingInputManager()).KeyBindingContainer;
}
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 ChildContainer
InternalChild = directionContainer = new Container
{
RelativeSizeAxes = Axes.X,
Height = Stage.HIT_TARGET_POSITION,