mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
@ -35,6 +36,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
private SkinnableDrawable scroller;
|
||||
|
||||
private DrumTouchInputArea drumTouchInputArea;
|
||||
|
||||
public DrawableTaikoRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
@ -53,11 +56,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
Depth = float.MaxValue
|
||||
});
|
||||
|
||||
DrumTouchInputArea touchInput = new DrumTouchInputArea(Playfield) {
|
||||
RelativePositionAxes = Axes.Both,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
Overlays.Add(touchInput);
|
||||
if ((drumTouchInputArea = CreateDrumTouchInputArea()) != null)
|
||||
KeyBindingInputManager.Add(drumTouchInputArea);
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
@ -76,6 +76,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
return ControlPoints[result];
|
||||
}
|
||||
|
||||
public DrumTouchInputArea CreateDrumTouchInputArea() => new DrumTouchInputArea();
|
||||
|
||||
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer();
|
||||
|
||||
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.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
@ -25,11 +23,9 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
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)
|
||||
private const float overhangPercent = 0.33f;
|
||||
private readonly InputDrum touchInputDrum;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private TaikoInputManager taikoInputManager { get; set; }
|
||||
private const float overhangPercent = 0.35f;
|
||||
private InputDrum touchInputDrum;
|
||||
private Circle drumBackground;
|
||||
|
||||
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
|
||||
private Dictionary<TouchSource, TaikoAction> touchActions = new Dictionary<TouchSource, TaikoAction>(Enum.GetNames(typeof(TouchSource)).Length);
|
||||
|
||||
private Playfield playfield;
|
||||
|
||||
public DrumTouchInputArea(Playfield playfield) {
|
||||
this.playfield = playfield;
|
||||
|
||||
public DrumTouchInputArea() {
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
RelativePositionAxes = Axes.Both;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box() {
|
||||
Alpha = 0.0f,
|
||||
Colour = new OsuColour().Blue,
|
||||
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
},
|
||||
new Container() {
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
|
||||
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,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
keyBindingContainer = taikoInputManager?.KeyBindingContainer;
|
||||
|
||||
Padding = new MarginPadding {
|
||||
Top = playfield.ScreenSpaceDrawQuad.BottomLeft.Y,
|
||||
Bottom = -DrawHeight * overhangPercent,
|
||||
Top = TaikoPlayfield.DEFAULT_HEIGHT * 2f, // Visual elements should start right below the playfield
|
||||
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)
|
||||
{
|
||||
mouseAction = getTaikoActionFromInput(e.ScreenSpaceMouseDownPosition);
|
||||
keyBindingContainer?.TriggerPressed(mouseAction);
|
||||
return base.OnMouseDown(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseUpEvent e)
|
||||
@ -99,20 +95,16 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
protected override bool OnTouchDown(TouchDownEvent e)
|
||||
{
|
||||
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]);
|
||||
|
||||
return base.OnTouchDown(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnTouchUp(TouchUpEvent e)
|
||||
{
|
||||
keyBindingContainer?.TriggerReleased(touchActions[e.Touch.Source]);
|
||||
touchActions.Remove(e.Touch.Source);
|
||||
base.OnTouchUp(e);
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,6 @@ using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
@ -25,13 +23,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
public const float centre_size = 0.7f;
|
||||
private const float middle_split = 0.025f;
|
||||
|
||||
[Cached]
|
||||
private DrumSampleTriggerSource sampleTriggerSource;
|
||||
|
||||
public InputDrum(HitObjectContainer hitObjectContainer)
|
||||
public InputDrum()
|
||||
{
|
||||
sampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
@ -70,8 +63,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
CentreAction = TaikoAction.RightCentre
|
||||
}
|
||||
}
|
||||
}),
|
||||
sampleTriggerSource
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@ -95,9 +87,6 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
private readonly Sprite centre;
|
||||
private readonly Sprite centreHit;
|
||||
|
||||
[Resolved]
|
||||
private DrumSampleTriggerSource sampleTriggerSource { get; set; }
|
||||
|
||||
public TaikoHalfDrum(bool flipped)
|
||||
{
|
||||
Masking = true;
|
||||
@ -158,15 +147,11 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
target = centreHit;
|
||||
back = centre;
|
||||
|
||||
sampleTriggerSource.Play(HitType.Centre);
|
||||
}
|
||||
else if (e.Action == RimAction)
|
||||
{
|
||||
target = rimHit;
|
||||
back = rim;
|
||||
|
||||
sampleTriggerSource.Play(HitType.Rim);
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
|
@ -123,7 +123,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
||||
new InputDrum(HitObjectContainer)
|
||||
new InputDrum()
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
@ -144,7 +144,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
drumRollHitContainer.CreateProxy(),
|
||||
// new DrumTouchInputArea(this),
|
||||
new DrumSamplePlayer(HitObjectContainer),
|
||||
};
|
||||
|
||||
RegisterPool<Hit, DrawableHit>(50);
|
||||
|
Loading…
Reference in New Issue
Block a user