From 964982e2e61885db1ab701e9b6eb242e4d2a25d5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 13:00:35 +0900 Subject: [PATCH 1/9] Remove now unneeded ApplyBeatmap. --- osu.Game/Rulesets/UI/RulesetContainer.cs | 7 ------- .../Rulesets/UI/ScrollingRulesetContainer.cs | 19 ++++++++----------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 50fcaa128c..5b19200f2d 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -173,8 +173,6 @@ 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(Mods); } @@ -192,11 +190,6 @@ namespace osu.Game.Rulesets.UI mod.ApplyToRulesetContainer(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. diff --git a/osu.Game/Rulesets/UI/ScrollingRulesetContainer.cs b/osu.Game/Rulesets/UI/ScrollingRulesetContainer.cs index 64e865473d..ff156f788c 100644 --- a/osu.Game/Rulesets/UI/ScrollingRulesetContainer.cs +++ b/osu.Game/Rulesets/UI/ScrollingRulesetContainer.cs @@ -39,17 +39,6 @@ namespace osu.Game.Rulesets.UI [BackgroundDependencyLoader] private void load() - { - DefaultControlPoints.ForEach(c => applySpeedAdjustment(c, Playfield)); - } - - private void applySpeedAdjustment(MultiplierControlPoint controlPoint, ScrollingPlayfield playfield) - { - playfield.HitObjects.AddSpeedAdjustment(CreateSpeedAdjustmentContainer(controlPoint)); - playfield.NestedPlayfields.ForEach(p => applySpeedAdjustment(controlPoint, p)); - } - - protected override void ApplyBeatmap() { // Calculate default multiplier control points var lastTimingPoint = new TimingControlPoint(); @@ -95,6 +84,14 @@ namespace osu.Game.Rulesets.UI // If we have no control points, add a default one if (DefaultControlPoints.Count == 0) DefaultControlPoints.Add(new MultiplierControlPoint()); + + DefaultControlPoints.ForEach(c => applySpeedAdjustment(c, Playfield)); + } + + private void applySpeedAdjustment(MultiplierControlPoint controlPoint, ScrollingPlayfield playfield) + { + playfield.HitObjects.AddSpeedAdjustment(CreateSpeedAdjustmentContainer(controlPoint)); + playfield.NestedPlayfields.ForEach(p => applySpeedAdjustment(controlPoint, p)); } /// From 4eec59f669684fcb32758e95b3fc5a6521a58fca Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 13:01:51 +0900 Subject: [PATCH 2/9] Only set the number of availableColumns once, at ManiaRulesetContainer level. # Conflicts: # osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs # osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs # osu.Game/Rulesets/UI/RulesetContainer.cs --- .../Beatmaps/ManiaBeatmapConverter.cs | 14 ++++++++++--- .../Beatmaps/Patterns/PatternGenerator.cs | 4 +--- .../UI/ManiaRulesetContainer.cs | 20 +++++++++---------- osu.Game/Rulesets/UI/RulesetContainer.cs | 19 +++++++++++++----- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index b55b9fdb37..e5a3c7849e 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -28,12 +28,18 @@ namespace osu.Game.Rulesets.Mania.Beatmaps private Pattern lastPattern = new Pattern(); private FastRandom random; private Beatmap beatmap; - private bool isForCurrentRuleset; - protected override Beatmap ConvertBeatmap(Beatmap original, bool isForCurrentRuleset) + private readonly int availableColumns; + private readonly bool isForCurrentRuleset; + + public ManiaBeatmapConverter(bool isForCurrentRuleset, int availableColumns) { this.isForCurrentRuleset = isForCurrentRuleset; + this.availableColumns = availableColumns; + } + protected override Beatmap ConvertBeatmap(Beatmap original) + { beatmap = original; BeatmapDifficulty difficulty = original.BeatmapInfo.Difficulty; @@ -89,7 +95,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// The hit objects generated. private IEnumerable generateSpecific(HitObject original) { - var generator = new SpecificBeatmapPatternGenerator(random, original, beatmap, lastPattern); + var generator = new SpecificBeatmapPatternGenerator(random, original, beatmap, lastPattern) { AvailableColumns = availableColumns }; Pattern newPattern = generator.Generate(); lastPattern = newPattern; @@ -128,6 +134,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps if (conversion == null) return null; + conversion.AvailableColumns = availableColumns; + Pattern newPattern = conversion.Generate(); lastPattern = newPattern; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index dda4d07182..6b85a51402 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns /// /// The number of columns available to create the pattern. /// - protected readonly int AvailableColumns; + public int AvailableColumns; /// /// The last pattern. @@ -37,8 +37,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns PreviousPattern = previousPattern; HitObject = hitObject; Beatmap = beatmap; - - AvailableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); } /// diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 9584dc34b8..58ce05b165 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -33,9 +33,10 @@ namespace osu.Game.Rulesets.Mania.UI public class ManiaRulesetContainer : ScrollingRulesetContainer { /// - /// Preferred column count. This will only have an effect during the initialization of the play field. + /// The number of columns which the should display, and which + /// the beatmap converter will attempt to convert beatmaps to use. /// - public int PreferredColumns; + private int availableColumns; public IEnumerable BarLines; @@ -76,14 +77,7 @@ namespace osu.Game.Rulesets.Mania.UI BarLines.ForEach(Playfield.Add); } - protected override void ApplyBeatmap() - { - base.ApplyBeatmap(); - - PreferredColumns = (int)Math.Max(1, Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize)); - } - - protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(PreferredColumns) + protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(availableColumns) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -95,7 +89,11 @@ namespace osu.Game.Rulesets.Mania.UI public override PassThroughInputManager CreateInputManager() => new ManiaInputManager(Ruleset.RulesetInfo); - protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); + protected override BeatmapConverter CreateBeatmapConverter() + { + availableColumns = (int)Math.Max(1, Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.CircleSize)); + return new ManiaBeatmapConverter(IsForCurrentRuleset, availableColumns); + } protected override DrawableHitObject GetVisualRepresentation(ManiaHitObject h) { diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 5b19200f2d..c7240448b9 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -139,16 +139,25 @@ namespace osu.Game.Rulesets.UI protected IEnumerable Mods; /// + /// The this was created with. + /// + protected readonly WorkingBeatmap WorkingBeatmap; + + /// + /// Whether to assume the beatmap passed into this is for the current ruleset. /// Creates a hit renderer for a beatmap. /// /// The ruleset being repesented. - /// The beatmap to create the hit renderer for. + /// The beatmap to create the hit renderer for. /// Whether to assume the beatmap is for the current ruleset. internal RulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset) : base(ruleset) + internal RulesetContainer(Ruleset ruleset, WorkingBeatmap workingBeatmap, bool isForCurrentRuleset) + : base(ruleset) { - Debug.Assert(beatmap != null, "RulesetContainer initialized with a null beatmap."); + Debug.Assert(workingBeatmap != null, "RulesetContainer initialized with a null beatmap."); - Mods = beatmap.Mods.Value; + WorkingBeatmap = workingBeatmap; + Mods = workingBeatmap.Mods.Value; RelativeSizeAxes = Axes.Both; @@ -156,11 +165,11 @@ namespace osu.Game.Rulesets.UI BeatmapProcessor processor = CreateBeatmapProcessor(); // Check if the beatmap can be converted - if (!converter.CanConvert(beatmap.Beatmap)) + if (!converter.CanConvert(workingBeatmap.Beatmap)) throw new BeatmapInvalidForRulesetException($"{nameof(Beatmap)} can not be converted for the current ruleset (converter: {converter})."); // Convert the beatmap - Beatmap = converter.Convert(beatmap.Beatmap, isForCurrentRuleset); + Beatmap = converter.Convert(workingBeatmap.Beatmap, isForCurrentRuleset); // Apply difficulty adjustments from mods before using Difficulty. foreach (var mod in Mods.OfType()) From 88151eff3f2a49b0882b833392935656357c4131 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 13:34:58 +0900 Subject: [PATCH 3/9] Fix dofficulty calculators not working and make mania set the correct key count for non-mania specific maps. --- .../ManiaDifficultyCalculator.cs | 5 +++-- .../UI/ManiaRulesetContainer.cs | 16 +++++++++++++++- .../TaikoDifficultyCalculator.cs | 4 ++-- osu.Game/Beatmaps/DifficultyCalculator.cs | 6 +++++- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 +- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs b/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs index aaba4d94f0..1f01750f44 100644 --- a/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs @@ -6,6 +6,7 @@ using osu.Game.Rulesets.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using System.Collections.Generic; +using System; namespace osu.Game.Rulesets.Mania { @@ -21,6 +22,6 @@ namespace osu.Game.Rulesets.Mania return 0; } - protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); + protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(true, (int)Math.Max(1, Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize))); } -} \ No newline at end of file +} diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 58ce05b165..6502b77cac 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -91,7 +91,21 @@ namespace osu.Game.Rulesets.Mania.UI protected override BeatmapConverter CreateBeatmapConverter() { - availableColumns = (int)Math.Max(1, Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.CircleSize)); + if (IsForCurrentRuleset) + availableColumns = (int)Math.Max(1, Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.CircleSize)); + else + { + float percentSliderOrSpinner = WorkingBeatmap.Beatmap.HitObjects.Count(h => h is IHasEndTime) / WorkingBeatmap.Beatmap.HitObjects.Count; + if (percentSliderOrSpinner < 0.2) + availableColumns = 7; + else if (percentSliderOrSpinner < 0.3 || Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.CircleSize) >= 5) + availableColumns = Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.OverallDifficulty) > 5 ? 7 : 6; + else if (percentSliderOrSpinner > 0.6) + availableColumns = Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.OverallDifficulty) > 4 ? 5 : 4; + else + availableColumns = Math.Max(4, Math.Min((int)Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.OverallDifficulty) + 1, 7)); + } + return new ManiaBeatmapConverter(IsForCurrentRuleset, availableColumns); } diff --git a/osu.Game.Rulesets.Taiko/TaikoDifficultyCalculator.cs b/osu.Game.Rulesets.Taiko/TaikoDifficultyCalculator.cs index 33e9510f1c..35f849c704 100644 --- a/osu.Game.Rulesets.Taiko/TaikoDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Taiko/TaikoDifficultyCalculator.cs @@ -135,6 +135,6 @@ namespace osu.Game.Rulesets.Taiko return difficulty; } - protected override BeatmapConverter CreateBeatmapConverter() => new TaikoBeatmapConverter(); + protected override BeatmapConverter CreateBeatmapConverter() => new TaikoBeatmapConverter(true); } -} \ No newline at end of file +} diff --git a/osu.Game/Beatmaps/DifficultyCalculator.cs b/osu.Game/Beatmaps/DifficultyCalculator.cs index 474d38aa1b..5071e2c1b6 100644 --- a/osu.Game/Beatmaps/DifficultyCalculator.cs +++ b/osu.Game/Beatmaps/DifficultyCalculator.cs @@ -30,11 +30,15 @@ namespace osu.Game.Beatmaps public abstract class DifficultyCalculator : DifficultyCalculator where T : HitObject { + protected readonly Beatmap Beatmap; + protected List Objects; protected DifficultyCalculator(Beatmap beatmap) { - Objects = CreateBeatmapConverter().Convert(beatmap, true).HitObjects; + Beatmap = beatmap; + + Objects = CreateBeatmapConverter().Convert(beatmap).HitObjects; foreach (var h in Objects) h.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.Difficulty); diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index c7240448b9..1d5b27a7fb 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -169,7 +169,7 @@ namespace osu.Game.Rulesets.UI throw new BeatmapInvalidForRulesetException($"{nameof(Beatmap)} can not be converted for the current ruleset (converter: {converter})."); // Convert the beatmap - Beatmap = converter.Convert(workingBeatmap.Beatmap, isForCurrentRuleset); + Beatmap = converter.Convert(workingBeatmap.Beatmap); // Apply difficulty adjustments from mods before using Difficulty. foreach (var mod in Mods.OfType()) From cd3c825bd22231ac520ac900d5fc14c05bb318b2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 14:04:14 +0900 Subject: [PATCH 4/9] Fix mania playfield not working. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 1 + osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index b836b54fa8..0c9351cad2 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -125,6 +125,7 @@ namespace osu.Game.Rulesets.Mania.UI for (int i = 0; i < columnCount; i++) { var c = new Column(); + c.Reversed.BindTo(Reversed); c.VisibleTimeRange.BindTo(VisibleTimeRange); columns.Add(c); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 6502b77cac..aea2d26791 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -74,6 +74,8 @@ namespace osu.Game.Rulesets.Mania.UI [BackgroundDependencyLoader] private void load() { + Playfield.Reversed.Value = true; + BarLines.ForEach(Playfield.Add); } @@ -81,8 +83,6 @@ namespace osu.Game.Rulesets.Mania.UI { Anchor = Anchor.Centre, Origin = Anchor.Centre, - // Invert by default for now (should be moved to config/skin later) - Scale = new Vector2(1, -1) }; public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); From 9a7c9e9af0107e3af439e422c7fcdd59f9b67819 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 14:17:57 +0900 Subject: [PATCH 5/9] Disable reversing for now - this needs to be re-implemented in a later PR. --- osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index aea2d26791..9b4d3adb86 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -74,8 +74,6 @@ namespace osu.Game.Rulesets.Mania.UI [BackgroundDependencyLoader] private void load() { - Playfield.Reversed.Value = true; - BarLines.ForEach(Playfield.Add); } From 68c7226d124bb9292dd9fd3364f502460031b5a8 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 14:18:17 +0900 Subject: [PATCH 6/9] Fix cherry pick issues. --- osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs | 2 +- osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs | 7 +++++-- osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs | 2 +- osu.Game/Rulesets/Beatmaps/BeatmapConverter.cs | 8 +++----- osu.Game/Rulesets/UI/RulesetContainer.cs | 7 ++++++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index e5a3c7849e..9b88a8c96c 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps int seed = (int)Math.Round(difficulty.DrainRate + difficulty.CircleSize) * 20 + (int)(difficulty.OverallDifficulty * 41.2) + (int)Math.Round(difficulty.ApproachRate); random = new FastRandom(seed); - return base.ConvertBeatmap(original, isForCurrentRuleset); + return base.ConvertBeatmap(original); } protected override IEnumerable ConvertHitObject(HitObject original, Beatmap beatmap) diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs index 869d54dded..40147f7c24 100644 --- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs +++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs @@ -43,15 +43,18 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps protected override IEnumerable ValidConversionTypes { get; } = new[] { typeof(HitObject) }; - protected override Beatmap ConvertBeatmap(Beatmap original, bool isForCurrentRuleset) + public TaikoBeatmapConverter(bool isForCurrentRuleset) { this.isForCurrentRuleset = isForCurrentRuleset; + } + protected override Beatmap ConvertBeatmap(Beatmap original) + { // Rewrite the beatmap info to add the slider velocity multiplier BeatmapInfo info = original.BeatmapInfo.DeepClone(); info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier; - Beatmap converted = base.ConvertBeatmap(original, isForCurrentRuleset); + Beatmap converted = base.ConvertBeatmap(original); // Post processing step to transform hit objects with the same start time into strong hits converted.HitObjects = converted.HitObjects.GroupBy(t => t.StartTime).Select(x => diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs index 1ecd699a8e..96e5df12cd 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs @@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Taiko.UI public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this); - protected override BeatmapConverter CreateBeatmapConverter() => new TaikoBeatmapConverter(); + protected override BeatmapConverter CreateBeatmapConverter() => new TaikoBeatmapConverter(IsForCurrentRuleset); public override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo); diff --git a/osu.Game/Rulesets/Beatmaps/BeatmapConverter.cs b/osu.Game/Rulesets/Beatmaps/BeatmapConverter.cs index aafa576d4b..e79d9eee4b 100644 --- a/osu.Game/Rulesets/Beatmaps/BeatmapConverter.cs +++ b/osu.Game/Rulesets/Beatmaps/BeatmapConverter.cs @@ -26,21 +26,19 @@ namespace osu.Game.Rulesets.Beatmaps /// Converts a Beatmap using this Beatmap Converter. /// /// The un-converted Beatmap. - /// Whether to assume the beatmap is for the current ruleset. /// The converted Beatmap. - public Beatmap Convert(Beatmap original, bool isForCurrentRuleset) + public Beatmap Convert(Beatmap original) { // We always operate on a clone of the original beatmap, to not modify it game-wide - return ConvertBeatmap(new Beatmap(original), isForCurrentRuleset); + return ConvertBeatmap(new Beatmap(original)); } /// /// Performs the conversion of a Beatmap using this Beatmap Converter. /// /// The un-converted Beatmap. - /// Whether to assume the beatmap is for the current ruleset. /// The converted Beatmap. - protected virtual Beatmap ConvertBeatmap(Beatmap original, bool isForCurrentRuleset) + protected virtual Beatmap ConvertBeatmap(Beatmap original) { return new Beatmap { diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 1d5b27a7fb..2f1cb915f3 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -143,6 +143,11 @@ namespace osu.Game.Rulesets.UI /// protected readonly WorkingBeatmap WorkingBeatmap; + /// + /// Whether the specified beatmap is assumed to be specific to the current ruleset. + /// + protected readonly bool IsForCurrentRuleset; + /// /// Whether to assume the beatmap passed into this is for the current ruleset. /// Creates a hit renderer for a beatmap. @@ -150,13 +155,13 @@ namespace osu.Game.Rulesets.UI /// The ruleset being repesented. /// The beatmap to create the hit renderer for. /// Whether to assume the beatmap is for the current ruleset. - internal RulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset) : base(ruleset) internal RulesetContainer(Ruleset ruleset, WorkingBeatmap workingBeatmap, bool isForCurrentRuleset) : base(ruleset) { Debug.Assert(workingBeatmap != null, "RulesetContainer initialized with a null beatmap."); WorkingBeatmap = workingBeatmap; + IsForCurrentRuleset = isForCurrentRuleset; Mods = workingBeatmap.Mods.Value; RelativeSizeAxes = Axes.Both; From 909cae5861da45943ec55b5d70d1bd81a8ab6915 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 14:21:28 +0900 Subject: [PATCH 7/9] CI fixes. --- osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs | 1 - osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs | 2 +- osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index 6b85a51402..6ab9c86b9f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 9b4d3adb86..0e750a348e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Mania.UI availableColumns = (int)Math.Max(1, Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.CircleSize)); else { - float percentSliderOrSpinner = WorkingBeatmap.Beatmap.HitObjects.Count(h => h is IHasEndTime) / WorkingBeatmap.Beatmap.HitObjects.Count; + float percentSliderOrSpinner = (float)WorkingBeatmap.Beatmap.HitObjects.Count(h => h is IHasEndTime) / WorkingBeatmap.Beatmap.HitObjects.Count; if (percentSliderOrSpinner < 0.2) availableColumns = 7; else if (percentSliderOrSpinner < 0.3 || Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.CircleSize) >= 5) diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs index 40147f7c24..2bf058fc2b 100644 --- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs +++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs @@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps /// private const float taiko_base_distance = 100; - private bool isForCurrentRuleset; + private readonly bool isForCurrentRuleset; protected override IEnumerable ValidConversionTypes { get; } = new[] { typeof(HitObject) }; From e337fbcf4fe9dedc008a1ff33be26919ca2a6de9 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 16:22:40 +0900 Subject: [PATCH 8/9] Make availableColumns into a ctor argument. --- .../Beatmaps/ManiaBeatmapConverter.cs | 14 ++++++-------- .../Legacy/DistanceObjectPatternGenerator.cs | 4 ++-- .../Legacy/EndTimeObjectPatternGenerator.cs | 4 ++-- .../Patterns/Legacy/HitObjectPatternGenerator.cs | 4 ++-- .../Beatmaps/Patterns/Legacy/PatternGenerator.cs | 4 ++-- .../Beatmaps/Patterns/PatternGenerator.cs | 7 ++++--- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 9b88a8c96c..262f1c67ed 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -95,7 +95,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// The hit objects generated. private IEnumerable generateSpecific(HitObject original) { - var generator = new SpecificBeatmapPatternGenerator(random, original, beatmap, lastPattern) { AvailableColumns = availableColumns }; + var generator = new SpecificBeatmapPatternGenerator(random, original, beatmap, availableColumns, lastPattern); Pattern newPattern = generator.Generate(); lastPattern = newPattern; @@ -119,14 +119,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps Patterns.PatternGenerator conversion = null; if (distanceData != null) - conversion = new DistanceObjectPatternGenerator(random, original, beatmap, lastPattern); + conversion = new DistanceObjectPatternGenerator(random, original, beatmap, availableColumns, lastPattern); else if (endTimeData != null) - conversion = new EndTimeObjectPatternGenerator(random, original, beatmap); + conversion = new EndTimeObjectPatternGenerator(random, original, beatmap, availableColumns); else if (positionData != null) { computeDensity(original.StartTime); - conversion = new HitObjectPatternGenerator(random, original, beatmap, lastPattern, lastTime, lastPosition, density, lastStair); + conversion = new HitObjectPatternGenerator(random, original, beatmap, availableColumns, lastPattern, lastTime, lastPosition, density, lastStair); recordNote(original.StartTime, positionData.Position); } @@ -134,8 +134,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps if (conversion == null) return null; - conversion.AvailableColumns = availableColumns; - Pattern newPattern = conversion.Generate(); lastPattern = newPattern; @@ -150,8 +148,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps /// private class SpecificBeatmapPatternGenerator : Patterns.Legacy.PatternGenerator { - public SpecificBeatmapPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern) - : base(random, hitObject, beatmap, previousPattern) + public SpecificBeatmapPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, int availableColumns, Pattern previousPattern) + : base(random, hitObject, beatmap, availableColumns, previousPattern) { } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index c03a8438ae..20966a75f7 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -29,8 +29,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy private PatternType convertType; - public DistanceObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern) - : base(random, hitObject, beatmap, previousPattern) + public DistanceObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, int availableColumns, Pattern previousPattern) + : base(random, hitObject, beatmap, availableColumns, previousPattern) { convertType = PatternType.None; if (Beatmap.ControlPointInfo.EffectPointAt(hitObject.StartTime).KiaiMode) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs index 6ad7489e0f..c353496410 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs @@ -15,8 +15,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { private readonly double endTime; - public EndTimeObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap) - : base(random, hitObject, beatmap, new Pattern()) + public EndTimeObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, int availableColumns) + : base(random, hitObject, beatmap, availableColumns, new Pattern()) { var endtimeData = HitObject as IHasEndTime; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs index 99f55cb98b..0716671da3 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs @@ -20,8 +20,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy private readonly PatternType convertType; - public HitObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern, double previousTime, Vector2 previousPosition, double density, PatternType lastStair) - : base(random, hitObject, beatmap, previousPattern) + public HitObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, int availableColumns, Pattern previousPattern, double previousTime, Vector2 previousPosition, double density, PatternType lastStair) + : base(random, hitObject, beatmap, availableColumns, previousPattern) { StairType = lastStair; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index b72618c36c..d1b962bdd4 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -25,8 +25,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// protected readonly FastRandom Random; - protected PatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern) - : base(hitObject, beatmap, previousPattern) + protected PatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, int availableColumns, Pattern previousPattern) + : base(hitObject, beatmap, availableColumns, previousPattern) { Random = random; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index 6ab9c86b9f..4fe100df23 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns /// /// The number of columns available to create the pattern. /// - public int AvailableColumns; + protected readonly int AvailableColumns; /// /// The last pattern. @@ -31,11 +31,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns /// protected readonly Beatmap Beatmap; - protected PatternGenerator(HitObject hitObject, Beatmap beatmap, Pattern previousPattern) + protected PatternGenerator(HitObject hitObject, Beatmap beatmap, int availableColumns, Pattern previousPattern) { - PreviousPattern = previousPattern; HitObject = hitObject; Beatmap = beatmap; + AvailableColumns = availableColumns; + PreviousPattern = previousPattern; } /// From 2f2abf122b38a4d53c0c1b02449781010f0f0dcd Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 16:46:12 +0900 Subject: [PATCH 9/9] Add exceptions galore. --- .../Beatmaps/ManiaBeatmapConverter.cs | 2 ++ .../Patterns/Legacy/HitObjectPatternGenerator.cs | 3 +++ .../Beatmaps/Patterns/Legacy/PatternGenerator.cs | 12 +++++++++++- .../Beatmaps/Patterns/PatternGenerator.cs | 6 ++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 262f1c67ed..be670936fd 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -34,6 +34,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps public ManiaBeatmapConverter(bool isForCurrentRuleset, int availableColumns) { + if (availableColumns <= 0) throw new ArgumentOutOfRangeException(nameof(availableColumns)); + this.isForCurrentRuleset = isForCurrentRuleset; this.availableColumns = availableColumns; } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs index 0716671da3..077b926635 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs @@ -23,6 +23,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy public HitObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, int availableColumns, Pattern previousPattern, double previousTime, Vector2 previousPosition, double density, PatternType lastStair) : base(random, hitObject, beatmap, availableColumns, previousPattern) { + if (previousTime > hitObject.StartTime) throw new ArgumentOutOfRangeException(nameof(previousTime)); + if (density < 0) throw new ArgumentOutOfRangeException(nameof(density)); + StairType = lastStair; TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index d1b962bdd4..a3173f9784 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -28,8 +28,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy protected PatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, int availableColumns, Pattern previousPattern) : base(hitObject, beatmap, availableColumns, previousPattern) { - Random = random; + if (random == null) throw new ArgumentNullException(nameof(random)); + if (beatmap == null) throw new ArgumentNullException(nameof(beatmap)); + if (availableColumns <= 0) throw new ArgumentOutOfRangeException(nameof(availableColumns)); + if (previousPattern == null) throw new ArgumentNullException(nameof(previousPattern)); + Random = random; RandomStart = AvailableColumns == 8 ? 1 : 0; } @@ -62,6 +66,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// The amount of notes to be generated. protected int GetRandomNoteCount(double p2, double p3, double p4 = 0, double p5 = 0, double p6 = 0) { + if (p2 < 0 || p2 > 1) throw new ArgumentOutOfRangeException(nameof(p2)); + if (p3 < 0 || p3 > 1) throw new ArgumentOutOfRangeException(nameof(p3)); + if (p4 < 0 || p4 > 1) throw new ArgumentOutOfRangeException(nameof(p4)); + if (p5 < 0 || p5 > 1) throw new ArgumentOutOfRangeException(nameof(p5)); + if (p6 < 0 || p6 > 1) throw new ArgumentOutOfRangeException(nameof(p6)); + double val = Random.NextDouble(); if (val >= 1 - p6) return 6; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs index 4fe100df23..ef321232c8 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/PatternGenerator.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects; @@ -33,6 +34,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns protected PatternGenerator(HitObject hitObject, Beatmap beatmap, int availableColumns, Pattern previousPattern) { + if (hitObject == null) throw new ArgumentNullException(nameof(hitObject)); + if (beatmap == null) throw new ArgumentNullException(nameof(beatmap)); + if (availableColumns <= 0) throw new ArgumentOutOfRangeException(nameof(availableColumns)); + if (previousPattern == null) throw new ArgumentNullException(nameof(previousPattern)); + HitObject = hitObject; Beatmap = beatmap; AvailableColumns = availableColumns;