From cd237da6d39fb2f846e2b575e8bde7230ca02612 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Thu, 28 Dec 2017 17:06:15 +0100 Subject: [PATCH] extend TestCaseHitCircle with new steps - Hidden, Size and Scale - also fix Auto still missing because no judgement was created --- osu.Game.Rulesets.Osu/Mods/OsuMod.cs | 6 +-- .../Tests/TestCaseHitCircle.cs | 48 +++++++++++++++++-- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuMod.cs b/osu.Game.Rulesets.Osu/Mods/OsuMod.cs index e8d98aebf3..77ce7235ee 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuMod.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuMod.cs @@ -41,10 +41,10 @@ public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects public void ApplyToDrawableHitObjects(IEnumerable drawables) { foreach (var d in drawables.OfType()) - d.ApplyCustomUpdateState += customSequence; + d.ApplyCustomUpdateState += CustomSequence; } - private void customSequence(DrawableHitObject drawable, ArmedState state) + protected void CustomSequence(DrawableHitObject drawable, ArmedState state) { if (!(drawable is DrawableOsuHitObject d)) return; @@ -70,7 +70,7 @@ private void customSequence(DrawableHitObject drawable, ArmedState state) circle.FadeIn(fadeIn).Then().FadeOut(fadeOut); // override fade in as it somehow gets cut otherwise break; case DrawableSlider slider: - slider.InitialCircle.ApplyCustomUpdateState += customSequence; + slider.InitialCircle.ApplyCustomUpdateState += CustomSequence; using (slider.BeginAbsoluteSequence(fadeOutTime, true)) { diff --git a/osu.Game.Rulesets.Osu/Tests/TestCaseHitCircle.cs b/osu.Game.Rulesets.Osu/Tests/TestCaseHitCircle.cs index ef0bffa14e..3e5201efc7 100644 --- a/osu.Game.Rulesets.Osu/Tests/TestCaseHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Tests/TestCaseHitCircle.cs @@ -11,6 +11,9 @@ using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Tests.Visual; using OpenTK; +using osu.Game.Rulesets.Osu.Mods; +using OpenTK.Graphics; +using osu.Game.Rulesets.Osu.Judgements; namespace osu.Game.Rulesets.Osu.Tests { @@ -21,7 +24,10 @@ public class TestCaseHitCircle : OsuTestCase protected override Container Content => content; private bool auto; + private bool hidden; private int depthIndex; + private int circleSize; + private float circleScale; public TestCaseHitCircle() { @@ -30,6 +36,9 @@ public TestCaseHitCircle() AddStep("Single", () => addSingle()); AddStep("Stream", addStream); AddToggleStep("Auto", v => auto = v); + AddToggleStep("Hidden", v => hidden = v); + AddSliderStep("CircleSize", 0, 10, 0, s => circleSize = s); + AddSliderStep("CircleScale", 0.5f, 2, 1, s => circleScale = s); } private void addSingle(double timeOffset = 0, Vector2? positionOffset = null) @@ -39,20 +48,25 @@ private void addSingle(double timeOffset = 0, Vector2? positionOffset = null) var circle = new HitCircle { StartTime = Time.Current + 1000 + timeOffset, - Position = positionOffset.Value + Position = positionOffset.Value, + ComboColour = Color4.LightSeaGreen }; - circle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 0 }); + circle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize }); - var drawable = new DrawableHitCircle(circle) + var drawable = new TestDrawableHitCircle(circle, auto) { Anchor = Anchor.Centre, + Scale = new Vector2(circleScale), Depth = depthIndex++ }; if (auto) drawable.State.Value = ArmedState.Hit; + if (hidden) + drawable.ApplyCustomUpdateState += new TestOsuModHidden().CustomSequence; + Add(drawable); } @@ -66,5 +80,33 @@ private void addStream() pos += new Vector2(10); } } + + private class TestOsuModHidden : OsuModHidden + { + public new void CustomSequence(DrawableHitObject drawable, ArmedState state) => base.CustomSequence(drawable, state); + } + + private class TestDrawableHitCircle : DrawableHitCircle + { + private readonly bool auto; + + public TestDrawableHitCircle(OsuHitObject h, bool auto) : base(h) + { + this.auto = auto; + } + + protected override void CheckForJudgements(bool userTriggered, double timeOffset) + { + if (auto && !userTriggered && timeOffset > 0) + { + // pretend we really hit it + AddJudgement(new OsuJudgement + { + Result = HitObject.ScoreResultForOffset(timeOffset) + }); + } + base.CheckForJudgements(userTriggered, timeOffset); + } + } } }