From 3ac89216bd7ede6f34c403c795be50c81a37f782 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 19 Nov 2016 19:07:57 +0900 Subject: [PATCH] Standardise some naming and make hitcircles feel better. --- .../Tests/TestCaseHitObjects.cs | 12 +++++- .../Objects/Drawables/DrawableHitCircle.cs | 40 ++++++++++-------- osu.Game.Mode.Osu/Objects/HitCircle.cs | 2 +- .../{OsuBaseHit.cs => OsuHitObject.cs} | 2 +- ...uConverter.cs => OsuHitObjectConverter.cs} | 8 ++-- .../Objects/OsuHitObjectParser.cs | 16 ++++---- osu.Game.Mode.Osu/Objects/Slider.cs | 2 +- osu.Game.Mode.Osu/Objects/Spinner.cs | 2 +- osu.Game.Mode.Osu/UI/OsuHitRenderer.cs | 9 ++-- osu.Game.Mode.Osu/UI/OsuPlayfield.cs | 41 +++++++++++-------- osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj | 4 +- .../Objects/CatchConverter.cs | 2 +- .../Objects/ManiaConverter.cs | 2 +- .../Objects/TaikoConverter.cs | 2 +- osu.Game/Modes/HitJudgementResolver.cs | 3 ++ .../Objects/Drawables/DrawableHitObject.cs | 4 ++ osu.Game/Modes/UI/HitRenderer.cs | 2 +- osu.Game/Modes/UI/Playfield.cs | 21 +++++++++- 18 files changed, 112 insertions(+), 62 deletions(-) rename osu.Game.Mode.Osu/Objects/{OsuBaseHit.cs => OsuHitObject.cs} (89%) rename osu.Game.Mode.Osu/Objects/{OsuConverter.cs => OsuHitObjectConverter.cs} (56%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 4c7b7ec577..2ea43ab175 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -11,6 +11,7 @@ using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; +using osu.Framework.Graphics.Containers; namespace osu.Desktop.VisualTests.Tests { @@ -34,6 +35,10 @@ namespace osu.Desktop.VisualTests.Tests ourClock.ProcessFrame(); + Container approachContainer = new Container { Depth = float.MaxValue, }; + + Add(approachContainer); + const int count = 10; for (int i = 0; i < count; i++) @@ -44,13 +49,16 @@ namespace osu.Desktop.VisualTests.Tests Position = new Vector2((i - count / 2) * 14), }; - Add(new DrawableHitCircle(h) + DrawableHitCircle d = new DrawableHitCircle(h) { Anchor = Anchor.Centre, Origin = Anchor.Centre, Depth = -i, State = ArmedState.Armed, - }); + }; + + approachContainer.Add(d.ApproachCircle.CreateProxy()); + Add(d); } } diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs index 6defbaa7dd..856c6580d1 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -1,6 +1,7 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; using osu.Game.Modes.Objects.Drawables; @@ -11,9 +12,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class DrawableHitCircle : DrawableHitObject { - private OsuBaseHit osuObject; + private OsuHitObject osuObject; - private ApproachCircle approachCircle; + public ApproachCircle ApproachCircle; private CirclePiece circle; private RingPiece ring; private FlashPiece flash; @@ -25,11 +26,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables public DrawableHitCircle(HitCircle h) : base(h) { osuObject = h; - } - - protected override void LoadComplete() - { - base.LoadComplete(); Origin = Anchor.Centre; Position = osuObject.Position; @@ -52,11 +48,16 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { Colour = osuObject.Colour, }, - approachCircle = new ApproachCircle() + ApproachCircle = new ApproachCircle() { Colour = osuObject.Colour, } }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); //may not be so correct Size = circle.DrawSize; @@ -70,26 +71,33 @@ namespace osu.Game.Modes.Osu.Objects.Drawables if (!IsLoaded) return; Flush(true); //move to DrawableHitObject - approachCircle.Flush(true); + ApproachCircle.Flush(true); double t = HitTime ?? osuObject.StartTime; Alpha = 0; //sane defaults - ring.Alpha = circle.Alpha = number.Alpha = approachCircle.Alpha = glow.Alpha = 1; + ring.Alpha = circle.Alpha = number.Alpha = glow.Alpha = 1; + ApproachCircle.Alpha = 0; + ApproachCircle.Scale = new Vector2(2); explode.Alpha = 0; Scale = new Vector2(0.5f); //this will probably need to be moved to DrawableHitObject at some point. - //always-present transforms - Transforms.Add(new TransformAlpha { StartTime = t - 1000, EndTime = t - 800, StartValue = 0, EndValue = 1 }); + const float preempt = 600; - approachCircle.Transforms.Add(new TransformScale { StartTime = t - 1000, EndTime = t, StartValue = new Vector2(2f), EndValue = new Vector2(0.6f) }); + const float fadein = 400; - //set transform delay to t==hitTime - Delay(t - Time.Current, true); + Delay(t - Time.Current - preempt, true); - approachCircle.FadeOut(); + FadeIn(fadein); + + ApproachCircle.FadeIn(Math.Min(fadein * 2, preempt)); + ApproachCircle.ScaleTo(0.6f, preempt); + + Delay(preempt, true); + + ApproachCircle.FadeOut(); glow.FadeOut(400); diff --git a/osu.Game.Mode.Osu/Objects/HitCircle.cs b/osu.Game.Mode.Osu/Objects/HitCircle.cs index 5df73602c8..6d06cc5f89 100644 --- a/osu.Game.Mode.Osu/Objects/HitCircle.cs +++ b/osu.Game.Mode.Osu/Objects/HitCircle.cs @@ -3,7 +3,7 @@ namespace osu.Game.Modes.Osu.Objects { - public class HitCircle : OsuBaseHit + public class HitCircle : OsuHitObject { } } diff --git a/osu.Game.Mode.Osu/Objects/OsuBaseHit.cs b/osu.Game.Mode.Osu/Objects/OsuHitObject.cs similarity index 89% rename from osu.Game.Mode.Osu/Objects/OsuBaseHit.cs rename to osu.Game.Mode.Osu/Objects/OsuHitObject.cs index 0bd3d62d9e..35f24699f1 100644 --- a/osu.Game.Mode.Osu/Objects/OsuBaseHit.cs +++ b/osu.Game.Mode.Osu/Objects/OsuHitObject.cs @@ -8,7 +8,7 @@ using OpenTK; namespace osu.Game.Modes.Osu.Objects { - public abstract class OsuBaseHit : HitObject + public abstract class OsuHitObject : HitObject { public Vector2 Position { get; set; } diff --git a/osu.Game.Mode.Osu/Objects/OsuConverter.cs b/osu.Game.Mode.Osu/Objects/OsuHitObjectConverter.cs similarity index 56% rename from osu.Game.Mode.Osu/Objects/OsuConverter.cs rename to osu.Game.Mode.Osu/Objects/OsuHitObjectConverter.cs index 5d8ade056f..23a6b3f5e9 100644 --- a/osu.Game.Mode.Osu/Objects/OsuConverter.cs +++ b/osu.Game.Mode.Osu/Objects/OsuHitObjectConverter.cs @@ -6,14 +6,14 @@ using osu.Game.Modes.Objects; namespace osu.Game.Modes.Osu.Objects { - public class OsuConverter : HitObjectConverter + public class OsuHitObjectConverter : HitObjectConverter { - public override List Convert(List input) + public override List Convert(List input) { - List output = new List(); + List output = new List(); foreach (HitObject h in input) - output.Add(h as OsuBaseHit); + output.Add(h as OsuHitObject); return output; } diff --git a/osu.Game.Mode.Osu/Objects/OsuHitObjectParser.cs b/osu.Game.Mode.Osu/Objects/OsuHitObjectParser.cs index 966b8b2f64..932a997769 100644 --- a/osu.Game.Mode.Osu/Objects/OsuHitObjectParser.cs +++ b/osu.Game.Mode.Osu/Objects/OsuHitObjectParser.cs @@ -15,17 +15,17 @@ namespace osu.Game.Modes.Osu.Objects public override HitObject Parse(string text) { string[] split = text.Split(','); - var type = (OsuBaseHit.HitObjectType)int.Parse(split[3]); - bool combo = type.HasFlag(OsuBaseHit.HitObjectType.NewCombo); - type &= (OsuBaseHit.HitObjectType)0xF; - type &= ~OsuBaseHit.HitObjectType.NewCombo; - OsuBaseHit result; + var type = (OsuHitObject.HitObjectType)int.Parse(split[3]); + bool combo = type.HasFlag(OsuHitObject.HitObjectType.NewCombo); + type &= (OsuHitObject.HitObjectType)0xF; + type &= ~OsuHitObject.HitObjectType.NewCombo; + OsuHitObject result; switch (type) { - case OsuBaseHit.HitObjectType.Circle: + case OsuHitObject.HitObjectType.Circle: result = new HitCircle(); break; - case OsuBaseHit.HitObjectType.Slider: + case OsuHitObject.HitObjectType.Slider: Slider s = new Slider(); CurveTypes curveType = CurveTypes.Catmull; @@ -89,7 +89,7 @@ namespace osu.Game.Modes.Osu.Objects result = s; break; - case OsuBaseHit.HitObjectType.Spinner: + case OsuHitObject.HitObjectType.Spinner: result = new Spinner(); break; default: diff --git a/osu.Game.Mode.Osu/Objects/Slider.cs b/osu.Game.Mode.Osu/Objects/Slider.cs index ee0cad8d15..b52a7c7623 100644 --- a/osu.Game.Mode.Osu/Objects/Slider.cs +++ b/osu.Game.Mode.Osu/Objects/Slider.cs @@ -6,7 +6,7 @@ using OpenTK; namespace osu.Game.Modes.Osu.Objects { - public class Slider : OsuBaseHit + public class Slider : OsuHitObject { public override double EndTime => StartTime + (RepeatCount + 1) * Curve.Length; diff --git a/osu.Game.Mode.Osu/Objects/Spinner.cs b/osu.Game.Mode.Osu/Objects/Spinner.cs index 1cda28c71f..a0452e5b1e 100644 --- a/osu.Game.Mode.Osu/Objects/Spinner.cs +++ b/osu.Game.Mode.Osu/Objects/Spinner.cs @@ -3,7 +3,7 @@ namespace osu.Game.Modes.Osu.Objects { - public class Spinner : OsuBaseHit + public class Spinner : OsuHitObject { } } diff --git a/osu.Game.Mode.Osu/UI/OsuHitRenderer.cs b/osu.Game.Mode.Osu/UI/OsuHitRenderer.cs index 50826f3d4e..01f95de5fb 100644 --- a/osu.Game.Mode.Osu/UI/OsuHitRenderer.cs +++ b/osu.Game.Mode.Osu/UI/OsuHitRenderer.cs @@ -6,18 +6,17 @@ 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 OsuBaseHit = osu.Game.Modes.Osu.Objects.OsuBaseHit; -using OsuConverter = osu.Game.Modes.Osu.Objects.OsuConverter; +using OsuConverter = osu.Game.Modes.Osu.Objects.OsuHitObjectConverter; namespace osu.Game.Modes.Osu.UI { - public class OsuHitRenderer : HitRenderer + public class OsuHitRenderer : HitRenderer { - protected override HitObjectConverter Converter => new OsuConverter(); + protected override HitObjectConverter Converter => new OsuHitObjectConverter(); protected override Playfield CreatePlayfield() => new OsuPlayfield(); - protected override DrawableHitObject GetVisualRepresentation(OsuBaseHit h) + protected override DrawableHitObject GetVisualRepresentation(OsuHitObject h) { if (h is HitCircle) return new DrawableHitCircle(h as HitCircle); diff --git a/osu.Game.Mode.Osu/UI/OsuPlayfield.cs b/osu.Game.Mode.Osu/UI/OsuPlayfield.cs index fe9578733c..94638fd79c 100644 --- a/osu.Game.Mode.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Mode.Osu/UI/OsuPlayfield.cs @@ -5,6 +5,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; 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 OpenTK.Graphics; @@ -13,9 +15,7 @@ namespace osu.Game.Modes.Osu.UI { public class OsuPlayfield : Playfield { - protected override Container Content => hitObjectContainer; - - private Container hitObjectContainer; + private Container approachCircles; public override Vector2 Size { @@ -35,24 +35,33 @@ namespace osu.Game.Modes.Osu.UI RelativeSizeAxes = Axes.Both; Size = new Vector2(0.75f); - AddInternal(new Box + AddInternal(new Drawable[] { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Colour = Color4.Black, - Alpha = 0.5f, - }); - - AddInternal(hitObjectContainer = new HitObjectContainer - { - RelativeSizeAxes = Axes.Both, + new Box + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = Color4.Black, + Depth = float.MinValue, + Alpha = 0.5f, + }, + approachCircles = new Container + { + RelativeSizeAxes = Axes.Both, + } }); } - class HitObjectContainer : Container + public override void Add(DrawableHitObject h) { - protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512); + DrawableHitCircle c = h as DrawableHitCircle; + if (c != null) + { + approachCircles.Add(c.ApproachCircle.CreateProxy()); + } + + base.Add(h); } } } \ No newline at end of file diff --git a/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj index 9dd65e9b4f..e7efa413c4 100644 --- a/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj @@ -58,8 +58,8 @@ - - + + diff --git a/osu.Game.Modes.Catch/Objects/CatchConverter.cs b/osu.Game.Modes.Catch/Objects/CatchConverter.cs index 81eabc15a2..0f48de2793 100644 --- a/osu.Game.Modes.Catch/Objects/CatchConverter.cs +++ b/osu.Game.Modes.Catch/Objects/CatchConverter.cs @@ -19,7 +19,7 @@ namespace osu.Game.Modes.Catch.Objects if (h == null) { - OsuBaseHit o = i as OsuBaseHit; + OsuHitObject o = i as OsuHitObject; if (o == null) throw new HitObjectConvertException(@"Catch", i); diff --git a/osu.Game.Modes.Mania/Objects/ManiaConverter.cs b/osu.Game.Modes.Mania/Objects/ManiaConverter.cs index d07d88d970..93c3f1a9e4 100644 --- a/osu.Game.Modes.Mania/Objects/ManiaConverter.cs +++ b/osu.Game.Modes.Mania/Objects/ManiaConverter.cs @@ -27,7 +27,7 @@ namespace osu.Game.Modes.Mania.Objects if (h == null) { - OsuBaseHit o = i as OsuBaseHit; + OsuHitObject o = i as OsuHitObject; if (o == null) throw new HitObjectConvertException(@"Mania", i); diff --git a/osu.Game.Modes.Taiko/Objects/TaikoConverter.cs b/osu.Game.Modes.Taiko/Objects/TaikoConverter.cs index 4f849d538b..59c6c0b6c9 100644 --- a/osu.Game.Modes.Taiko/Objects/TaikoConverter.cs +++ b/osu.Game.Modes.Taiko/Objects/TaikoConverter.cs @@ -19,7 +19,7 @@ namespace osu.Game.Modes.Taiko.Objects if (h == null) { - OsuBaseHit o = i as OsuBaseHit; + OsuHitObject o = i as OsuHitObject; if (o == null) throw new HitObjectConvertException(@"Taiko", i); diff --git a/osu.Game/Modes/HitJudgementResolver.cs b/osu.Game/Modes/HitJudgementResolver.cs index 0644cf2fd3..5f2afec369 100644 --- a/osu.Game/Modes/HitJudgementResolver.cs +++ b/osu.Game/Modes/HitJudgementResolver.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using osu.Game.Modes.Objects; +using OpenTK; namespace osu.Game.Modes { @@ -20,6 +21,8 @@ namespace osu.Game.Modes { public ComboJudgement Combo; public Judgement Judgement; + public float TimeOffset; + public Vector2 PositionOffset; } public enum ComboJudgement diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index 1fca19484b..387d5d061a 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -15,6 +15,10 @@ namespace osu.Game.Modes.Objects.Drawables public Func AllowHit; + public Container ChildObjects; + + public JudgementResult Result; + public HitObject HitObject; public DrawableHitObject(HitObject hitObject) diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index 5f4b0b9b02..f160356cb4 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -19,7 +19,7 @@ namespace osu.Game.Modes.UI protected Playfield Playfield; - public IEnumerable DrawableObjects => Playfield.Children.Cast(); + public IEnumerable DrawableObjects => Playfield.HitObjects.Children; } public abstract class HitRenderer : HitRenderer diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index 24aecb8a22..8bfd82e407 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -1,11 +1,30 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Modes.Objects.Drawables; +using OpenTK; namespace osu.Game.Modes.UI { - public class Playfield : Container + public abstract class Playfield : Container { + public HitObjectContainer HitObjects; + + public virtual void Add(DrawableHitObject h) => HitObjects.Add(h); + + public Playfield() + { + AddInternal(HitObjects = new HitObjectContainer + { + RelativeSizeAxes = Axes.Both, + }); + } + + public class HitObjectContainer : Container + { + protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512); + } } }