1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 16:02:55 +08:00

Make timing sections scroll again.

This commit is contained in:
smoogipooo 2017-05-16 17:03:43 +09:00
parent a25f11e809
commit da932276e8
3 changed files with 36 additions and 9 deletions

View File

@ -41,10 +41,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
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

View File

@ -15,8 +15,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
public DrawableNote(Note hitObject)
: base(hitObject)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.Both;
Height = 100;
Add(headPiece = new NotePiece
{

View File

@ -71,6 +71,9 @@ namespace osu.Game.Rulesets.Mania.Timing
{
private readonly ControlPoint timingChange;
protected override Container<Drawable> Content => content;
private readonly Container content;
/// <summary>
/// Creates a drawable timing section. The height of this container will be proportional
/// to the beat length of the timing section and the timespan of its parent at all times.
@ -89,7 +92,14 @@ namespace osu.Game.Rulesets.Mania.Timing
RelativeSizeAxes = Axes.Both;
Y = -(float)timingChange.Time;
AddInternal(content = new AutoTimeRelativeContainer
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both,
Y = -(float)timingChange.Time
});
}
protected override void Update()
@ -101,7 +111,7 @@ namespace osu.Game.Rulesets.Mania.Timing
RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan);
// Scroll the content
Y = (float)(Time.Current - timingChange.Time);
content.Y = (float)(Time.Current - timingChange.Time);
}
public override void Add(Drawable drawable)
@ -120,7 +130,28 @@ namespace osu.Game.Rulesets.Mania.Timing
/// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity).
/// </summary>
/// <param name="drawable">The drawable to check.</param>
public bool CanContain(Drawable drawable) => Y >= drawable.Y;
public bool CanContain(Drawable drawable) => content.Y >= drawable.Y;
private class AutoTimeRelativeContainer : Container
{
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
{
float height = 0;
foreach (Drawable child in Children)
{
// Todo: This is wrong, it won't work for absolute-y-sized children
float childEndPos = -child.Y + child.Height;
if (childEndPos > height)
height = childEndPos;
}
Height = height;
RelativeCoordinateSpace = new Vector2(1, height);
return base.Invalidate(invalidation, source, shallPropagate);
}
}
}
}
}