mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 10:43:04 +08:00
Basic functionality for Taiko touch input now complete
This commit is contained in:
parent
fc2cd78fa2
commit
317869078f
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
@ -35,6 +36,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
private SkinnableDrawable scroller;
|
private SkinnableDrawable scroller;
|
||||||
|
|
||||||
|
private DrumTouchInputArea drumTouchInputArea;
|
||||||
|
|
||||||
public DrawableTaikoRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
public DrawableTaikoRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
@ -53,11 +56,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
Depth = float.MaxValue
|
Depth = float.MaxValue
|
||||||
});
|
});
|
||||||
|
|
||||||
DrumTouchInputArea touchInput = new DrumTouchInputArea(Playfield) {
|
if ((drumTouchInputArea = CreateDrumTouchInputArea()) != null)
|
||||||
RelativePositionAxes = Axes.Both,
|
KeyBindingInputManager.Add(drumTouchInputArea);
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
};
|
|
||||||
Overlays.Add(touchInput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
@ -76,6 +76,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
return ControlPoints[result];
|
return ControlPoints[result];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DrumTouchInputArea CreateDrumTouchInputArea() => new DrumTouchInputArea();
|
||||||
|
|
||||||
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer();
|
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer();
|
||||||
|
|
||||||
protected override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);
|
protected override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);
|
||||||
|
55
osu.Game.Rulesets.Taiko/UI/DrumSamplePlayer.cs
Normal file
55
osu.Game.Rulesets.Taiko/UI/DrumSamplePlayer.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.UI
|
||||||
|
{
|
||||||
|
internal class DrumSamplePlayer : Container, IKeyBindingHandler<TaikoAction> {
|
||||||
|
private DrumSampleTriggerSource leftRimSampleTriggerSource;
|
||||||
|
private DrumSampleTriggerSource leftCentreSampleTriggerSource;
|
||||||
|
private DrumSampleTriggerSource rightCentreSampleTriggerSource;
|
||||||
|
private DrumSampleTriggerSource rightRimSampleTriggerSource;
|
||||||
|
|
||||||
|
public DrumSamplePlayer(HitObjectContainer hitObjectContainer) {
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
leftRimSampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer),
|
||||||
|
leftCentreSampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer),
|
||||||
|
rightCentreSampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer),
|
||||||
|
rightRimSampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(KeyBindingPressEvent<TaikoAction> e)
|
||||||
|
{
|
||||||
|
if (e.Action == TaikoAction.LeftRim)
|
||||||
|
{
|
||||||
|
leftRimSampleTriggerSource.Play(HitType.Rim);
|
||||||
|
}
|
||||||
|
else if (e.Action == TaikoAction.LeftCentre)
|
||||||
|
{
|
||||||
|
leftCentreSampleTriggerSource.Play(HitType.Centre);
|
||||||
|
}
|
||||||
|
else if (e.Action == TaikoAction.RightCentre)
|
||||||
|
{
|
||||||
|
rightCentreSampleTriggerSource.Play(HitType.Centre);
|
||||||
|
}
|
||||||
|
else if (e.Action == TaikoAction.RightRim)
|
||||||
|
{
|
||||||
|
rightRimSampleTriggerSource.Play(HitType.Rim);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(KeyBindingReleaseEvent<TaikoAction> e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,9 +10,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Logging;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.UI
|
namespace osu.Game.Rulesets.Taiko.UI
|
||||||
@ -25,11 +23,9 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
public class DrumTouchInputArea : Container
|
public class DrumTouchInputArea : Container
|
||||||
{
|
{
|
||||||
// The percent of the drum that extends past the bottom of the screen (set to 0.0f to show the full drum)
|
// The percent of the drum that extends past the bottom of the screen (set to 0.0f to show the full drum)
|
||||||
private const float overhangPercent = 0.33f;
|
private const float overhangPercent = 0.35f;
|
||||||
private readonly InputDrum touchInputDrum;
|
private InputDrum touchInputDrum;
|
||||||
|
private Circle drumBackground;
|
||||||
[Resolved(canBeNull: true)]
|
|
||||||
private TaikoInputManager taikoInputManager { get; set; }
|
|
||||||
|
|
||||||
private KeyBindingContainer<TaikoAction> keyBindingContainer;
|
private KeyBindingContainer<TaikoAction> keyBindingContainer;
|
||||||
|
|
||||||
@ -39,55 +35,55 @@ 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 Playfield playfield;
|
public DrumTouchInputArea() {
|
||||||
|
|
||||||
public DrumTouchInputArea(Playfield playfield) {
|
|
||||||
this.playfield = playfield;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
RelativePositionAxes = Axes.Both;
|
RelativePositionAxes = Axes.Both;
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box() {
|
|
||||||
Alpha = 0.0f,
|
|
||||||
Colour = new OsuColour().Blue,
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
RelativePositionAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
new Container() {
|
new Container() {
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RelativePositionAxes = Axes.Both,
|
RelativePositionAxes = Axes.Both,
|
||||||
|
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
touchInputDrum = new InputDrum(playfield.HitObjectContainer) {
|
drumBackground = new Circle() {
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RelativePositionAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
Alpha = 0.9f,
|
||||||
|
},
|
||||||
|
touchInputDrum = new InputDrum() {
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
keyBindingContainer = taikoInputManager?.KeyBindingContainer;
|
|
||||||
|
|
||||||
Padding = new MarginPadding {
|
Padding = new MarginPadding {
|
||||||
Top = playfield.ScreenSpaceDrawQuad.BottomLeft.Y,
|
Top = TaikoPlayfield.DEFAULT_HEIGHT * 2f, // Visual elements should start right below the playfield
|
||||||
Bottom = -DrawHeight * overhangPercent,
|
Bottom = -touchInputDrum.DrawHeight * overhangPercent, // The drum should go past the bottom of the screen so that it can be wider
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TaikoInputManager taikoInputManager, OsuColour colours)
|
||||||
|
{
|
||||||
|
keyBindingContainer = taikoInputManager?.KeyBindingContainer;
|
||||||
|
drumBackground.Colour = colours.Gray0;
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
{
|
{
|
||||||
mouseAction = getTaikoActionFromInput(e.ScreenSpaceMouseDownPosition);
|
mouseAction = getTaikoActionFromInput(e.ScreenSpaceMouseDownPosition);
|
||||||
keyBindingContainer?.TriggerPressed(mouseAction);
|
keyBindingContainer?.TriggerPressed(mouseAction);
|
||||||
return base.OnMouseDown(e);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnMouseUp(MouseUpEvent e)
|
protected override void OnMouseUp(MouseUpEvent e)
|
||||||
@ -99,20 +95,16 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
protected override bool OnTouchDown(TouchDownEvent e)
|
protected override bool OnTouchDown(TouchDownEvent e)
|
||||||
{
|
{
|
||||||
TaikoAction taikoAction = getTaikoActionFromInput(e.ScreenSpaceTouchDownPosition);
|
TaikoAction taikoAction = getTaikoActionFromInput(e.ScreenSpaceTouchDownPosition);
|
||||||
if (touchActions.ContainsKey(e.Touch.Source)) {
|
|
||||||
touchActions[e.Touch.Source] = taikoAction;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
touchActions.Add(e.Touch.Source, taikoAction);
|
touchActions.Add(e.Touch.Source, taikoAction);
|
||||||
}
|
|
||||||
keyBindingContainer?.TriggerPressed(touchActions[e.Touch.Source]);
|
keyBindingContainer?.TriggerPressed(touchActions[e.Touch.Source]);
|
||||||
|
|
||||||
return base.OnTouchDown(e);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnTouchUp(TouchUpEvent e)
|
protected override void OnTouchUp(TouchUpEvent e)
|
||||||
{
|
{
|
||||||
keyBindingContainer?.TriggerReleased(touchActions[e.Touch.Source]);
|
keyBindingContainer?.TriggerReleased(touchActions[e.Touch.Source]);
|
||||||
|
touchActions.Remove(e.Touch.Source);
|
||||||
base.OnTouchUp(e);
|
base.OnTouchUp(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@ using osu.Framework.Graphics.Textures;
|
|||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -25,13 +23,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
public const float centre_size = 0.7f;
|
public const float centre_size = 0.7f;
|
||||||
private const float middle_split = 0.025f;
|
private const float middle_split = 0.025f;
|
||||||
|
|
||||||
[Cached]
|
public InputDrum()
|
||||||
private DrumSampleTriggerSource sampleTriggerSource;
|
|
||||||
|
|
||||||
public InputDrum(HitObjectContainer hitObjectContainer)
|
|
||||||
{
|
{
|
||||||
sampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer);
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +63,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
CentreAction = TaikoAction.RightCentre
|
CentreAction = TaikoAction.RightCentre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
sampleTriggerSource
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,9 +87,6 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
private readonly Sprite centre;
|
private readonly Sprite centre;
|
||||||
private readonly Sprite centreHit;
|
private readonly Sprite centreHit;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private DrumSampleTriggerSource sampleTriggerSource { get; set; }
|
|
||||||
|
|
||||||
public TaikoHalfDrum(bool flipped)
|
public TaikoHalfDrum(bool flipped)
|
||||||
{
|
{
|
||||||
Masking = true;
|
Masking = true;
|
||||||
@ -158,15 +147,11 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
target = centreHit;
|
target = centreHit;
|
||||||
back = centre;
|
back = centre;
|
||||||
|
|
||||||
sampleTriggerSource.Play(HitType.Centre);
|
|
||||||
}
|
}
|
||||||
else if (e.Action == RimAction)
|
else if (e.Action == RimAction)
|
||||||
{
|
{
|
||||||
target = rimHit;
|
target = rimHit;
|
||||||
back = rim;
|
back = rim;
|
||||||
|
|
||||||
sampleTriggerSource.Play(HitType.Rim);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != null)
|
if (target != null)
|
||||||
|
@ -123,7 +123,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
||||||
new InputDrum(HitObjectContainer)
|
new InputDrum()
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
@ -144,7 +144,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
drumRollHitContainer.CreateProxy(),
|
drumRollHitContainer.CreateProxy(),
|
||||||
// new DrumTouchInputArea(this),
|
new DrumSamplePlayer(HitObjectContainer),
|
||||||
};
|
};
|
||||||
|
|
||||||
RegisterPool<Hit, DrawableHit>(50);
|
RegisterPool<Hit, DrawableHit>(50);
|
||||||
|
Loading…
Reference in New Issue
Block a user