From 77ee161be8afa156dc8c95d22ed3c0111cad94bf Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 06:16:23 +0100 Subject: [PATCH 1/9] Add follow points. --- .../Objects/Drawables/FollowPoint.cs | 64 +++++++++++++++++ osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 71 ++++++++++++++++++- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 1 + osu.Game/Modes/UI/HitRenderer.cs | 1 + osu.Game/Modes/UI/Playfield.cs | 6 +- 5 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs diff --git a/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs b/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs new file mode 100644 index 0000000000..22ffead4d9 --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Framework.Graphics.Transformations; + +namespace osu.Game.Modes.Osu.Objects.Drawables +{ + public class FollowPoint : Container + { + private Sprite followPoint; + + public double StartTime; + public double EndTime; + public Vector2 EndPosition; + + public FollowPoint() + { + Origin = Anchor.Centre; + Alpha = 0; + + Children = new Drawable[] + { + followPoint = new Sprite + { + Size = new Vector2(12f), + Origin = Anchor.Centre, + BlendingMode = BlendingMode.Additive, + Alpha = 0.5f + }, + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + DelayReset(); + + Delay(StartTime); + FadeIn(DrawableOsuHitObject.TIME_FADEIN); + ScaleTo(1.5f); + ScaleTo(1, DrawableOsuHitObject.TIME_FADEIN, EasingTypes.Out); + MoveTo(EndPosition, DrawableOsuHitObject.TIME_FADEIN, EasingTypes.Out); + + Delay(EndTime - StartTime); + FadeOut(DrawableOsuHitObject.TIME_FADEIN); + + Delay(DrawableOsuHitObject.TIME_FADEIN); + Expire(true); + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + followPoint.Texture = textures.Get(@"Play/osu/ring-glow"); + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 49c6869189..1be73a0452 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -1,13 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.UI; -using OpenTK; +using System; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Modes.Osu.UI { @@ -15,6 +18,7 @@ namespace osu.Game.Modes.Osu.UI { private Container approachCircles; private Container judgementLayer; + private Container followPointsLayer; public override Vector2 Size { @@ -36,11 +40,16 @@ namespace osu.Game.Modes.Osu.UI Add(new Drawable[] { - judgementLayer = new Container + followPointsLayer = new Container { RelativeSizeAxes = Axes.Both, Depth = 1, }, + judgementLayer = new Container + { + RelativeSizeAxes = Axes.Both, + Depth = 0, + }, approachCircles = new Container { RelativeSizeAxes = Axes.Both, @@ -63,11 +72,69 @@ namespace osu.Game.Modes.Osu.UI base.Add(h); } + public override void PostProcess() + { + AddFollowPoints(); + } + private void judgement(DrawableHitObject h, JudgementInfo j) { HitExplosion explosion = new HitExplosion((OsuJudgementInfo)j, (OsuHitObject)h.HitObject); judgementLayer.Add(explosion); } + + public void AddFollowPoints(int startIndex = 0, int endIndex = -1) + { + var followLineDistance = 32; + var followLinePreEmpt = 800; + + var hitObjects = new List(HitObjects.Children + .Select(d => (OsuHitObject)d.HitObject) + .OrderBy(h => h.StartTime)); + + if (endIndex < 0) + endIndex = hitObjects.Count - 1; + + for (int i = startIndex + 1; i <= endIndex; i++) + { + var prevHitObject = hitObjects[i - 1]; + var currHitObject = hitObjects[i]; + + if (prevHitObject.StartTime > currHitObject.StartTime) + throw new Exception(); + + if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) + { + Vector2 startPosition = prevHitObject.EndPosition; + Vector2 endPosition = currHitObject.Position; + double startTime = prevHitObject.EndTime; + double endTime = currHitObject.StartTime; + + Vector2 distanceVector = endPosition - startPosition; + int distance = (int)distanceVector.Length; + float rotation = (float)Math.Atan2(distanceVector.Y, distanceVector.X); + double duration = endTime - startTime; + + for (int d = (int)(followLineDistance * 1.5); d < distance - followLineDistance; d += followLineDistance) + { + float fraction = ((float)d / distance); + Vector2 pointStartPosition = startPosition + (fraction - 0.1f) * distanceVector; + Vector2 pointEndPosition = startPosition + fraction * distanceVector; + double fadeOutTime = startTime + fraction * duration; + double fadeInTime = fadeOutTime - followLinePreEmpt; + + followPointsLayer.Add(new FollowPoint() + { + StartTime = fadeInTime, + EndTime = fadeOutTime, + Position = pointStartPosition, + EndPosition = pointEndPosition, + Rotation = rotation, + }); + } + } + } + } } } \ No newline at end of file diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index a9a346f563..88d25cb8f4 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -47,6 +47,7 @@ + diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index aa2af83cb4..14d9599be6 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -83,6 +83,7 @@ namespace osu.Game.Modes.UI Playfield.Add(drawableObject); } + Playfield.PostProcess(); } private void onJudgement(DrawableHitObject o, JudgementInfo j) => TriggerOnJudgement(j); diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index 748c71a8b3..91eddce73c 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -1,10 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects.Drawables; -using OpenTK; namespace osu.Game.Modes.UI { @@ -32,6 +32,10 @@ namespace osu.Game.Modes.UI }); } + public virtual void PostProcess() + { + } + public class ScaledContainer : Container { protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512); From 4e6b6ab794c54d5e3f50382c60f5ddeeb0b76c00 Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 08:10:24 +0100 Subject: [PATCH 2/9] Abstract follow points into a separate class. --- .../{ => Connections}/FollowPoint.cs | 2 +- .../Connections/FollowPointConnection.cs | 65 +++++++++++++++++++ .../Connections/HitObjectConnection.cs | 14 ++++ osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 63 ++---------------- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 4 +- 5 files changed, 87 insertions(+), 61 deletions(-) rename osu.Game.Modes.Osu/Objects/Drawables/{ => Connections}/FollowPoint.cs (93%) create mode 100644 osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs create mode 100644 osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs diff --git a/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs similarity index 93% rename from osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs rename to osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs index 22ffead4d9..b0b63d17b9 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs @@ -9,7 +9,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transformations; -namespace osu.Game.Modes.Osu.Objects.Drawables +namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { public class FollowPoint : Container { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs new file mode 100644 index 0000000000..78c875d874 --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs @@ -0,0 +1,65 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Game.Modes.Objects.Drawables; +using osu.Game.Modes.Osu.Objects.Drawables.Connections; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace osu.Game.Modes.Osu.Objects.Drawables +{ + public class FollowPointConnection : HitObjectConnection + { + public int PointDistance = 32; + public int PreEmpt = 800; + + public override void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1) + { + var hitObjects = new List(drawableHitObjects + .Select(d => (OsuHitObject)d.HitObject) + .OrderBy(h => h.StartTime)); + + if (endIndex < 0) + endIndex = hitObjects.Count - 1; + + for (int i = startIndex + 1; i <= endIndex; i++) + { + var prevHitObject = hitObjects[i - 1]; + var currHitObject = hitObjects[i]; + + if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) + { + Vector2 startPosition = prevHitObject.EndPosition; + Vector2 endPosition = currHitObject.Position; + double startTime = prevHitObject.EndTime; + double endTime = currHitObject.StartTime; + + Vector2 distanceVector = endPosition - startPosition; + int distance = (int)distanceVector.Length; + float rotation = (float)Math.Atan2(distanceVector.Y, distanceVector.X); + double duration = endTime - startTime; + + for (int d = (int)(PointDistance * 1.5); d < distance - PointDistance; d += PointDistance) + { + float fraction = ((float)d / distance); + Vector2 pointStartPosition = startPosition + (fraction - 0.1f) * distanceVector; + Vector2 pointEndPosition = startPosition + fraction * distanceVector; + double fadeOutTime = startTime + fraction * duration; + double fadeInTime = fadeOutTime - PreEmpt; + + Add(new FollowPoint() + { + StartTime = fadeInTime, + EndTime = fadeOutTime, + Position = pointStartPosition, + EndPosition = pointEndPosition, + Rotation = rotation, + }); + } + } + } + } + } +} diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs new file mode 100644 index 0000000000..d8c91f23df --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Game.Modes.Objects.Drawables; +using System.Collections.Generic; + +namespace osu.Game.Modes.Osu.Objects.Drawables.Connections +{ + public abstract class HitObjectConnection : Container + { + public abstract void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1); + } +} diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 1be73a0452..ef7b36b0bd 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -7,10 +7,8 @@ using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; +using osu.Game.Modes.Osu.Objects.Drawables.Connections; using osu.Game.Modes.UI; -using System; -using System.Collections.Generic; -using System.Linq; namespace osu.Game.Modes.Osu.UI { @@ -18,7 +16,7 @@ namespace osu.Game.Modes.Osu.UI { private Container approachCircles; private Container judgementLayer; - private Container followPointsLayer; + private HitObjectConnection hitObjectConnection; public override Vector2 Size { @@ -40,7 +38,7 @@ namespace osu.Game.Modes.Osu.UI Add(new Drawable[] { - followPointsLayer = new Container + hitObjectConnection = new FollowPointConnection { RelativeSizeAxes = Axes.Both, Depth = 1, @@ -74,7 +72,7 @@ namespace osu.Game.Modes.Osu.UI public override void PostProcess() { - AddFollowPoints(); + hitObjectConnection.AddConnections(HitObjects.Children); } private void judgement(DrawableHitObject h, JudgementInfo j) @@ -83,58 +81,5 @@ namespace osu.Game.Modes.Osu.UI judgementLayer.Add(explosion); } - - public void AddFollowPoints(int startIndex = 0, int endIndex = -1) - { - var followLineDistance = 32; - var followLinePreEmpt = 800; - - var hitObjects = new List(HitObjects.Children - .Select(d => (OsuHitObject)d.HitObject) - .OrderBy(h => h.StartTime)); - - if (endIndex < 0) - endIndex = hitObjects.Count - 1; - - for (int i = startIndex + 1; i <= endIndex; i++) - { - var prevHitObject = hitObjects[i - 1]; - var currHitObject = hitObjects[i]; - - if (prevHitObject.StartTime > currHitObject.StartTime) - throw new Exception(); - - if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) - { - Vector2 startPosition = prevHitObject.EndPosition; - Vector2 endPosition = currHitObject.Position; - double startTime = prevHitObject.EndTime; - double endTime = currHitObject.StartTime; - - Vector2 distanceVector = endPosition - startPosition; - int distance = (int)distanceVector.Length; - float rotation = (float)Math.Atan2(distanceVector.Y, distanceVector.X); - double duration = endTime - startTime; - - for (int d = (int)(followLineDistance * 1.5); d < distance - followLineDistance; d += followLineDistance) - { - float fraction = ((float)d / distance); - Vector2 pointStartPosition = startPosition + (fraction - 0.1f) * distanceVector; - Vector2 pointEndPosition = startPosition + fraction * distanceVector; - double fadeOutTime = startTime + fraction * duration; - double fadeInTime = fadeOutTime - followLinePreEmpt; - - followPointsLayer.Add(new FollowPoint() - { - StartTime = fadeInTime, - EndTime = fadeOutTime, - Position = pointStartPosition, - EndPosition = pointEndPosition, - Rotation = rotation, - }); - } - } - } - } } } \ No newline at end of file diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index 88d25cb8f4..567eec593c 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -44,10 +44,12 @@ + + - + From 6f37c028681e95560e7830076eb548601995f2c3 Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 10:02:37 +0100 Subject: [PATCH 3/9] Fix followpoints needing a DelayReset. --- .../Objects/Drawables/Connections/FollowPoint.cs | 2 -- osu.Game/Screens/Play/Player.cs | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs index b0b63d17b9..72a5358efb 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs @@ -40,8 +40,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { base.LoadComplete(); - DelayReset(); - Delay(StartTime); FadeIn(DrawableOsuHitObject.TIME_FADEIN); ScaleTo(1.5f); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a9584a1f10..a1effa242a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -237,11 +237,10 @@ namespace osu.Game.Screens.Play { base.LoadComplete(); - Delay(250, true); + Content.Delay(250); Content.FadeIn(250); - Delay(500, true); - + Delay(500); Schedule(() => { sourceClock.Start(); From ec64455573557c1da2e61b019a034c933d8a7f8e Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 10:24:31 +0100 Subject: [PATCH 4/9] Add xml-doc. --- .../Objects/Drawables/Connections/FollowPointConnection.cs | 7 +++++++ .../Objects/Drawables/Connections/HitObjectConnection.cs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs index 78c875d874..60ae997a77 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs @@ -12,7 +12,14 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class FollowPointConnection : HitObjectConnection { + /// + /// Determines how much space there is between points. + /// public int PointDistance = 32; + + /// + /// 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 drawableHitObjects, int startIndex = 0, int endIndex = -1) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs index d8c91f23df..3ef4b4aa29 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs @@ -9,6 +9,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { public abstract class HitObjectConnection : Container { + /// + /// Create drawables inside this container, connecting hitobjects visually, for example with follow points. + /// + /// The drawables hit objects to create connections for + /// Start index into the drawableHitObjects enumeration. + /// End index into the drawableHitObjects enumeration. Use -1 to draw connections until the end. public abstract void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1); } } From 2d155f6a5c0c86f6eb929b750a1c07902a029bb9 Mon Sep 17 00:00:00 2001 From: Damnae Date: Fri, 10 Feb 2017 10:48:25 +0100 Subject: [PATCH 5/9] Bring back the delay to what it was before. --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a1effa242a..6eda0ec9ca 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -240,7 +240,7 @@ namespace osu.Game.Screens.Play Content.Delay(250); Content.FadeIn(250); - Delay(500); + Delay(750); Schedule(() => { sourceClock.Start(); From 4162ef72d44ea4c9bebec180db0b67546b520652 Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 06:02:45 +0100 Subject: [PATCH 6/9] Remove start/end index. --- .../Objects/Drawables/Connections/FollowPointConnection.cs | 7 ++----- .../Objects/Drawables/Connections/HitObjectConnection.cs | 4 +--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs index 60ae997a77..3af77e41f8 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs @@ -22,16 +22,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables /// public int PreEmpt = 800; - public override void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1) + public override void AddConnections(IEnumerable drawableHitObjects) { var hitObjects = new List(drawableHitObjects .Select(d => (OsuHitObject)d.HitObject) .OrderBy(h => h.StartTime)); - if (endIndex < 0) - endIndex = hitObjects.Count - 1; - - for (int i = startIndex + 1; i <= endIndex; i++) + for (int i = 1; i <= hitObjects.Count - 1; i++) { var prevHitObject = hitObjects[i - 1]; var currHitObject = hitObjects[i]; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs index 3ef4b4aa29..e2131504cf 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs @@ -13,8 +13,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Connections /// Create drawables inside this container, connecting hitobjects visually, for example with follow points. /// /// The drawables hit objects to create connections for - /// Start index into the drawableHitObjects enumeration. - /// End index into the drawableHitObjects enumeration. Use -1 to draw connections until the end. - public abstract void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1); + public abstract void AddConnections(IEnumerable drawableHitObjects); } } From d7be9539d1a18cec2ec45b10871e4853461cb80c Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 07:29:36 +0100 Subject: [PATCH 7/9] Create connections from HitObjects instead of DrawableHitObjects. --- ...ectConnection.cs => ConnectionRenderer.cs} | 11 ++++++----- ...ntConnection.cs => FollowPointRenderer.cs} | 19 ++++++------------- osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 13 ++++++++----- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 4 ++-- 4 files changed, 22 insertions(+), 25 deletions(-) rename osu.Game.Modes.Osu/Objects/Drawables/Connections/{HitObjectConnection.cs => ConnectionRenderer.cs} (52%) rename osu.Game.Modes.Osu/Objects/Drawables/Connections/{FollowPointConnection.cs => FollowPointRenderer.cs} (75%) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs similarity index 52% rename from osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs rename to osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs index e2131504cf..d35a731feb 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs @@ -2,17 +2,18 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics.Containers; -using osu.Game.Modes.Objects.Drawables; +using osu.Game.Modes.Objects; using System.Collections.Generic; namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { - public abstract class HitObjectConnection : Container + public abstract class ConnectionRenderer : Container + where T : HitObject { /// - /// Create drawables inside this container, connecting hitobjects visually, for example with follow points. + /// Create drawables inside this container, connecting hit objects visually, for example with follow points. /// - /// The drawables hit objects to create connections for - public abstract void AddConnections(IEnumerable drawableHitObjects); + /// Hit objects to create connections for + public abstract void AddConnections(IEnumerable hitObjects); } } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs similarity index 75% rename from osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs rename to osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs index 3af77e41f8..469ce390d0 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs @@ -2,15 +2,13 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Connections; using System; using System.Collections.Generic; -using System.Linq; namespace osu.Game.Modes.Osu.Objects.Drawables { - public class FollowPointConnection : HitObjectConnection + public class FollowPointRenderer : ConnectionRenderer { /// /// Determines how much space there is between points. @@ -22,18 +20,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables /// public int PreEmpt = 800; - public override void AddConnections(IEnumerable drawableHitObjects) + public override void AddConnections(IEnumerable hitObjects) { - var hitObjects = new List(drawableHitObjects - .Select(d => (OsuHitObject)d.HitObject) - .OrderBy(h => h.StartTime)); - - for (int i = 1; i <= hitObjects.Count - 1; i++) + OsuHitObject prevHitObject = null; + foreach (var currHitObject in hitObjects) { - var prevHitObject = hitObjects[i - 1]; - var currHitObject = hitObjects[i]; - - if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) + if (prevHitObject != null && !currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) { Vector2 startPosition = prevHitObject.EndPosition; Vector2 endPosition = currHitObject.Position; @@ -63,6 +55,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables }); } } + prevHitObject = currHitObject; } } } diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index ef7b36b0bd..f2fafc8883 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -9,6 +9,7 @@ using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Connections; using osu.Game.Modes.UI; +using System.Linq; namespace osu.Game.Modes.Osu.UI { @@ -16,7 +17,7 @@ namespace osu.Game.Modes.Osu.UI { private Container approachCircles; private Container judgementLayer; - private HitObjectConnection hitObjectConnection; + private ConnectionRenderer connectionLayer; public override Vector2 Size { @@ -38,15 +39,15 @@ namespace osu.Game.Modes.Osu.UI Add(new Drawable[] { - hitObjectConnection = new FollowPointConnection + connectionLayer = new FollowPointRenderer { RelativeSizeAxes = Axes.Both, - Depth = 1, + Depth = 2, }, judgementLayer = new Container { RelativeSizeAxes = Axes.Both, - Depth = 0, + Depth = 1, }, approachCircles = new Container { @@ -72,7 +73,9 @@ namespace osu.Game.Modes.Osu.UI public override void PostProcess() { - hitObjectConnection.AddConnections(HitObjects.Children); + connectionLayer.AddConnections(HitObjects.Children + .Select(d => (OsuHitObject)d.HitObject) + .OrderBy(h => h.StartTime)); } private void judgement(DrawableHitObject h, JudgementInfo j) diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index 567eec593c..d8c381a648 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -44,8 +44,8 @@ - - + + From de2791e179322aa97aad4f8f9da193add759b5ff Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 08:19:52 +0100 Subject: [PATCH 8/9] Better looking follow points. --- .../Drawables/Connections/FollowPoint.cs | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs index 72a5358efb..bc24186e14 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs @@ -2,36 +2,47 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Framework.Allocation; +using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transformations; +using osu.Game.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { public class FollowPoint : Container { - private Sprite followPoint; - public double StartTime; public double EndTime; public Vector2 EndPosition; + const float width = 8; + public FollowPoint() { Origin = Anchor.Centre; Alpha = 0; + Masking = true; + AutoSizeAxes = Axes.Both; + CornerRadius = width / 2; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Colour = Color4.White.Opacity(0.2f), + Radius = 4, + }; + Children = new Drawable[] { - followPoint = new Sprite + new Box { - Size = new Vector2(12f), - Origin = Anchor.Centre, + Size = new Vector2(width), BlendingMode = BlendingMode.Additive, - Alpha = 0.5f + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Alpha = 0.5f, }, }; } @@ -52,11 +63,5 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Connections Delay(DrawableOsuHitObject.TIME_FADEIN); Expire(true); } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - followPoint.Texture = textures.Get(@"Play/osu/ring-glow"); - } } } \ No newline at end of file From daa14bfec8be065464c8f22ecdf7e845b7282f53 Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 08:31:43 +0100 Subject: [PATCH 9/9] 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)