diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 8368f0f810..e10ca2aee0 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -49,14 +49,14 @@ namespace osu.Desktop.VisualTests.Tests { if (gravity) { - return new DrawableGravityTimingChange(new TimingChange + return new DrawableManiaGravityTimingChange(new TimingChange { BeatLength = 1000, Time = time }); } - return new DrawableScrollingTimingChange(new TimingChange + return new DrawableManiaScrollingTimingChange(new TimingChange { BeatLength = 1000, Time = time diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs index 6657831c37..8db5f40574 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs @@ -31,20 +31,19 @@ namespace osu.Game.Rulesets.Mania.Mods { var maniaHitRenderer = (ManiaHitRenderer)hitRenderer; - maniaHitRenderer.HitObjectTimingChanges = new Dictionary>(); + maniaHitRenderer.HitObjectTimingChanges = new List[maniaHitRenderer.PreferredColumns]; maniaHitRenderer.BarlineTimingChanges = new List(); + for (int i = 0; i < maniaHitRenderer.PreferredColumns; i++) + maniaHitRenderer.HitObjectTimingChanges[i] = new List(); + foreach (HitObject obj in maniaHitRenderer.Objects) { var maniaObject = obj as ManiaHitObject; if (maniaObject == null) continue; - List timingChanges; - if (!maniaHitRenderer.HitObjectTimingChanges.TryGetValue(maniaObject.Column, out timingChanges)) - maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column] = timingChanges = new List(); - - timingChanges.Add(new DrawableGravityTimingChange(new TimingChange + maniaHitRenderer.HitObjectTimingChanges[maniaObject.Column].Add(new DrawableManiaGravityTimingChange(new TimingChange { Time = obj.StartTime, BeatLength = 1000 @@ -63,7 +62,7 @@ namespace osu.Game.Rulesets.Mania.Mods for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength) { - maniaHitRenderer.BarlineTimingChanges.Add(new DrawableGravityTimingChange(new TimingChange + maniaHitRenderer.BarlineTimingChanges.Add(new DrawableManiaGravityTimingChange(new TimingChange { Time = t, BeatLength = 1000 diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaGravityTimingChange.cs similarity index 91% rename from osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs rename to osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaGravityTimingChange.cs index 54b8bb35ae..6de89739cb 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaGravityTimingChange.cs @@ -5,9 +5,9 @@ using osu.Game.Rulesets.Timing; namespace osu.Game.Rulesets.Mania.Timing.Drawables { - public class DrawableGravityTimingChange : DrawableManiaTimingChange + public class DrawableManiaGravityTimingChange : DrawableManiaTimingChange { - public DrawableGravityTimingChange(TimingChange timingChange) + public DrawableManiaGravityTimingChange(TimingChange timingChange) : base(timingChange) { } diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaScrollingTimingChange.cs similarity index 61% rename from osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs rename to osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaScrollingTimingChange.cs index dfd36686e7..10b5e4dc60 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableScrollingTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaScrollingTimingChange.cs @@ -5,9 +5,12 @@ using osu.Game.Rulesets.Timing; namespace osu.Game.Rulesets.Mania.Timing.Drawables { - public class DrawableScrollingTimingChange : DrawableManiaTimingChange + /// + /// A basic timing change which scrolls along with a timing change. + /// + public class DrawableManiaScrollingTimingChange : DrawableManiaTimingChange { - public DrawableScrollingTimingChange(TimingChange timingChange) + public DrawableManiaScrollingTimingChange(TimingChange timingChange) : base(timingChange) { } diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaTimingChange.cs index 448f554c44..8c19918689 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableManiaTimingChange.cs @@ -7,7 +7,7 @@ using osu.Game.Rulesets.Timing.Drawables; namespace osu.Game.Rulesets.Mania.Timing.Drawables { - public class DrawableManiaTimingChange : DrawableTimingChange + public abstract class DrawableManiaTimingChange : DrawableTimingChange { public DrawableManiaTimingChange(TimingChange timingChange) : base(timingChange, Axes.Y) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 0b4d0088b5..c8b845eb9a 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -32,19 +32,31 @@ namespace osu.Game.Rulesets.Mania.UI { public class ManiaHitRenderer : HitRenderer { - private int? columns; - public int Columns - { - get { return columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize); } - set { columns = value; } - } + /// + /// Preferred column count. This will only have an effect during the initialization of the play field. + /// + public int PreferredColumns; - public Dictionary> HitObjectTimingChanges; + /// + /// Per-column timing changes. + /// + public List[] HitObjectTimingChanges; + + /// + /// Bar line timing changes. + /// public List BarlineTimingChanges; + /// + /// Number of columns in the playfield of this hit renderer. Null if the play field hasn't been generated yet. + /// + public int? Columns { get; private set; } + public ManiaHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) : base(beatmap, isForCurrentRuleset) { + Columns = PreferredColumns; + generateDefaultTimingChanges(); } @@ -53,9 +65,12 @@ namespace osu.Game.Rulesets.Mania.UI if (HitObjectTimingChanges != null || BarlineTimingChanges != null) return; - HitObjectTimingChanges = new Dictionary>(); + HitObjectTimingChanges = new List[Columns.Value]; BarlineTimingChanges = new List(); + for (int i = 0; i < Columns.Value; i++) + HitObjectTimingChanges[i] = new List(); + double lastSpeedMultiplier = 1; double lastBeatLength = 500; @@ -98,22 +113,22 @@ namespace osu.Game.Rulesets.Mania.UI timingChanges.ForEach(t => { - for (int i = 0; i < Columns; i++) - { - List columnTimingChanges; - if (!HitObjectTimingChanges.TryGetValue(i, out columnTimingChanges)) - HitObjectTimingChanges[i] = columnTimingChanges = new List(); + for (int i = 0; i < Columns.Value; i++) + HitObjectTimingChanges[i].Add(new DrawableManiaScrollingTimingChange(t)); - columnTimingChanges.Add(new DrawableScrollingTimingChange(t)); - } - - BarlineTimingChanges.Add(new DrawableScrollingTimingChange(t)); + BarlineTimingChanges.Add(new DrawableManiaScrollingTimingChange(t)); }); } + protected override void ApplyBeatmap() + { + base.ApplyBeatmap(); + PreferredColumns = (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize); + } + protected override Playfield CreatePlayfield() { - var playfield = new ManiaPlayfield(Columns) + var playfield = new ManiaPlayfield(Columns.Value) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -121,13 +136,10 @@ namespace osu.Game.Rulesets.Mania.UI Scale = new Vector2(1, -1) }; - foreach (var kvp in HitObjectTimingChanges) + for (int i = 0; i < Columns; i++) { - int column = kvp.Key; - List timingChanges = kvp.Value; - - foreach (var change in timingChanges) - playfield.Columns.ElementAt(column).Add(change); + foreach (var change in HitObjectTimingChanges[i]) + playfield.Columns.ElementAt(i).Add(change); } foreach (var change in BarlineTimingChanges) diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index e265dcf8a3..7e92e1865c 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -84,9 +84,9 @@ - + - + diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index f0dc143668..7001567f25 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -148,6 +148,8 @@ namespace osu.Game.Rulesets.UI // Post-process the beatmap processor.PostProcess(Beatmap); + ApplyBeatmap(); + // Add mods, should always be the last thing applied to give full control to mods applyMods(beatmap.Mods.Value); } @@ -165,6 +167,11 @@ namespace osu.Game.Rulesets.UI mod.ApplyToHitRenderer(this); } + /// + /// Called when the beatmap of this hit renderer has been set. Used to apply any default values from the beatmap. + /// + protected virtual void ApplyBeatmap() { } + /// /// Creates a processor to perform post-processing operations /// on HitObjects in converted Beatmaps.