diff --git a/osu-framework b/osu-framework index c76d8b811b..cfbfbe6329 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit c76d8b811b93d0c0862f342ebbab70a461006e13 +Subproject commit cfbfbe63294b88bdcdfb92fd6ae69aa826ff62c4 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 3113b63db1..a8a6a3f46d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -8,6 +8,7 @@ using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using OpenTK.Graphics; using OpenTK; +using osu.Framework.Graphics.Primitives; namespace osu.Desktop.VisualTests.Tests { @@ -40,7 +41,7 @@ namespace osu.Desktop.VisualTests.Tests { Name = "Timing section", RelativeSizeAxes = Axes.Both, - RelativeCoordinateSpace = new Vector2(1, 10000), + RelativeCoordinateSpace = new RectangleF(0, 0, 1, 10000), Children = new[] { new DrawableNote(new Note { StartTime = 5000 }) { AccentColour = Color4.Red }, @@ -62,7 +63,7 @@ namespace osu.Desktop.VisualTests.Tests { Name = "Timing section", RelativeSizeAxes = Axes.Both, - RelativeCoordinateSpace = new Vector2(1, 10000), + RelativeCoordinateSpace = new RectangleF(0, 0, 1, 10000), Children = new[] { new DrawableHoldNote(new HoldNote diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 5d7f3314cd..53194a29f8 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -12,6 +12,7 @@ using OpenTK; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Mania.Judgements; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics.Primitives; namespace osu.Game.Rulesets.Mania.Objects.Drawables { @@ -55,7 +56,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables tickContainer = new Container { RelativeSizeAxes = Axes.Both, - RelativeCoordinateSpace = new Vector2(1, (float)HitObject.Duration) + RelativeCoordinateSpace = new RectangleF(0, 0, 1, (float)HitObject.Duration) }, head = new DrawableHeadNote(this, key) { diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs index beb43d3c87..39b78cee46 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables // The gravity-adjusted start position float startY = (float)computeGravityTime(TimingChange.Time); // The gravity-adjusted end position - float endY = (float)computeGravityTime(TimingChange.Time + Content.RelativeCoordinateSpace.Y); + float endY = (float)computeGravityTime(TimingChange.Time + Content.RelativeCoordinateSpace.Height); Content.Y = startY; Content.Height = endY - startY; @@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables /// /// The time spanned by this container. /// - private double timeSpan => RelativeCoordinateSpace.Y; + private double timeSpan => RelativeCoordinateSpace.Height; /// /// The acceleration due to "gravity" of the content of this container. diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaTimingChange.cs index df7eb9e442..ccf23f254c 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaTimingChange.cs @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables // This is very naive and can be improved, but is adequate for now LifetimeStart = TimingChange.Time - parent.TimeSpan.Y; - LifetimeEnd = TimingChange.Time + Content.RelativeCoordinateSpace.Y * 2; + LifetimeEnd = TimingChange.Time + Content.RelativeCoordinateSpace.Height * 2; } } } \ No newline at end of file diff --git a/osu.Game/Rulesets/Timing/Drawables/DrawableTimingChange.cs b/osu.Game/Rulesets/Timing/Drawables/DrawableTimingChange.cs index 29ce98cceb..f554780a56 100644 --- a/osu.Game/Rulesets/Timing/Drawables/DrawableTimingChange.cs +++ b/osu.Game/Rulesets/Timing/Drawables/DrawableTimingChange.cs @@ -10,6 +10,7 @@ using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; using osu.Framework.Caching; +using osu.Framework.Graphics.Primitives; namespace osu.Game.Rulesets.Timing.Drawables { @@ -41,7 +42,8 @@ namespace osu.Game.Rulesets.Timing.Drawables AddInternal(content = new RelativeCoordinateAutoSizingContainer(scrollingAxes) { RelativeSizeAxes = Axes.Both, - RelativePositionAxes = Axes.Both + RelativePositionAxes = Axes.Both, + RelativeCoordinateSpace = new RectangleF((scrollingAxes & Axes.X) > 0 ? (float)TimingChange.Time : 0, (scrollingAxes & Axes.Y) > 0 ? (float)TimingChange.Time : 0, 1, 1) }); } @@ -61,23 +63,8 @@ namespace osu.Game.Rulesets.Timing.Drawables // Adjust our size to account for the speed changes float speedAdjustedSize = (float)(1000 / TimingChange.BeatLength / TimingChange.SpeedMultiplier); - Size = new Vector2((scrollingAxes & Axes.X) > 0 ? speedAdjustedSize : 1, - (scrollingAxes & Axes.Y) > 0 ? speedAdjustedSize : 1); - - RelativeCoordinateSpace = new Vector2((scrollingAxes & Axes.X) > 0 ? parent.TimeSpan.X : 1, - (scrollingAxes & Axes.Y) > 0 ? parent.TimeSpan.Y : 1); - } - - public override void Add(DrawableHitObject hitObject) - { - // The previously relatively-positioned hit object will now become relative to content, but since the hit object has no knowledge of content, - // we need to offset it back by content's position (timing change time) so that it becomes correctly relatively-positioned to content - // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing change - // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet - hitObject.Position = new Vector2((scrollingAxes & Axes.X) > 0 ? hitObject.X - (float)TimingChange.Time : hitObject.X, - (scrollingAxes & Axes.Y) > 0 ? hitObject.Y - (float)TimingChange.Time : hitObject.Y); - - base.Add(hitObject); + Size = new Vector2((scrollingAxes & Axes.X) > 0 ? speedAdjustedSize : 1, (scrollingAxes & Axes.Y) > 0 ? speedAdjustedSize : 1); + RelativeCoordinateSpace = new RectangleF(0, 0, (scrollingAxes & Axes.X) > 0 ? parent.TimeSpan.X : 1, (scrollingAxes & Axes.Y) > 0 ? parent.TimeSpan.Y : 1); } /// @@ -133,14 +120,20 @@ namespace osu.Game.Rulesets.Timing.Drawables if (!Children.Any()) return; - float height = Children.Select(child => child.Y + child.Height).Max(); - float width = Children.Select(child => child.X + child.Width).Max(); + float width = Children.Select(child => child.X + child.Width).Max() - RelativeChildOffset.X; + float height = Children.Select(child => child.Y + child.Height).Max() - RelativeChildOffset.Y; - Size = new Vector2((autoSizingAxes & Axes.X) > 0 ? width : Size.X, - (autoSizingAxes & Axes.Y) > 0 ? height : Size.Y); + Size = new Vector2((autoSizingAxes & Axes.X) > 0 ? width : Size.X, (autoSizingAxes & Axes.Y) > 0 ? height : Size.Y); - RelativeCoordinateSpace = new Vector2((autoSizingAxes & Axes.X) > 0 ? width : 1, - (autoSizingAxes & Axes.Y) > 0 ? height : 1); + var space = RelativeCoordinateSpace; + + if ((autoSizingAxes & Axes.X) > 0) + space.Width = width; + + if ((autoSizingAxes & Axes.Y) > 0) + space.Height = height; + + RelativeCoordinateSpace = space; }); } }