Example #1
0
        /// <summary>
        /// Reads a playlist from a stream
        /// </summary>
        /// <param name="stream">Stream</param>
        /// <param name="dispose">Whether to dispose of the stream after reading is finished</param>
        public Playlist(Stream stream, bool dispose = false)
        {
            ReadMagicNumber(stream);

            using var gzStream = new GZipStream(stream, CompressionMode.Decompress);
            using var reader   = new BinaryBlisterReader(gzStream);

            Title       = reader.ReadShortString();
            Author      = reader.ReadShortString();
            Description = reader.ReadOptionalLongString();
            Cover       = reader.ReadOptionalBytes();

            var mapCount = (int)reader.ReadUInt32();
            var maps     = new List <Beatmap>(mapCount);

            for (var i = 0; i < mapCount; i++)
            {
                maps.Add(Beatmap.Read(reader));
            }
            Maps = maps;

            if (dispose)
            {
                stream.Dispose();
            }
        }
Example #2
0
        internal static Beatmap Read(BinaryBlisterReader reader)
        {
            var type = reader.ReadByte();

            return(type switch
            {
                KeyBeatmap.Type => new KeyBeatmap(reader),
                HashBeatmap.Type => new HashBeatmap(reader),
                ZipBeatmap.Type => new ZipBeatmap(reader),
                LevelIDBeatmap.Type => new LevelIDBeatmap(reader),
                _ => throw new InvalidBeatmapTypeException(),
            });
Example #3
0
 internal Beatmap(BinaryBlisterReader reader)
 {
     DateAdded = reader.ReadDateTimeOffset();
 }