1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 11:27:24 +08:00

Replace AddConnections by a HitObjects property.

This commit is contained in:
Damnae 2017-02-12 08:31:43 +01:00
parent de2791e179
commit daa14bfec8
3 changed files with 46 additions and 9 deletions

View File

@ -7,13 +7,15 @@ using System.Collections.Generic;
namespace osu.Game.Modes.Osu.Objects.Drawables.Connections
{
/// <summary>
/// Connects hit objects visually, for example with follow points.
/// </summary>
public abstract class ConnectionRenderer<T> : Container
where T : HitObject
{
/// <summary>
/// Create drawables inside this container, connecting hit objects visually, for example with follow points.
/// Hit objects to create connections for
/// </summary>
/// <param name="hitObjects">Hit objects to create connections for</param>
public abstract void AddConnections(IEnumerable<T> hitObjects);
public abstract IEnumerable<T> HitObjects { get; set; }
}
}

View File

@ -10,18 +10,53 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class FollowPointRenderer : ConnectionRenderer<OsuHitObject>
{
private int pointDistance = 32;
/// <summary>
/// Determines how much space there is between points.
/// </summary>
public int PointDistance = 32;
public int PointDistance
{
get { return pointDistance; }
set
{
if (pointDistance == value) return;
pointDistance = value;
update();
}
}
private int preEmpt = 800;
/// <summary>
/// Follow points to the next hitobject start appearing for this many milliseconds before an hitobject's end time.
/// </summary>
public int PreEmpt = 800;
public override void AddConnections(IEnumerable<OsuHitObject> hitObjects)
public int PreEmpt
{
get { return preEmpt; }
set
{
if (preEmpt == value) return;
preEmpt = value;
update();
}
}
private IEnumerable<OsuHitObject> hitObjects;
public override IEnumerable<OsuHitObject> HitObjects
{
get { return hitObjects; }
set
{
hitObjects = value;
update();
}
}
private void update()
{
Clear();
if (hitObjects == null)
return;
OsuHitObject prevHitObject = null;
foreach (var currHitObject in hitObjects)
{

View File

@ -73,9 +73,9 @@ namespace osu.Game.Modes.Osu.UI
public override void PostProcess()
{
connectionLayer.AddConnections(HitObjects.Children
connectionLayer.HitObjects = HitObjects.Children
.Select(d => (OsuHitObject)d.HitObject)
.OrderBy(h => h.StartTime));
.OrderBy(h => h.StartTime);
}
private void judgement(DrawableHitObject h, JudgementInfo j)