From 5cd973fb3490dcc10d10e4775e294d690b0ffda1 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 6 Feb 2023 19:20:43 -0600 Subject: [PATCH 01/10] Add test --- .../TestSceneHitCircleLateFade.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs new file mode 100644 index 0000000000..3195c0b24b --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs @@ -0,0 +1,48 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +#nullable disable + +using NUnit.Framework; +using osu.Framework.Extensions.ObjectExtensions; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Tests.Visual; +using osuTK; + +namespace osu.Game.Rulesets.Osu.Tests +{ + public partial class TestSceneHitCircleLateFade : OsuTestScene + { + [Test] + public void TestFadeOutIntoMiss() + { + float? alphaAtMiss = null; + + AddStep("Create hit circle", () => + { + alphaAtMiss = null; + + DrawableHitCircle drawableHitCircle = new DrawableHitCircle(new HitCircle + { + StartTime = Time.Current + 500, + Position = new Vector2(250) + }); + + drawableHitCircle.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); + + drawableHitCircle.OnNewResult += (_, _) => + { + alphaAtMiss = drawableHitCircle.Alpha; + }; + + Child = drawableHitCircle; + }); + + AddUntilStep("Wait until circle is missed", () => alphaAtMiss.IsNotNull()); + AddAssert("Transparent when missed", () => alphaAtMiss == 0); + } + } +} From d027d69913610087527c61a7d33939e5bf229b77 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 6 Feb 2023 19:22:47 -0600 Subject: [PATCH 02/10] Make hit circle fade out into late miss judgement --- osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 3458069dd1..8467d33e9b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -200,6 +200,10 @@ protected override void UpdateStartTimeStateTransforms() // always fade out at the circle's start time (to match user expectations). ApproachCircle.FadeOut(50); + + double mehWindow = HitObject.HitWindows.WindowFor(HitResult.Meh); + double lateMissFadeTime = mehWindow / 4 + 15; + this.Delay(mehWindow - lateMissFadeTime).FadeOut(lateMissFadeTime); } protected override void UpdateHitStateTransforms(ArmedState state) From 7bad0113cddef9dade7c49a8cea1a0b78cdad28c Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 9 Feb 2023 11:15:21 -0600 Subject: [PATCH 03/10] Move early fade effect to classic mod setting --- osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs | 25 +++++++++++++++++++ .../Objects/Drawables/DrawableHitCircle.cs | 4 --- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs index e021992f86..8d79157f82 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs @@ -4,6 +4,7 @@ using System; using System.Linq; using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Game.Configuration; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; @@ -11,6 +12,7 @@ using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.UI; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.Mods @@ -31,6 +33,9 @@ public class OsuModClassic : ModClassic, IApplicableToHitObject, IApplicableToDr [SettingSource("Always play a slider's tail sample", "Always plays a slider's tail sample regardless of whether it was hit or not.")] public Bindable AlwaysPlayTailSample { get; } = new BindableBool(true); + [SettingSource("Fade out hit circles earlier", "Make hit circles fade out into a miss, rather than after it.")] + public Bindable FadeHitCircleEarly { get; } = new Bindable(true); + public void ApplyToHitObject(HitObject hitObject) { switch (hitObject) @@ -59,12 +64,32 @@ public void ApplyToDrawableHitObject(DrawableHitObject obj) { case DrawableSliderHead head: head.TrackFollowCircle = !NoSliderHeadMovement.Value; + if (FadeHitCircleEarly.Value) + applyEarlyFading(head); break; case DrawableSliderTail tail: tail.SamplePlaysOnlyOnHit = !AlwaysPlayTailSample.Value; break; + + case DrawableHitCircle circle: + if (FadeHitCircleEarly.Value) + applyEarlyFading(circle); + break; } } + + private void applyEarlyFading(DrawableHitCircle circle) + { + circle.ApplyCustomUpdateState += (o, _) => + { + using (o.BeginAbsoluteSequence(o.StateUpdateTime)) + { + double mehWindow = o.HitObject.HitWindows.WindowFor(HitResult.Meh); + double lateMissFadeTime = mehWindow / 4 + 15; + o.Delay(mehWindow - lateMissFadeTime).FadeOut(lateMissFadeTime); + } + }; + } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 8467d33e9b..3458069dd1 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -200,10 +200,6 @@ protected override void UpdateStartTimeStateTransforms() // always fade out at the circle's start time (to match user expectations). ApproachCircle.FadeOut(50); - - double mehWindow = HitObject.HitWindows.WindowFor(HitResult.Meh); - double lateMissFadeTime = mehWindow / 4 + 15; - this.Delay(mehWindow - lateMissFadeTime).FadeOut(lateMissFadeTime); } protected override void UpdateHitStateTransforms(ArmedState state) From 6d99e099129c9518dadd34c3b1a683ed6c5c33c6 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 9 Feb 2023 16:10:11 -0600 Subject: [PATCH 04/10] Modify tests --- .../TestSceneHitCircleLateFade.cs | 124 +++++++++++++++--- 1 file changed, 104 insertions(+), 20 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs index 3195c0b24b..170c230ef7 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs @@ -3,10 +3,16 @@ #nullable disable +using System; +using System.Linq; using NUnit.Framework; using osu.Framework.Extensions.ObjectExtensions; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Tests.Visual; @@ -16,33 +22,111 @@ namespace osu.Game.Rulesets.Osu.Tests { public partial class TestSceneHitCircleLateFade : OsuTestScene { - [Test] - public void TestFadeOutIntoMiss() - { - float? alphaAtMiss = null; + private float? alphaAtMiss; + [Test] + public void TestHitCircleClassicMod() + { AddStep("Create hit circle", () => { - alphaAtMiss = null; - - DrawableHitCircle drawableHitCircle = new DrawableHitCircle(new HitCircle - { - StartTime = Time.Current + 500, - Position = new Vector2(250) - }); - - drawableHitCircle.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); - - drawableHitCircle.OnNewResult += (_, _) => - { - alphaAtMiss = drawableHitCircle.Alpha; - }; - - Child = drawableHitCircle; + SelectedMods.Value = new Mod[] { new OsuModClassic() }; + createCircle(); }); AddUntilStep("Wait until circle is missed", () => alphaAtMiss.IsNotNull()); AddAssert("Transparent when missed", () => alphaAtMiss == 0); } + + [Test] + public void TestHitCircleNoMod() + { + AddStep("Create hit circle", () => + { + SelectedMods.Value = Array.Empty(); + createCircle(); + }); + + AddUntilStep("Wait until circle is missed", () => alphaAtMiss.IsNotNull()); + AddAssert("Opaque when missed", () => alphaAtMiss == 1); + } + + [Test] + public void TestSliderClassicMod() + { + AddStep("Create slider", () => + { + SelectedMods.Value = new Mod[] { new OsuModClassic() }; + createSlider(); + }); + + AddUntilStep("Wait until head circle is missed", () => alphaAtMiss.IsNotNull()); + AddAssert("Head circle transparent when missed", () => alphaAtMiss == 0); + } + + [Test] + public void TestSliderNoMod() + { + AddStep("Create slider", () => + { + SelectedMods.Value = Array.Empty(); + createSlider(); + }); + + AddUntilStep("Wait until head circle is missed", () => alphaAtMiss.IsNotNull()); + AddAssert("Head circle opaque when missed", () => alphaAtMiss == 1); + } + + private void createCircle() + { + alphaAtMiss = null; + + DrawableHitCircle drawableHitCircle = new DrawableHitCircle(new HitCircle + { + StartTime = Time.Current + 500, + Position = new Vector2(250) + }); + + foreach (var mod in SelectedMods.Value.OfType()) + mod.ApplyToDrawableHitObject(drawableHitCircle); + + drawableHitCircle.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); + + drawableHitCircle.OnNewResult += (_, _) => + { + alphaAtMiss = drawableHitCircle.Alpha; + }; + + Child = drawableHitCircle; + } + + private void createSlider() + { + alphaAtMiss = null; + + DrawableSlider drawableSlider = new DrawableSlider(new Slider + { + StartTime = Time.Current + 500, + Position = new Vector2(250), + Path = new SliderPath(PathType.Linear, new[] + { + Vector2.Zero, + new Vector2(0, 100), + }) + }); + + drawableSlider.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); + + drawableSlider.OnLoadComplete += _ => + { + foreach (var mod in SelectedMods.Value.OfType()) + mod.ApplyToDrawableHitObject(drawableSlider.HeadCircle); + + drawableSlider.HeadCircle.OnNewResult += (_, _) => + { + alphaAtMiss = drawableSlider.HeadCircle.Alpha; + }; + }; + Child = drawableSlider; + } } } From defe1fbf5032d7120d173571852d5d3f6ae2fe75 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 12 Feb 2023 09:25:28 -0600 Subject: [PATCH 05/10] Remove '#nullable disable' --- osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs index 170c230ef7..615c878014 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Linq; using NUnit.Framework; From 5e774a28d86f3ad35931d0df5da5a94f084eefc4 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 15 Feb 2023 00:45:58 -0600 Subject: [PATCH 06/10] Correct timings to match stable exactly + don't fade with hidden --- osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs index 8d79157f82..786b89d790 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs @@ -36,6 +36,8 @@ public class OsuModClassic : ModClassic, IApplicableToHitObject, IApplicableToDr [SettingSource("Fade out hit circles earlier", "Make hit circles fade out into a miss, rather than after it.")] public Bindable FadeHitCircleEarly { get; } = new Bindable(true); + private bool hiddenModActive; + public void ApplyToHitObject(HitObject hitObject) { switch (hitObject) @@ -56,6 +58,8 @@ public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset if (ClassicNoteLock.Value) osuRuleset.Playfield.HitPolicy = new ObjectOrderedHitPolicy(); + + hiddenModActive = drawableRuleset.Mods.OfType().Any(); } public void ApplyToDrawableHitObject(DrawableHitObject obj) @@ -64,7 +68,7 @@ public void ApplyToDrawableHitObject(DrawableHitObject obj) { case DrawableSliderHead head: head.TrackFollowCircle = !NoSliderHeadMovement.Value; - if (FadeHitCircleEarly.Value) + if (FadeHitCircleEarly.Value && !hiddenModActive) applyEarlyFading(head); break; @@ -73,7 +77,7 @@ public void ApplyToDrawableHitObject(DrawableHitObject obj) break; case DrawableHitCircle circle: - if (FadeHitCircleEarly.Value) + if (FadeHitCircleEarly.Value && !hiddenModActive) applyEarlyFading(circle); break; } @@ -85,9 +89,9 @@ private void applyEarlyFading(DrawableHitCircle circle) { using (o.BeginAbsoluteSequence(o.StateUpdateTime)) { - double mehWindow = o.HitObject.HitWindows.WindowFor(HitResult.Meh); - double lateMissFadeTime = mehWindow / 4 + 15; - o.Delay(mehWindow - lateMissFadeTime).FadeOut(lateMissFadeTime); + double okWindow = o.HitObject.HitWindows.WindowFor(HitResult.Ok); + double lateMissFadeTime = o.HitObject.HitWindows.WindowFor(HitResult.Meh) - okWindow; + o.Delay(okWindow).FadeOut(lateMissFadeTime); } }; } From e06502085e57ec6f53a7dc93c78794a6f440bb8a Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 16 Feb 2023 16:31:42 -0600 Subject: [PATCH 07/10] Enable fading when hidden only hides appreach circles --- osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs index 786b89d790..ca2f59cfb7 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs @@ -36,7 +36,7 @@ public class OsuModClassic : ModClassic, IApplicableToHitObject, IApplicableToDr [SettingSource("Fade out hit circles earlier", "Make hit circles fade out into a miss, rather than after it.")] public Bindable FadeHitCircleEarly { get; } = new Bindable(true); - private bool hiddenModActive; + private bool usingHiddenFading; public void ApplyToHitObject(HitObject hitObject) { @@ -59,7 +59,7 @@ public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset if (ClassicNoteLock.Value) osuRuleset.Playfield.HitPolicy = new ObjectOrderedHitPolicy(); - hiddenModActive = drawableRuleset.Mods.OfType().Any(); + usingHiddenFading = !drawableRuleset.Mods.OfType().FirstOrDefault()?.OnlyFadeApproachCircles.Value ?? false; } public void ApplyToDrawableHitObject(DrawableHitObject obj) @@ -68,7 +68,7 @@ public void ApplyToDrawableHitObject(DrawableHitObject obj) { case DrawableSliderHead head: head.TrackFollowCircle = !NoSliderHeadMovement.Value; - if (FadeHitCircleEarly.Value && !hiddenModActive) + if (FadeHitCircleEarly.Value && !usingHiddenFading) applyEarlyFading(head); break; @@ -77,7 +77,7 @@ public void ApplyToDrawableHitObject(DrawableHitObject obj) break; case DrawableHitCircle circle: - if (FadeHitCircleEarly.Value && !hiddenModActive) + if (FadeHitCircleEarly.Value && !usingHiddenFading) applyEarlyFading(circle); break; } From 58d64cdbd04e07f56c50913efab939b664204751 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 18 Feb 2023 17:31:18 -0600 Subject: [PATCH 08/10] Clarify usingHiddenFading logic --- osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs index ca2f59cfb7..a337634e9a 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs @@ -59,7 +59,7 @@ public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset if (ClassicNoteLock.Value) osuRuleset.Playfield.HitPolicy = new ObjectOrderedHitPolicy(); - usingHiddenFading = !drawableRuleset.Mods.OfType().FirstOrDefault()?.OnlyFadeApproachCircles.Value ?? false; + usingHiddenFading = (drawableRuleset.Mods.OfType().SingleOrDefault()?.OnlyFadeApproachCircles.Value ?? true) != true; } public void ApplyToDrawableHitObject(DrawableHitObject obj) From 0611fd40350632d0bdf2b4af807990e50653a7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 19 Feb 2023 16:39:16 +0100 Subject: [PATCH 09/10] Add coverage for classic/hidden interactions --- .../TestSceneHitCircleLateFade.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs index 615c878014..3c32b4fa65 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs @@ -35,6 +35,32 @@ public void TestHitCircleClassicMod() AddAssert("Transparent when missed", () => alphaAtMiss == 0); } + [Test] + public void TestHitCircleClassicAndFullHiddenMods() + { + AddStep("Create hit circle", () => + { + SelectedMods.Value = new Mod[] { new OsuModHidden(), new OsuModClassic() }; + createCircle(); + }); + + AddUntilStep("Wait until circle is missed", () => alphaAtMiss.IsNotNull()); + AddAssert("Transparent when missed", () => alphaAtMiss == 0); + } + + [Test] + public void TestHitCircleClassicAndApproachCircleOnlyHiddenMods() + { + AddStep("Create hit circle", () => + { + SelectedMods.Value = new Mod[] { new OsuModHidden { OnlyFadeApproachCircles = { Value = true } }, new OsuModClassic() }; + createCircle(); + }); + + AddUntilStep("Wait until circle is missed", () => alphaAtMiss.IsNotNull()); + AddAssert("Transparent when missed", () => alphaAtMiss == 0); + } + [Test] public void TestHitCircleNoMod() { From 8a488ebccc4274c3bc8692513239b0f10fd903ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 19 Feb 2023 16:12:10 +0100 Subject: [PATCH 10/10] Actually simplify condition --- osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs index a337634e9a..250d97c537 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs @@ -59,7 +59,7 @@ public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset if (ClassicNoteLock.Value) osuRuleset.Playfield.HitPolicy = new ObjectOrderedHitPolicy(); - usingHiddenFading = (drawableRuleset.Mods.OfType().SingleOrDefault()?.OnlyFadeApproachCircles.Value ?? true) != true; + usingHiddenFading = drawableRuleset.Mods.OfType().SingleOrDefault()?.OnlyFadeApproachCircles.Value == false; } public void ApplyToDrawableHitObject(DrawableHitObject obj)