diff --git a/osu.Game.Modes.Osu/Beatmaps/OsuBeatmapProcessor.cs b/osu.Game.Modes.Osu/Beatmaps/OsuBeatmapProcessor.cs index 1f7785f174..08c9d94141 100644 --- a/osu.Game.Modes.Osu/Beatmaps/OsuBeatmapProcessor.cs +++ b/osu.Game.Modes.Osu/Beatmaps/OsuBeatmapProcessor.cs @@ -8,11 +8,6 @@ namespace osu.Game.Modes.Osu.Beatmaps { internal class OsuBeatmapProcessor : IBeatmapProcessor { - public void SetDefaults(OsuHitObject hitObject, Beatmap beatmap) - { - hitObject.SetDefaultsFromBeatmap(beatmap); - } - public void PostProcess(Beatmap beatmap) { if (beatmap.ComboColors.Count == 0) diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs index cee55a281c..bedde7a763 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs @@ -3,10 +3,11 @@ using osu.Game.Modes.Objects; using OpenTK; -using osu.Game.Beatmaps; using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.Objects.Types; using OpenTK.Graphics; +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; namespace osu.Game.Modes.Osu.Objects { @@ -67,9 +68,11 @@ namespace osu.Game.Modes.Osu.Objects return OsuScoreResult.Miss; } - public virtual void SetDefaultsFromBeatmap(Beatmap beatmap) + public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { - Scale = (1.0f - 0.7f * (beatmap.BeatmapInfo.Difficulty.CircleSize - 5) / 5) / 2; + base.ApplyDefaults(timing, difficulty); + + Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2; } } } diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index fdf3658d44..d94b6534ed 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -2,13 +2,13 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Game.Beatmaps; using osu.Game.Beatmaps.Samples; using osu.Game.Beatmaps.Timing; using osu.Game.Modes.Objects.Types; using System; using System.Collections.Generic; using osu.Game.Modes.Objects; +using osu.Game.Database; namespace osu.Game.Modes.Osu.Objects { @@ -47,19 +47,17 @@ namespace osu.Game.Modes.Osu.Objects public double Velocity; public double TickDistance; - public override void SetDefaultsFromBeatmap(Beatmap beatmap) + public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { - base.SetDefaultsFromBeatmap(beatmap); - - var baseDifficulty = beatmap.BeatmapInfo.Difficulty; + base.ApplyDefaults(timing, difficulty); ControlPoint overridePoint; - ControlPoint timingPoint = beatmap.TimingInfo.TimingPointAt(StartTime, out overridePoint); + ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint); var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1; - var baseVelocity = 100 * baseDifficulty.SliderMultiplier / velocityAdjustment; + var baseVelocity = 100 * difficulty.SliderMultiplier / velocityAdjustment; Velocity = baseVelocity / timingPoint.BeatLength; - TickDistance = baseVelocity / baseDifficulty.SliderTickRate; + TickDistance = baseVelocity / difficulty.SliderTickRate; } public IEnumerable Ticks diff --git a/osu.Game/Beatmaps/IBeatmapProcessor.cs b/osu.Game/Beatmaps/IBeatmapProcessor.cs index 3773f69279..9157a760b1 100644 --- a/osu.Game/Beatmaps/IBeatmapProcessor.cs +++ b/osu.Game/Beatmaps/IBeatmapProcessor.cs @@ -8,17 +8,10 @@ namespace osu.Game.Beatmaps /// /// Processes a post-converted Beatmap. /// - /// The type of HitObject contained in the Beatmap. - public interface IBeatmapProcessor - where T : HitObject + /// The type of HitObject contained in the Beatmap. + public interface IBeatmapProcessor + where TObject : HitObject { - /// - /// Sets default values for a HitObject. - /// - /// The HitObject to set default values for. - /// The Beatmap to extract the default values from. - void SetDefaults(T hitObject, Beatmap beatmap); - /// /// Post-processes a Beatmap to add mode-specific components that aren't added during conversion. /// @@ -26,6 +19,6 @@ namespace osu.Game.Beatmaps /// /// /// The Beatmap to process. - void PostProcess(Beatmap beatmap); + void PostProcess(Beatmap beatmap); } } diff --git a/osu.Game/Modes/Objects/HitObject.cs b/osu.Game/Modes/Objects/HitObject.cs index e43702e2da..f2712d92ba 100644 --- a/osu.Game/Modes/Objects/HitObject.cs +++ b/osu.Game/Modes/Objects/HitObject.cs @@ -2,6 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Beatmaps.Samples; +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; namespace osu.Game.Modes.Objects { @@ -22,5 +24,12 @@ namespace osu.Game.Modes.Objects /// The sample to be played when this HitObject is hit. /// public HitSampleInfo Sample { get; set; } + + /// + /// Applies default values to this HitObject. + /// + /// The difficulty settings to use. + /// The timing settings to use. + public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { } } } diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index 1971559f49..b82e3ada51 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -89,16 +89,26 @@ namespace osu.Game.Modes.UI { Debug.Assert(beatmap != null, "HitRenderer initialized with a null beatmap."); - // Convert + process the beatmap - Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap); - Beatmap.HitObjects.ForEach(h => CreateBeatmapProcessor().SetDefaults(h, Beatmap)); - CreateBeatmapProcessor().PostProcess(Beatmap); - - applyMods(beatmap.Mods.Value); - RelativeSizeAxes = Axes.Both; + + IBeatmapConverter converter = CreateBeatmapConverter(); + IBeatmapProcessor processor = CreateBeatmapProcessor(); + + // Convert the beatmap + Beatmap = converter.Convert(beatmap.Beatmap); + + // Apply defaults + foreach (var h in Beatmap.HitObjects) + h.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty); + + // Post-process the beatmap + processor.PostProcess(Beatmap); + + // Add mods, should always be the last thing applied to give full control to mods + applyMods(beatmap.Mods.Value); } + /// /// Applies the active mods to this HitRenderer. ///