From 0e38ff07c74de55cfc640361f51b8ea5658171d9 Mon Sep 17 00:00:00 2001 From: NullifiedJosh <86538544+NullifiedJosh@users.noreply.github.com> Date: Fri, 23 Sep 2022 20:19:56 +0800 Subject: [PATCH 1/5] Check if relax is one of the mods, if so hide. --- osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs index ef2936ac94..07968e4bee 100644 --- a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs @@ -4,6 +4,7 @@ #nullable disable using System.Collections.Generic; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Input; using osu.Game.Beatmaps; @@ -26,9 +27,15 @@ namespace osu.Game.Rulesets.Catch.UI protected override bool UserScrollSpeedAdjustment => false; + private bool showMobileMapper = true; + public DrawableCatchRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods = null) : base(ruleset, beatmap, mods) { + // Check if mods have RelaxMod instance + if (mods.OfType().Any()) + showMobileMapper = false; + Direction.Value = ScrollingDirection.Down; TimeRange.Value = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450); } @@ -36,7 +43,8 @@ namespace osu.Game.Rulesets.Catch.UI [BackgroundDependencyLoader] private void load() { - KeyBindingInputManager.Add(new CatchTouchInputMapper()); + if (showMobileMapper) + KeyBindingInputManager.Add(new CatchTouchInputMapper()); } protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new CatchFramedReplayInputHandler(replay); From 0f6a6287f246f974a9e21304846c6b0083d8d343 Mon Sep 17 00:00:00 2001 From: NullifiedJosh <86538544+NullifiedJosh@users.noreply.github.com> Date: Thu, 6 Oct 2022 18:17:33 +0800 Subject: [PATCH 2/5] Fix bugs and add test --- .../TestSceneDrawableCatchRuleset.cs | 59 +++++++++++++++++++ .../UI/DrawableCatchRuleset.cs | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs new file mode 100644 index 0000000000..b826a064e6 --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs @@ -0,0 +1,59 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using osu.Framework.Logging; +using osu.Framework.Testing; +using osu.Game.Rulesets.Catch.Beatmaps; +using osu.Game.Rulesets.Catch.Mods; +using osu.Game.Rulesets.Catch.UI; +using osu.Game.Rulesets.Mods; +using osu.Game.Tests.Visual; + +namespace osu.Game.Rulesets.Catch.Tests +{ + [TestFixture] + public class TestSceneDrawableCatchRulesetWithRelax : OsuTestScene + { + [SetUpSteps] + public void SetUpSteps() + { + AddStep("create drawable ruleset with relax mod", () => + { + Child = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), new List() { + new CatchModRelax() + }); + }); + AddUntilStep("wait for load", () => Child.IsLoaded); + } + + [Test] + public void TestBasic() + { + AddAssert("check if touch catcher is showing", () => this.ChildrenOfType().Any() == false); + } + } + + [TestFixture] + public class TestSceneDrawableCatchRulesetWithoutRelax : OsuTestScene + { + [SetUpSteps] + public void SetUpSteps() + { + AddStep("create drawable ruleset without relax mod", () => + { + Child = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), new List()); + }); + AddUntilStep("wait for load", () => Child.IsLoaded); + Logger.Log("Ready"); + } + + [Test] + public void TestBasic() + { + AddAssert("check if touch catcher is showing", () => this.ChildrenOfType().Any()); + } + } +} diff --git a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs index 07968e4bee..dfa6126d3f 100644 --- a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs @@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Catch.UI : base(ruleset, beatmap, mods) { // Check if mods have RelaxMod instance - if (mods.OfType().Any()) + if (mods != null && mods.OfType().Any()) showMobileMapper = false; Direction.Value = ScrollingDirection.Down; From 6543171169b37a79b3b6ddb192dcd15b4332f4a5 Mon Sep 17 00:00:00 2001 From: NullifiedJosh <86538544+NullifiedJosh@users.noreply.github.com> Date: Thu, 6 Oct 2022 18:30:49 +0800 Subject: [PATCH 3/5] Fix formating. --- .../TestSceneDrawableCatchRuleset.cs | 38 +++++-------------- .../UI/DrawableCatchRuleset.cs | 2 +- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs index b826a064e6..8b794fd919 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; -using osu.Framework.Logging; using osu.Framework.Testing; using osu.Game.Rulesets.Catch.Beatmaps; using osu.Game.Rulesets.Catch.Mods; @@ -15,45 +14,28 @@ using osu.Game.Tests.Visual; namespace osu.Game.Rulesets.Catch.Tests { [TestFixture] - public class TestSceneDrawableCatchRulesetWithRelax : OsuTestScene + public class TestSceneDrawableCatchRuleset : OsuTestScene { - [SetUpSteps] - public void SetUpSteps() - { - AddStep("create drawable ruleset with relax mod", () => - { - Child = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), new List() { - new CatchModRelax() - }); - }); - AddUntilStep("wait for load", () => Child.IsLoaded); - } - [Test] - public void TestBasic() - { - AddAssert("check if touch catcher is showing", () => this.ChildrenOfType().Any() == false); - } - } - - [TestFixture] - public class TestSceneDrawableCatchRulesetWithoutRelax : OsuTestScene - { - [SetUpSteps] - public void SetUpSteps() + public void TestWithoutRelax() { AddStep("create drawable ruleset without relax mod", () => { Child = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), new List()); }); AddUntilStep("wait for load", () => Child.IsLoaded); - Logger.Log("Ready"); + AddAssert("check if touch catcher is showing", () => this.ChildrenOfType().Any()); } [Test] - public void TestBasic() + public void TestWithRelax() { - AddAssert("check if touch catcher is showing", () => this.ChildrenOfType().Any()); + AddStep("create drawable ruleset with relax mod", () => + { + Child = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), new List { new CatchModRelax() }); + }); + AddUntilStep("wait for load", () => Child.IsLoaded); + AddAssert("check if touch catcher is showing", () => this.ChildrenOfType().Any() == false); } } } diff --git a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs index dfa6126d3f..ce1fa963e7 100644 --- a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch.UI protected override bool UserScrollSpeedAdjustment => false; - private bool showMobileMapper = true; + private readonly bool showMobileMapper = true; public DrawableCatchRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods = null) : base(ruleset, beatmap, mods) From 994db55b6d542c187d96d6905552f79d2a352d6a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2022 02:19:43 +0900 Subject: [PATCH 4/5] Simplify check conditionals --- osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs index ce1fa963e7..27f7886d79 100644 --- a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs @@ -27,15 +27,9 @@ namespace osu.Game.Rulesets.Catch.UI protected override bool UserScrollSpeedAdjustment => false; - private readonly bool showMobileMapper = true; - public DrawableCatchRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods = null) : base(ruleset, beatmap, mods) { - // Check if mods have RelaxMod instance - if (mods != null && mods.OfType().Any()) - showMobileMapper = false; - Direction.Value = ScrollingDirection.Down; TimeRange.Value = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450); } @@ -43,7 +37,8 @@ namespace osu.Game.Rulesets.Catch.UI [BackgroundDependencyLoader] private void load() { - if (showMobileMapper) + // With relax mod, input maps directly to x position and left/right buttons are not used. + if (!Mods.Any(m => m is ModRelax)) KeyBindingInputManager.Add(new CatchTouchInputMapper()); } From f3262103c44ad9d430e8e3883ccb490c0916e23e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Oct 2022 02:21:31 +0900 Subject: [PATCH 5/5] Move test into existing catch touch test scene --- .../TestSceneCatchTouchInput.cs | 35 +++++++++++++--- .../TestSceneDrawableCatchRuleset.cs | 41 ------------------- 2 files changed, 29 insertions(+), 47 deletions(-) delete mode 100644 osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchTouchInput.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchTouchInput.cs index cbf6e8f202..cf6a8169c4 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchTouchInput.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchTouchInput.cs @@ -1,10 +1,15 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Testing; +using osu.Game.Rulesets.Catch.Beatmaps; +using osu.Game.Rulesets.Catch.Mods; using osu.Game.Rulesets.Catch.UI; +using osu.Game.Rulesets.Mods; using osu.Game.Tests.Visual; namespace osu.Game.Rulesets.Catch.Tests @@ -12,11 +17,11 @@ namespace osu.Game.Rulesets.Catch.Tests [TestFixture] public class TestSceneCatchTouchInput : OsuTestScene { - private CatchTouchInputMapper catchTouchInputMapper = null!; - - [SetUpSteps] - public void SetUpSteps() + [Test] + public void TestBasic() { + CatchTouchInputMapper catchTouchInputMapper = null!; + AddStep("create input overlay", () => { Child = new CatchInputManager(new CatchRuleset().RulesetInfo) @@ -32,12 +37,30 @@ namespace osu.Game.Rulesets.Catch.Tests } }; }); + + AddStep("show overlay", () => catchTouchInputMapper.Show()); } [Test] - public void TestBasic() + public void TestWithoutRelax() { - AddStep("show overlay", () => catchTouchInputMapper.Show()); + AddStep("create drawable ruleset without relax mod", () => + { + Child = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), new List()); + }); + AddUntilStep("wait for load", () => Child.IsLoaded); + AddAssert("check touch input is shown", () => this.ChildrenOfType().Any()); + } + + [Test] + public void TestWithRelax() + { + AddStep("create drawable ruleset with relax mod", () => + { + Child = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), new List { new CatchModRelax() }); + }); + AddUntilStep("wait for load", () => Child.IsLoaded); + AddAssert("check touch input is not shown", () => !this.ChildrenOfType().Any()); } } } diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs deleted file mode 100644 index 8b794fd919..0000000000 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableCatchRuleset.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using System.Linq; -using NUnit.Framework; -using osu.Framework.Testing; -using osu.Game.Rulesets.Catch.Beatmaps; -using osu.Game.Rulesets.Catch.Mods; -using osu.Game.Rulesets.Catch.UI; -using osu.Game.Rulesets.Mods; -using osu.Game.Tests.Visual; - -namespace osu.Game.Rulesets.Catch.Tests -{ - [TestFixture] - public class TestSceneDrawableCatchRuleset : OsuTestScene - { - [Test] - public void TestWithoutRelax() - { - AddStep("create drawable ruleset without relax mod", () => - { - Child = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), new List()); - }); - AddUntilStep("wait for load", () => Child.IsLoaded); - AddAssert("check if touch catcher is showing", () => this.ChildrenOfType().Any()); - } - - [Test] - public void TestWithRelax() - { - AddStep("create drawable ruleset with relax mod", () => - { - Child = new DrawableCatchRuleset(new CatchRuleset(), new CatchBeatmap(), new List { new CatchModRelax() }); - }); - AddUntilStep("wait for load", () => Child.IsLoaded); - AddAssert("check if touch catcher is showing", () => this.ChildrenOfType().Any() == false); - } - } -}