Skip to content

Commit 5de4807

Browse files
committed
Replace ManiaTouchInputArea with touchable columns
1 parent 5bdd7c2 commit 5de4807

File tree

4 files changed

+25
-219
lines changed

4 files changed

+25
-219
lines changed

osu.Game.Rulesets.Mania.Tests/TestSceneManiaTouchInputArea.cs

+9-18
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,38 @@
33

44
using System.Linq;
55
using NUnit.Framework;
6-
using osu.Framework.Graphics.Containers;
76
using osu.Framework.Input;
87
using osu.Framework.Testing;
98
using osu.Game.Rulesets.Mania.UI;
109
using osu.Game.Tests.Visual;
1110

1211
namespace osu.Game.Rulesets.Mania.Tests
1312
{
14-
public partial class TestSceneManiaTouchInputArea : PlayerTestScene
13+
public partial class TestSceneManiaTouchInput : PlayerTestScene
1514
{
1615
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
1716

1817
[Test]
19-
public void TestTouchAreaNotInitiallyVisible()
18+
public void TestPressColumns()
2019
{
21-
AddAssert("touch area not visible", () => getTouchOverlay()?.State.Value == Visibility.Hidden);
22-
}
23-
24-
[Test]
25-
public void TestPressReceptors()
26-
{
27-
AddAssert("touch area not visible", () => getTouchOverlay()?.State.Value == Visibility.Hidden);
28-
2920
for (int i = 0; i < 4; i++)
3021
{
3122
int index = i;
3223

33-
AddStep($"touch receptor {index}", () => InputManager.BeginTouch(new Touch(TouchSource.Touch1, getReceptor(index).ScreenSpaceDrawQuad.Centre)));
24+
AddStep($"touch column {index}", () => InputManager.BeginTouch(new Touch(TouchSource.Touch1, getColumn(index).ScreenSpaceDrawQuad.Centre)));
3425

3526
AddAssert("action sent",
3627
() => this.ChildrenOfType<ManiaInputManager>().SelectMany(m => m.KeyBindingContainer.PressedActions),
37-
() => Does.Contain(getReceptor(index).Action.Value));
28+
() => Does.Contain(getColumn(index).Action.Value));
3829

39-
AddStep($"release receptor {index}", () => InputManager.EndTouch(new Touch(TouchSource.Touch1, getReceptor(index).ScreenSpaceDrawQuad.Centre)));
30+
AddStep($"release receptor {index}", () => InputManager.EndTouch(new Touch(TouchSource.Touch1, getColumn(index).ScreenSpaceDrawQuad.Centre)));
4031

41-
AddAssert("touch area visible", () => getTouchOverlay()?.State.Value == Visibility.Visible);
32+
AddAssert("action released",
33+
() => this.ChildrenOfType<ManiaInputManager>().SelectMany(m => m.KeyBindingContainer.PressedActions),
34+
() => Does.Not.Contain(getColumn(index).Action.Value));
4235
}
4336
}
4437

45-
private ManiaTouchInputArea? getTouchOverlay() => this.ChildrenOfType<ManiaTouchInputArea>().SingleOrDefault();
46-
47-
private ManiaTouchInputArea.ColumnInputReceptor getReceptor(int index) => this.ChildrenOfType<ManiaTouchInputArea.ColumnInputReceptor>().ElementAt(index);
38+
private Column getColumn(int index) => this.ChildrenOfType<Column>().ElementAt(index);
4839
}
4940
}

osu.Game.Rulesets.Mania/UI/Column.cs

+16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#nullable disable
55

6+
using JetBrains.Annotations;
67
using osu.Framework.Allocation;
78
using osu.Framework.Bindables;
89
using osu.Framework.Graphics;
@@ -125,6 +126,21 @@ protected override void LoadComplete()
125126
NewResult += OnNewResult;
126127
}
127128

129+
[Resolved(canBeNull: true)]
130+
[CanBeNull]
131+
private ManiaInputManager inputManager { get; set; }
132+
133+
protected override bool OnTouchDown(TouchDownEvent e)
134+
{
135+
inputManager?.KeyBindingContainer.TriggerPressed(Action.Value);
136+
return true;
137+
}
138+
139+
protected override void OnTouchUp(TouchUpEvent e)
140+
{
141+
inputManager?.KeyBindingContainer.TriggerReleased(Action.Value);
142+
}
143+
128144
protected override void Dispose(bool isDisposing)
129145
{
130146
// must happen before children are disposed in base call to prevent illegal accesses to the hit explosion pool.

osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs

-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ private void load(ISkinSource source)
112112
configScrollSpeed.BindValueChanged(speed => TargetTimeRange = ComputeScrollTime(speed.NewValue));
113113

114114
TimeRange.Value = TargetTimeRange = currentTimeRange = ComputeScrollTime(configScrollSpeed.Value);
115-
116-
KeyBindingInputManager.Add(new ManiaTouchInputArea());
117115
}
118116

119117
protected override void AdjustScrollSpeed(int amount) => configScrollSpeed.Value += amount;

osu.Game.Rulesets.Mania/UI/ManiaTouchInputArea.cs

-199
This file was deleted.

0 commit comments

Comments
 (0)