diff --git a/osu-framework b/osu-framework index 3ad1dd52ae..b72b5a59a6 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 3ad1dd52ae511b816fb928f70ef811ec605c5c18 +Subproject commit b72b5a59a689358c4c5785623fbf5019169a66fc diff --git a/osu.Game/Rulesets/Timing/Drawables/DrawableTimingSection.cs b/osu.Game/Rulesets/Timing/Drawables/DrawableTimingSection.cs index 48c55151d6..4e93102f9a 100644 --- a/osu.Game/Rulesets/Timing/Drawables/DrawableTimingSection.cs +++ b/osu.Game/Rulesets/Timing/Drawables/DrawableTimingSection.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Objects.Drawables; @@ -18,7 +19,7 @@ namespace osu.Game.Rulesets.Timing.Drawables public readonly TimingSection TimingSection; protected override Container Content => content; - private readonly Container content; + private Container content; private readonly Axes scrollingAxes; @@ -32,8 +33,12 @@ namespace osu.Game.Rulesets.Timing.Drawables this.scrollingAxes = scrollingAxes; TimingSection = timingSection; + } - AddInternal(content = CreateHitObjectCollection(scrollingAxes)); + [BackgroundDependencyLoader] + private void load() + { + AddInternal(content = CreateHitObjectCollection()); content.RelativeChildOffset = new Vector2((scrollingAxes & Axes.X) > 0 ? (float)TimingSection.Time : 0, (scrollingAxes & Axes.Y) > 0 ? (float)TimingSection.Time : 0); } @@ -45,7 +50,7 @@ namespace osu.Game.Rulesets.Timing.Drawables protected override void Update() { - var parent = Parent as Container; + var parent = Parent as TimingSectionCollection; if (parent == null) return; @@ -55,7 +60,7 @@ namespace osu.Game.Rulesets.Timing.Drawables // The application of speed changes happens by modifying our size while maintaining the parent's relative child size as our own // By doing this the scroll speed of the hit objects is changed by a factor of Size / RelativeChildSize Size = new Vector2((scrollingAxes & Axes.X) > 0 ? speedAdjustedSize : 1, (scrollingAxes & Axes.Y) > 0 ? speedAdjustedSize : 1); - RelativeChildSize = parent.RelativeChildSize; + RelativeChildSize = new Vector2((scrollingAxes & Axes.X) > 0 ? (float)parent.TimeSpan : 1, (scrollingAxes & Axes.Y) > 0 ? (float)parent.TimeSpan : 1); } /// @@ -66,8 +71,7 @@ namespace osu.Game.Rulesets.Timing.Drawables /// /// Creates the container which handles the movement of a collection of hit objects. /// - /// - /// - protected abstract HitObjectCollection CreateHitObjectCollection(Axes autoSizingAxes); + /// The hit object collection. + protected abstract HitObjectCollection CreateHitObjectCollection(); } } \ No newline at end of file diff --git a/osu.Game/Rulesets/Timing/Drawables/HitObjectCollection.cs b/osu.Game/Rulesets/Timing/Drawables/HitObjectCollection.cs index 4165513915..acd2862253 100644 --- a/osu.Game/Rulesets/Timing/Drawables/HitObjectCollection.cs +++ b/osu.Game/Rulesets/Timing/Drawables/HitObjectCollection.cs @@ -28,9 +28,9 @@ namespace osu.Game.Rulesets.Timing.Drawables /// /// /// - /// This container will always be relatively-sized to its parent through the use of such that the - /// parent can utilise and to apply further - /// time offsets to this collection of hit objects. + /// This container will always be relatively-sized and positioned to its parent through the use of + /// and such that the parent can utilise and + /// to apply further time offsets to this collection of hit objects. /// /// public abstract class HitObjectCollection : Container @@ -48,6 +48,9 @@ namespace osu.Game.Rulesets.Timing.Drawables protected HitObjectCollection(Axes autoSizingAxes) { this.autoSizingAxes = autoSizingAxes; + + // We need a default size since RelativeSizeAxes is overridden + Size = Vector2.One; } public override Axes AutoSizeAxes { set { throw new InvalidOperationException($"{nameof(HitObjectCollection)} must always be relatively-sized."); } } @@ -58,6 +61,12 @@ namespace osu.Game.Rulesets.Timing.Drawables set { throw new InvalidOperationException($"{nameof(HitObjectCollection)} must always be relatively-sized."); } } + public override Axes RelativePositionAxes + { + get { return Axes.Both; } + set { throw new InvalidOperationException($"{nameof(HitObjectCollection)} must always be relatively-positioned."); } + } + public override void InvalidateFromChild(Invalidation invalidation) { // We only want to re-compute our size when a child's size or position has changed @@ -88,7 +97,7 @@ namespace osu.Game.Rulesets.Timing.Drawables float height = Children.Select(child => child.Y + child.Height).Max() - RelativeChildOffset.Y; // Consider that width/height are time values. To have ourselves span these time values 1:1, we first need to set our size - base.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); // Then to make our position-space be time values again, we need our relative child size to follow our size RelativeChildSize = Size; }); diff --git a/osu.Game/Rulesets/Timing/TimingSectionCollection.cs b/osu.Game/Rulesets/Timing/TimingSectionCollection.cs index c629a584ac..1f591e65f4 100644 --- a/osu.Game/Rulesets/Timing/TimingSectionCollection.cs +++ b/osu.Game/Rulesets/Timing/TimingSectionCollection.cs @@ -11,7 +11,7 @@ using osu.Game.Rulesets.Timing.Drawables; namespace osu.Game.Rulesets.Timing { - public abstract class TimingSectionCollection : Container + public class TimingSectionCollection : Container { /// /// The length of time which is visualized @@ -55,11 +55,11 @@ namespace osu.Game.Rulesets.Timing var timingChangeY = y as DrawableTimingSection; // If either of the two drawables are not hit objects, fall back to the base comparer - if (timingChangeX?.TimingChange == null || timingChangeY?.TimingChange == null) + if (timingChangeX?.TimingSection == null || timingChangeY?.TimingSection == null) return base.Compare(x, y); // Compare by start time - int i = timingChangeY.TimingChange.Time.CompareTo(timingChangeX.TimingChange.Time); + int i = timingChangeY.TimingSection.Time.CompareTo(timingChangeX.TimingSection.Time); if (i != 0) return i; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index ef946c78dd..e4bdc5b0b3 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -194,6 +194,7 @@ +