mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 10:47:28 +08:00
Add action support to InputDrum
This commit is contained in:
parent
ff84eb219b
commit
59fc6cbed7
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Taiko.Judgements;
|
using osu.Game.Rulesets.Taiko.Judgements;
|
||||||
|
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Input;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.UI
|
namespace osu.Game.Rulesets.Taiko.UI
|
||||||
{
|
{
|
||||||
@ -36,8 +36,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RelativePositionAxes = Axes.X,
|
RelativePositionAxes = Axes.X,
|
||||||
X = -middle_split / 2,
|
X = -middle_split / 2,
|
||||||
RimKey = Key.D,
|
RimAction = TaikoAction.LeftRim,
|
||||||
CentreKey = Key.F
|
CentreAction = TaikoAction.LeftCentre
|
||||||
},
|
},
|
||||||
new TaikoHalfDrum(true)
|
new TaikoHalfDrum(true)
|
||||||
{
|
{
|
||||||
@ -47,8 +47,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RelativePositionAxes = Axes.X,
|
RelativePositionAxes = Axes.X,
|
||||||
X = middle_split / 2,
|
X = middle_split / 2,
|
||||||
RimKey = Key.K,
|
RimAction = TaikoAction.RightRim,
|
||||||
CentreKey = Key.J
|
CentreAction = TaikoAction.RightCentre
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -56,17 +56,17 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A half-drum. Contains one centre and one rim hit.
|
/// A half-drum. Contains one centre and one rim hit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private class TaikoHalfDrum : Container
|
private class TaikoHalfDrum : Container, IKeyBindingHandler<TaikoAction>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The key to be used for the rim of the half-drum.
|
/// The key to be used for the rim of the half-drum.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Key RimKey;
|
public TaikoAction RimAction;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The key to be used for the centre of the half-drum.
|
/// The key to be used for the centre of the half-drum.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Key CentreKey;
|
public TaikoAction CentreAction;
|
||||||
|
|
||||||
private readonly Sprite rim;
|
private readonly Sprite rim;
|
||||||
private readonly Sprite rimHit;
|
private readonly Sprite rimHit;
|
||||||
@ -124,20 +124,17 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
centreHit.Colour = colours.Pink;
|
centreHit.Colour = colours.Pink;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
public bool OnPressed(TaikoAction action)
|
||||||
{
|
{
|
||||||
if (args.Repeat)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Drawable target = null;
|
Drawable target = null;
|
||||||
Drawable back = null;
|
Drawable back = null;
|
||||||
|
|
||||||
if (args.Key == CentreKey)
|
if (action == CentreAction)
|
||||||
{
|
{
|
||||||
target = centreHit;
|
target = centreHit;
|
||||||
back = centre;
|
back = centre;
|
||||||
}
|
}
|
||||||
else if (args.Key == RimKey)
|
else if (action == RimAction)
|
||||||
{
|
{
|
||||||
target = rimHit;
|
target = rimHit;
|
||||||
back = rim;
|
back = rim;
|
||||||
@ -166,6 +163,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnReleased(TaikoAction action) => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user