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

@ -1 +1 @@
Subproject commit 3ad1dd52ae511b816fb928f70ef811ec605c5c18
Subproject commit b72b5a59a689358c4c5785623fbf5019169a66fc

View File

@ -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 @@ public abstract class DrawableTimingSection : Container<DrawableHitObject>
public readonly TimingSection TimingSection;
protected override Container<DrawableHitObject> Content => content;
private readonly Container<DrawableHitObject> content;
private Container<DrawableHitObject> content;
private readonly Axes scrollingAxes;
@ -32,8 +33,12 @@ protected DrawableTimingSection(TimingSection timingSection, Axes scrollingAxes)
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 @@ public override Axes RelativeSizeAxes
protected override void Update()
{
var parent = Parent as Container;
var parent = Parent as TimingSectionCollection;
if (parent == null)
return;
@ -55,7 +60,7 @@ protected override void Update()
// 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);
}
/// <summary>
@ -66,8 +71,7 @@ protected override void Update()
/// <summary>
/// Creates the container which handles the movement of a collection of hit objects.
/// </summary>
/// <param name="autoSizingAxes"></param>
/// <returns></returns>
protected abstract HitObjectCollection CreateHitObjectCollection(Axes autoSizingAxes);
/// <returns>The hit object collection.</returns>
protected abstract HitObjectCollection CreateHitObjectCollection();
}
}

View File

@ -28,9 +28,9 @@ namespace osu.Game.Rulesets.Timing.Drawables
/// </para>
///
/// <para>
/// This container will always be relatively-sized to its parent through the use of <see cref="Drawable.RelativeSizeAxes"/> such that the
/// parent can utilise <see cref="Container{T}.RelativeChildSize"/> and <see cref="Container{T}.RelativeChildOffset"/> 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 <see cref="Drawable.RelativeSizeAxes"/>
/// and <see cref="Drawable.RelativePositionAxes"/> such that the parent can utilise <see cref="Container{T}.RelativeChildSize"/> and
/// <see cref="Container{T}.RelativeChildOffset"/> to apply further time offsets to this collection of hit objects.
/// </para>
/// </summary>
public abstract class HitObjectCollection : Container<DrawableHitObject>
@ -48,6 +48,9 @@ public abstract class HitObjectCollection : Container<DrawableHitObject>
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 @@ public override Axes RelativeSizeAxes
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 @@ protected override void UpdateAfterChildren()
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;
});

View File

@ -11,7 +11,7 @@
namespace osu.Game.Rulesets.Timing
{
public abstract class TimingSectionCollection : Container<DrawableTimingSection>
public class TimingSectionCollection : Container<DrawableTimingSection>
{
/// <summary>
/// The length of time which is visualized
@ -55,11 +55,11 @@ public override int Compare(Drawable x, Drawable y)
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;

View File

@ -194,6 +194,7 @@
<Compile Include="Rulesets\Scoring\Score.cs" />
<Compile Include="Rulesets\Scoring\ScoreProcessor.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\TimingSectionCollection.cs" />
<Compile Include="Screens\Menu\MenuSideFlashes.cs" />