From a95ee7494f54b36929dbc7574b893adc199b47a8 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 8 Aug 2017 16:01:18 +0900 Subject: [PATCH 01/10] Initial conversion of taiko to use ScrollingPlayfield. --- .../Visual/TestCaseTaikoPlayfield.cs | 12 ++----- .../Objects/Drawables/DrawableBarLine.cs | 29 +++++---------- .../Objects/Drawables/DrawableDrumRoll.cs | 36 ++++++++----------- .../Objects/Drawables/DrawableDrumRollTick.cs | 5 --- .../Objects/Drawables/DrawableSwell.cs | 13 +++---- .../Drawables/DrawableTaikoHitObject.cs | 18 +--------- .../Drawables/Pieces/ElongatedCirclePiece.cs | 12 +------ osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs | 1 - .../Objects/TaikoHitObject.cs | 14 -------- .../UI/TaikoHitRenderer.cs | 4 +-- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 20 ++++------- 11 files changed, 41 insertions(+), 123 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs b/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs index 45be9e800d..f6ee2a5bf3 100644 --- a/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs @@ -151,13 +151,9 @@ namespace osu.Desktop.Tests.Visual private void addBarLine(bool major, double delay = scroll_time) { - BarLine bl = new BarLine - { - StartTime = playfield.Time.Current + delay, - ScrollTime = scroll_time - }; + BarLine bl = new BarLine { StartTime = playfield.Time.Current + delay }; - playfield.AddBarLine(major ? new DrawableBarLineMajor(bl) : new DrawableBarLine(bl)); + playfield.Add(major ? new DrawableBarLineMajor(bl) : new DrawableBarLine(bl)); } private void addSwell(double duration = default_duration) @@ -166,7 +162,6 @@ namespace osu.Desktop.Tests.Visual { StartTime = playfield.Time.Current + scroll_time, Duration = duration, - ScrollTime = scroll_time })); } @@ -180,7 +175,6 @@ namespace osu.Desktop.Tests.Visual StartTime = playfield.Time.Current + scroll_time, IsStrong = strong, Duration = duration, - ScrollTime = scroll_time, }; playfield.Add(new DrawableDrumRoll(d)); @@ -191,7 +185,6 @@ namespace osu.Desktop.Tests.Visual Hit h = new Hit { StartTime = playfield.Time.Current + scroll_time, - ScrollTime = scroll_time, IsStrong = strong }; @@ -206,7 +199,6 @@ namespace osu.Desktop.Tests.Visual Hit h = new Hit { StartTime = playfield.Time.Current + scroll_time, - ScrollTime = scroll_time, IsStrong = strong }; diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs index 7507ee600e..f6959fb426 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs @@ -5,13 +5,16 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using OpenTK; +using osu.Game.Rulesets.Objects.Drawables; +using System; +using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces; namespace osu.Game.Rulesets.Taiko.Objects.Drawables { /// /// A line that scrolls alongside hit objects in the playfield and visualises control points. /// - public class DrawableBarLine : Container + public class DrawableBarLine : DrawableTaikoHitObject { /// /// The width of the line tracker. @@ -34,15 +37,11 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables protected readonly BarLine BarLine; public DrawableBarLine(BarLine barLine) + : base(barLine) { BarLine = barLine; - Anchor = Anchor.CentreLeft; - Origin = Anchor.Centre; - - RelativePositionAxes = Axes.X; RelativeSizeAxes = Axes.Y; - Width = tracker_width; Children = new[] @@ -56,24 +55,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables Alpha = 0.75f } }; - - LifetimeStart = BarLine.StartTime - BarLine.ScrollTime * 2; - LifetimeEnd = BarLine.StartTime + BarLine.ScrollTime; } - protected override void LoadComplete() + protected override TaikoPiece CreateMainPiece() => new TaikoPiece(); + + protected override void UpdateState(ArmedState state) { - base.LoadComplete(); - this.Delay(BarLine.StartTime - Time.Current).FadeOut(base_fadeout_time * BarLine.ScrollTime / 1000); - } - - private void updateScrollPosition(double time) => this.MoveToX((float)((BarLine.StartTime - time) / BarLine.ScrollTime)); - - protected override void Update() - { - base.Update(); - - updateScrollPosition(Time.Current); } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs index 74f0f2326d..e9c50dacf8 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs @@ -11,6 +11,7 @@ using OpenTK; using OpenTK.Graphics; using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; namespace osu.Game.Rulesets.Taiko.Objects.Drawables { @@ -34,27 +35,29 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; + Width = (float)HitObject.Duration; + + Container tickContainer; + MainPiece.Add(tickContainer = new Container + { + RelativeSizeAxes = Axes.Both, + RelativeChildOffset = new Vector2((float)HitObject.StartTime, 0), + RelativeChildSize = new Vector2((float)HitObject.Duration, 1) + }); + foreach (var tick in drumRoll.Ticks) { - var newTick = new DrawableDrumRollTick(tick) - { - X = (float)((tick.StartTime - HitObject.StartTime) / HitObject.Duration) - }; - + var newTick = new DrawableDrumRollTick(tick) { X = (float)tick.StartTime }; newTick.OnJudgement += onTickJudgement; AddNested(newTick); - MainPiece.Add(newTick); + tickContainer.Add(newTick); } } protected override TaikoJudgement CreateJudgement() => new TaikoJudgement { SecondHit = HitObject.IsStrong }; - protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece - { - Length = (float)(HitObject.Duration / HitObject.ScrollTime), - PlayfieldLengthReference = () => Parent.DrawSize.X - }; + protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece(); [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -63,17 +66,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables accentDarkColour = colours.YellowDarker; } - protected override void LoadComplete() - { - base.LoadComplete(); - - // This is naive, however it's based on the reasoning that the hit target - // is further than mid point of the play field, so the time taken to scroll in should always - // be greater than the time taken to scroll out to the left of the screen. - // Thus, using PreEmpt here is enough for the drum roll to completely scroll out. - LifetimeEnd = HitObject.EndTime + HitObject.ScrollTime; - } - private void onTickJudgement(DrawableHitObject obj) { if (obj.Judgement.Result == HitResult.Hit) diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs index 0e1cd05de3..ad065395b9 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs @@ -47,11 +47,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables } } - protected override void UpdateScrollPosition(double time) - { - // Ticks don't move - } - protected override bool HandleKeyPress(Key key) { return Judgement.Result == HitResult.None && UpdateJudgement(true); diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs index e861af03cf..f704879f1a 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs @@ -118,7 +118,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables }); MainPiece.Add(symbol = new SwellSymbolPiece()); - } [BackgroundDependencyLoader] @@ -189,20 +188,22 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables Expire(); } - protected override void UpdateScrollPosition(double time) + protected override void Update() { - // Make the swell stop at the hit target - double t = Math.Min(HitObject.StartTime, time); + base.Update(); + // Make the swell stop at the hit target + X = (float)Math.Max(Time.Current, HitObject.StartTime); + + double t = Math.Min(HitObject.StartTime, Time.Current); if (t == HitObject.StartTime && !hasStarted) { OnStart?.Invoke(); hasStarted = true; } - - base.UpdateScrollPosition(t); } + protected override bool HandleKeyPress(Key key) { if (Judgement.Result != HitResult.None) diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs index 510994ed70..caae70fe05 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs @@ -12,7 +12,7 @@ using OpenTK.Input; namespace osu.Game.Rulesets.Taiko.Objects.Drawables { - public abstract class DrawableTaikoHitObject : DrawableHitObject + public abstract class DrawableTaikoHitObject : DrawableScrollingHitObject where TaikoHitType : TaikoHitObject { /// @@ -38,30 +38,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables RelativeSizeAxes = Axes.Both; Size = new Vector2(HitObject.IsStrong ? TaikoHitObject.DEFAULT_STRONG_SIZE : TaikoHitObject.DEFAULT_SIZE); - RelativePositionAxes = Axes.X; - Add(MainPiece = CreateMainPiece()); MainPiece.KiaiMode = HitObject.Kiai; - - LifetimeStart = HitObject.StartTime - HitObject.ScrollTime * 2; } protected override TaikoJudgement CreateJudgement() => new TaikoJudgement(); protected virtual TaikoPiece CreateMainPiece() => new CirclePiece(); - /// - /// Sets the scroll position of the DrawableHitObject relative to the offset between - /// a time value and the HitObject's StartTime. - /// - /// - protected virtual void UpdateScrollPosition(double time) => X = (float)((HitObject.StartTime - time) / HitObject.ScrollTime); - - protected override void Update() - { - UpdateScrollPosition(Time.Current); - } - protected virtual bool HandleKeyPress(Key key) => false; protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs index 2f5b4eefd6..d3786a4324 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs @@ -8,16 +8,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces { public class ElongatedCirclePiece : CirclePiece { - /// - /// As we are being used to define the absolute size of hits, we need to be given a relative reference of our containing playfield container. - /// - public Func PlayfieldLengthReference; - - /// - /// The length of this piece as a multiple of the value returned by - /// - public float Length; - public ElongatedCirclePiece() { RelativeSizeAxes = Axes.Y; @@ -35,7 +25,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces Right = padding, }; - Width = (PlayfieldLengthReference?.Invoke() ?? 0) * Length + DrawHeight; + Width = Parent.DrawSize.X + DrawHeight; } } } diff --git a/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs index fd9daa269c..526d23f51a 100644 --- a/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs +++ b/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs @@ -80,7 +80,6 @@ namespace osu.Game.Rulesets.Taiko.Objects ret.Add(new DrumRollTick { FirstTick = first, - ScrollTime = ScrollTime, TickSpacing = tickSpacing, StartTime = t, IsStrong = IsStrong, diff --git a/osu.Game.Rulesets.Taiko/Objects/TaikoHitObject.cs b/osu.Game.Rulesets.Taiko/Objects/TaikoHitObject.cs index 7e7dc3662f..f1c0afc675 100644 --- a/osu.Game.Rulesets.Taiko/Objects/TaikoHitObject.cs +++ b/osu.Game.Rulesets.Taiko/Objects/TaikoHitObject.cs @@ -24,16 +24,6 @@ namespace osu.Game.Rulesets.Taiko.Objects /// public const float DEFAULT_STRONG_SIZE = DEFAULT_SIZE * STRONG_SCALE; - /// - /// The time taken from the initial (off-screen) spawn position to the centre of the hit target for a of 1000ms. - /// - private const double scroll_time = 6000; - - /// - /// Our adjusted taking into consideration local and other speed multipliers. - /// - public double ScrollTime; - /// /// Whether this HitObject is a "strong" type. /// Strong hit objects give more points for hitting the hit object with both keys. @@ -49,12 +39,8 @@ namespace osu.Game.Rulesets.Taiko.Objects { base.ApplyDefaults(controlPointInfo, difficulty); - TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); - DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime); EffectControlPoint effectPoint = controlPointInfo.EffectPointAt(StartTime); - ScrollTime = scroll_time * (timingPoint.BeatLength * difficultyPoint.SpeedMultiplier / 1000) / difficulty.SliderMultiplier; - Kiai |= effectPoint.KiaiMode; } } diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoHitRenderer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoHitRenderer.cs index 570b4be488..9c9c71ab46 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoHitRenderer.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoHitRenderer.cs @@ -21,7 +21,7 @@ using System.Linq; namespace osu.Game.Rulesets.Taiko.UI { - public class TaikoHitRenderer : HitRenderer + public class TaikoHitRenderer : ScrollingHitRenderer { public TaikoHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) : base(beatmap, isForCurrentRuleset) @@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Taiko.UI barLine.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.Difficulty); bool isMajor = currentBeat % (int)currentPoint.TimeSignature == 0; - taikoPlayfield.AddBarLine(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine)); + taikoPlayfield.Add(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine)); double bl = currentPoint.BeatLength; if (bl < 800) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index dca339f734..d94b69f141 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -18,7 +18,7 @@ using osu.Game.Rulesets.Taiko.Objects.Drawables; namespace osu.Game.Rulesets.Taiko.UI { - public class TaikoPlayfield : Playfield + public class TaikoPlayfield : ScrollingPlayfield { /// /// Default height of a when inside a . @@ -35,14 +35,14 @@ namespace osu.Game.Rulesets.Taiko.UI /// private const float left_area_size = 240; - protected override Container Content => hitObjectContainer; private readonly Container hitExplosionContainer; private readonly Container kiaiExplosionContainer; - private readonly Container barLineContainer; private readonly Container judgementContainer; - private readonly Container hitObjectContainer; + protected override Container Content => content; + private readonly Container content; + private readonly Container topLevelHitContainer; private readonly Container overlayBackgroundContainer; @@ -52,6 +52,7 @@ namespace osu.Game.Rulesets.Taiko.UI private readonly Box background; public TaikoPlayfield() + : base(Axes.X) { AddRangeInternal(new Drawable[] { @@ -96,10 +97,6 @@ namespace osu.Game.Rulesets.Taiko.UI FillMode = FillMode.Fit, BlendingMode = BlendingMode.Additive, }, - barLineContainer = new Container - { - RelativeSizeAxes = Axes.Both, - }, new HitTarget { Anchor = Anchor.CentreLeft, @@ -107,7 +104,7 @@ namespace osu.Game.Rulesets.Taiko.UI RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fit }, - hitObjectContainer = new Container + content = new Container { RelativeSizeAxes = Axes.Both, }, @@ -205,11 +202,6 @@ namespace osu.Game.Rulesets.Taiko.UI swell.OnStart += () => topLevelHitContainer.Add(swell.CreateProxy()); } - public void AddBarLine(DrawableBarLine barLine) - { - barLineContainer.Add(barLine); - } - public override void OnJudgement(DrawableHitObject judgedObject) { bool wasHit = judgedObject.Judgement.Result == HitResult.Hit; From 27e63eb7c4d2947e8acec044b189349102593bd4 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 10:54:00 +0900 Subject: [PATCH 02/10] Fix up sizing issues. --- osu-framework | 2 +- .../Objects/Drawables/DrawableBarLine.cs | 8 ++++++-- .../Objects/Drawables/DrawableDrumRoll.cs | 3 --- .../Objects/Drawables/DrawableDrumRollTick.cs | 8 ++++++++ osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs | 8 ++++++++ .../Objects/Drawables/DrawableSwell.cs | 8 ++++++++ 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/osu-framework b/osu-framework index dd0daafcfc..3b858d078c 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit dd0daafcfc0d625bb588c8e12d7db58bc00c255e +Subproject commit 3b858d078cf54465d9af8e2bb9e1a144bcfcdbf4 diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs index f6959fb426..28f0af4aba 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs @@ -8,13 +8,14 @@ using OpenTK; using osu.Game.Rulesets.Objects.Drawables; using System; using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces; +using osu.Game.Rulesets.Taiko.Judgements; namespace osu.Game.Rulesets.Taiko.Objects.Drawables { /// /// A line that scrolls alongside hit objects in the playfield and visualises control points. /// - public class DrawableBarLine : DrawableTaikoHitObject + public class DrawableBarLine : DrawableScrollingHitObject { /// /// The width of the line tracker. @@ -41,6 +42,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables { BarLine = barLine; + Anchor = Anchor.CentreLeft; + Origin = Anchor.Centre; + RelativeSizeAxes = Axes.Y; Width = tracker_width; @@ -57,7 +61,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables }; } - protected override TaikoPiece CreateMainPiece() => new TaikoPiece(); + protected override TaikoJudgement CreateJudgement() => new TaikoJudgement(); protected override void UpdateState(ArmedState state) { diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs index e9c50dacf8..425f87752f 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs @@ -32,9 +32,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables public DrawableDrumRoll(DrumRoll drumRoll) : base(drumRoll) { - RelativeSizeAxes = Axes.Y; - AutoSizeAxes = Axes.X; - Width = (float)HitObject.Duration; Container tickContainer; diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs index ad065395b9..5a6abd24b1 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs @@ -18,6 +18,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables FillMode = FillMode.Fit; } + protected override void LoadComplete() + { + base.LoadComplete(); + + // We need to set this here because RelativeSizeAxes won't/can't set our size by default with a different RelativeChildSize + Width *= Parent.RelativeChildSize.X; + } + protected override TaikoPiece CreateMainPiece() => new TickPiece { Filled = HitObject.FirstTick diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs index 5a17355cdb..0666d75083 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs @@ -29,6 +29,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables FillMode = FillMode.Fit; } + protected override void LoadComplete() + { + base.LoadComplete(); + + // We need to set this here because RelativeSizeAxes won't/can't set our size by default with a different RelativeChildSize + Width *= Parent.RelativeChildSize.X; + } + protected override void CheckJudgement(bool userTriggered) { if (!userTriggered) diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs index f704879f1a..2b1ed07da7 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs @@ -128,6 +128,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables targetRing.BorderColour = colours.YellowDark.Opacity(0.25f); } + protected override void LoadComplete() + { + base.LoadComplete(); + + // We need to set this here because RelativeSizeAxes won't/can't set our size by default with a different RelativeChildSize + Width *= Parent.RelativeChildSize.X; + } + protected override void CheckJudgement(bool userTriggered) { if (userTriggered) From d83c218e08155add50e570246f09e84ebdf0d6a5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 16:19:09 +0900 Subject: [PATCH 03/10] Remove various scrolling container optimisations (removing when not alive). --- .../Drawables/DrawableScrollingHitObject.cs | 2 ++ osu.Game/Rulesets/Timing/ScrollingContainer.cs | 2 ++ .../Rulesets/Timing/SpeedAdjustmentContainer.cs | 2 ++ osu.Game/Rulesets/UI/ScrollingPlayfield.cs | 17 +++++++++-------- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableScrollingHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableScrollingHitObject.cs index f67dd4dfea..a7c4dd0333 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableScrollingHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableScrollingHitObject.cs @@ -32,6 +32,8 @@ namespace osu.Game.Rulesets.Objects.Drawables } } + public override bool RemoveWhenNotAlive => false; + protected DrawableScrollingHitObject(TObject hitObject) : base(hitObject) { diff --git a/osu.Game/Rulesets/Timing/ScrollingContainer.cs b/osu.Game/Rulesets/Timing/ScrollingContainer.cs index 843f307d0d..9bb32ead77 100644 --- a/osu.Game/Rulesets/Timing/ScrollingContainer.cs +++ b/osu.Game/Rulesets/Timing/ScrollingContainer.cs @@ -27,6 +27,8 @@ namespace osu.Game.Rulesets.Timing /// internal Axes ScrollingAxes; + public override bool RemoveWhenNotAlive => false; + /// /// The control point that defines the speed adjustments for this container. This is set by the . /// diff --git a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs index 9d5f49e155..5d6c03b9de 100644 --- a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs +++ b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs @@ -34,6 +34,8 @@ namespace osu.Game.Rulesets.Timing /// public Axes ScrollingAxes { get; internal set; } + public override bool RemoveWhenNotAlive => false; + /// /// The that defines the speed adjustments. /// diff --git a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs index 66ca2dd7c4..f8e090d613 100644 --- a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs @@ -7,6 +7,7 @@ using System.Linq; using OpenTK.Input; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using osu.Framework.MathUtils; @@ -154,7 +155,7 @@ namespace osu.Game.Rulesets.UI /// Hit objects that are to be re-processed on the next update. /// private readonly List queuedHitObjects = new List(); - private readonly List speedAdjustments = new List(); + private readonly Container speedAdjustments; private readonly Axes scrollingAxes; @@ -165,6 +166,8 @@ namespace osu.Game.Rulesets.UI public ScrollingHitObjectContainer(Axes scrollingAxes) { this.scrollingAxes = scrollingAxes; + + AddInternal(speedAdjustments = new Container { RelativeSizeAxes = Axes.Both }); } /// @@ -176,9 +179,7 @@ namespace osu.Game.Rulesets.UI speedAdjustment.ScrollingAxes = scrollingAxes; speedAdjustment.VisibleTimeRange.BindTo(VisibleTimeRange); speedAdjustment.Reversed.BindTo(Reversed); - speedAdjustments.Add(speedAdjustment); - AddInternal(speedAdjustment); } public override IEnumerable Objects => speedAdjustments.SelectMany(s => s.Children); @@ -210,11 +211,11 @@ namespace osu.Game.Rulesets.UI var hitObject = queuedHitObjects[i]; var target = adjustmentContainerFor(hitObject); - if (target != null) - { - target.Add(hitObject); - queuedHitObjects.RemoveAt(i); - } + if (target == null) + continue; + + target.Add(hitObject); + queuedHitObjects.RemoveAt(i); } } From 88cefa77bd69ec637afbfaf6dddf1614e9fd9e8d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 16:19:20 +0900 Subject: [PATCH 04/10] Make TestCaseTaikoPlayfield work again. --- .../Visual/TestCaseTaikoPlayfield.cs | 64 +++++++++++++------ 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs b/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs index f6ee2a5bf3..1589ca8f9b 100644 --- a/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs @@ -14,6 +14,9 @@ using osu.Game.Rulesets.Taiko.UI; using OpenTK; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps; +using osu.Desktop.Tests.Beatmaps; +using System.Collections.Generic; +using osu.Game.Rulesets.Objects; namespace osu.Desktop.Tests.Visual { @@ -27,7 +30,7 @@ namespace osu.Desktop.Tests.Visual protected override double TimePerAction => default_duration * 2; private readonly Random rng = new Random(1337); - private readonly TaikoPlayfield playfield; + private readonly TaikoRulesetContainer rulesetContainer; private readonly Container playfieldContainer; public TestCaseTaikoPlayfield() @@ -51,7 +54,29 @@ namespace osu.Desktop.Tests.Visual AddStep("Height test 5", () => changePlayfieldSize(5)); AddStep("Reset height", () => changePlayfieldSize(6)); - var rateAdjustClock = new StopwatchClock(true) { Rate = 1 }; + var controlPointInfo = new ControlPointInfo(); + controlPointInfo.TimingPoints.Add(new TimingControlPoint + { + BeatLength = 200 + }); + + WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap + { + HitObjects = new List { new CentreHit() }, + BeatmapInfo = new BeatmapInfo + { + Difficulty = new BeatmapDifficulty(), + Metadata = new BeatmapMetadata + { + Artist = @"Unknown", + Title = @"Sample Beatmap", + Author = @"peppy", + }, + }, + ControlPointInfo = controlPointInfo + }); + + var rateAdjustClock = new StopwatchClock(true) { Rate = 0.1 }; Add(playfieldContainer = new Container { @@ -60,10 +85,7 @@ namespace osu.Desktop.Tests.Visual RelativeSizeAxes = Axes.X, Height = TaikoPlayfield.DEFAULT_HEIGHT, Clock = new FramedClock(rateAdjustClock), - Children = new[] - { - playfield = new TaikoPlayfield() - } + Children = new[] { rulesetContainer = new TaikoRulesetContainer(null, beatmap, true) } }); } @@ -128,18 +150,18 @@ namespace osu.Desktop.Tests.Visual } }; - playfield.OnJudgement(h); + rulesetContainer.Playfield.OnJudgement(h); if (RNG.Next(10) == 0) { h.Judgement.SecondHit = true; - playfield.OnJudgement(h); + rulesetContainer.Playfield.OnJudgement(h); } } private void addMissJudgement() { - playfield.OnJudgement(new DrawableTestHit(new Hit()) + rulesetContainer.Playfield.OnJudgement(new DrawableTestHit(new Hit()) { Judgement = new TaikoJudgement { @@ -151,16 +173,16 @@ namespace osu.Desktop.Tests.Visual private void addBarLine(bool major, double delay = scroll_time) { - BarLine bl = new BarLine { StartTime = playfield.Time.Current + delay }; + BarLine bl = new BarLine { StartTime = rulesetContainer.Playfield.Time.Current + delay }; - playfield.Add(major ? new DrawableBarLineMajor(bl) : new DrawableBarLine(bl)); + rulesetContainer.Playfield.Add(major ? new DrawableBarLineMajor(bl) : new DrawableBarLine(bl)); } private void addSwell(double duration = default_duration) { - playfield.Add(new DrawableSwell(new Swell + rulesetContainer.Playfield.Add(new DrawableSwell(new Swell { - StartTime = playfield.Time.Current + scroll_time, + StartTime = rulesetContainer.Playfield.Time.Current + scroll_time, Duration = duration, })); } @@ -172,40 +194,40 @@ namespace osu.Desktop.Tests.Visual var d = new DrumRoll { - StartTime = playfield.Time.Current + scroll_time, + StartTime = rulesetContainer.Playfield.Time.Current + scroll_time, IsStrong = strong, Duration = duration, }; - playfield.Add(new DrawableDrumRoll(d)); + rulesetContainer.Playfield.Add(new DrawableDrumRoll(d)); } private void addCentreHit(bool strong) { Hit h = new Hit { - StartTime = playfield.Time.Current + scroll_time, + StartTime = rulesetContainer.Playfield.Time.Current + scroll_time, IsStrong = strong }; if (strong) - playfield.Add(new DrawableCentreHitStrong(h)); + rulesetContainer.Playfield.Add(new DrawableCentreHitStrong(h)); else - playfield.Add(new DrawableCentreHit(h)); + rulesetContainer.Playfield.Add(new DrawableCentreHit(h)); } private void addRimHit(bool strong) { Hit h = new Hit { - StartTime = playfield.Time.Current + scroll_time, + StartTime = rulesetContainer.Playfield.Time.Current + scroll_time, IsStrong = strong }; if (strong) - playfield.Add(new DrawableRimHitStrong(h)); + rulesetContainer.Playfield.Add(new DrawableRimHitStrong(h)); else - playfield.Add(new DrawableRimHit(h)); + rulesetContainer.Playfield.Add(new DrawableRimHit(h)); } private class DrawableTestHit : DrawableHitObject From 8b4f28318f5e45a365f27efaad51e79ff39bc438 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 16:19:31 +0900 Subject: [PATCH 05/10] Fix drum roll ticks. --- osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs | 2 +- .../Objects/Drawables/DrawableDrumRollTick.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs index 425f87752f..8f81368a2c 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs @@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables foreach (var tick in drumRoll.Ticks) { - var newTick = new DrawableDrumRollTick(tick) { X = (float)tick.StartTime }; + var newTick = new DrawableDrumRollTick(tick); newTick.OnJudgement += onTickJudgement; AddNested(newTick); diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs index 5a6abd24b1..6e916aa9d5 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs @@ -15,6 +15,10 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables public DrawableDrumRollTick(DrumRollTick tick) : base(tick) { + // Because ticks aren't added by the ScrollingPlayfield, we need to set the following properties ourselves + RelativePositionAxes = Axes.X; + X = (float)tick.StartTime; + FillMode = FillMode.Fit; } From 7237f834c4e1144bef0c38627cc6b2d02dc49922 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 16:39:19 +0900 Subject: [PATCH 06/10] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 67d89a3601..9bad670471 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 67d89a36016f98c0ede576b859a2ccafe114fce8 +Subproject commit 9bad670471a03e299760315fd9d3fa9a726f6233 From 2334c109e5262514970e54ab34a626d94d0aff52 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 16:46:08 +0900 Subject: [PATCH 07/10] Set better TaikoPlayfield default VisibleTimeRange. --- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index e2823ccdfe..da86c31123 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -178,6 +178,8 @@ namespace osu.Game.Rulesets.Taiko.UI RelativeSizeAxes = Axes.Both, } }); + + VisibleTimeRange.Value = 6000; } [BackgroundDependencyLoader] From 0c1b68d7111a2e5da1d4bb073db1f3ccf374b2ff Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 16:46:22 +0900 Subject: [PATCH 08/10] Fix up TestCaseTaikoPlayfield. --- osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs b/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs index 1589ca8f9b..43148da512 100644 --- a/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.Tests/Visual/TestCaseTaikoPlayfield.cs @@ -55,10 +55,7 @@ namespace osu.Desktop.Tests.Visual AddStep("Reset height", () => changePlayfieldSize(6)); var controlPointInfo = new ControlPointInfo(); - controlPointInfo.TimingPoints.Add(new TimingControlPoint - { - BeatLength = 200 - }); + controlPointInfo.TimingPoints.Add(new TimingControlPoint()); WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap { @@ -76,14 +73,14 @@ namespace osu.Desktop.Tests.Visual ControlPointInfo = controlPointInfo }); - var rateAdjustClock = new StopwatchClock(true) { Rate = 0.1 }; + var rateAdjustClock = new StopwatchClock(true) { Rate = 1 }; Add(playfieldContainer = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, - Height = TaikoPlayfield.DEFAULT_HEIGHT, + Height = 768, Clock = new FramedClock(rateAdjustClock), Children = new[] { rulesetContainer = new TaikoRulesetContainer(null, beatmap, true) } }); From e9a98358b3d47ad6708e39a9ad9f0ea71adf7030 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 17:26:59 +0900 Subject: [PATCH 09/10] Don't move completed drum rolls above the playfield. --- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index da86c31123..eb9e41f771 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -224,7 +224,7 @@ namespace osu.Game.Rulesets.Taiko.UI if (!secondHit) { - if (judgedObject.X >= -0.05f && !(judgedObject is DrawableSwell)) + if (judgedObject.X >= -0.05f && judgedObject is DrawableHit) { // If we're far enough away from the left stage, we should bring outselves in front of it topLevelHitContainer.Add(judgedObject.CreateProxy()); From bb8c5338022cd6d1313ec64750930917cccb523e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 17:34:09 +0900 Subject: [PATCH 10/10] Fix CI issues. --- .../Objects/Drawables/DrawableBarLine.cs | 3 --- .../Objects/Drawables/Pieces/ElongatedCirclePiece.cs | 1 - osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs | 7 +------ 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs index 28f0af4aba..06702e8141 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs @@ -2,12 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using OpenTK; using osu.Game.Rulesets.Objects.Drawables; -using System; -using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces; using osu.Game.Rulesets.Taiko.Judgements; namespace osu.Game.Rulesets.Taiko.Objects.Drawables diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs index d3786a4324..4642e318c4 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/ElongatedCirclePiece.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Framework.Graphics; namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs index 36ee0c2a1d..723af3e4e9 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs @@ -36,11 +36,6 @@ namespace osu.Game.Rulesets.Taiko.UI private void loadBarLines() { - var taikoPlayfield = Playfield as TaikoPlayfield; - - if (taikoPlayfield == null) - return; - TaikoHitObject lastObject = Beatmap.HitObjects[Beatmap.HitObjects.Count - 1]; double lastHitTime = 1 + (lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime; @@ -72,7 +67,7 @@ namespace osu.Game.Rulesets.Taiko.UI barLine.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.Difficulty); bool isMajor = currentBeat % (int)currentPoint.TimeSignature == 0; - taikoPlayfield.Add(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine)); + Playfield.Add(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine)); double bl = currentPoint.BeatLength; if (bl < 800)