mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 04:32:57 +08:00
Hook up touch device mod
This commit is contained in:
parent
e3f2e1ba08
commit
a761a7bced
@ -0,0 +1,64 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
{
|
||||
public partial class TestSceneModTouchDevice : ModTestScene
|
||||
{
|
||||
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
|
||||
|
||||
[Test]
|
||||
public void TestOverlayVisibleWithMod() => CreateModTest(new ModTestData
|
||||
{
|
||||
Mod = new ModTouchDevice(),
|
||||
Autoplay = false,
|
||||
PassCondition = () => getSkinnableOverlay()?.IsPresent == true
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestOverlayNotVisibleWithoutMod() => CreateModTest(new ModTestData
|
||||
{
|
||||
Autoplay = false,
|
||||
PassCondition = () => getSkinnableOverlay()?.IsPresent == false
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestPressReceptors()
|
||||
{
|
||||
CreateModTest(new ModTestData
|
||||
{
|
||||
Mod = new ModTouchDevice(),
|
||||
Autoplay = false,
|
||||
PassCondition = () => true
|
||||
});
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int index = i;
|
||||
|
||||
AddStep($"touch receptor {index}", () => InputManager.BeginTouch(new Touch(TouchSource.Touch1, getReceptor(index).ScreenSpaceDrawQuad.Centre)));
|
||||
|
||||
AddAssert("action sent",
|
||||
() => this.ChildrenOfType<ManiaInputManager>().SelectMany(m => m.KeyBindingContainer.PressedActions),
|
||||
() => Does.Contain(getReceptor(index).Action.Value));
|
||||
|
||||
AddStep($"release receptor {index}", () => InputManager.EndTouch(new Touch(TouchSource.Touch1, getReceptor(index).ScreenSpaceDrawQuad.Centre)));
|
||||
}
|
||||
}
|
||||
|
||||
private Drawable? getSkinnableOverlay() => this.ChildrenOfType<SkinnableDrawable>()
|
||||
.SingleOrDefault(d => d.Lookup.Equals(new ManiaSkinComponentLookup(ManiaSkinComponents.TouchOverlay)));
|
||||
|
||||
private ManiaTouchInputOverlay.InputReceptor getReceptor(int index) => this.ChildrenOfType<ManiaTouchInputOverlay.InputReceptor>().ElementAt(index);
|
||||
}
|
||||
}
|
@ -163,6 +163,9 @@ namespace osu.Game.Rulesets.Mania
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.ScoreV2))
|
||||
yield return new ModScoreV2();
|
||||
|
||||
if (mods.HasFlagFast(LegacyMods.TouchDevice))
|
||||
yield return new ModTouchDevice();
|
||||
}
|
||||
|
||||
public override LegacyMods ConvertToLegacyMods(Mod[] mods)
|
||||
@ -225,6 +228,10 @@ namespace osu.Game.Rulesets.Mania
|
||||
case ManiaModRandom:
|
||||
value |= LegacyMods.Random;
|
||||
break;
|
||||
|
||||
case ModTouchDevice:
|
||||
value |= LegacyMods.TouchDevice;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,6 +303,7 @@ namespace osu.Game.Rulesets.Mania
|
||||
case ModType.System:
|
||||
return new Mod[]
|
||||
{
|
||||
new ModTouchDevice(),
|
||||
new ModScoreV2(),
|
||||
};
|
||||
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
@ -26,6 +27,8 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
private readonly List<Stage> stages = new List<Stage>();
|
||||
|
||||
private readonly ManiaTouchInputOverlay touchOverlay;
|
||||
|
||||
public override Quad SkinnableComponentScreenSpaceDrawQuad
|
||||
{
|
||||
get
|
||||
@ -74,9 +77,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
Content = new[] { new Drawable[stageDefinitions.Count] },
|
||||
ColumnDimensions = Enumerable.Range(0, stageDefinitions.Count).Select(_ => new Dimension(GridSizeMode.AutoSize)).ToArray()
|
||||
},
|
||||
new ManiaTouchInputOverlay
|
||||
touchOverlay = new ManiaTouchInputOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
});
|
||||
|
||||
@ -97,6 +100,13 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
touchOverlay.Alpha = Mods?.Any(m => m is ModTouchDevice) == true ? 1 : 0;
|
||||
}
|
||||
|
||||
public override void Add(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Add(hitObject);
|
||||
|
||||
public override bool Remove(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Remove(hitObject);
|
||||
|
Loading…
Reference in New Issue
Block a user