From beee9b89d53806803a45a87462c2711daa689225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 13 Dec 2020 19:29:41 +0100 Subject: [PATCH] Change bar line SHOC to nested playfield --- .../UI/BarLinePlayfield.cs | 11 ++++ osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 62 ++++++++++++++++--- 2 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 osu.Game.Rulesets.Taiko/UI/BarLinePlayfield.cs diff --git a/osu.Game.Rulesets.Taiko/UI/BarLinePlayfield.cs b/osu.Game.Rulesets.Taiko/UI/BarLinePlayfield.cs new file mode 100644 index 0000000000..83d0a17e09 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/UI/BarLinePlayfield.cs @@ -0,0 +1,11 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.UI.Scrolling; + +namespace osu.Game.Rulesets.Taiko.UI +{ + public class BarLinePlayfield : ScrollingPlayfield + { + } +} diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 370760f03e..d20b190c86 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -10,6 +10,7 @@ using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; @@ -38,10 +39,15 @@ namespace osu.Game.Rulesets.Taiko.UI private SkinnableDrawable mascot; private ProxyContainer topLevelHitContainer; - private ScrollingHitObjectContainer barlineContainer; private Container rightArea; private Container leftArea; + /// + /// is purposefully not called on this to prevent i.e. being able to interact + /// with bar lines in the editor. + /// + private BarLinePlayfield barLinePlayfield; + private Container hitTargetOffsetContent; public TaikoPlayfield(ControlPointInfo controlPoints) @@ -84,7 +90,7 @@ namespace osu.Game.Rulesets.Taiko.UI RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - barlineContainer = new ScrollingHitObjectContainer(), + barLinePlayfield = new BarLinePlayfield(), new Container { Name = "Hit objects", @@ -155,12 +161,50 @@ namespace osu.Game.Rulesets.Taiko.UI mascot.Scale = new Vector2(DrawHeight / DEFAULT_HEIGHT); } + #region Pooling support + + public override void Add(HitObject h) + { + switch (h) + { + case BarLine barLine: + barLinePlayfield.Add(barLine); + break; + + case TaikoHitObject taikoHitObject: + base.Add(taikoHitObject); + break; + + default: + throw new ArgumentException($"Unsupported {nameof(HitObject)} type: {h.GetType()}"); + } + } + + public override bool Remove(HitObject h) + { + switch (h) + { + case BarLine barLine: + return barLinePlayfield.Remove(barLine); + + case TaikoHitObject taikoHitObject: + return base.Remove(taikoHitObject); + + default: + throw new ArgumentException($"Unsupported {nameof(HitObject)} type: {h.GetType()}"); + } + } + + #endregion + + #region Non-pooling support + public override void Add(DrawableHitObject h) { switch (h) { - case DrawableBarLine barline: - barlineContainer.Add(barline); + case DrawableBarLine barLine: + barLinePlayfield.Add(barLine); break; case DrawableTaikoHitObject taikoObject: @@ -170,7 +214,7 @@ namespace osu.Game.Rulesets.Taiko.UI break; default: - throw new ArgumentException($"Unsupported {nameof(DrawableHitObject)} type"); + throw new ArgumentException($"Unsupported {nameof(DrawableHitObject)} type: {h.GetType()}"); } } @@ -178,8 +222,8 @@ namespace osu.Game.Rulesets.Taiko.UI { switch (h) { - case DrawableBarLine barline: - return barlineContainer.Remove(barline); + case DrawableBarLine barLine: + return barLinePlayfield.Remove(barLine); case DrawableTaikoHitObject _: h.OnNewResult -= OnNewResult; @@ -187,10 +231,12 @@ namespace osu.Game.Rulesets.Taiko.UI return base.Remove(h); default: - throw new ArgumentException($"Unsupported {nameof(DrawableHitObject)} type"); + throw new ArgumentException($"Unsupported {nameof(DrawableHitObject)} type: {h.GetType()}"); } } + #endregion + internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result) { if (!DisplayJudgements.Value)