Пример #1
0
        static public BemaniSSQ Read(Stream source, int measureUnit)
        {
            BinaryReaderEx reader      = new BinaryReaderEx(source);
            BemaniSSQ      result      = new BemaniSSQ();
            Chunk          tempoChunk  = new Chunk();
            List <Chunk>   chartChunks = new List <Chunk>();

            // parse all chunks in the file
            while (true)
            {
                int length = reader.ReadInt32();

                if (length <= 0)
                {
                    break;
                }

                Chunk chunk = Chunk.Read(source, length);

                switch (chunk.Type)
                {
                case 0x0001:     // tempo info
                    tempoChunk = chunk;
                    break;

                case 0x0003:     // chart
                    chartChunks.Add(chunk);
                    break;

                default:
                    result.extraChunks.Add(chunk);
                    break;
                }
            }

            // assemble tempo information
            result.TempoEntries.AddRange(DecodeTempoChunk(tempoChunk, measureUnit));

            // convert charts
            foreach (Chunk chartChunk in chartChunks)
            {
                Chart chart = new Chart();
                chart.Entries.AddRange(DecodeStepChunk(chartChunk, measureUnit));
                chart.Tags["Panels"]     = (chartChunk.Parameter & 0xF).ToString();
                chart.Tags["Difficulty"] = ((chartChunk.Parameter & 0xFF00) >> 8).ToString();
                result.charts.Add(chart);
            }

            return(result);
        }
Пример #2
0
        public static BemaniSSQ Read(Stream source, int measureUnit)
        {
            BinaryReaderEx reader = new BinaryReaderEx(source);
            BemaniSSQ result = new BemaniSSQ();
            Chunk tempoChunk = new Chunk();
            List<Chunk> chartChunks = new List<Chunk>();

            // parse all chunks in the file
            while (true)
            {
                int length = reader.ReadInt32();

                if (length <= 0)
                    break;

                Chunk chunk = Chunk.Read(source, length);

                switch (chunk.Type)
                {
                    case 0x0001: // tempo info
                        tempoChunk = chunk;
                        break;
                    case 0x0003: // chart
                        chartChunks.Add(chunk);
                        break;
                    default:
                        result.extraChunks.Add(chunk);
                        break;
                }
            }

            // assemble tempo information
            result.TempoEntries.AddRange(DecodeTempoChunk(tempoChunk, measureUnit));

            // convert charts
            foreach (Chunk chartChunk in chartChunks)
            {
                Chart chart = new Chart();
                chart.Entries.AddRange(DecodeStepChunk(chartChunk, measureUnit));
                chart.Tags["Panels"] = (chartChunk.Parameter & 0xF).ToString();
                chart.Tags["Difficulty"] = ((chartChunk.Parameter & 0xFF00) >> 8).ToString();
                result.charts.Add(chart);
            }

            return result;
        }