mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'mania-beatmap-conversion' into mania-endtime-object-conversion
# Conflicts: # osu.Game.Rulesets.Mania/Beatmaps/LegacyBeatmapConverter.cs
This commit is contained in:
@ -85,25 +85,25 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Clock = new FramedClock(),
|
Clock = new FramedClock(),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuHitRenderer(beatmap)
|
new OsuHitRenderer(beatmap, false)
|
||||||
{
|
{
|
||||||
Scale = new Vector2(0.5f),
|
Scale = new Vector2(0.5f),
|
||||||
Anchor = Anchor.TopLeft,
|
Anchor = Anchor.TopLeft,
|
||||||
Origin = Anchor.TopLeft
|
Origin = Anchor.TopLeft
|
||||||
},
|
},
|
||||||
new TaikoHitRenderer(beatmap)
|
new TaikoHitRenderer(beatmap, false)
|
||||||
{
|
{
|
||||||
Scale = new Vector2(0.5f),
|
Scale = new Vector2(0.5f),
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight
|
Origin = Anchor.TopRight
|
||||||
},
|
},
|
||||||
new CatchHitRenderer(beatmap)
|
new CatchHitRenderer(beatmap, false)
|
||||||
{
|
{
|
||||||
Scale = new Vector2(0.5f),
|
Scale = new Vector2(0.5f),
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft
|
Origin = Anchor.BottomLeft
|
||||||
},
|
},
|
||||||
new ManiaHitRenderer(beatmap)
|
new ManiaHitRenderer(beatmap, false)
|
||||||
{
|
{
|
||||||
Scale = new Vector2(0.5f),
|
Scale = new Vector2(0.5f),
|
||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
{
|
{
|
||||||
public class CatchRuleset : Ruleset
|
public class CatchRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new CatchHitRenderer(beatmap);
|
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new CatchHitRenderer(beatmap, isForCurrentRuleset);
|
||||||
|
|
||||||
public override IEnumerable<Mod> GetModsFor(ModType type)
|
public override IEnumerable<Mod> GetModsFor(ModType type)
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
{
|
{
|
||||||
public class CatchHitRenderer : HitRenderer<CatchBaseHit, CatchJudgement>
|
public class CatchHitRenderer : HitRenderer<CatchBaseHit, CatchJudgement>
|
||||||
{
|
{
|
||||||
public CatchHitRenderer(WorkingBeatmap beatmap)
|
public CatchHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset)
|
||||||
: base(beatmap)
|
: base(beatmap, isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,146 +0,0 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps.Patterns;
|
|
||||||
using osu.Game.Rulesets.Mania.MathUtils;
|
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Beatmaps
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Special converter used for converting from osu!stable beatmaps.
|
|
||||||
/// </summary>
|
|
||||||
internal class LegacyBeatmapConverter
|
|
||||||
{
|
|
||||||
private Pattern lastPattern = new Pattern();
|
|
||||||
|
|
||||||
private readonly FastRandom random;
|
|
||||||
private readonly Beatmap beatmap;
|
|
||||||
|
|
||||||
public LegacyBeatmapConverter(Beatmap beatmap)
|
|
||||||
{
|
|
||||||
this.beatmap = beatmap;
|
|
||||||
|
|
||||||
int seed = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.DrainRate + beatmap.BeatmapInfo.Difficulty.CircleSize)
|
|
||||||
* 20 + (int)(beatmap.BeatmapInfo.Difficulty.OverallDifficulty * 41.2) + (int)Math.Round(beatmap.BeatmapInfo.Difficulty.ApproachRate);
|
|
||||||
random = new FastRandom(seed);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<ManiaHitObject> Convert(HitObject original)
|
|
||||||
{
|
|
||||||
var maniaOriginal = original as ManiaHitObject;
|
|
||||||
if (maniaOriginal != null)
|
|
||||||
{
|
|
||||||
yield return maniaOriginal;
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerable<ManiaHitObject> objects;
|
|
||||||
switch (beatmap.BeatmapInfo.RulesetID)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
objects = generateConverted(original);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
objects = generateSpecific(original);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objects == null)
|
|
||||||
yield break;
|
|
||||||
|
|
||||||
foreach (ManiaHitObject obj in objects)
|
|
||||||
yield return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<ManiaHitObject> generateSpecific(HitObject original)
|
|
||||||
{
|
|
||||||
var generator = new SpecificPatternGenerator(random, original, beatmap, lastPattern);
|
|
||||||
|
|
||||||
Pattern newPattern = generator.Generate();
|
|
||||||
lastPattern = newPattern;
|
|
||||||
|
|
||||||
return newPattern.HitObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<ManiaHitObject> generateConverted(HitObject original)
|
|
||||||
{
|
|
||||||
var endTimeData = original as IHasEndTime;
|
|
||||||
var distanceData = original as IHasDistance;
|
|
||||||
var positionData = original as IHasPosition;
|
|
||||||
|
|
||||||
Patterns.PatternGenerator conversion = null;
|
|
||||||
|
|
||||||
if (distanceData != null)
|
|
||||||
{
|
|
||||||
// Slider
|
|
||||||
}
|
|
||||||
else if (endTimeData != null)
|
|
||||||
{
|
|
||||||
conversion = new EndTimeObjectPatternGenerator(random, original, beatmap);
|
|
||||||
// Spinner
|
|
||||||
}
|
|
||||||
else if (positionData != null)
|
|
||||||
{
|
|
||||||
// Circle
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conversion == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Pattern newPattern = conversion.Generate();
|
|
||||||
lastPattern = newPattern;
|
|
||||||
|
|
||||||
return newPattern.HitObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A pattern generator for mania-specific beatmaps.
|
|
||||||
/// </summary>
|
|
||||||
private class SpecificPatternGenerator : Patterns.Legacy.PatternGenerator
|
|
||||||
{
|
|
||||||
public SpecificPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern)
|
|
||||||
: base(random, hitObject, beatmap, previousPattern)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Pattern Generate()
|
|
||||||
{
|
|
||||||
var endTimeData = HitObject as IHasEndTime;
|
|
||||||
var positionData = HitObject as IHasXPosition;
|
|
||||||
|
|
||||||
int column = GetColumn(positionData?.X ?? 0);
|
|
||||||
|
|
||||||
var pattern = new Pattern();
|
|
||||||
|
|
||||||
if (endTimeData != null)
|
|
||||||
{
|
|
||||||
pattern.Add(new HoldNote
|
|
||||||
{
|
|
||||||
StartTime = HitObject.StartTime,
|
|
||||||
Samples = HitObject.Samples,
|
|
||||||
Duration = endTimeData.Duration,
|
|
||||||
Column = column,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (positionData != null)
|
|
||||||
{
|
|
||||||
pattern.Add(new Note
|
|
||||||
{
|
|
||||||
StartTime = HitObject.StartTime,
|
|
||||||
Samples = HitObject.Samples,
|
|
||||||
Column = column
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return pattern;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,9 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using System.Linq;
|
using osu.Game.Rulesets.Mania.Beatmaps.Patterns;
|
||||||
|
using osu.Game.Rulesets.Mania.MathUtils;
|
||||||
|
using osu.Game.Database;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Beatmaps
|
namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||||
{
|
{
|
||||||
@ -16,24 +18,136 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
{
|
{
|
||||||
protected override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) };
|
protected override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) };
|
||||||
|
|
||||||
protected override Beatmap<ManiaHitObject> ConvertBeatmap(Beatmap original)
|
private Pattern lastPattern = new Pattern();
|
||||||
{
|
private FastRandom random;
|
||||||
// Todo: This should be cased when we get better conversion methods
|
private Beatmap beatmap;
|
||||||
var converter = new LegacyBeatmapConverter(original);
|
private bool isForCurrentRuleset;
|
||||||
|
|
||||||
return new Beatmap<ManiaHitObject>
|
protected override Beatmap<ManiaHitObject> ConvertBeatmap(Beatmap original, bool isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
BeatmapInfo = original.BeatmapInfo,
|
this.isForCurrentRuleset = isForCurrentRuleset;
|
||||||
TimingInfo = original.TimingInfo,
|
|
||||||
// We need to sort here, because the converter generates patterns
|
beatmap = original;
|
||||||
HitObjects = original.HitObjects.SelectMany(converter.Convert).OrderBy(h => h.StartTime).ToList()
|
|
||||||
};
|
BeatmapDifficulty difficulty = original.BeatmapInfo.Difficulty;
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerable<ManiaHitObject> ConvertHitObject(HitObject original, Beatmap beatmap)
|
protected override IEnumerable<ManiaHitObject> ConvertHitObject(HitObject original, Beatmap beatmap)
|
||||||
{
|
{
|
||||||
// Handled by the LegacyConvereter
|
var maniaOriginal = original as ManiaHitObject;
|
||||||
yield return null;
|
if (maniaOriginal != null)
|
||||||
|
{
|
||||||
|
yield return maniaOriginal;
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var objects = isForCurrentRuleset ? generateSpecific(original) : generateConverted(original);
|
||||||
|
|
||||||
|
if (objects == null)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
foreach (ManiaHitObject obj in objects)
|
||||||
|
yield return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method that generates hit objects for osu!mania specific beatmaps.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="original">The original hit object.</param>
|
||||||
|
/// <returns>The hit objects generated.</returns>
|
||||||
|
private IEnumerable<ManiaHitObject> generateSpecific(HitObject original)
|
||||||
|
{
|
||||||
|
var generator = new SpecificBeatmapPatternGenerator(random, original, beatmap, lastPattern);
|
||||||
|
|
||||||
|
Pattern newPattern = generator.Generate();
|
||||||
|
lastPattern = newPattern;
|
||||||
|
|
||||||
|
return newPattern.HitObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method that generates hit objects for non-osu!mania beatmaps.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="original">The original hit object.</param>
|
||||||
|
/// <returns>The hit objects generated.</returns>
|
||||||
|
private IEnumerable<ManiaHitObject> generateConverted(HitObject original)
|
||||||
|
{
|
||||||
|
var endTimeData = original as IHasEndTime;
|
||||||
|
var distanceData = original as IHasDistance;
|
||||||
|
var positionData = original as IHasPosition;
|
||||||
|
|
||||||
|
// Following lines currently commented out to appease resharper
|
||||||
|
|
||||||
|
//Patterns.PatternGenerator conversion = null;
|
||||||
|
|
||||||
|
if (distanceData != null)
|
||||||
|
{
|
||||||
|
// Slider
|
||||||
|
}
|
||||||
|
else if (endTimeData != null)
|
||||||
|
{
|
||||||
|
// Spinner
|
||||||
|
}
|
||||||
|
else if (positionData != null)
|
||||||
|
{
|
||||||
|
// Circle
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (conversion == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
//Pattern newPattern = conversion.Generate();
|
||||||
|
//lastPattern = newPattern;
|
||||||
|
|
||||||
|
//return newPattern.HitObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A pattern generator for osu!mania-specific beatmaps.
|
||||||
|
/// </summary>
|
||||||
|
private class SpecificBeatmapPatternGenerator : Patterns.Legacy.PatternGenerator
|
||||||
|
{
|
||||||
|
public SpecificBeatmapPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern)
|
||||||
|
: base(random, hitObject, beatmap, previousPattern)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Pattern Generate()
|
||||||
|
{
|
||||||
|
var endTimeData = HitObject as IHasEndTime;
|
||||||
|
var positionData = HitObject as IHasXPosition;
|
||||||
|
|
||||||
|
int column = GetColumn(positionData?.X ?? 0);
|
||||||
|
|
||||||
|
var pattern = new Pattern();
|
||||||
|
|
||||||
|
if (endTimeData != null)
|
||||||
|
{
|
||||||
|
pattern.Add(new HoldNote
|
||||||
|
{
|
||||||
|
StartTime = HitObject.StartTime,
|
||||||
|
Samples = HitObject.Samples,
|
||||||
|
Duration = endTimeData.Duration,
|
||||||
|
Column = column,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (positionData != null)
|
||||||
|
{
|
||||||
|
pattern.Add(new Note
|
||||||
|
{
|
||||||
|
StartTime = HitObject.StartTime,
|
||||||
|
Samples = HitObject.Samples,
|
||||||
|
Column = column
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return pattern;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
{
|
{
|
||||||
public class ManiaRuleset : Ruleset
|
public class ManiaRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new ManiaHitRenderer(beatmap);
|
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new ManiaHitRenderer(beatmap, isForCurrentRuleset);
|
||||||
|
|
||||||
public override IEnumerable<Mod> GetModsFor(ModType type)
|
public override IEnumerable<Mod> GetModsFor(ModType type)
|
||||||
{
|
{
|
||||||
|
@ -24,8 +24,8 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
{
|
{
|
||||||
public int? Columns;
|
public int? Columns;
|
||||||
|
|
||||||
public ManiaHitRenderer(WorkingBeatmap beatmap)
|
public ManiaHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset)
|
||||||
: base(beatmap)
|
: base(beatmap, isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@
|
|||||||
<Compile Include="Beatmaps\Patterns\Legacy\EndTimeObjectPatternGenerator.cs" />
|
<Compile Include="Beatmaps\Patterns\Legacy\EndTimeObjectPatternGenerator.cs" />
|
||||||
<Compile Include="Beatmaps\Patterns\Legacy\PatternGenerator.cs" />
|
<Compile Include="Beatmaps\Patterns\Legacy\PatternGenerator.cs" />
|
||||||
<Compile Include="Beatmaps\Patterns\PatternGenerator.cs" />
|
<Compile Include="Beatmaps\Patterns\PatternGenerator.cs" />
|
||||||
<Compile Include="Beatmaps\LegacyBeatmapConverter.cs" />
|
|
||||||
<Compile Include="Beatmaps\Patterns\Legacy\PatternType.cs" />
|
<Compile Include="Beatmaps\Patterns\Legacy\PatternType.cs" />
|
||||||
<Compile Include="Beatmaps\ManiaBeatmapConverter.cs" />
|
<Compile Include="Beatmaps\ManiaBeatmapConverter.cs" />
|
||||||
<Compile Include="Beatmaps\Patterns\Pattern.cs" />
|
<Compile Include="Beatmaps\Patterns\Pattern.cs" />
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
public class OsuRuleset : Ruleset
|
public class OsuRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new OsuHitRenderer(beatmap);
|
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new OsuHitRenderer(beatmap, isForCurrentRuleset);
|
||||||
|
|
||||||
public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[]
|
public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[]
|
||||||
{
|
{
|
||||||
|
@ -18,8 +18,8 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
{
|
{
|
||||||
public class OsuHitRenderer : HitRenderer<OsuHitObject, OsuJudgement>
|
public class OsuHitRenderer : HitRenderer<OsuHitObject, OsuJudgement>
|
||||||
{
|
{
|
||||||
public OsuHitRenderer(WorkingBeatmap beatmap)
|
public OsuHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset)
|
||||||
: base(beatmap)
|
: base(beatmap, isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,13 +41,13 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
|
|||||||
|
|
||||||
protected override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(HitObject) };
|
protected override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(HitObject) };
|
||||||
|
|
||||||
protected override Beatmap<TaikoHitObject> ConvertBeatmap(Beatmap original)
|
protected override Beatmap<TaikoHitObject> ConvertBeatmap(Beatmap original, bool isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
// Rewrite the beatmap info to add the slider velocity multiplier
|
// Rewrite the beatmap info to add the slider velocity multiplier
|
||||||
BeatmapInfo info = original.BeatmapInfo.DeepClone();
|
BeatmapInfo info = original.BeatmapInfo.DeepClone();
|
||||||
info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier;
|
info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier;
|
||||||
|
|
||||||
Beatmap<TaikoHitObject> converted = base.ConvertBeatmap(original);
|
Beatmap<TaikoHitObject> converted = base.ConvertBeatmap(original, isForCurrentRuleset);
|
||||||
|
|
||||||
// Post processing step to transform hit objects with the same start time into strong hits
|
// 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 =>
|
converted.HitObjects = converted.HitObjects.GroupBy(t => t.StartTime).Select(x =>
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
{
|
{
|
||||||
public class TaikoRuleset : Ruleset
|
public class TaikoRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap) => new TaikoHitRenderer(beatmap);
|
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new TaikoHitRenderer(beatmap, isForCurrentRuleset);
|
||||||
|
|
||||||
public override IEnumerable<Mod> GetModsFor(ModType type)
|
public override IEnumerable<Mod> GetModsFor(ModType type)
|
||||||
{
|
{
|
||||||
|
@ -22,8 +22,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
public class TaikoHitRenderer : HitRenderer<TaikoHitObject, TaikoJudgement>
|
public class TaikoHitRenderer : HitRenderer<TaikoHitObject, TaikoJudgement>
|
||||||
{
|
{
|
||||||
public TaikoHitRenderer(WorkingBeatmap beatmap)
|
public TaikoHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset)
|
||||||
: base(beatmap)
|
: base(beatmap, isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
protected DifficultyCalculator(Beatmap beatmap)
|
protected DifficultyCalculator(Beatmap beatmap)
|
||||||
{
|
{
|
||||||
Objects = CreateBeatmapConverter().Convert(beatmap).HitObjects;
|
Objects = CreateBeatmapConverter().Convert(beatmap, true).HitObjects;
|
||||||
|
|
||||||
foreach (var h in Objects)
|
foreach (var h in Objects)
|
||||||
h.ApplyDefaults(beatmap.TimingInfo, beatmap.BeatmapInfo.Difficulty);
|
h.ApplyDefaults(beatmap.TimingInfo, beatmap.BeatmapInfo.Difficulty);
|
||||||
|
@ -26,19 +26,21 @@ namespace osu.Game.Rulesets.Beatmaps
|
|||||||
/// Converts a Beatmap using this Beatmap Converter.
|
/// Converts a Beatmap using this Beatmap Converter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="original">The un-converted Beatmap.</param>
|
/// <param name="original">The un-converted Beatmap.</param>
|
||||||
|
/// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param>
|
||||||
/// <returns>The converted Beatmap.</returns>
|
/// <returns>The converted Beatmap.</returns>
|
||||||
public Beatmap<T> Convert(Beatmap original)
|
public Beatmap<T> Convert(Beatmap original, bool isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
// We always operate on a clone of the original beatmap, to not modify it game-wide
|
// We always operate on a clone of the original beatmap, to not modify it game-wide
|
||||||
return ConvertBeatmap(new Beatmap(original));
|
return ConvertBeatmap(new Beatmap(original), isForCurrentRuleset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs the conversion of a Beatmap using this Beatmap Converter.
|
/// Performs the conversion of a Beatmap using this Beatmap Converter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="original">The un-converted Beatmap.</param>
|
/// <param name="original">The un-converted Beatmap.</param>
|
||||||
|
/// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param>
|
||||||
/// <returns>The converted Beatmap.</returns>
|
/// <returns>The converted Beatmap.</returns>
|
||||||
protected virtual Beatmap<T> ConvertBeatmap(Beatmap original)
|
protected virtual Beatmap<T> ConvertBeatmap(Beatmap original, bool isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
return new Beatmap<T>
|
return new Beatmap<T>
|
||||||
{
|
{
|
||||||
|
@ -18,12 +18,13 @@ namespace osu.Game.Rulesets
|
|||||||
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempt to create a HitRenderer for the provided beatmap.
|
/// Attempt to create a hit renderer for a beatmap
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap"></param>
|
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
|
||||||
|
/// <param name="isForCurrentRuleset">Whether the hit renderer should assume the beatmap is for the current ruleset.</param>
|
||||||
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public abstract HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap);
|
public abstract HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset);
|
||||||
|
|
||||||
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);
|
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract bool AllObjectsJudged { get; }
|
protected abstract bool AllObjectsJudged { get; }
|
||||||
|
|
||||||
protected HitRenderer()
|
internal HitRenderer()
|
||||||
{
|
{
|
||||||
KeyConversionInputManager = CreateKeyConversionInputManager();
|
KeyConversionInputManager = CreateKeyConversionInputManager();
|
||||||
KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
|
KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
|
||||||
@ -120,7 +120,12 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Beatmap<TObject> Beatmap;
|
public Beatmap<TObject> Beatmap;
|
||||||
|
|
||||||
protected HitRenderer(WorkingBeatmap beatmap)
|
/// <summary>
|
||||||
|
/// Creates a hit renderer for a beatmap.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
|
||||||
|
/// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param>
|
||||||
|
internal HitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
Debug.Assert(beatmap != null, "HitRenderer initialized with a null beatmap.");
|
Debug.Assert(beatmap != null, "HitRenderer initialized with a null beatmap.");
|
||||||
|
|
||||||
@ -134,7 +139,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
throw new BeatmapInvalidForRulesetException($"{nameof(Beatmap)} can't be converted for the current ruleset.");
|
throw new BeatmapInvalidForRulesetException($"{nameof(Beatmap)} can't be converted for the current ruleset.");
|
||||||
|
|
||||||
// Convert the beatmap
|
// Convert the beatmap
|
||||||
Beatmap = converter.Convert(beatmap.Beatmap);
|
Beatmap = converter.Convert(beatmap.Beatmap, isForCurrentRuleset);
|
||||||
|
|
||||||
// Apply defaults
|
// Apply defaults
|
||||||
foreach (var h in Beatmap.HitObjects)
|
foreach (var h in Beatmap.HitObjects)
|
||||||
@ -201,8 +206,13 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
private readonly List<DrawableHitObject<TObject, TJudgement>> drawableObjects = new List<DrawableHitObject<TObject, TJudgement>>();
|
private readonly List<DrawableHitObject<TObject, TJudgement>> drawableObjects = new List<DrawableHitObject<TObject, TJudgement>>();
|
||||||
|
|
||||||
protected HitRenderer(WorkingBeatmap beatmap)
|
/// <summary>
|
||||||
: base(beatmap)
|
/// Creates a hit renderer for a beatmap.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
|
||||||
|
/// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param>
|
||||||
|
protected HitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset)
|
||||||
|
: base(beatmap, isForCurrentRuleset)
|
||||||
{
|
{
|
||||||
InputManager.Add(content = new Container
|
InputManager.Add(content = new Container
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap);
|
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap, ruleset.ID == Beatmap.BeatmapInfo.Ruleset.ID);
|
||||||
}
|
}
|
||||||
catch (BeatmapInvalidForRulesetException)
|
catch (BeatmapInvalidForRulesetException)
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ namespace osu.Game.Screens.Play
|
|||||||
// let's try again forcing the beatmap's ruleset.
|
// let's try again forcing the beatmap's ruleset.
|
||||||
ruleset = Beatmap.BeatmapInfo.Ruleset;
|
ruleset = Beatmap.BeatmapInfo.Ruleset;
|
||||||
rulesetInstance = ruleset.CreateInstance();
|
rulesetInstance = ruleset.CreateInstance();
|
||||||
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap);
|
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HitRenderer.Objects.Any())
|
if (!HitRenderer.Objects.Any())
|
||||||
|
Reference in New Issue
Block a user