More renaming + fixes.

This commit is contained in:
smoogipooo
2017-06-09 02:42:17 +09:00
parent 7d921f92b1
commit 1231d5d35e
5 changed files with 29 additions and 15 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
@ -18,7 +19,7 @@ namespace osu.Game.Rulesets.Timing.Drawables
public readonly TimingSection TimingSection; public readonly TimingSection TimingSection;
protected override Container<DrawableHitObject> Content => content; protected override Container<DrawableHitObject> Content => content;
private readonly Container<DrawableHitObject> content; private Container<DrawableHitObject> content;
private readonly Axes scrollingAxes; private readonly Axes scrollingAxes;
@ -32,8 +33,12 @@ namespace osu.Game.Rulesets.Timing.Drawables
this.scrollingAxes = scrollingAxes; this.scrollingAxes = scrollingAxes;
TimingSection = timingSection; 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); 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() protected override void Update()
{ {
var parent = Parent as Container; var parent = Parent as TimingSectionCollection;
if (parent == null) if (parent == null)
return; 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 // 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 // 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); 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);
} }
/// <summary> /// <summary>
@ -66,8 +71,7 @@ namespace osu.Game.Rulesets.Timing.Drawables
/// <summary> /// <summary>
/// Creates the container which handles the movement of a collection of hit objects. /// Creates the container which handles the movement of a collection of hit objects.
/// </summary> /// </summary>
/// <param name="autoSizingAxes"></param> /// <returns>The hit object collection.</returns>
/// <returns></returns> protected abstract HitObjectCollection CreateHitObjectCollection();
protected abstract HitObjectCollection CreateHitObjectCollection(Axes autoSizingAxes);
} }
} }

View File

@ -28,9 +28,9 @@ namespace osu.Game.Rulesets.Timing.Drawables
/// </para> /// </para>
/// ///
/// <para> /// <para>
/// This container will always be relatively-sized to its parent through the use of <see cref="Drawable.RelativeSizeAxes"/> such that the /// This container will always be relatively-sized and positioned to its parent through the use of <see cref="Drawable.RelativeSizeAxes"/>
/// parent can utilise <see cref="Container{T}.RelativeChildSize"/> and <see cref="Container{T}.RelativeChildOffset"/> to apply further /// and <see cref="Drawable.RelativePositionAxes"/> such that the parent can utilise <see cref="Container{T}.RelativeChildSize"/> and
/// time offsets to this collection of hit objects. /// <see cref="Container{T}.RelativeChildOffset"/> to apply further time offsets to this collection of hit objects.
/// </para> /// </para>
/// </summary> /// </summary>
public abstract class HitObjectCollection : Container<DrawableHitObject> public abstract class HitObjectCollection : Container<DrawableHitObject>
@ -48,6 +48,9 @@ namespace osu.Game.Rulesets.Timing.Drawables
protected HitObjectCollection(Axes autoSizingAxes) protected HitObjectCollection(Axes autoSizingAxes)
{ {
this.autoSizingAxes = 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."); } } 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."); } 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) public override void InvalidateFromChild(Invalidation invalidation)
{ {
// We only want to re-compute our size when a child's size or position has changed // 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; 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 // 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 // Then to make our position-space be time values again, we need our relative child size to follow our size
RelativeChildSize = Size; RelativeChildSize = Size;
}); });

View File

@ -11,7 +11,7 @@ using osu.Game.Rulesets.Timing.Drawables;
namespace osu.Game.Rulesets.Timing namespace osu.Game.Rulesets.Timing
{ {
public abstract class TimingSectionCollection : Container<DrawableTimingSection> public class TimingSectionCollection : Container<DrawableTimingSection>
{ {
/// <summary> /// <summary>
/// The length of time which is visualized /// The length of time which is visualized
@ -55,11 +55,11 @@ namespace osu.Game.Rulesets.Timing
var timingChangeY = y as DrawableTimingSection; var timingChangeY = y as DrawableTimingSection;
// If either of the two drawables are not hit objects, fall back to the base comparer // 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); return base.Compare(x, y);
// Compare by start time // 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) if (i != 0)
return i; return i;

View File

@ -194,6 +194,7 @@
<Compile Include="Rulesets\Scoring\Score.cs" /> <Compile Include="Rulesets\Scoring\Score.cs" />
<Compile Include="Rulesets\Scoring\ScoreProcessor.cs" /> <Compile Include="Rulesets\Scoring\ScoreProcessor.cs" />
<Compile Include="Rulesets\Timing\Drawables\DrawableTimingSection.cs" /> <Compile Include="Rulesets\Timing\Drawables\DrawableTimingSection.cs" />
<Compile Include="Rulesets\Timing\Drawables\HitObjectCollection.cs" />
<Compile Include="Rulesets\Timing\TimingSection.cs" /> <Compile Include="Rulesets\Timing\TimingSection.cs" />
<Compile Include="Rulesets\Timing\TimingSectionCollection.cs" /> <Compile Include="Rulesets\Timing\TimingSectionCollection.cs" />
<Compile Include="Screens\Menu\MenuSideFlashes.cs" /> <Compile Include="Screens\Menu\MenuSideFlashes.cs" />