mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Add the concept of a "WorkingBeatmap" and make player load beatmaps and audio from SongSelect.
This commit is contained in:
@ -130,43 +130,46 @@ namespace osu.Game.Database
|
||||
{
|
||||
return ArchiveReader.GetReader(storage, beatmapSet.Path);
|
||||
}
|
||||
|
||||
|
||||
public BeatmapSetInfo GetBeatmapSet(int id)
|
||||
{
|
||||
return Query<BeatmapSetInfo>().Where(s => s.BeatmapSetID == id).FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
public WorkingBeatmap GetBeatmapData(BeatmapInfo beatmapInfo)
|
||||
{
|
||||
var beatmapSet = Query<BeatmapSetInfo>().Where(s => s.BeatmapSetID == beatmapInfo.BeatmapSetID).FirstOrDefault();
|
||||
if (beatmapSet == null)
|
||||
throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetID} is not in the local database.");
|
||||
|
||||
var reader = GetReader(beatmapSet);
|
||||
|
||||
using (var stream = new StreamReader(reader.ReadFile(beatmapInfo.Path)))
|
||||
return new WorkingBeatmap(BeatmapDecoder.GetDecoder(stream)?.Decode(stream), reader);
|
||||
}
|
||||
|
||||
public Beatmap GetBeatmap(BeatmapInfo beatmapInfo)
|
||||
{
|
||||
var beatmapSet = Query<BeatmapSetInfo>()
|
||||
.Where(s => s.BeatmapSetID == beatmapInfo.BeatmapSetID).FirstOrDefault();
|
||||
if (beatmapSet == null)
|
||||
throw new InvalidOperationException(
|
||||
$@"Beatmap set {beatmapInfo.BeatmapSetID} is not in the local database.");
|
||||
using (var reader = GetReader(beatmapSet))
|
||||
using (var stream = new StreamReader(reader.ReadFile(beatmapInfo.Path)))
|
||||
{
|
||||
var decoder = BeatmapDecoder.GetDecoder(stream);
|
||||
return decoder.Decode(stream);
|
||||
}
|
||||
using (WorkingBeatmap data = GetBeatmapData(beatmapInfo))
|
||||
return data.Beatmap;
|
||||
}
|
||||
|
||||
|
||||
public TableQuery<T> Query<T>() where T : class
|
||||
{
|
||||
return connection.Table<T>();
|
||||
}
|
||||
|
||||
|
||||
public T GetWithChildren<T>(object id) where T : class
|
||||
{
|
||||
return connection.GetWithChildren<T>(id);
|
||||
}
|
||||
|
||||
|
||||
public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null,
|
||||
bool recursive = true) where T : class
|
||||
{
|
||||
return connection.GetAllWithChildren<T>(filter, recursive);
|
||||
}
|
||||
|
||||
|
||||
public T GetChildren<T>(T item, bool recursive = true)
|
||||
{
|
||||
if (item == null) return default(T);
|
||||
|
Reference in New Issue
Block a user