mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Give ArchiveReader a filename
This commit is contained in:
@ -174,7 +174,7 @@ namespace osu.Game.Beatmaps
|
|||||||
private ArchiveReader getReaderFrom(string path)
|
private ArchiveReader getReaderFrom(string path)
|
||||||
{
|
{
|
||||||
if (ZipFile.IsZipFile(path))
|
if (ZipFile.IsZipFile(path))
|
||||||
return new OszArchiveReader(Files.Storage.GetStream(path));
|
return new OszArchiveReader(Files.Storage.GetStream(path), Path.GetFileName(path));
|
||||||
return new LegacyFilesystemReader(path);
|
return new LegacyFilesystemReader(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
// This gets scheduled back to the update thread, but we want the import to run in the background.
|
// This gets scheduled back to the update thread, but we want the import to run in the background.
|
||||||
using (var stream = new MemoryStream(data))
|
using (var stream = new MemoryStream(data))
|
||||||
using (var archive = new OszArchiveReader(stream))
|
using (var archive = new OszArchiveReader(stream, beatmapSetInfo.ToString()))
|
||||||
Import(archive);
|
Import(archive);
|
||||||
|
|
||||||
downloadNotification.State = ProgressNotificationState.Completed;
|
downloadNotification.State = ProgressNotificationState.Completed;
|
||||||
|
@ -17,6 +17,16 @@ namespace osu.Game.Beatmaps.IO
|
|||||||
|
|
||||||
public abstract void Dispose();
|
public abstract void Dispose();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of this archive (usually the containing filename).
|
||||||
|
/// </summary>
|
||||||
|
public readonly string Name;
|
||||||
|
|
||||||
|
protected ArchiveReader(string name)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract IEnumerable<string> Filenames { get; }
|
public abstract IEnumerable<string> Filenames { get; }
|
||||||
|
|
||||||
public virtual byte[] Get(string name)
|
public virtual byte[] Get(string name)
|
||||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Beatmaps.IO
|
|||||||
{
|
{
|
||||||
private readonly string path;
|
private readonly string path;
|
||||||
|
|
||||||
public LegacyFilesystemReader(string path)
|
public LegacyFilesystemReader(string path) : base(Path.GetFileName(path))
|
||||||
{
|
{
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ namespace osu.Game.Beatmaps.IO
|
|||||||
private readonly Stream archiveStream;
|
private readonly Stream archiveStream;
|
||||||
private readonly ZipFile archive;
|
private readonly ZipFile archive;
|
||||||
|
|
||||||
public OszArchiveReader(Stream archiveStream)
|
public OszArchiveReader(Stream archiveStream, string name = null)
|
||||||
|
: base(name)
|
||||||
{
|
{
|
||||||
this.archiveStream = archiveStream;
|
this.archiveStream = archiveStream;
|
||||||
archive = ZipFile.Read(archiveStream);
|
archive = ZipFile.Read(archiveStream);
|
||||||
|
@ -62,7 +62,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
if (setInfo == null)
|
if (setInfo == null)
|
||||||
{
|
{
|
||||||
// we need to import the default menu background beatmap
|
// we need to import the default menu background beatmap
|
||||||
setInfo = beatmaps.Import(new OszArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz")));
|
setInfo = beatmaps.Import(new OszArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz"), "circles.osz"));
|
||||||
setInfo.Protected = true;
|
setInfo.Protected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user