mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 22:33:05 +08:00
Merge pull request #17200 from hongaaronc/master
Add basic touch support for osu!taiko
This commit is contained in:
commit
27ec8f3ae6
@ -23,13 +23,29 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
protected DrawableTaikoRuleset DrawableRuleset { get; private set; }
|
protected DrawableTaikoRuleset DrawableRuleset { get; private set; }
|
||||||
protected Container PlayfieldContainer { get; private set; }
|
protected Container PlayfieldContainer { get; private set; }
|
||||||
|
|
||||||
|
private ControlPointInfo controlPointInfo { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
var controlPointInfo = new ControlPointInfo();
|
controlPointInfo = new ControlPointInfo();
|
||||||
controlPointInfo.Add(0, new TimingControlPoint());
|
controlPointInfo.Add(0, new TimingControlPoint());
|
||||||
|
|
||||||
IWorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
|
IWorkingBeatmap beatmap = CreateWorkingBeatmap(CreateBeatmap(new TaikoRuleset().RulesetInfo));
|
||||||
|
|
||||||
|
Add(PlayfieldContainer = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = DEFAULT_PLAYFIELD_CONTAINER_HEIGHT,
|
||||||
|
Children = new[] { DrawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap.GetPlayableBeatmap(beatmap.BeatmapInfo.Ruleset)) }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||||
|
{
|
||||||
|
return new Beatmap
|
||||||
{
|
{
|
||||||
HitObjects = new List<HitObject> { new Hit { Type = HitType.Centre } },
|
HitObjects = new List<HitObject> { new Hit { Type = HitType.Centre } },
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
@ -41,19 +57,10 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
Title = @"Sample Beatmap",
|
Title = @"Sample Beatmap",
|
||||||
Author = { Username = @"peppy" },
|
Author = { Username = @"peppy" },
|
||||||
},
|
},
|
||||||
Ruleset = new TaikoRuleset().RulesetInfo
|
Ruleset = ruleset
|
||||||
},
|
},
|
||||||
ControlPointInfo = controlPointInfo
|
ControlPointInfo = controlPointInfo
|
||||||
});
|
};
|
||||||
|
|
||||||
Add(PlayfieldContainer = new Container
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = DEFAULT_PLAYFIELD_CONTAINER_HEIGHT,
|
|
||||||
Children = new[] { DrawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap.GetPlayableBeatmap(new TaikoRuleset().RulesetInfo)) }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Size = new Vector2(200),
|
Size = new Vector2(200),
|
||||||
Child = new InputDrum(playfield.HitObjectContainer)
|
Child = new InputDrum()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
49
osu.Game.Rulesets.Taiko.Tests/TestSceneDrumTouchInputArea.cs
Normal file
49
osu.Game.Rulesets.Taiko.Tests/TestSceneDrumTouchInputArea.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Rulesets.Taiko.UI;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneDrumTouchInputArea : OsuTestScene
|
||||||
|
{
|
||||||
|
private DrumTouchInputArea drumTouchInputArea = null!;
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
|
{
|
||||||
|
AddStep("create drum", () =>
|
||||||
|
{
|
||||||
|
Child = new TaikoInputManager(new TaikoRuleset().RulesetInfo)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new InputDrum
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Height = 0.2f,
|
||||||
|
},
|
||||||
|
drumTouchInputArea = new DrumTouchInputArea
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrum()
|
||||||
|
{
|
||||||
|
AddStep("show drum", () => drumTouchInputArea.Show());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,8 +10,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
|
||||||
using osu.Game.Rulesets.Taiko.UI;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -115,9 +113,6 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
|||||||
public readonly Sprite Rim;
|
public readonly Sprite Rim;
|
||||||
public readonly Sprite Centre;
|
public readonly Sprite Centre;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private DrumSampleTriggerSource sampleTriggerSource { get; set; }
|
|
||||||
|
|
||||||
public LegacyHalfDrum(bool flipped)
|
public LegacyHalfDrum(bool flipped)
|
||||||
{
|
{
|
||||||
Masking = true;
|
Masking = true;
|
||||||
@ -152,12 +147,10 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
|||||||
if (e.Action == CentreAction)
|
if (e.Action == CentreAction)
|
||||||
{
|
{
|
||||||
target = Centre;
|
target = Centre;
|
||||||
sampleTriggerSource.Play(HitType.Centre);
|
|
||||||
}
|
}
|
||||||
else if (e.Action == RimAction)
|
else if (e.Action == RimAction)
|
||||||
{
|
{
|
||||||
target = Rim;
|
target = Rim;
|
||||||
sampleTriggerSource.Play(HitType.Rim);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != null)
|
if (target != null)
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko
|
namespace osu.Game.Rulesets.Taiko
|
||||||
{
|
{
|
||||||
|
[Cached] // Used for touch input, see DrumTouchInputArea.
|
||||||
public class TaikoInputManager : RulesetInputManager<TaikoAction>
|
public class TaikoInputManager : RulesetInputManager<TaikoAction>
|
||||||
{
|
{
|
||||||
public TaikoInputManager(RulesetInfo ruleset)
|
public TaikoInputManager(RulesetInfo ruleset)
|
||||||
|
@ -8,18 +8,18 @@ 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.Game.Beatmaps;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using osu.Game.Rulesets.Taiko.Replays;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Input.Handlers;
|
using osu.Game.Input.Handlers;
|
||||||
using osu.Game.Replays;
|
using osu.Game.Replays;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
|
using osu.Game.Rulesets.Taiko.Replays;
|
||||||
using osu.Game.Rulesets.Timing;
|
using osu.Game.Rulesets.Timing;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -56,6 +56,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Depth = float.MaxValue
|
Depth = float.MaxValue
|
||||||
});
|
});
|
||||||
|
|
||||||
|
KeyBindingInputManager.Add(new DrumTouchInputArea());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
|
59
osu.Game.Rulesets.Taiko/UI/DrumSamplePlayer.cs
Normal file
59
osu.Game.Rulesets.Taiko/UI/DrumSamplePlayer.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// 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 : CompositeDrawable, IKeyBindingHandler<TaikoAction>
|
||||||
|
{
|
||||||
|
private readonly DrumSampleTriggerSource leftRimSampleTriggerSource;
|
||||||
|
private readonly DrumSampleTriggerSource leftCentreSampleTriggerSource;
|
||||||
|
private readonly DrumSampleTriggerSource rightCentreSampleTriggerSource;
|
||||||
|
private readonly DrumSampleTriggerSource rightRimSampleTriggerSource;
|
||||||
|
|
||||||
|
public DrumSamplePlayer(HitObjectContainer hitObjectContainer)
|
||||||
|
{
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
leftRimSampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer),
|
||||||
|
leftCentreSampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer),
|
||||||
|
rightCentreSampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer),
|
||||||
|
rightRimSampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(KeyBindingPressEvent<TaikoAction> e)
|
||||||
|
{
|
||||||
|
switch (e.Action)
|
||||||
|
{
|
||||||
|
case TaikoAction.LeftRim:
|
||||||
|
leftRimSampleTriggerSource.Play(HitType.Rim);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TaikoAction.LeftCentre:
|
||||||
|
leftCentreSampleTriggerSource.Play(HitType.Centre);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TaikoAction.RightCentre:
|
||||||
|
rightCentreSampleTriggerSource.Play(HitType.Centre);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TaikoAction.RightRim:
|
||||||
|
rightRimSampleTriggerSource.Play(HitType.Rim);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(KeyBindingReleaseEvent<TaikoAction> e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
243
osu.Game.Rulesets.Taiko/UI/DrumTouchInputArea.cs
Normal file
243
osu.Game.Rulesets.Taiko/UI/DrumTouchInputArea.cs
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
// 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 System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.UI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An overlay that captures and displays osu!taiko mouse and touch input.
|
||||||
|
/// </summary>
|
||||||
|
public class DrumTouchInputArea : VisibilityContainer
|
||||||
|
{
|
||||||
|
// visibility state affects our child. we always want to handle input.
|
||||||
|
public override bool PropagatePositionalInputSubTree => true;
|
||||||
|
public override bool PropagateNonPositionalInputSubTree => true;
|
||||||
|
|
||||||
|
private KeyBindingContainer<TaikoAction> keyBindingContainer = null!;
|
||||||
|
|
||||||
|
private readonly Dictionary<object, TaikoAction> trackedActions = new Dictionary<object, TaikoAction>();
|
||||||
|
|
||||||
|
private Container mainContent = null!;
|
||||||
|
|
||||||
|
private QuarterCircle leftCentre = null!;
|
||||||
|
private QuarterCircle rightCentre = null!;
|
||||||
|
private QuarterCircle leftRim = null!;
|
||||||
|
private QuarterCircle rightRim = null!;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TaikoInputManager taikoInputManager, OsuColour colours)
|
||||||
|
{
|
||||||
|
Debug.Assert(taikoInputManager.KeyBindingContainer != null);
|
||||||
|
keyBindingContainer = taikoInputManager.KeyBindingContainer;
|
||||||
|
|
||||||
|
// Container should handle input everywhere.
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
const float centre_region = 0.80f;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 350,
|
||||||
|
Y = 20,
|
||||||
|
Masking = true,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
mainContent = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
leftRim = new QuarterCircle(TaikoAction.LeftRim, colours.Blue)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
X = -2,
|
||||||
|
},
|
||||||
|
rightRim = new QuarterCircle(TaikoAction.RightRim, colours.Blue)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
X = 2,
|
||||||
|
Rotation = 90,
|
||||||
|
},
|
||||||
|
leftCentre = new QuarterCircle(TaikoAction.LeftCentre, colours.Pink)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
X = -2,
|
||||||
|
Scale = new Vector2(centre_region),
|
||||||
|
},
|
||||||
|
rightCentre = new QuarterCircle(TaikoAction.RightCentre, colours.Pink)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
X = 2,
|
||||||
|
Scale = new Vector2(centre_region),
|
||||||
|
Rotation = 90,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
|
{
|
||||||
|
// Hide whenever the keyboard is used.
|
||||||
|
Hide();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
|
{
|
||||||
|
if (!validMouse(e))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
handleDown(e.Button, e.ScreenSpaceMousePosition);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnMouseUp(MouseUpEvent e)
|
||||||
|
{
|
||||||
|
if (!validMouse(e))
|
||||||
|
return;
|
||||||
|
|
||||||
|
handleUp(e.Button);
|
||||||
|
base.OnMouseUp(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnTouchDown(TouchDownEvent e)
|
||||||
|
{
|
||||||
|
handleDown(e.Touch.Source, e.ScreenSpaceTouchDownPosition);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnTouchUp(TouchUpEvent e)
|
||||||
|
{
|
||||||
|
handleUp(e.Touch.Source);
|
||||||
|
base.OnTouchUp(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleDown(object source, Vector2 position)
|
||||||
|
{
|
||||||
|
Show();
|
||||||
|
|
||||||
|
TaikoAction taikoAction = getTaikoActionFromInput(position);
|
||||||
|
|
||||||
|
// Not too sure how this can happen, but let's avoid throwing.
|
||||||
|
if (trackedActions.ContainsKey(source))
|
||||||
|
return;
|
||||||
|
|
||||||
|
trackedActions.Add(source, taikoAction);
|
||||||
|
keyBindingContainer.TriggerPressed(taikoAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleUp(object source)
|
||||||
|
{
|
||||||
|
keyBindingContainer.TriggerReleased(trackedActions[source]);
|
||||||
|
trackedActions.Remove(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool validMouse(MouseButtonEvent e) =>
|
||||||
|
leftRim.Contains(e.ScreenSpaceMouseDownPosition) || rightRim.Contains(e.ScreenSpaceMouseDownPosition);
|
||||||
|
|
||||||
|
private TaikoAction getTaikoActionFromInput(Vector2 inputPosition)
|
||||||
|
{
|
||||||
|
bool centreHit = leftCentre.Contains(inputPosition) || rightCentre.Contains(inputPosition);
|
||||||
|
bool leftSide = ToLocalSpace(inputPosition).X < DrawWidth / 2;
|
||||||
|
|
||||||
|
if (leftSide)
|
||||||
|
return centreHit ? TaikoAction.LeftCentre : TaikoAction.LeftRim;
|
||||||
|
|
||||||
|
return centreHit ? TaikoAction.RightCentre : TaikoAction.RightRim;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopIn()
|
||||||
|
{
|
||||||
|
mainContent.FadeIn(500, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
mainContent.FadeOut(300);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class QuarterCircle : CompositeDrawable, IKeyBindingHandler<TaikoAction>
|
||||||
|
{
|
||||||
|
private readonly Circle overlay;
|
||||||
|
|
||||||
|
private readonly TaikoAction handledAction;
|
||||||
|
|
||||||
|
private readonly Circle circle;
|
||||||
|
|
||||||
|
public override bool Contains(Vector2 screenSpacePos) => circle.Contains(screenSpacePos);
|
||||||
|
|
||||||
|
public QuarterCircle(TaikoAction handledAction, Color4 colour)
|
||||||
|
{
|
||||||
|
this.handledAction = handledAction;
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
FillMode = FillMode.Fit;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
circle = new Circle
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colour.Multiply(1.4f).Darken(2.8f),
|
||||||
|
Alpha = 0.8f,
|
||||||
|
Scale = new Vector2(2),
|
||||||
|
},
|
||||||
|
overlay = new Circle
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
Colour = colour,
|
||||||
|
Scale = new Vector2(2),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(KeyBindingPressEvent<TaikoAction> e)
|
||||||
|
{
|
||||||
|
if (e.Action == handledAction)
|
||||||
|
overlay.FadeTo(1f, 80, Easing.OutQuint);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(KeyBindingReleaseEvent<TaikoAction> e)
|
||||||
|
{
|
||||||
|
if (e.Action == handledAction)
|
||||||
|
overlay.FadeOut(1000, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,8 +12,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.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -27,13 +25,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
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);
|
|
||||||
|
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
}
|
}
|
||||||
@ -48,7 +41,6 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
AutoSizeAxes = Axes.X,
|
AutoSizeAxes = Axes.X,
|
||||||
},
|
},
|
||||||
sampleTriggerSource
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,9 +108,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;
|
||||||
@ -179,15 +168,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)
|
||||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
inputDrum = new InputDrum(HitObjectContainer)
|
inputDrum = new InputDrum
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
@ -164,6 +164,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
drumRollHitContainer.CreateProxy(),
|
drumRollHitContainer.CreateProxy(),
|
||||||
|
new DrumSamplePlayer(HitObjectContainer),
|
||||||
// this is added at the end of the hierarchy to receive input before taiko objects.
|
// this is added at the end of the hierarchy to receive input before taiko objects.
|
||||||
// but is proxied below everything to not cover visual effects such as hit explosions.
|
// but is proxied below everything to not cover visual effects such as hit explosions.
|
||||||
inputDrum,
|
inputDrum,
|
||||||
|
Loading…
Reference in New Issue
Block a user