Slightly clean up archive readers + decoders. Read beatmap version into BeatmapInfo.

This commit is contained in:
smoogipooo
2017-04-03 20:26:46 +09:00
parent 91eec9e8fc
commit 19b5555ef2
11 changed files with 61 additions and 73 deletions

View File

@ -5,7 +5,6 @@ using System.IO;
using System.Linq;
using Ionic.Zip;
using osu.Game.Beatmaps.Formats;
using osu.Game.Database;
namespace osu.Game.Beatmaps.IO
{
@ -23,23 +22,18 @@ namespace osu.Game.Beatmaps.IO
private readonly Stream archiveStream;
private readonly ZipFile archive;
private readonly Beatmap firstMap;
public OszArchiveReader(Stream archiveStream)
{
this.archiveStream = archiveStream;
archive = ZipFile.Read(archiveStream);
BeatmapFilenames = archive.Entries.Where(e => e.FileName.EndsWith(@".osu"))
.Select(e => e.FileName).ToArray();
BeatmapFilenames = archive.Entries.Where(e => e.FileName.EndsWith(@".osu")).Select(e => e.FileName).ToArray();
if (BeatmapFilenames.Length == 0)
throw new FileNotFoundException(@"This directory contains no beatmaps");
StoryboardFilename = archive.Entries.Where(e => e.FileName.EndsWith(@".osb"))
.Select(e => e.FileName).FirstOrDefault();
using (var stream = new StreamReader(GetStream(BeatmapFilenames[0])))
{
var decoder = BeatmapDecoder.GetDecoder(stream);
firstMap = decoder.Decode(stream);
}
StoryboardFilename = archive.Entries.Where(e => e.FileName.EndsWith(@".osb")).Select(e => e.FileName).FirstOrDefault();
}
public override Stream GetStream(string name)
@ -50,11 +44,6 @@ namespace osu.Game.Beatmaps.IO
return entry.OpenReader();
}
public override BeatmapMetadata ReadMetadata()
{
return firstMap.BeatmapInfo.Metadata;
}
public override void Dispose()
{
archive.Dispose();