From a25f4880d6074b80cda388d5ba7baa7711c430e1 Mon Sep 17 00:00:00 2001 From: Gagah Pangeran Date: Tue, 14 Jul 2020 10:35:01 +0700 Subject: [PATCH 01/10] disable hit explotion when hit lighting off --- osu.Game.Rulesets.Catch/UI/Catcher.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs index 82cbbefcca..793db361da 100644 --- a/osu.Game.Rulesets.Catch/UI/Catcher.cs +++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs @@ -11,6 +11,7 @@ using osu.Framework.Input.Bindings; using osu.Framework.Utils; using osu.Game.Beatmaps; +using osu.Game.Configuration; using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects.Drawables; using osu.Game.Rulesets.Catch.Skinning; @@ -99,6 +100,7 @@ protected set private double hyperDashModifier = 1; private int hyperDashDirection; private float hyperDashTargetPosition; + private bool hitLighting; public Catcher([NotNull] Container trailsTarget, BeatmapDifficulty difficulty = null) { @@ -114,8 +116,10 @@ public Catcher([NotNull] Container trailsTarget, BeatmapDifficulty difficulty = } [BackgroundDependencyLoader] - private void load() + private void load(OsuConfigManager config) { + hitLighting = config.Get(OsuSetting.HitLighting); + InternalChildren = new Drawable[] { caughtFruit = new Container @@ -189,11 +193,14 @@ public void PlaceOnPlate(DrawableCatchHitObject fruit) caughtFruit.Add(fruit); - AddInternal(new HitExplosion(fruit) + if (hitLighting) { - X = fruit.X, - Scale = new Vector2(fruit.HitObject.Scale) - }); + AddInternal(new HitExplosion(fruit) + { + X = fruit.X, + Scale = new Vector2(fruit.HitObject.Scale) + }); + } } /// From 3e2d184a911ff88e445618064451e186e5e7c592 Mon Sep 17 00:00:00 2001 From: Gagah Pangeran Date: Tue, 14 Jul 2020 10:52:34 +0700 Subject: [PATCH 02/10] change hitlighting bool to bindable --- osu.Game.Rulesets.Catch/UI/Catcher.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs index 793db361da..a0a5f7279c 100644 --- a/osu.Game.Rulesets.Catch/UI/Catcher.cs +++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs @@ -5,6 +5,7 @@ using System.Linq; using JetBrains.Annotations; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Animations; using osu.Framework.Graphics.Containers; @@ -100,7 +101,7 @@ protected set private double hyperDashModifier = 1; private int hyperDashDirection; private float hyperDashTargetPosition; - private bool hitLighting; + private Bindable hitLighting; public Catcher([NotNull] Container trailsTarget, BeatmapDifficulty difficulty = null) { @@ -118,7 +119,7 @@ public Catcher([NotNull] Container trailsTarget, BeatmapDifficulty difficulty = [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - hitLighting = config.Get(OsuSetting.HitLighting); + hitLighting = config.GetBindable(OsuSetting.HitLighting); InternalChildren = new Drawable[] { @@ -193,7 +194,7 @@ public void PlaceOnPlate(DrawableCatchHitObject fruit) caughtFruit.Add(fruit); - if (hitLighting) + if (hitLighting.Value) { AddInternal(new HitExplosion(fruit) { From 8e4f85414573d6a788cdbb050bb1bc6f80fe18eb Mon Sep 17 00:00:00 2001 From: Gagah Pangeran Date: Wed, 15 Jul 2020 16:34:13 +0700 Subject: [PATCH 03/10] initial test hit lighting catch --- .../TestSceneHitLighting.cs | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 osu.Game.Rulesets.Catch.Tests/TestSceneHitLighting.cs diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneHitLighting.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneHitLighting.cs new file mode 100644 index 0000000000..c5fa957130 --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneHitLighting.cs @@ -0,0 +1,96 @@ +// Copyright (c) ppy Pty Ltd . 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.Allocation; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics; +using osu.Framework.Testing; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Configuration; +using osu.Game.Rulesets.Catch.Beatmaps; +using osu.Game.Rulesets.Catch.Judgements; +using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Catch.Objects.Drawables; +using osu.Game.Rulesets.Catch.UI; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Scoring; +using osu.Game.Rulesets.UI; + +namespace osu.Game.Rulesets.Catch.Tests +{ + [TestFixture] + public class TestSceneHitLighting : CatchSkinnableTestScene + { + private RulesetInfo catchRuleset; + private OsuConfigManager config; + + public TestSceneHitLighting() + { + AddToggleStep("toggle hit lighting", enabled => createCatcher(enabled)); + AddStep("catch fruit", () => catchFruit(new TestFruit() + { + X = this.ChildrenOfType().First().MovableCatcher.X + })); + } + + private void catchFruit(Fruit fruit) + { + this.ChildrenOfType().ForEach(area => + { + DrawableFruit drawable = new DrawableFruit(fruit); + area.Add(drawable); + + Schedule(() => + { + area.AttemptCatch(fruit); + area.OnResult(drawable, new JudgementResult(fruit, new CatchJudgement()) { Type = HitResult.Great }); + + drawable.Expire(); + }); + }); + } + + private void createCatcher(bool hitLighting) + { + config.Set(OsuSetting.HitLighting, hitLighting); + SetContents(() => new CatchInputManager(catchRuleset) + { + RelativeSizeAxes = Axes.Both, + Child = new TestCatcherArea() + { + Anchor = Anchor.Centre, + Origin = Anchor.TopCentre, + CreateDrawableRepresentation = ((DrawableRuleset)catchRuleset.CreateInstance().CreateDrawableRulesetWith(new CatchBeatmap())).CreateDrawableRepresentation + }, + }); + } + + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets, OsuConfigManager configManager) + { + catchRuleset = rulesets.GetRuleset(2); + config = configManager; + } + + public class TestFruit : Fruit + { + public TestFruit() + { + ApplyDefaultsToSelf(new ControlPointInfo(), new BeatmapDifficulty()); + } + } + + private class TestCatcherArea : CatcherArea + { + public TestCatcherArea() + : base(new BeatmapDifficulty()) + { + } + + public new Catcher MovableCatcher => base.MovableCatcher; + } + } +} From 16d429d2b6b5d62ddba792786376cd03ca5fef55 Mon Sep 17 00:00:00 2001 From: Gagah Pangeran Date: Thu, 16 Jul 2020 15:24:03 +0700 Subject: [PATCH 04/10] Delete test hitlighting --- .../TestSceneHitLighting.cs | 96 ------------------- 1 file changed, 96 deletions(-) delete mode 100644 osu.Game.Rulesets.Catch.Tests/TestSceneHitLighting.cs diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneHitLighting.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneHitLighting.cs deleted file mode 100644 index c5fa957130..0000000000 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneHitLighting.cs +++ /dev/null @@ -1,96 +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.Linq; -using NUnit.Framework; -using osu.Framework.Allocation; -using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Framework.Graphics; -using osu.Framework.Testing; -using osu.Game.Beatmaps; -using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Configuration; -using osu.Game.Rulesets.Catch.Beatmaps; -using osu.Game.Rulesets.Catch.Judgements; -using osu.Game.Rulesets.Catch.Objects; -using osu.Game.Rulesets.Catch.Objects.Drawables; -using osu.Game.Rulesets.Catch.UI; -using osu.Game.Rulesets.Judgements; -using osu.Game.Rulesets.Scoring; -using osu.Game.Rulesets.UI; - -namespace osu.Game.Rulesets.Catch.Tests -{ - [TestFixture] - public class TestSceneHitLighting : CatchSkinnableTestScene - { - private RulesetInfo catchRuleset; - private OsuConfigManager config; - - public TestSceneHitLighting() - { - AddToggleStep("toggle hit lighting", enabled => createCatcher(enabled)); - AddStep("catch fruit", () => catchFruit(new TestFruit() - { - X = this.ChildrenOfType().First().MovableCatcher.X - })); - } - - private void catchFruit(Fruit fruit) - { - this.ChildrenOfType().ForEach(area => - { - DrawableFruit drawable = new DrawableFruit(fruit); - area.Add(drawable); - - Schedule(() => - { - area.AttemptCatch(fruit); - area.OnResult(drawable, new JudgementResult(fruit, new CatchJudgement()) { Type = HitResult.Great }); - - drawable.Expire(); - }); - }); - } - - private void createCatcher(bool hitLighting) - { - config.Set(OsuSetting.HitLighting, hitLighting); - SetContents(() => new CatchInputManager(catchRuleset) - { - RelativeSizeAxes = Axes.Both, - Child = new TestCatcherArea() - { - Anchor = Anchor.Centre, - Origin = Anchor.TopCentre, - CreateDrawableRepresentation = ((DrawableRuleset)catchRuleset.CreateInstance().CreateDrawableRulesetWith(new CatchBeatmap())).CreateDrawableRepresentation - }, - }); - } - - [BackgroundDependencyLoader] - private void load(RulesetStore rulesets, OsuConfigManager configManager) - { - catchRuleset = rulesets.GetRuleset(2); - config = configManager; - } - - public class TestFruit : Fruit - { - public TestFruit() - { - ApplyDefaultsToSelf(new ControlPointInfo(), new BeatmapDifficulty()); - } - } - - private class TestCatcherArea : CatcherArea - { - public TestCatcherArea() - : base(new BeatmapDifficulty()) - { - } - - public new Catcher MovableCatcher => base.MovableCatcher; - } - } -} From 7021459c752fe32a07fe3053474d56464877072a Mon Sep 17 00:00:00 2001 From: Gagah Pangeran Date: Thu, 16 Jul 2020 15:25:07 +0700 Subject: [PATCH 05/10] add hit lighting test in test scene catcher area --- .../TestSceneCatcherArea.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs index fbb22a8498..6d6f0357c2 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs @@ -9,6 +9,7 @@ using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Configuration; using osu.Game.Rulesets.Catch.Beatmaps; using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Catch.Objects; @@ -24,6 +25,7 @@ namespace osu.Game.Rulesets.Catch.Tests public class TestSceneCatcherArea : CatchSkinnableTestScene { private RulesetInfo catchRuleset; + private OsuConfigManager config; public TestSceneCatcherArea() { @@ -52,6 +54,24 @@ public TestSceneCatcherArea() }, true), 20); } + [TestCase(true)] + [TestCase(false)] + public void TestHitLighting(bool enable) { + Catcher catcher = this.ChildrenOfType().First().MovableCatcher; + + AddStep("Toggle hit lighting", () => config.Set(OsuSetting.HitLighting, enable)); + AddStep("Catch fruit", () => catchFruit(new TestFruit(false) + { + X = catcher.X + })); + AddStep("Catch fruit last combo", () => catchFruit(new TestFruit(false) + { + X = catcher.X, + LastInCombo = true + })); + AddAssert("Check hit explotion", () => catcher.ChildrenOfType().Any() == enable); + } + private void catchFruit(Fruit fruit, bool miss = false) { this.ChildrenOfType().ForEach(area => @@ -84,9 +104,10 @@ private void createCatcher(float size) } [BackgroundDependencyLoader] - private void load(RulesetStore rulesets) + private void load(RulesetStore rulesets, OsuConfigManager configManager) { catchRuleset = rulesets.GetRuleset(2); + config = configManager; } public class TestFruit : Fruit From 545e4a1f66ad25a1969d7669dc79fee47ce6a7c3 Mon Sep 17 00:00:00 2001 From: Gagah Pangeran Date: Thu, 16 Jul 2020 15:32:07 +0700 Subject: [PATCH 06/10] fix formatting --- osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs index 6d6f0357c2..5f9dedcbed 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs @@ -56,7 +56,8 @@ public TestSceneCatcherArea() [TestCase(true)] [TestCase(false)] - public void TestHitLighting(bool enable) { + public void TestHitLighting(bool enable) + { Catcher catcher = this.ChildrenOfType().First().MovableCatcher; AddStep("Toggle hit lighting", () => config.Set(OsuSetting.HitLighting, enable)); From f72a6b8c9d55642706b80e419fb567e620de1a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 16 Jul 2020 20:08:48 +0200 Subject: [PATCH 07/10] Use [Resolved] instead --- osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs index 5f9dedcbed..6bacb0383f 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs @@ -25,7 +25,9 @@ namespace osu.Game.Rulesets.Catch.Tests public class TestSceneCatcherArea : CatchSkinnableTestScene { private RulesetInfo catchRuleset; - private OsuConfigManager config; + + [Resolved] + private OsuConfigManager config { get; set; } public TestSceneCatcherArea() { @@ -105,10 +107,9 @@ private void createCatcher(float size) } [BackgroundDependencyLoader] - private void load(RulesetStore rulesets, OsuConfigManager configManager) + private void load(RulesetStore rulesets) { catchRuleset = rulesets.GetRuleset(2); - config = configManager; } public class TestFruit : Fruit From 54b0321581cfd75da817323b93eeb4be88395f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 16 Jul 2020 20:12:32 +0200 Subject: [PATCH 08/10] Factor out catcher as property --- .../TestSceneCatcherArea.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs index 6bacb0383f..0588c4ba57 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs @@ -29,6 +29,8 @@ public class TestSceneCatcherArea : CatchSkinnableTestScene [Resolved] private OsuConfigManager config { get; set; } + private Catcher catcher => this.ChildrenOfType().First().MovableCatcher; + public TestSceneCatcherArea() { AddSliderStep("CircleSize", 0, 8, 5, createCatcher); @@ -38,20 +40,20 @@ public TestSceneCatcherArea() AddRepeatStep("catch fruit", () => catchFruit(new TestFruit(false) { - X = this.ChildrenOfType().First().MovableCatcher.X + X = catcher.X }), 20); AddRepeatStep("catch fruit last in combo", () => catchFruit(new TestFruit(false) { - X = this.ChildrenOfType().First().MovableCatcher.X, + X = catcher.X, LastInCombo = true, }), 20); AddRepeatStep("catch kiai fruit", () => catchFruit(new TestFruit(true) { - X = this.ChildrenOfType().First().MovableCatcher.X, + X = catcher.X }), 20); AddRepeatStep("miss fruit", () => catchFruit(new Fruit { - X = this.ChildrenOfType().First().MovableCatcher.X + 100, + X = catcher.X + 100, LastInCombo = true, }, true), 20); } @@ -60,8 +62,6 @@ public TestSceneCatcherArea() [TestCase(false)] public void TestHitLighting(bool enable) { - Catcher catcher = this.ChildrenOfType().First().MovableCatcher; - AddStep("Toggle hit lighting", () => config.Set(OsuSetting.HitLighting, enable)); AddStep("Catch fruit", () => catchFruit(new TestFruit(false) { From fbf3a098351d7a7dec872bd2953d2e3f563862ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 16 Jul 2020 20:14:57 +0200 Subject: [PATCH 09/10] Create catcher explicitly to make tests independent of ctor --- osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs index 0588c4ba57..d23c691023 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs @@ -62,6 +62,8 @@ public TestSceneCatcherArea() [TestCase(false)] public void TestHitLighting(bool enable) { + AddStep("create catcher", () => createCatcher(5)); + AddStep("Toggle hit lighting", () => config.Set(OsuSetting.HitLighting, enable)); AddStep("Catch fruit", () => catchFruit(new TestFruit(false) { From a8e96b399457bfafa4caa0a3b4dc84939a964086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 16 Jul 2020 20:17:37 +0200 Subject: [PATCH 10/10] Reword test steps for consistency & fix typo --- osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs index d23c691023..b4f123598b 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs @@ -64,17 +64,17 @@ public void TestHitLighting(bool enable) { AddStep("create catcher", () => createCatcher(5)); - AddStep("Toggle hit lighting", () => config.Set(OsuSetting.HitLighting, enable)); - AddStep("Catch fruit", () => catchFruit(new TestFruit(false) + AddStep("toggle hit lighting", () => config.Set(OsuSetting.HitLighting, enable)); + AddStep("catch fruit", () => catchFruit(new TestFruit(false) { X = catcher.X })); - AddStep("Catch fruit last combo", () => catchFruit(new TestFruit(false) + AddStep("catch fruit last in combo", () => catchFruit(new TestFruit(false) { X = catcher.X, LastInCombo = true })); - AddAssert("Check hit explotion", () => catcher.ChildrenOfType().Any() == enable); + AddAssert("check hit explosion", () => catcher.ChildrenOfType().Any() == enable); } private void catchFruit(Fruit fruit, bool miss = false)