From daa14bfec8be065464c8f22ecdf7e845b7282f53 Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 08:31:43 +0100 Subject: [PATCH] Replace AddConnections by a HitObjects property. --- .../Connections/ConnectionRenderer.cs | 8 ++-- .../Connections/FollowPointRenderer.cs | 43 +++++++++++++++++-- osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 4 +- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs index d35a731feb..a680c847ac 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs @@ -7,13 +7,15 @@ using System.Collections.Generic; namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { + /// + /// Connects hit objects visually, for example with follow points. + /// public abstract class ConnectionRenderer : Container where T : HitObject { /// - /// Create drawables inside this container, connecting hit objects visually, for example with follow points. + /// Hit objects to create connections for /// - /// Hit objects to create connections for - public abstract void AddConnections(IEnumerable hitObjects); + public abstract IEnumerable HitObjects { get; set; } } } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs index 469ce390d0..b57f0881bc 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs @@ -10,18 +10,53 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class FollowPointRenderer : ConnectionRenderer { + private int pointDistance = 32; /// /// Determines how much space there is between points. /// - public int PointDistance = 32; + public int PointDistance + { + get { return pointDistance; } + set + { + if (pointDistance == value) return; + pointDistance = value; + update(); + } + } + private int preEmpt = 800; /// /// Follow points to the next hitobject start appearing for this many milliseconds before an hitobject's end time. /// - public int PreEmpt = 800; - - public override void AddConnections(IEnumerable hitObjects) + public int PreEmpt { + get { return preEmpt; } + set + { + if (preEmpt == value) return; + preEmpt = value; + update(); + } + } + + private IEnumerable hitObjects; + public override IEnumerable HitObjects + { + get { return hitObjects; } + set + { + hitObjects = value; + update(); + } + } + + private void update() + { + Clear(); + if (hitObjects == null) + return; + OsuHitObject prevHitObject = null; foreach (var currHitObject in hitObjects) { diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index f2fafc8883..b6daffbb8b 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -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)