From e348f86ce1d8381707000b69414fda8568c72114 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 1 Jun 2017 14:24:31 +0900 Subject: [PATCH 01/70] Update to match framework. --- osu-framework | 2 +- osu.Game/Graphics/Containers/ReverseDepthFillFlowContainer.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu-framework b/osu-framework index e5f0cf73c1..f9f962ac73 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit e5f0cf73c1e0bbcbd04194bf175d73af47fc850a +Subproject commit f9f962ac735c5fc83e9e6d510d54359b8062ad73 diff --git a/osu.Game/Graphics/Containers/ReverseDepthFillFlowContainer.cs b/osu.Game/Graphics/Containers/ReverseDepthFillFlowContainer.cs index 2b52b06abc..0b38bf5fe0 100644 --- a/osu.Game/Graphics/Containers/ReverseDepthFillFlowContainer.cs +++ b/osu.Game/Graphics/Containers/ReverseDepthFillFlowContainer.cs @@ -10,7 +10,7 @@ namespace osu.Game.Graphics.Containers { public class ReverseDepthFillFlowContainer : FillFlowContainer where T : Drawable { - protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); - protected override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); + protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); + protected override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); } } From f612914e8756b3462bb8888cc1aead5f6f656b6f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 1 Jun 2017 14:26:21 +0900 Subject: [PATCH 02/70] Initial rewrite of timing changes to allow them to be more extensible. --- .../Tests/TestCaseManiaPlayfield.cs | 11 +- .../Timing/ControlPointContainer.cs | 156 ------------------ .../Timing/DrawableTimingChange.cs | 112 +++++++++++++ .../Timing/TimingChangeContainer.cs | 44 +++++ osu.Game.Rulesets.Mania/UI/Column.cs | 17 +- .../UI/ManiaHitRenderer.cs | 7 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 12 +- .../osu.Game.Rulesets.Mania.csproj | 3 +- 8 files changed, 191 insertions(+), 171 deletions(-) delete mode 100644 osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs create mode 100644 osu.Game.Rulesets.Mania/Timing/DrawableTimingChange.cs create mode 100644 osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 95287c3199..20e94e0dde 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mania.Timing; using osu.Framework.Configuration; using OpenTK.Input; using osu.Framework.Timing; +using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Desktop.VisualTests.Tests { @@ -30,7 +31,7 @@ namespace osu.Desktop.VisualTests.Tests Action createPlayfield = (cols, pos) => { Clear(); - Add(new ManiaPlayfield(cols, new List()) + Add(new ManiaPlayfield(cols) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -44,7 +45,7 @@ namespace osu.Desktop.VisualTests.Tests Clear(); ManiaPlayfield playField; - Add(playField = new ManiaPlayfield(cols, new List { new TimingChange { BeatLength = 200 } }) + Add(playField = new ManiaPlayfield(cols) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -52,6 +53,8 @@ namespace osu.Desktop.VisualTests.Tests Scale = new Vector2(1, -1) }); + playField.Columns.ForEach(c => c.Add(new DrawableScrollingTimingChange(new TimingChange { BeatLength = 200 }))); + for (int i = 0; i < cols; i++) { playField.Add(new DrawableNote(new Note @@ -69,7 +72,7 @@ namespace osu.Desktop.VisualTests.Tests var rateAdjustClock = new StopwatchClock(true) { Rate = 0.5 }; ManiaPlayfield playField; - Add(playField = new ManiaPlayfield(4, new List { new TimingChange { BeatLength = 200 } }) + Add(playField = new ManiaPlayfield(4) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -77,6 +80,8 @@ namespace osu.Desktop.VisualTests.Tests Clock = new FramedClock(rateAdjustClock) }); + playField.Columns.ForEach(c => c.Add(new DrawableScrollingTimingChange(new TimingChange { BeatLength = 200 }))); + for (int t = 1000; t <= 2000; t += 100) { playField.Add(new DrawableNote(new Note diff --git a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs deleted file mode 100644 index 0a8bc2d44a..0000000000 --- a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using OpenTK; -using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Rulesets.Objects; - -namespace osu.Game.Rulesets.Mania.Timing -{ - /// - /// A container in which added drawables are put into a relative coordinate space spanned by a length of time. - /// - /// This container contains s which scroll inside this container. - /// Drawables added to this container are moved inside the relevant , - /// and as such, will scroll along with the s. - /// - /// - public class ControlPointContainer : Container - { - /// - /// The amount of time which this container spans. - /// - public double TimeSpan { get; set; } - - private readonly List drawableControlPoints; - - public ControlPointContainer(IEnumerable timingChanges) - { - drawableControlPoints = timingChanges.Select(t => new DrawableControlPoint(t)).ToList(); - Children = drawableControlPoints; - } - - /// - /// Adds a drawable to this container. Note that the drawable added must have its Y-position be - /// an absolute unit of time that is _not_ relative to . - /// - /// The drawable to add. - public override void Add(Drawable drawable) - { - // Always add timing sections to ourselves - if (drawable is DrawableControlPoint) - { - base.Add(drawable); - return; - } - - var controlPoint = drawableControlPoints.LastOrDefault(t => t.CanContain(drawable)) ?? drawableControlPoints.FirstOrDefault(); - - if (controlPoint == null) - throw new InvalidOperationException("Could not find suitable timing section to add object to."); - - controlPoint.Add(drawable); - } - - /// - /// A container that contains drawables within the time span of a timing section. - /// - /// The content of this container will scroll relative to the current time. - /// - /// - private class DrawableControlPoint : Container - { - private readonly TimingChange timingChange; - - protected override Container Content => content; - private readonly Container content; - - /// - /// Creates a drawable control point. The height of this container will be proportional - /// to the beat length of the control point it is initialized with such that, e.g. a beat length - /// of 500ms results in this container being twice as high as its parent, which further means that - /// the content container will scroll at twice the normal rate. - /// - /// The control point to create the drawable control point for. - public DrawableControlPoint(TimingChange timingChange) - { - this.timingChange = timingChange; - - RelativeSizeAxes = Axes.Both; - - AddInternal(content = new AutoTimeRelativeContainer - { - RelativeSizeAxes = Axes.Both, - RelativePositionAxes = Axes.Both, - Y = (float)timingChange.Time - }); - } - - protected override void Update() - { - var parent = (ControlPointContainer)Parent; - - // Adjust our height to account for the speed changes - Height = (float)(1000 / timingChange.BeatLength / timingChange.SpeedMultiplier); - RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); - - // Scroll the content - content.Y = (float)(timingChange.Time - Time.Current); - } - - public override void Add(Drawable drawable) - { - // The previously relatively-positioned drawable will now become relative to content, but since the drawable has no knowledge of content, - // we need to offset it back by content's position position so that it becomes correctly relatively-positioned to content - // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing change - // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet - drawable.Y -= (float)timingChange.Time; - - base.Add(drawable); - } - - /// - /// Whether this control point can contain a drawable. This control point can contain a drawable if the drawable is positioned "after" this control point. - /// - /// The drawable to check. - public bool CanContain(Drawable drawable) => content.Y <= drawable.Y; - - /// - /// A container which always keeps its height and relative coordinate space "auto-sized" to its children. - /// - /// This is used in the case where children are relatively positioned/sized to time values (e.g. notes/bar lines) to keep - /// such children wrapped inside a container, otherwise they would disappear due to container flattening. - /// - /// - private class AutoTimeRelativeContainer : Container - { - protected override IComparer DepthComparer => new HitObjectReverseStartTimeComparer(); - - public override void InvalidateFromChild(Invalidation invalidation) - { - // We only want to re-compute our size when a child's size or position has changed - if ((invalidation & Invalidation.Geometry) == 0) - { - base.InvalidateFromChild(invalidation); - return; - } - - if (!Children.Any()) - return; - - float height = Children.Select(child => child.Y + child.Height).Max(); - - Height = height; - RelativeCoordinateSpace = new Vector2(1, height); - - base.InvalidateFromChild(invalidation); - } - } - } - } -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Timing/DrawableTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/DrawableTimingChange.cs new file mode 100644 index 0000000000..38b28f16a8 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Timing/DrawableTimingChange.cs @@ -0,0 +1,112 @@ +using System.Collections.Generic; +using System.Linq; +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Timing +{ + public abstract class DrawableTimingChange : Container + { + protected readonly TimingChange TimingChange; + + protected override Container Content => content; + private readonly Container content; + + public DrawableTimingChange(TimingChange timingChange) + { + TimingChange = timingChange; + + RelativeSizeAxes = Axes.Both; + + AddInternal(content = new RelativeCoordinateAutoSizingContainer + { + RelativeSizeAxes = Axes.Both, + RelativePositionAxes = Axes.Both, + Y = (float)timingChange.Time + }); + } + + protected override void Update() + { + var parent = (TimingChangeContainer)Parent; + + // Adjust our height to account for the speed changes + Height = (float)(1000 / TimingChange.BeatLength / TimingChange.SpeedMultiplier); + RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); + } + + public override void Add(DrawableHitObject drawable) + { + // The previously relatively-positioned drawable will now become relative to content, but since the drawable has no knowledge of content, + // we need to offset it back by content's position position so that it becomes correctly relatively-positioned to content + // This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing change + // they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet + drawable.Y -= (float)TimingChange.Time; + + base.Add(drawable); + } + + /// + /// Whether this timing change can contain a drawable. This is true if the drawable occurs "after" after this timing change. + /// + public bool CanContain(DrawableHitObject hitObject) => TimingChange.Time <= hitObject.HitObject.StartTime; + + private class RelativeCoordinateAutoSizingContainer : Container + { + protected override IComparer DepthComparer => new HitObjectReverseStartTimeComparer(); + + public override void InvalidateFromChild(Invalidation invalidation) + { + // We only want to re-compute our size when a child's size or position has changed + if ((invalidation & Invalidation.Geometry) == 0) + { + base.InvalidateFromChild(invalidation); + return; + } + + if (!Children.Any()) + return; + + float height = Children.Select(child => child.Y + child.Height).Max(); + + Height = height; + RelativeCoordinateSpace = new Vector2(1, height); + + base.InvalidateFromChild(invalidation); + } + } + } + + public class DrawableScrollingTimingChange : DrawableTimingChange + { + public DrawableScrollingTimingChange(TimingChange timingChange) + : base(timingChange) + { + } + + protected override void Update() + { + base.Update(); + + Content.Y = (float)(TimingChange.Time - Time.Current); + } + } + + public class DrawableGravityTimingChange : DrawableTimingChange + { + public DrawableGravityTimingChange(TimingChange timingChange) + : base(timingChange) + { + } + + protected override void Update() + { + base.Update(); + + // Todo: Gravity calculations here + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs new file mode 100644 index 0000000000..2fdd365ab7 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs @@ -0,0 +1,44 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using OpenTK; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Timing +{ + public class TimingChangeContainer : Container + { + /// + /// The amount of time which this container spans. + /// + public double TimeSpan { get; set; } + + /// + /// Adds a hit object to the most applicable timing change in this container. + /// + /// The hit object to add. + public void Add(DrawableHitObject hitObject) + { + var target = timingChangeFor(hitObject); + + if (target == null) + throw new ArgumentException("No timing change could be found that can contain the hit object.", nameof(hitObject)); + + target.Add(hitObject); + } + + /// + /// Finds the most applicable timing change that can contain a hit object. + /// + /// The hit object to contain. + /// The last timing change which can contain . + private DrawableTimingChange timingChangeFor(DrawableHitObject hitObject) => Children.LastOrDefault(c => c.CanContain(hitObject)); + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 6dfd5000d4..edb396a1e6 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -42,9 +42,9 @@ namespace osu.Game.Rulesets.Mania.UI private readonly Container hitTargetBar; private readonly Container keyIcon; - public readonly ControlPointContainer ControlPointContainer; + private readonly TimingChangeContainer timingChanges; - public Column(IEnumerable timingChanges) + public Column() { RelativeSizeAxes = Axes.Y; Width = column_width; @@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Mania.UI } } }, - ControlPointContainer = new ControlPointContainer(timingChanges) + timingChanges = new TimingChangeContainer { Name = "Hit objects", RelativeSizeAxes = Axes.Both, @@ -187,10 +187,17 @@ namespace osu.Game.Rulesets.Mania.UI } } - public void Add(DrawableHitObject hitObject) + public double TimeSpan + { + get { return timingChanges.TimeSpan; } + set { timingChanges.TimeSpan = value; } + } + + public void Add(DrawableTimingChange timingChange) => timingChanges.Add(timingChange); + public void Add(DrawableHitObject hitObject) { hitObject.AccentColour = AccentColour; - ControlPointContainer.Add(hitObject); + timingChanges.Add(hitObject); } private bool onKeyDown(InputState state, KeyDownEventArgs args) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 57477147d5..a250c56944 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -8,6 +8,7 @@ using OpenTK; using OpenTK.Input; using osu.Framework.Allocation; using osu.Framework.Configuration; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Lists; using osu.Framework.MathUtils; @@ -78,13 +79,17 @@ namespace osu.Game.Rulesets.Mania.UI .GroupBy(s => s.BeatLength * s.SpeedMultiplier).Select(g => g.First()) .ToList(); - return new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize), timingChanges) + var playfield = new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize)) { Anchor = Anchor.Centre, Origin = Anchor.Centre, // Invert by default for now (should be moved to config/skin later) Scale = new Vector2(1, -1) }; + + timingChanges.ForEach(t => playfield.Columns.ForEach(c => c.Add(new DrawableScrollingTimingChange(t)))); + + return playfield; } [BackgroundDependencyLoader] diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 2e6b63579e..a50673d117 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -58,14 +58,14 @@ namespace osu.Game.Rulesets.Mania.UI private readonly FlowContainer columns; public IEnumerable Columns => columns.Children; - private readonly ControlPointContainer barLineContainer; + private readonly TimingChangeContainer barLineContainer; private List normalColumnColours = new List(); private Color4 specialColumnColour; private readonly int columnCount; - public ManiaPlayfield(int columnCount, IEnumerable timingChanges) + public ManiaPlayfield(int columnCount) { this.columnCount = columnCount; @@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Mania.UI Padding = new MarginPadding { Top = HIT_TARGET_POSITION }, Children = new[] { - barLineContainer = new ControlPointContainer(timingChanges) + barLineContainer = new TimingChangeContainer { Name = "Bar lines", Anchor = Anchor.TopCentre, @@ -131,7 +131,7 @@ namespace osu.Game.Rulesets.Mania.UI }; for (int i = 0; i < columnCount; i++) - columns.Add(new Column(timingChanges)); + columns.Add(new Column()); TimeSpan = time_span_default; } @@ -207,6 +207,8 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); + + public void Add(DrawableTimingChange timingChange) => barLineContainer.Add(timingChange); public void Add(DrawableBarLine barline) => barLineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) @@ -243,7 +245,7 @@ namespace osu.Game.Rulesets.Mania.UI timeSpan = MathHelper.Clamp(timeSpan, time_span_min, time_span_max); barLineContainer.TimeSpan = value; - Columns.ForEach(c => c.ControlPointContainer.TimeSpan = value); + Columns.ForEach(c => c.TimeSpan = value); } } diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 3d5614bd90..c437847a2b 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -83,8 +83,9 @@ - + + From 3e2aa267227804185304de4115d8c462b1286869 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 1 Jun 2017 15:08:41 +0900 Subject: [PATCH 03/70] Add bar line timing changes. --- osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs | 2 +- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs index 2fdd365ab7..8acbe6d24c 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs @@ -39,6 +39,6 @@ namespace osu.Game.Rulesets.Mania.Timing /// /// The hit object to contain. /// The last timing change which can contain . - private DrawableTimingChange timingChangeFor(DrawableHitObject hitObject) => Children.LastOrDefault(c => c.CanContain(hitObject)); + private DrawableTimingChange timingChangeFor(DrawableHitObject hitObject) => Children.LastOrDefault(c => c.CanContain(hitObject)) ?? Children.FirstOrDefault(); } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index a250c56944..9c698225ec 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -21,6 +21,7 @@ using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Mania.Timing; +using osu.Game.Rulesets.Mania.Timing.Drawable; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; @@ -88,6 +89,7 @@ namespace osu.Game.Rulesets.Mania.UI }; timingChanges.ForEach(t => playfield.Columns.ForEach(c => c.Add(new DrawableScrollingTimingChange(t)))); + timingChanges.ForEach(t => playfield.Add(new DrawableScrollingTimingChange(t))); return playfield; } From d30706f640c1bc957c02f19056717b00e55cd106 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 1 Jun 2017 15:13:52 +0900 Subject: [PATCH 04/70] Move drawable timing changes to Timing/Drawables. --- .../Tests/TestCaseManiaPlayfield.cs | 1 + .../Drawables/DrawableGravityTimingChange.cs | 25 +++++++++++++++ .../DrawableScrollingTimingChange.cs | 17 ++++++++++ .../{ => Drawables}/DrawableTimingChange.cs | 32 +------------------ .../Timing/TimingChangeContainer.cs | 1 + osu.Game.Rulesets.Mania/UI/Column.cs | 1 + .../UI/ManiaHitRenderer.cs | 2 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 1 + .../osu.Game.Rulesets.Mania.csproj | 4 ++- 9 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs create mode 100644 osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs rename osu.Game.Rulesets.Mania/Timing/{ => Drawables}/DrawableTimingChange.cs (78%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 20e94e0dde..ea6548d296 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -15,6 +15,7 @@ using osu.Framework.Configuration; using OpenTK.Input; using osu.Framework.Timing; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Game.Rulesets.Mania.Timing.Drawables; namespace osu.Desktop.VisualTests.Tests { diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs new file mode 100644 index 0000000000..cb7a290cd2 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs @@ -0,0 +1,25 @@ +using osu.Framework.Physics; + +namespace osu.Game.Rulesets.Mania.Timing.Drawables +{ + public class DrawableGravityTimingChange : DrawableTimingChange + { + private const float acceleration = 9.8f; + private const float terminal_velocity = 50f; + + private RigidBodySimulation sim; + + public DrawableGravityTimingChange(TimingChange timingChange) + : base(timingChange) + { + sim = new RigidBodySimulation(Content); + } + + protected override void Update() + { + base.Update(); + + // Todo: Gravity calculations here + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs new file mode 100644 index 0000000000..dce644cec2 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs @@ -0,0 +1,17 @@ +namespace osu.Game.Rulesets.Mania.Timing.Drawables +{ + public class DrawableScrollingTimingChange : DrawableTimingChange + { + public DrawableScrollingTimingChange(TimingChange timingChange) + : base(timingChange) + { + } + + protected override void Update() + { + base.Update(); + + Content.Y = (float)(TimingChange.Time - Time.Current); + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Timing/DrawableTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs similarity index 78% rename from osu.Game.Rulesets.Mania/Timing/DrawableTimingChange.cs rename to osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs index 38b28f16a8..045a3d33cc 100644 --- a/osu.Game.Rulesets.Mania/Timing/DrawableTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs @@ -6,7 +6,7 @@ using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; -namespace osu.Game.Rulesets.Mania.Timing +namespace osu.Game.Rulesets.Mania.Timing.Drawables { public abstract class DrawableTimingChange : Container { @@ -79,34 +79,4 @@ namespace osu.Game.Rulesets.Mania.Timing } } } - - public class DrawableScrollingTimingChange : DrawableTimingChange - { - public DrawableScrollingTimingChange(TimingChange timingChange) - : base(timingChange) - { - } - - protected override void Update() - { - base.Update(); - - Content.Y = (float)(TimingChange.Time - Time.Current); - } - } - - public class DrawableGravityTimingChange : DrawableTimingChange - { - public DrawableGravityTimingChange(TimingChange timingChange) - : base(timingChange) - { - } - - protected override void Update() - { - base.Update(); - - // Todo: Gravity calculations here - } - } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs index 8acbe6d24c..d01819b291 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs @@ -10,6 +10,7 @@ using OpenTK; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Mania.Timing.Drawables; namespace osu.Game.Rulesets.Mania.Timing { diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index edb396a1e6..75e1c4e8ec 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -18,6 +18,7 @@ using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Judgements; using System; using osu.Framework.Configuration; +using osu.Game.Rulesets.Mania.Timing.Drawables; namespace osu.Game.Rulesets.Mania.UI { diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 9c698225ec..0a2b929446 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -21,7 +21,7 @@ using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Mania.Timing; -using osu.Game.Rulesets.Mania.Timing.Drawable; +using osu.Game.Rulesets.Mania.Timing.Drawables; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index a50673d117..792227ae90 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -22,6 +22,7 @@ using osu.Framework.Input; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; using osu.Game.Rulesets.Mania.Objects.Drawables; +using osu.Game.Rulesets.Mania.Timing.Drawables; namespace osu.Game.Rulesets.Mania.UI { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index c437847a2b..5b8cf0457b 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -83,7 +83,9 @@ - + + + From 1da5d508fac44ba69eebc87f53a4be27e3e27335 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 11:35:51 +0900 Subject: [PATCH 05/70] aaaaa --- .../Tests/TestCaseManiaPlayfield.cs | 59 +++++++++++++------ .../Drawables/DrawableGravityTimingChange.cs | 24 ++++++-- 2 files changed, 60 insertions(+), 23 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index ea6548d296..d90cc2be71 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -16,6 +16,7 @@ using OpenTK.Input; using osu.Framework.Timing; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Rulesets.Mania.Timing.Drawables; +using System.Linq; namespace osu.Desktop.VisualTests.Tests { @@ -54,7 +55,7 @@ namespace osu.Desktop.VisualTests.Tests Scale = new Vector2(1, -1) }); - playField.Columns.ForEach(c => c.Add(new DrawableScrollingTimingChange(new TimingChange { BeatLength = 200 }))); + playField.Columns.ForEach(c => c.Add(new DrawableGravityTimingChange(new TimingChange { BeatLength = 200 }))); for (int i = 0; i < cols; i++) { @@ -81,16 +82,26 @@ namespace osu.Desktop.VisualTests.Tests Clock = new FramedClock(rateAdjustClock) }); - playField.Columns.ForEach(c => c.Add(new DrawableScrollingTimingChange(new TimingChange { BeatLength = 200 }))); - for (int t = 1000; t <= 2000; t += 100) { + playField.Columns.ElementAt(0).Add(new DrawableGravityTimingChange(new TimingChange + { + BeatLength = 200, + Time = t + })); + playField.Add(new DrawableNote(new Note { StartTime = t, Column = 0 }, new Bindable(Key.D))); + playField.Columns.ElementAt(3).Add(new DrawableGravityTimingChange(new TimingChange + { + BeatLength = 200, + Time = t + })); + playField.Add(new DrawableNote(new Note { StartTime = t, @@ -98,6 +109,12 @@ namespace osu.Desktop.VisualTests.Tests }, new Bindable(Key.K))); } + playField.Columns.ElementAt(1).Add(new DrawableGravityTimingChange(new TimingChange + { + BeatLength = 200, + Time = 1000 + })); + playField.Add(new DrawableHoldNote(new HoldNote { StartTime = 1000, @@ -105,6 +122,12 @@ namespace osu.Desktop.VisualTests.Tests Column = 1 }, new Bindable(Key.F))); + playField.Columns.ElementAt(2).Add(new DrawableGravityTimingChange(new TimingChange + { + BeatLength = 200, + Time = 1000 + })); + playField.Add(new DrawableHoldNote(new HoldNote { StartTime = 1000, @@ -113,23 +136,23 @@ namespace osu.Desktop.VisualTests.Tests }, new Bindable(Key.J))); }; - AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); - AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal)); - AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left)); - AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right)); - AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal)); - AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal)); - AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left)); - AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right)); + // AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); + // AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal)); + // AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left)); + // AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right)); + // AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal)); + // AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal)); + // AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left)); + // AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right)); - AddStep("Normal special style", () => createPlayfield(4, SpecialColumnPosition.Normal)); + // AddStep("Normal special style", () => createPlayfield(4, SpecialColumnPosition.Normal)); - AddStep("Notes", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Normal)); - AddWaitStep(10); - AddStep("Left special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Left)); - AddWaitStep(10); - AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); - AddWaitStep(10); + // AddStep("Notes", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Normal)); + // AddWaitStep(10); + // AddStep("Left special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Left)); + // AddWaitStep(10); + // AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); + // AddWaitStep(10); AddStep("Notes with input", () => createPlayfieldWithNotesAcceptingInput()); } diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs index cb7a290cd2..3213ff650b 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs @@ -1,25 +1,39 @@ +using System; +using osu.Framework.Graphics; +using osu.Framework.MathUtils; using osu.Framework.Physics; +using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Timing.Drawables { public class DrawableGravityTimingChange : DrawableTimingChange { - private const float acceleration = 9.8f; - private const float terminal_velocity = 50f; + private const double acceleration = 9.8f; + private const double terminal_velocity = 50f; + + private const double duration = 2000; - private RigidBodySimulation sim; public DrawableGravityTimingChange(TimingChange timingChange) : base(timingChange) { - sim = new RigidBodySimulation(Content); } protected override void Update() { base.Update(); - // Todo: Gravity calculations here + var parent = (TimingChangeContainer)Parent; + + double elapsed = Math.Max(0, Time.Current - TimingChange.Time); + + // @ Current == TimingChange.Time - duration -> Y = TimingChange.Time + // @ Current == TimingChange.Time -> Y = 0 + // @ Current == TimingChange.Time + x -> Y = -f(x) + + double acceleration = elapsed / 2 / 1000 / 1000; + + Content.Y = (float)(TimingChange.Time - 1 / 2f * acceleration * elapsed * elapsed); } } } \ No newline at end of file From d75bbb2b88debd6b578e4e77ea5de73c87c2f4dc Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 15:28:30 +0900 Subject: [PATCH 06/70] Fix incorrect sorting. --- .../Timing/TimingChangeContainer.cs | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs index d01819b291..cb6f4319a3 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs @@ -35,11 +35,37 @@ namespace osu.Game.Rulesets.Mania.Timing target.Add(hitObject); } + protected override IComparer DepthComparer => new TimingChangeReverseStartTimeComparer(); + /// /// Finds the most applicable timing change that can contain a hit object. /// /// The hit object to contain. - /// The last timing change which can contain . - private DrawableTimingChange timingChangeFor(DrawableHitObject hitObject) => Children.LastOrDefault(c => c.CanContain(hitObject)) ?? Children.FirstOrDefault(); + /// The last timing change which can contain . Null if no timing change can contain the hit object. + private DrawableTimingChange timingChangeFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject)); + } + + /// + /// Compares two timing changes by their start time, falling back to creation order if their start time is equal. + /// This will compare the two timing changes in reverse order. + /// + public class TimingChangeReverseStartTimeComparer : Drawable.ReverseCreationOrderDepthComparer + { + public override int Compare(Drawable x, Drawable y) + { + var timingChangeX = x as DrawableTimingChange; + var timingChangeY = y as DrawableTimingChange; + + // If either of the two drawables are not hit objects, fall back to the base comparer + if (timingChangeX?.TimingChange == null || timingChangeY?.TimingChange == null) + return base.Compare(x, y); + + // Compare by start time + int i = timingChangeY.TimingChange.Time.CompareTo(timingChangeX.TimingChange.Time); + if (i != 0) + return i; + + return base.Compare(x, y); + } } } \ No newline at end of file From 563f746acff9843d1f7065bea8e0e93232b2c1e6 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 15:30:59 +0900 Subject: [PATCH 07/70] Add gravity timing change. --- .../Drawables/DrawableGravityTimingChange.cs | 65 ++++++++++++++----- .../Timing/Drawables/DrawableTimingChange.cs | 2 +- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs index 3213ff650b..9372950855 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs @@ -8,11 +8,11 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables { public class DrawableGravityTimingChange : DrawableTimingChange { - private const double acceleration = 9.8f; - private const double terminal_velocity = 50f; - - private const double duration = 2000; - + // Amount of time to travel this container such that + // at time = 0, gravityTime = timeSpan and + // at time = travel_time, gravityTime = 0 + // Where gravityTime is used as the position of the content + private const double travel_time = 1000; public DrawableGravityTimingChange(TimingChange timingChange) : base(timingChange) @@ -23,17 +23,52 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables { base.Update(); - var parent = (TimingChangeContainer)Parent; + // The gravity-adjusted start position + float startY = (float)computeGravityTime(TimingChange.Time); + // The gravity-adjusted end position + float endY = (float)computeGravityTime(TimingChange.Time + Content.RelativeCoordinateSpace.Y); - double elapsed = Math.Max(0, Time.Current - TimingChange.Time); - - // @ Current == TimingChange.Time - duration -> Y = TimingChange.Time - // @ Current == TimingChange.Time -> Y = 0 - // @ Current == TimingChange.Time + x -> Y = -f(x) - - double acceleration = elapsed / 2 / 1000 / 1000; - - Content.Y = (float)(TimingChange.Time - 1 / 2f * acceleration * elapsed * elapsed); + Content.Y = startY; + Content.Height = endY - startY; } + + /// + /// Applies gravity to a time value based on the current time. + /// + /// The time value gravity should be applied to. + /// The time after gravity is applied to . + private double computeGravityTime(double time) + { + double relativeTime = relativeTimeAt(time); + + // The sign of the relative time, this is used to apply backwards acceleration leading into startTime + double sign = relativeTime < 0 ? -1 : 1; + + return timeSpan - acceleration / 2 * relativeTime * relativeTime * sign; + } + + /// + /// The time spanned by this container. + /// + private double timeSpan => RelativeCoordinateSpace.Y; + + /// + /// The acceleration due to "gravity" of the content of this container. + /// + private double acceleration => 2 * timeSpan / travel_time / travel_time; + + /// + /// Computes the current time relative to , accounting for . + /// + /// The non-offset time. + /// The current time relative to - . + private double relativeTimeAt(double time) => Time.Current - time + travel_time; + + /// + /// The velocity of the content of this container at a time. + /// + /// The non-offset time. + /// The velocity at . + private double velocityAt(double time) => acceleration * relativeTimeAt(time); } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs index 045a3d33cc..a0d6a8625d 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs @@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables { public abstract class DrawableTimingChange : Container { - protected readonly TimingChange TimingChange; + public readonly TimingChange TimingChange; protected override Container Content => content; private readonly Container content; From 1eddc278a47b05b450eee9f7500f717e32fb15e5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 16:04:14 +0900 Subject: [PATCH 08/70] Cleanup + make travel time equal to the time span. --- .../Drawables/DrawableGravityTimingChange.cs | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs index 9372950855..d5bfab9723 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs @@ -8,12 +8,6 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables { public class DrawableGravityTimingChange : DrawableTimingChange { - // Amount of time to travel this container such that - // at time = 0, gravityTime = timeSpan and - // at time = travel_time, gravityTime = 0 - // Where gravityTime is used as the position of the content - private const double travel_time = 1000; - public DrawableGravityTimingChange(TimingChange timingChange) : base(timingChange) { @@ -44,7 +38,7 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables // The sign of the relative time, this is used to apply backwards acceleration leading into startTime double sign = relativeTime < 0 ? -1 : 1; - return timeSpan - acceleration / 2 * relativeTime * relativeTime * sign; + return timeSpan - acceleration * relativeTime * relativeTime * sign; } /// @@ -55,20 +49,18 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables /// /// The acceleration due to "gravity" of the content of this container. /// - private double acceleration => 2 * timeSpan / travel_time / travel_time; + private double acceleration => timeSpan / travelTime / travelTime; /// - /// Computes the current time relative to , accounting for . + /// The travel time, after beat length adjustments. /// - /// The non-offset time. - /// The current time relative to - . - private double relativeTimeAt(double time) => Time.Current - time + travel_time; + private double travelTime => timeSpan / TimingChange.SpeedMultiplier; /// - /// The velocity of the content of this container at a time. + /// Computes the current time relative to , accounting for . /// /// The non-offset time. - /// The velocity at . - private double velocityAt(double time) => acceleration * relativeTimeAt(time); + /// The current time relative to - . + private double relativeTimeAt(double time) => Time.Current - time + travelTime; } } \ No newline at end of file From 8f6118ffb85b1a45168cf1c5eddb1b3fac2d4294 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 16:39:31 +0900 Subject: [PATCH 09/70] Set lifetime for timing change containers very naively for now. --- .../Timing/Drawables/DrawableTimingChange.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs index a0d6a8625d..61704187af 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs @@ -36,6 +36,9 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables // Adjust our height to account for the speed changes Height = (float)(1000 / TimingChange.BeatLength / TimingChange.SpeedMultiplier); RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); + + LifetimeStart = TimingChange.Time - parent.TimeSpan; + LifetimeEnd = TimingChange.Time + Content.RelativeCoordinateSpace.Y * 2; } public override void Add(DrawableHitObject drawable) From b46a9dd0ef18e7da381ddf9259c4d24b719b6695 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 17:33:58 +0900 Subject: [PATCH 10/70] Add gravity mod. --- osu.Game.Rulesets.Mania/ManiaRuleset.cs | 1 + .../Mods/ManiaModGravity.cs | 65 +++++++++++++++++++ .../Timing/TimingChangeContainer.cs | 2 +- .../UI/ManiaHitRenderer.cs | 47 ++++++++++++-- .../osu.Game.Rulesets.Mania.csproj | 1 + 5 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 30d1846746..bbbce03b19 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -89,6 +89,7 @@ namespace osu.Game.Rulesets.Mania new ModCinema(), }, }, + new ManiaModGravity() }; default: diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs new file mode 100644 index 0000000000..c4b984472c --- /dev/null +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.UI; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.UI; +using osu.Game.Rulesets.Mania.Timing; +using osu.Game.Rulesets.Mania.Timing.Drawables; +using osu.Game.Rulesets.Objects.Types; +using System.Linq; +using osu.Framework.Lists; +using osu.Game.Beatmaps.ControlPoints; +using osu.Framework.MathUtils; + +namespace osu.Game.Rulesets.Mania.Mods +{ + public class ManiaModGravity : Mod, IApplicableMod + { + public override string Name => "Gravity"; + + public override double ScoreMultiplier => 0; + + public void ApplyToHitRenderer(HitRenderer hitRenderer) + { + var maniaHitRenderer = (ManiaHitRenderer)hitRenderer; + + maniaHitRenderer.HitObjectTimingChanges = new Dictionary>(); + maniaHitRenderer.BarlineTimingChanges = new List(); + + foreach (ManiaHitObject obj in maniaHitRenderer.Objects) + { + List timingChanges; + if (!maniaHitRenderer.HitObjectTimingChanges.TryGetValue(obj.Column, out timingChanges)) + maniaHitRenderer.HitObjectTimingChanges[obj.Column] = timingChanges = new List(); + + timingChanges.Add(new DrawableGravityTimingChange(new TimingChange + { + Time = obj.StartTime, + BeatLength = 1000 + })); + } + + double lastObjectTime = (maniaHitRenderer.Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? maniaHitRenderer.Objects.LastOrDefault()?.StartTime ?? double.MaxValue; + + SortedList timingPoints = maniaHitRenderer.Beatmap.ControlPointInfo.TimingPoints; + for (int i = 0; i < timingPoints.Count; i++) + { + TimingControlPoint point = timingPoints[i]; + + // Stop on the beat before the next timing point, or if there is no next timing point stop slightly past the last object + double endTime = i < timingPoints.Count - 1 ? timingPoints[i + 1].Time - point.BeatLength : lastObjectTime + point.BeatLength * (int)point.TimeSignature; + + int index = 0; + for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength, index++) + { + maniaHitRenderer.BarlineTimingChanges.Add(new DrawableGravityTimingChange(new TimingChange + { + Time = t, + BeatLength = 1000 + })); + } + } + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs index cb6f4319a3..65f6632a2c 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs @@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.Timing /// /// The hit object to contain. /// The last timing change which can contain . Null if no timing change can contain the hit object. - private DrawableTimingChange timingChangeFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject)); + private DrawableTimingChange timingChangeFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject)) ?? Children.LastOrDefault(); } /// diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 0a2b929446..cc71775c3e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -31,15 +31,26 @@ namespace osu.Game.Rulesets.Mania.UI { public class ManiaHitRenderer : HitRenderer { - public int? Columns; + private int? columns; + public int Columns => columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize); + + public Dictionary> HitObjectTimingChanges; + public List BarlineTimingChanges; public ManiaHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) : base(beatmap, isForCurrentRuleset) { + generateTimingChanges(); } - protected override Playfield CreatePlayfield() + private void generateTimingChanges() { + if (HitObjectTimingChanges != null || BarlineTimingChanges != null) + return; + + HitObjectTimingChanges = new Dictionary>(); + BarlineTimingChanges = new List(); + double lastSpeedMultiplier = 1; double lastBeatLength = 500; @@ -80,7 +91,24 @@ namespace osu.Game.Rulesets.Mania.UI .GroupBy(s => s.BeatLength * s.SpeedMultiplier).Select(g => g.First()) .ToList(); - var playfield = new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize)) + timingChanges.ForEach(t => + { + for (int i = 0; i < Columns; i++) + { + List columnTimingChanges; + if (!HitObjectTimingChanges.TryGetValue(i, out columnTimingChanges)) + HitObjectTimingChanges[i] = columnTimingChanges = new List(); + + columnTimingChanges.Add(new DrawableScrollingTimingChange(t)); + } + + BarlineTimingChanges.Add(new DrawableScrollingTimingChange(t)); + }); + } + + protected override Playfield CreatePlayfield() + { + var playfield = new ManiaPlayfield(Columns) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -88,8 +116,17 @@ namespace osu.Game.Rulesets.Mania.UI Scale = new Vector2(1, -1) }; - timingChanges.ForEach(t => playfield.Columns.ForEach(c => c.Add(new DrawableScrollingTimingChange(t)))); - timingChanges.ForEach(t => playfield.Add(new DrawableScrollingTimingChange(t))); + foreach (var kvp in HitObjectTimingChanges) + { + int column = kvp.Key; + List timingChanges = kvp.Value; + + foreach (var change in timingChanges) + playfield.Columns.ElementAt(column).Add(change); + } + + foreach (var change in BarlineTimingChanges) + playfield.Add(change); return playfield; } diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 5b8cf0457b..4b0c42f673 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -82,6 +82,7 @@ + From 519f5f785b2b66cf69a789a3a11c1afb1f92fa54 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 17:43:24 +0900 Subject: [PATCH 11/70] Add gravity mod icon. --- osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs index c4b984472c..3100b15b2c 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs @@ -11,6 +11,7 @@ using System.Linq; using osu.Framework.Lists; using osu.Game.Beatmaps.ControlPoints; using osu.Framework.MathUtils; +using osu.Game.Graphics; namespace osu.Game.Rulesets.Mania.Mods { @@ -20,6 +21,8 @@ namespace osu.Game.Rulesets.Mania.Mods public override double ScoreMultiplier => 0; + public override FontAwesome Icon => FontAwesome.fa_sort_desc; + public void ApplyToHitRenderer(HitRenderer hitRenderer) { var maniaHitRenderer = (ManiaHitRenderer)hitRenderer; From 5ebe08ed2a02a6e42459c94e4390a493c8d73478 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 17:45:48 +0900 Subject: [PATCH 12/70] Make default mania playfield timespan 1.5s for now. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 792227ae90..28ea4271b0 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Mania.UI { public const float HIT_TARGET_POSITION = 50; - private const float time_span_default = 5000; + private const float time_span_default = 1500; private const float time_span_min = 10; private const float time_span_max = 50000; private const float time_span_step = 200; From a96c259a8ee4f5d6b36e68c7dadf4cde25032ff1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 18:02:05 +0900 Subject: [PATCH 13/70] Fix up test case. --- .../Tests/TestCaseManiaPlayfield.cs | 106 ++++++++---------- 1 file changed, 44 insertions(+), 62 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index d90cc2be71..1b60e3165d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -42,32 +42,28 @@ namespace osu.Desktop.VisualTests.Tests }); }; - Action createPlayfieldWithNotes = (cols, pos) => + const double start_time = 500; + const double duration = 1000; + + Func createTimingChange = (time, gravity) => { - Clear(); - - ManiaPlayfield playField; - Add(playField = new ManiaPlayfield(cols) + if (gravity) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - SpecialColumnPosition = pos, - Scale = new Vector2(1, -1) - }); - - playField.Columns.ForEach(c => c.Add(new DrawableGravityTimingChange(new TimingChange { BeatLength = 200 }))); - - for (int i = 0; i < cols; i++) - { - playField.Add(new DrawableNote(new Note + return new DrawableGravityTimingChange(new TimingChange { - StartTime = Time.Current + 1000, - Column = i - })); + BeatLength = 1000, + Time = time + }); } + + return new DrawableScrollingTimingChange(new TimingChange + { + BeatLength = 1000, + Time = time + }); }; - Action createPlayfieldWithNotesAcceptingInput = () => + Action createPlayfieldWithNotes = g => { Clear(); @@ -82,13 +78,13 @@ namespace osu.Desktop.VisualTests.Tests Clock = new FramedClock(rateAdjustClock) }); - for (int t = 1000; t <= 2000; t += 100) + if (!g) + playField.Columns.ForEach(c => c.Add(createTimingChange(0, false))); + + for (double t = start_time; t <= start_time + duration; t += 100) { - playField.Columns.ElementAt(0).Add(new DrawableGravityTimingChange(new TimingChange - { - BeatLength = 200, - Time = t - })); + if (g) + playField.Columns.ElementAt(0).Add(createTimingChange(t, true)); playField.Add(new DrawableNote(new Note { @@ -96,11 +92,8 @@ namespace osu.Desktop.VisualTests.Tests Column = 0 }, new Bindable(Key.D))); - playField.Columns.ElementAt(3).Add(new DrawableGravityTimingChange(new TimingChange - { - BeatLength = 200, - Time = t - })); + if (g) + playField.Columns.ElementAt(3).Add(createTimingChange(t, true)); playField.Add(new DrawableNote(new Note { @@ -109,52 +102,41 @@ namespace osu.Desktop.VisualTests.Tests }, new Bindable(Key.K))); } - playField.Columns.ElementAt(1).Add(new DrawableGravityTimingChange(new TimingChange - { - BeatLength = 200, - Time = 1000 - })); + if (g) + playField.Columns.ElementAt(1).Add(createTimingChange(start_time, true)); playField.Add(new DrawableHoldNote(new HoldNote { - StartTime = 1000, - Duration = 1000, + StartTime = start_time, + Duration = duration, Column = 1 }, new Bindable(Key.F))); - playField.Columns.ElementAt(2).Add(new DrawableGravityTimingChange(new TimingChange - { - BeatLength = 200, - Time = 1000 - })); + if (g) + playField.Columns.ElementAt(2).Add(createTimingChange(start_time, true)); playField.Add(new DrawableHoldNote(new HoldNote { - StartTime = 1000, - Duration = 1000, + StartTime = start_time, + Duration = duration, Column = 2 }, new Bindable(Key.J))); }; - // AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); - // AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal)); - // AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left)); - // AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right)); - // AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal)); - // AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal)); - // AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left)); - // AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right)); + AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); + AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal)); + AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left)); + AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right)); + AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal)); + AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal)); + AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left)); + AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right)); - // AddStep("Normal special style", () => createPlayfield(4, SpecialColumnPosition.Normal)); + AddStep("Notes with input", () => createPlayfieldWithNotes(false)); + AddWaitStep(15); - // AddStep("Notes", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Normal)); - // AddWaitStep(10); - // AddStep("Left special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Left)); - // AddWaitStep(10); - // AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); - // AddWaitStep(10); - - AddStep("Notes with input", () => createPlayfieldWithNotesAcceptingInput()); + AddStep("Notes with gravity", () => createPlayfieldWithNotes(true)); + AddWaitStep(15); } private void triggerKeyDown(Column column) From 264bf17bc256f8b16f662cfcf8c2882e76e2becc Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 18:11:06 +0900 Subject: [PATCH 14/70] Significantly reduce test case time. --- osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 1b60e3165d..b9c2ed66c6 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -43,7 +43,7 @@ namespace osu.Desktop.VisualTests.Tests }; const double start_time = 500; - const double duration = 1000; + const double duration = 500; Func createTimingChange = (time, gravity) => { @@ -67,7 +67,7 @@ namespace osu.Desktop.VisualTests.Tests { Clear(); - var rateAdjustClock = new StopwatchClock(true) { Rate = 0.5 }; + var rateAdjustClock = new StopwatchClock(true) { Rate = 1 }; ManiaPlayfield playField; Add(playField = new ManiaPlayfield(4) @@ -133,10 +133,10 @@ namespace osu.Desktop.VisualTests.Tests AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right)); AddStep("Notes with input", () => createPlayfieldWithNotes(false)); - AddWaitStep(15); + AddWaitStep((int)Math.Ceiling((start_time + duration) / TimePerAction)); AddStep("Notes with gravity", () => createPlayfieldWithNotes(true)); - AddWaitStep(15); + AddWaitStep((int)Math.Ceiling((start_time + duration) / TimePerAction)); } private void triggerKeyDown(Column column) From 97dd80b874d7a856d78d9e35dbb0f3889eadc7ba Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 18:11:36 +0900 Subject: [PATCH 15/70] Make life time set after children are updated (for now). --- .../Timing/Drawables/DrawableTimingChange.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs index 61704187af..2cf7a6ba9e 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs @@ -36,6 +36,13 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables // Adjust our height to account for the speed changes Height = (float)(1000 / TimingChange.BeatLength / TimingChange.SpeedMultiplier); RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan); + } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + var parent = (TimingChangeContainer)Parent; LifetimeStart = TimingChange.Time - parent.TimeSpan; LifetimeEnd = TimingChange.Time + Content.RelativeCoordinateSpace.Y * 2; From 1d3f5d86494f680ebeb2d9d64c285610de2c1cee Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 18:19:21 +0900 Subject: [PATCH 16/70] CI fixes. --- osu-framework | 2 +- .../Tests/TestCaseManiaPlayfield.cs | 1 - osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs | 15 +++++++++------ .../Drawables/DrawableGravityTimingChange.cs | 6 ------ .../Timing/Drawables/DrawableTimingChange.cs | 2 +- .../Timing/TimingChangeContainer.cs | 3 --- osu.Game.Rulesets.Mania/UI/Column.cs | 3 --- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 7 ++++++- 8 files changed, 17 insertions(+), 22 deletions(-) diff --git a/osu-framework b/osu-framework index f9f962ac73..8ba3f5079e 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit f9f962ac735c5fc83e9e6d510d54359b8062ad73 +Subproject commit 8ba3f5079e904f72e02b02909b681b5d64c81466 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index b9c2ed66c6..1d6f805204 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -6,7 +6,6 @@ using osu.Framework.Testing; using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.UI; using System; -using System.Collections.Generic; using OpenTK; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects; diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs index 3100b15b2c..c85a83fa2e 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.UI; @@ -12,6 +11,7 @@ using osu.Framework.Lists; using osu.Game.Beatmaps.ControlPoints; using osu.Framework.MathUtils; using osu.Game.Graphics; +using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Mods { @@ -30,11 +30,15 @@ namespace osu.Game.Rulesets.Mania.Mods maniaHitRenderer.HitObjectTimingChanges = new Dictionary>(); maniaHitRenderer.BarlineTimingChanges = new List(); - foreach (ManiaHitObject obj in maniaHitRenderer.Objects) + foreach (HitObject obj in maniaHitRenderer.Objects) { + var maniaObject = obj as ManiaHitObject; + if (maniaObject == null) + continue; + List timingChanges; - if (!maniaHitRenderer.HitObjectTimingChanges.TryGetValue(obj.Column, out timingChanges)) - maniaHitRenderer.HitObjectTimingChanges[obj.Column] = timingChanges = new List(); + if (!maniaHitRenderer.HitObjectTimingChanges.TryGetValue(maniaObject.Column, out timingChanges)) + maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column] = timingChanges = new List(); timingChanges.Add(new DrawableGravityTimingChange(new TimingChange { @@ -53,8 +57,7 @@ namespace osu.Game.Rulesets.Mania.Mods // Stop on the beat before the next timing point, or if there is no next timing point stop slightly past the last object double endTime = i < timingPoints.Count - 1 ? timingPoints[i + 1].Time - point.BeatLength : lastObjectTime + point.BeatLength * (int)point.TimeSignature; - int index = 0; - for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength, index++) + for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength) { maniaHitRenderer.BarlineTimingChanges.Add(new DrawableGravityTimingChange(new TimingChange { diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs index d5bfab9723..fa69a55202 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs @@ -1,9 +1,3 @@ -using System; -using osu.Framework.Graphics; -using osu.Framework.MathUtils; -using osu.Framework.Physics; -using osu.Game.Rulesets.Objects.Drawables; - namespace osu.Game.Rulesets.Mania.Timing.Drawables { public class DrawableGravityTimingChange : DrawableTimingChange diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs index 2cf7a6ba9e..ccbf074ef9 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables protected override Container Content => content; private readonly Container content; - public DrawableTimingChange(TimingChange timingChange) + protected DrawableTimingChange(TimingChange timingChange) { TimingChange = timingChange; diff --git a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs index 65f6632a2c..3187be58d4 100644 --- a/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/TimingChangeContainer.cs @@ -6,9 +6,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using OpenTK; -using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Timing.Drawables; diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 75e1c4e8ec..b29019934a 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -12,10 +12,7 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Rulesets.Mania.Timing; -using System.Collections.Generic; using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Mania.Objects; -using osu.Game.Rulesets.Mania.Judgements; using System; using osu.Framework.Configuration; using osu.Game.Rulesets.Mania.Timing.Drawables; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index cc71775c3e..2b4d29ae0f 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -32,7 +32,12 @@ namespace osu.Game.Rulesets.Mania.UI public class ManiaHitRenderer : HitRenderer { private int? columns; - public int Columns => columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize); + + public int Columns + { + get { return columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize); } + set { columns = value; } + } public Dictionary> HitObjectTimingChanges; public List BarlineTimingChanges; From 186fecca82bc35c38a0dae151bce6045dc4bf48e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 18:20:14 +0900 Subject: [PATCH 17/70] Add missing license headers. --- osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs | 3 +++ .../Timing/Drawables/DrawableGravityTimingChange.cs | 3 +++ .../Timing/Drawables/DrawableScrollingTimingChange.cs | 3 +++ .../Timing/Drawables/DrawableTimingChange.cs | 3 +++ osu.Game.Rulesets.Mania/packages.config | 1 - 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs index c85a83fa2e..15cc1de4e9 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs @@ -1,3 +1,6 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + using System.Collections.Generic; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.UI; diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs index fa69a55202..5e65adc57a 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs @@ -1,3 +1,6 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + namespace osu.Game.Rulesets.Mania.Timing.Drawables { public class DrawableGravityTimingChange : DrawableTimingChange diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs index dce644cec2..c6058e81c7 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs @@ -1,3 +1,6 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + namespace osu.Game.Rulesets.Mania.Timing.Drawables { public class DrawableScrollingTimingChange : DrawableTimingChange diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs index ccbf074ef9..4e423bb741 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableTimingChange.cs @@ -1,3 +1,6 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + using System.Collections.Generic; using System.Linq; using OpenTK; diff --git a/osu.Game.Rulesets.Mania/packages.config b/osu.Game.Rulesets.Mania/packages.config index 634d0b51f6..dc059c684b 100644 --- a/osu.Game.Rulesets.Mania/packages.config +++ b/osu.Game.Rulesets.Mania/packages.config @@ -1,5 +1,4 @@  -