From d852567d1d09a3e8475d2b9f914cf89328d05e18 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 9 May 2017 20:33:59 +0900 Subject: [PATCH] Rewrite notes to have time-relative position and length. --- osu-framework | 2 +- .../Tests/TestCaseManiaHitObjects.cs | 20 +++++++--- .../Objects/Drawables/DrawableHoldNote.cs | 30 ++++++++------- .../Drawables/DrawableManiaHitObject.cs | 38 +++++++------------ .../Objects/Drawables/DrawableNote.cs | 9 ++++- .../Objects/Drawables/Pieces/BodyPiece.cs | 2 +- 6 files changed, 53 insertions(+), 48 deletions(-) diff --git a/osu-framework b/osu-framework index cebdfb1bbb..cd37a9cad9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cebdfb1bbb260e5aaca0a01e06d7128b3d1faae4 +Subproject commit cd37a9cad9aaede267152cf3753cd31fe697cec4 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index a842406f99..c4aa5749b3 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -34,32 +34,40 @@ namespace osu.Desktop.VisualTests.Tests { new Container { + Name = "Normal note column", Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, + RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableNote(new Note()) + new DrawableNote(new Note + { + StartTime = 5000 + }) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, AccentColour = Color4.Red } } }, new Container { + Name = "Hold note column", Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, + RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableHoldNote(new HoldNote()) + new DrawableHoldNote(new HoldNote + { + StartTime = 5000, + Duration = 1000, + + }) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, AccentColour = Color4.Red, Length = 0.4f } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 7db65a6522..460c65dbbd 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Allocation; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; +using osu.Framework.Graphics.Containers; namespace osu.Game.Rulesets.Mania.Objects.Drawables { @@ -24,24 +25,31 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public DrawableHoldNote(HoldNote hitObject) : base(hitObject) { - Children = new Drawable[] + RelativeSizeAxes = Axes.Both; + Height = (float)HitObject.Duration; + + Add(new Drawable[] { - headPiece = new NotePiece - { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre - }, bodyPiece = new BodyPiece { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, }, - tailPiece = new NotePiece + headPiece = new NotePiece { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre + }, + tailPiece = new NotePiece + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre } - }; + }); + + // The "length" of the hold note stops at the "base" of the tail piece + // but we want to contain the tail piece within our bounds + Height += (float)HitObject.Duration / headPiece.Height; } public override Color4 AccentColour @@ -59,12 +67,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } } - - protected override void Update() - { - bodyPiece.Height = Parent.DrawSize.Y * Length; - } - protected override void UpdateState(ArmedState state) { } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index 9f4c5f6ee2..28f9fa79b2 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -17,44 +18,31 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container glowContainer; - protected override Container Content => noteFlow; - private readonly FlowContainer noteFlow; - public DrawableManiaHitObject(TObject hitObject) : base(hitObject) { HitObject = hitObject; - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; + Anchor = Anchor.TopCentre; + Origin = Anchor.BottomCentre; - InternalChildren = new Drawable[] + RelativePositionAxes = Axes.Y; + Y = (float)HitObject.StartTime; + + Add(glowContainer = new Container { - glowContainer = new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Masking = true, - Children = new[] + RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new[] { new Box { RelativeSizeAxes = Axes.Both, - AlwaysPresent = true, - Alpha = 0 + Alpha = 0, + AlwaysPresent = true } } - }, - noteFlow = new FillFlowContainer - { - Name = "Main container", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y - } - }; + }); } public override Color4 AccentColour diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 09443b6893..57990f2738 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -18,7 +18,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public DrawableNote(Note hitObject) : base(hitObject) { - Add(headPiece = new NotePiece()); + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + Add(headPiece = new NotePiece + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre + }); } public override Color4 AccentColour diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index b2451c9995..7a61fd3a00 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces public BodyPiece() { - RelativeSizeAxes = Axes.X; + RelativeSizeAxes = Axes.Both; Masking = true; Children = new[]