mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 10:42:55 +08:00
Move DatabaseWorkingBeatmap out of partial class
This commit is contained in:
parent
2b1d31e69c
commit
2e1f596b2a
@ -18,7 +18,7 @@ using SQLiteNetExtensions.Extensions;
|
|||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
{
|
{
|
||||||
public partial class BeatmapDatabase
|
public class BeatmapDatabase
|
||||||
{
|
{
|
||||||
private SQLiteConnection connection { get; }
|
private SQLiteConnection connection { get; }
|
||||||
private Storage storage;
|
private Storage storage;
|
||||||
|
@ -10,75 +10,72 @@ using osu.Game.Beatmaps.IO;
|
|||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
{
|
{
|
||||||
public partial class BeatmapDatabase
|
internal class DatabaseWorkingBeatmap : WorkingBeatmap
|
||||||
{
|
{
|
||||||
private class DatabaseWorkingBeatmap : WorkingBeatmap
|
private readonly BeatmapDatabase database;
|
||||||
|
|
||||||
|
public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false)
|
||||||
|
: base(beatmapInfo, beatmapSetInfo, withStoryboard)
|
||||||
{
|
{
|
||||||
private readonly BeatmapDatabase database;
|
this.database = database;
|
||||||
|
}
|
||||||
|
|
||||||
public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false)
|
private ArchiveReader getReader() => database?.GetReader(BeatmapSetInfo);
|
||||||
: base(beatmapInfo, beatmapSetInfo, withStoryboard)
|
|
||||||
|
protected override Beatmap GetBeatmap()
|
||||||
|
{
|
||||||
|
Beatmap beatmap;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
this.database = database;
|
using (var reader = getReader())
|
||||||
}
|
|
||||||
|
|
||||||
private ArchiveReader getReader() => database?.GetReader(BeatmapSetInfo);
|
|
||||||
|
|
||||||
protected override Beatmap GetBeatmap()
|
|
||||||
{
|
|
||||||
Beatmap beatmap;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
using (var reader = getReader())
|
BeatmapDecoder decoder;
|
||||||
|
using (var stream = new StreamReader(reader.GetStream(BeatmapInfo.Path)))
|
||||||
{
|
{
|
||||||
BeatmapDecoder decoder;
|
decoder = BeatmapDecoder.GetDecoder(stream);
|
||||||
using (var stream = new StreamReader(reader.GetStream(BeatmapInfo.Path)))
|
beatmap = decoder?.Decode(stream);
|
||||||
{
|
|
||||||
decoder = BeatmapDecoder.GetDecoder(stream);
|
|
||||||
beatmap = decoder?.Decode(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WithStoryboard && beatmap != null && BeatmapSetInfo.StoryboardFile != null)
|
|
||||||
using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile)))
|
|
||||||
decoder.Decode(stream, beatmap);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch { return null; }
|
|
||||||
return beatmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Texture GetBackground()
|
|
||||||
{
|
|
||||||
Texture background;
|
|
||||||
if (BeatmapInfo?.Metadata?.BackgroundFile == null)
|
|
||||||
return null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (var reader = getReader())
|
|
||||||
{
|
|
||||||
background = new TextureStore(
|
|
||||||
new RawTextureLoaderStore(reader),
|
|
||||||
false).Get(BeatmapInfo.Metadata.BackgroundFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { return null; }
|
|
||||||
return background;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArchiveReader trackReader;
|
if (WithStoryboard && beatmap != null && BeatmapSetInfo.StoryboardFile != null)
|
||||||
protected override Track GetTrack()
|
using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile)))
|
||||||
{
|
decoder.Decode(stream, beatmap);
|
||||||
Track track;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//store a reference to the reader as we may continue accessing the stream in the background.
|
|
||||||
trackReader = getReader();
|
|
||||||
var trackData = trackReader?.GetStream(BeatmapInfo.Metadata.AudioFile);
|
|
||||||
track = trackData == null ? null : new TrackBass(trackData);
|
|
||||||
}
|
}
|
||||||
catch { return null; }
|
|
||||||
return track;
|
|
||||||
}
|
}
|
||||||
|
catch { return null; }
|
||||||
|
return beatmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Texture GetBackground()
|
||||||
|
{
|
||||||
|
Texture background;
|
||||||
|
if (BeatmapInfo?.Metadata?.BackgroundFile == null)
|
||||||
|
return null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var reader = getReader())
|
||||||
|
{
|
||||||
|
background = new TextureStore(
|
||||||
|
new RawTextureLoaderStore(reader),
|
||||||
|
false).Get(BeatmapInfo.Metadata.BackgroundFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { return null; }
|
||||||
|
return background;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArchiveReader trackReader;
|
||||||
|
protected override Track GetTrack()
|
||||||
|
{
|
||||||
|
Track track;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//store a reference to the reader as we may continue accessing the stream in the background.
|
||||||
|
trackReader = getReader();
|
||||||
|
var trackData = trackReader?.GetStream(BeatmapInfo.Metadata.AudioFile);
|
||||||
|
track = trackData == null ? null : new TrackBass(trackData);
|
||||||
|
}
|
||||||
|
catch { return null; }
|
||||||
|
return track;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user