mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 15:44:04 +09:00
Use IBeatmap wherever possible
This commit is contained in:
@ -17,7 +17,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// This beatmap's info.
|
||||
/// </summary>
|
||||
BeatmapInfo BeatmapInfo { get; }
|
||||
BeatmapInfo BeatmapInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This beatmap's metadata.
|
||||
|
@ -27,27 +27,27 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The Beatmap to check.</param>
|
||||
/// <returns>Whether the Beatmap can be converted using this Beatmap Converter.</returns>
|
||||
public bool CanConvert(Beatmap beatmap) => ValidConversionTypes.All(t => beatmap.HitObjects.Any(t.IsInstanceOfType));
|
||||
public bool CanConvert(IBeatmap beatmap) => ValidConversionTypes.All(t => beatmap.HitObjects.Any(t.IsInstanceOfType));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Beatmap using this Beatmap Converter.
|
||||
/// </summary>
|
||||
/// <param name="original">The un-converted Beatmap.</param>
|
||||
/// <returns>The converted Beatmap.</returns>
|
||||
public Beatmap<T> Convert(Beatmap original)
|
||||
public Beatmap<T> Convert(IBeatmap original)
|
||||
{
|
||||
// We always operate on a clone of the original beatmap, to not modify it game-wide
|
||||
return ConvertBeatmap(original.Clone());
|
||||
}
|
||||
|
||||
void IBeatmapConverter.Convert(Beatmap original) => Convert(original);
|
||||
void IBeatmapConverter.Convert(IBeatmap original) => Convert(original);
|
||||
|
||||
/// <summary>
|
||||
/// Performs the conversion of a Beatmap using this Beatmap Converter.
|
||||
/// </summary>
|
||||
/// <param name="original">The un-converted Beatmap.</param>
|
||||
/// <returns>The converted Beatmap.</returns>
|
||||
protected virtual Beatmap<T> ConvertBeatmap(Beatmap original)
|
||||
protected virtual Beatmap<T> ConvertBeatmap(IBeatmap original)
|
||||
{
|
||||
var beatmap = CreateBeatmap();
|
||||
|
||||
@ -67,7 +67,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <param name="original">The hit object to convert.</param>
|
||||
/// <param name="beatmap">The un-converted Beatmap.</param>
|
||||
/// <returns>The converted hit object.</returns>
|
||||
private IEnumerable<T> convert(HitObject original, Beatmap beatmap)
|
||||
private IEnumerable<T> convert(HitObject original, IBeatmap beatmap)
|
||||
{
|
||||
// Check if the hitobject is already the converted type
|
||||
T tObject = original as T;
|
||||
@ -107,6 +107,6 @@ namespace osu.Game.Beatmaps
|
||||
/// <param name="original">The hit object to convert.</param>
|
||||
/// <param name="beatmap">The un-converted Beatmap.</param>
|
||||
/// <returns>The converted hit object.</returns>
|
||||
protected abstract IEnumerable<T> ConvertHitObject(HitObject original, Beatmap beatmap);
|
||||
protected abstract IEnumerable<T> ConvertHitObject(HitObject original, IBeatmap beatmap);
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ namespace osu.Game.Beatmaps
|
||||
ms.Position = 0;
|
||||
|
||||
var decoder = Decoder.GetDecoder<Beatmap>(sr);
|
||||
Beatmap beatmap = decoder.Decode(sr);
|
||||
IBeatmap beatmap = decoder.Decode(sr);
|
||||
|
||||
beatmap.BeatmapInfo.Path = name;
|
||||
beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Beatmaps
|
||||
this.audioManager = audioManager;
|
||||
}
|
||||
|
||||
protected override Beatmap GetBeatmap()
|
||||
protected override IBeatmap GetBeatmap()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Beatmaps
|
||||
protected readonly Beatmap<T> Beatmap;
|
||||
protected readonly Mod[] Mods;
|
||||
|
||||
protected DifficultyCalculator(Beatmap beatmap, Mod[] mods = null)
|
||||
protected DifficultyCalculator(IBeatmap beatmap, Mod[] mods = null)
|
||||
{
|
||||
Mods = mods ?? new Mod[0];
|
||||
|
||||
@ -59,6 +59,6 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract BeatmapConverter<T> CreateBeatmapConverter(Beatmap beatmap);
|
||||
protected abstract BeatmapConverter<T> CreateBeatmapConverter(IBeatmap beatmap);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Beatmaps
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
protected override Beatmap GetBeatmap() => new Beatmap();
|
||||
protected override IBeatmap GetBeatmap() => new Beatmap();
|
||||
|
||||
protected override Texture GetBackground() => game.Textures.Get(@"Backgrounds/bg4");
|
||||
|
||||
@ -58,7 +58,7 @@ namespace osu.Game.Beatmaps
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null) => null;
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(IBeatmap beatmap, Mod[] mods = null) => null;
|
||||
|
||||
public override string Description => "dummy";
|
||||
|
||||
|
@ -20,6 +20,6 @@ namespace osu.Game.Beatmaps
|
||||
/// Converts a Beatmap using this Beatmap Converter.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The un-converted Beatmap.</param>
|
||||
void Convert(Beatmap beatmap);
|
||||
void Convert(IBeatmap beatmap);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
Mods.ValueChanged += mods => applyRateAdjustments();
|
||||
|
||||
beatmap = new AsyncLazy<Beatmap>(populateBeatmap);
|
||||
beatmap = new AsyncLazy<IBeatmap>(populateBeatmap);
|
||||
background = new AsyncLazy<Texture>(populateBackground, b => b == null || !b.IsDisposed);
|
||||
track = new AsyncLazy<Track>(populateTrack);
|
||||
waveform = new AsyncLazy<Waveform>(populateWaveform);
|
||||
@ -55,7 +55,7 @@ namespace osu.Game.Beatmaps
|
||||
Process.Start(path);
|
||||
}
|
||||
|
||||
protected abstract Beatmap GetBeatmap();
|
||||
protected abstract IBeatmap GetBeatmap();
|
||||
protected abstract Texture GetBackground();
|
||||
protected abstract Track GetTrack();
|
||||
protected virtual Skin GetSkin() => new DefaultSkin();
|
||||
@ -63,12 +63,12 @@ namespace osu.Game.Beatmaps
|
||||
protected virtual Storyboard GetStoryboard() => new Storyboard { BeatmapInfo = BeatmapInfo };
|
||||
|
||||
public bool BeatmapLoaded => beatmap.IsResultAvailable;
|
||||
public Beatmap Beatmap => beatmap.Value.Result;
|
||||
public async Task<Beatmap> GetBeatmapAsync() => await beatmap.Value;
|
||||
public IBeatmap Beatmap => beatmap.Value.Result;
|
||||
public async Task<IBeatmap> GetBeatmapAsync() => await beatmap.Value;
|
||||
|
||||
private readonly AsyncLazy<Beatmap> beatmap;
|
||||
private readonly AsyncLazy<IBeatmap> beatmap;
|
||||
|
||||
private Beatmap populateBeatmap()
|
||||
private IBeatmap populateBeatmap()
|
||||
{
|
||||
var b = GetBeatmap() ?? new Beatmap();
|
||||
|
||||
|
Reference in New Issue
Block a user