Load beatmap data from an optional osb file.

This commit is contained in:
Damnae
2017-02-09 15:09:48 +01:00
parent c5cf6a6909
commit a504c73f33
10 changed files with 68 additions and 24 deletions

View File

@ -26,8 +26,9 @@ namespace osu.Game.Beatmaps.IO
private Stream archiveStream;
private ZipFile archive;
private string[] beatmaps;
private string storyboard;
private Beatmap firstMap;
public OszArchiveReader(Stream archiveStream)
{
this.archiveStream = archiveStream;
@ -36,6 +37,8 @@ namespace osu.Game.Beatmaps.IO
.Select(e => e.FileName).ToArray();
if (beatmaps.Length == 0)
throw new FileNotFoundException(@"This directory contains no beatmaps");
storyboard = archive.Entries.Where(e => e.FileName.EndsWith(@".osb"))
.Select(e => e.FileName).FirstOrDefault();
using (var stream = new StreamReader(GetStream(beatmaps[0])))
{
var decoder = BeatmapDecoder.GetDecoder(stream);
@ -48,6 +51,11 @@ namespace osu.Game.Beatmaps.IO
return beatmaps;
}
public override string ReadStoryboard()
{
return storyboard;
}
public override Stream GetStream(string name)
{
ZipEntry entry = archive.Entries.SingleOrDefault(e => e.FileName == name);