mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 04:23:14 +08:00
Make IBeatmapConverter an abstract class instead of an interface.
This commit is contained in:
parent
456aee63ca
commit
efc050a95a
@ -10,11 +10,11 @@ using osu.Game.Modes.Beatmaps;
|
||||
|
||||
namespace osu.Game.Modes.Catch.Beatmaps
|
||||
{
|
||||
internal class CatchBeatmapConverter : IBeatmapConverter<CatchBaseHit>
|
||||
internal class CatchBeatmapConverter : BeatmapConverter<CatchBaseHit>
|
||||
{
|
||||
public IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) };
|
||||
public override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) };
|
||||
|
||||
public Beatmap<CatchBaseHit> Convert(Beatmap original)
|
||||
public override Beatmap<CatchBaseHit> Convert(Beatmap original)
|
||||
{
|
||||
return new Beatmap<CatchBaseHit>(original)
|
||||
{
|
||||
|
@ -20,6 +20,6 @@ namespace osu.Game.Modes.Catch
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected override IBeatmapConverter<CatchBaseHit> CreateBeatmapConverter() => new CatchBeatmapConverter();
|
||||
protected override BeatmapConverter<CatchBaseHit> CreateBeatmapConverter() => new CatchBeatmapConverter();
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ namespace osu.Game.Modes.Catch.UI
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(this);
|
||||
|
||||
protected override IBeatmapConverter<CatchBaseHit> CreateBeatmapConverter() => new CatchBeatmapConverter();
|
||||
protected override BeatmapConverter<CatchBaseHit> CreateBeatmapConverter() => new CatchBeatmapConverter();
|
||||
|
||||
protected override IBeatmapProcessor<CatchBaseHit> CreateBeatmapProcessor() => new CatchBeatmapProcessor();
|
||||
|
||||
|
@ -10,11 +10,11 @@ using osu.Game.Modes.Beatmaps;
|
||||
|
||||
namespace osu.Game.Modes.Mania.Beatmaps
|
||||
{
|
||||
internal class ManiaBeatmapConverter : IBeatmapConverter<ManiaBaseHit>
|
||||
internal class ManiaBeatmapConverter : BeatmapConverter<ManiaBaseHit>
|
||||
{
|
||||
public IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasColumn) };
|
||||
public override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasColumn) };
|
||||
|
||||
public Beatmap<ManiaBaseHit> Convert(Beatmap original)
|
||||
public override Beatmap<ManiaBaseHit> Convert(Beatmap original)
|
||||
{
|
||||
return new Beatmap<ManiaBaseHit>(original)
|
||||
{
|
||||
|
@ -21,6 +21,6 @@ namespace osu.Game.Modes.Mania
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected override IBeatmapConverter<ManiaBaseHit> CreateBeatmapConverter() => new ManiaBeatmapConverter();
|
||||
protected override BeatmapConverter<ManiaBaseHit> CreateBeatmapConverter() => new ManiaBeatmapConverter();
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ namespace osu.Game.Modes.Mania.UI
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this);
|
||||
|
||||
protected override IBeatmapConverter<ManiaBaseHit> CreateBeatmapConverter() => new ManiaBeatmapConverter();
|
||||
protected override BeatmapConverter<ManiaBaseHit> CreateBeatmapConverter() => new ManiaBeatmapConverter();
|
||||
|
||||
protected override IBeatmapProcessor<ManiaBaseHit> CreateBeatmapProcessor() => new ManiaBeatmapProcessor();
|
||||
|
||||
|
@ -14,11 +14,11 @@ using osu.Game.Modes.Beatmaps;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Beatmaps
|
||||
{
|
||||
internal class OsuBeatmapConverter : IBeatmapConverter<OsuHitObject>
|
||||
internal class OsuBeatmapConverter : BeatmapConverter<OsuHitObject>
|
||||
{
|
||||
public IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasPosition) };
|
||||
public override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasPosition) };
|
||||
|
||||
public Beatmap<OsuHitObject> Convert(Beatmap original)
|
||||
public override Beatmap<OsuHitObject> Convert(Beatmap original)
|
||||
{
|
||||
return new Beatmap<OsuHitObject>(original)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ namespace osu.Game.Modes.Osu
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
protected override IBeatmapConverter<OsuHitObject> CreateBeatmapConverter() => new OsuBeatmapConverter();
|
||||
protected override BeatmapConverter<OsuHitObject> CreateBeatmapConverter() => new OsuBeatmapConverter();
|
||||
|
||||
// Those values are used as array indices. Be careful when changing them!
|
||||
public enum DifficultyType
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Modes.Osu.UI
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(this);
|
||||
|
||||
protected override IBeatmapConverter<OsuHitObject> CreateBeatmapConverter() => new OsuBeatmapConverter();
|
||||
protected override BeatmapConverter<OsuHitObject> CreateBeatmapConverter() => new OsuBeatmapConverter();
|
||||
|
||||
protected override IBeatmapProcessor<OsuHitObject> CreateBeatmapProcessor() => new OsuBeatmapProcessor();
|
||||
|
||||
|
@ -15,7 +15,7 @@ using osu.Game.Modes.Beatmaps;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Beatmaps
|
||||
{
|
||||
internal class TaikoBeatmapConverter : IBeatmapConverter<TaikoHitObject>
|
||||
internal class TaikoBeatmapConverter : BeatmapConverter<TaikoHitObject>
|
||||
{
|
||||
/// <summary>
|
||||
/// osu! is generally slower than taiko, so a factor is added to increase
|
||||
@ -39,9 +39,9 @@ namespace osu.Game.Modes.Taiko.Beatmaps
|
||||
/// </summary>
|
||||
private const float taiko_base_distance = 100;
|
||||
|
||||
public IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(HitObject) };
|
||||
public override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(HitObject) };
|
||||
|
||||
public Beatmap<TaikoHitObject> Convert(Beatmap original)
|
||||
public override Beatmap<TaikoHitObject> Convert(Beatmap original)
|
||||
{
|
||||
BeatmapInfo info = original.BeatmapInfo.DeepClone<BeatmapInfo>();
|
||||
info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier;
|
||||
|
@ -20,6 +20,6 @@ namespace osu.Game.Modes.Taiko
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected override IBeatmapConverter<TaikoHitObject> CreateBeatmapConverter() => new TaikoBeatmapConverter();
|
||||
protected override BeatmapConverter<TaikoHitObject> CreateBeatmapConverter() => new TaikoBeatmapConverter();
|
||||
}
|
||||
}
|
@ -115,7 +115,7 @@ namespace osu.Game.Modes.Taiko.UI
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);
|
||||
|
||||
protected override IBeatmapConverter<TaikoHitObject> CreateBeatmapConverter() => new TaikoBeatmapConverter();
|
||||
protected override BeatmapConverter<TaikoHitObject> CreateBeatmapConverter() => new TaikoBeatmapConverter();
|
||||
|
||||
protected override IBeatmapProcessor<TaikoHitObject> CreateBeatmapProcessor() => new TaikoBeatmapProcessor();
|
||||
|
||||
|
@ -42,6 +42,6 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract IBeatmapConverter<T> CreateBeatmapConverter();
|
||||
protected abstract BeatmapConverter<T> CreateBeatmapConverter();
|
||||
}
|
||||
}
|
||||
|
@ -13,30 +13,25 @@ namespace osu.Game.Modes.Beatmaps
|
||||
/// Converts a Beatmap for another mode.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of HitObject stored in the Beatmap.</typeparam>
|
||||
public interface IBeatmapConverter<T> where T : HitObject
|
||||
public abstract class BeatmapConverter<T> where T : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The types of HitObjects that can be converted to be used for this Beatmap.
|
||||
/// </summary>
|
||||
IEnumerable<Type> ValidConversionTypes { get; }
|
||||
public abstract IEnumerable<Type> ValidConversionTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Beatmap to another mode.
|
||||
/// </summary>
|
||||
/// <param name="original">The original Beatmap.</param>
|
||||
/// <returns>The converted Beatmap.</returns>
|
||||
Beatmap<T> Convert(Beatmap original);
|
||||
}
|
||||
public abstract Beatmap<T> Convert(Beatmap original);
|
||||
|
||||
public static class BeatmapConverterExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if a Beatmap can be converted using this Beatmap Converter.
|
||||
/// </summary>
|
||||
/// <param name="converter">The Beatmap Converter.</param>
|
||||
/// <param name="beatmap">The Beatmap to check.</param>
|
||||
/// <returns>Whether the Beatmap can be converted using <paramref name="converter"/>.</returns>
|
||||
public static bool CanConvert<TObject>(this IBeatmapConverter<TObject> converter, Beatmap beatmap) where TObject : HitObject
|
||||
=> converter.ValidConversionTypes.All(t => beatmap.HitObjects.Any(h => t.IsAssignableFrom(h.GetType())));
|
||||
/// <returns>Whether the Beatmap can be converted using this Beatmap Converter.</returns>
|
||||
public bool CanConvert(Beatmap beatmap) => ValidConversionTypes.All(t => beatmap.HitObjects.Any(h => t.IsAssignableFrom(h.GetType())));
|
||||
}
|
||||
}
|
@ -120,7 +120,7 @@ namespace osu.Game.Modes.UI
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
IBeatmapConverter<TObject> converter = CreateBeatmapConverter();
|
||||
BeatmapConverter<TObject> converter = CreateBeatmapConverter();
|
||||
IBeatmapProcessor<TObject> processor = CreateBeatmapProcessor();
|
||||
|
||||
// Check if the beatmap can be converted
|
||||
@ -158,7 +158,7 @@ namespace osu.Game.Modes.UI
|
||||
/// Creates a converter to convert Beatmap to a specific mode.
|
||||
/// </summary>
|
||||
/// <returns>The Beatmap converter.</returns>
|
||||
protected abstract IBeatmapConverter<TObject> CreateBeatmapConverter();
|
||||
protected abstract BeatmapConverter<TObject> CreateBeatmapConverter();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a processor to perform post-processing operations
|
||||
|
@ -72,7 +72,7 @@
|
||||
<Compile Include="Audio\SampleInfo.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
||||
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
||||
<Compile Include="Modes\Beatmaps\IBeatmapConverter.cs" />
|
||||
<Compile Include="Modes\Beatmaps\BeatmapConverter.cs" />
|
||||
<Compile Include="Modes\Beatmaps\IBeatmapProcessor.cs" />
|
||||
<Compile Include="Beatmaps\Legacy\LegacyBeatmap.cs" />
|
||||
<Compile Include="Beatmaps\Timing\TimeSignatures.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user