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