Пример #1
0
        public BMS Parse(Stream s)
        {
            var bmsData = new BMSData();
            var sr      = new StreamReader(s);

            while (sr.Peek() > -1)
            {
                var line = sr.ReadLine();
                if (line.Length == 0)
                {
                    continue;
                }
                switch (line[0])
                {
                case '*':     // コメント
                    continue;

                case '#':
                    this.parseDef(bmsData, line.Substring(1));
                    break;
                }
            }
            return(new BMS(bmsData));
        }
Пример #2
0
        void parseDef(BMSData bmsData, string def)
        {
            Match m;

            m = DefPlayer.Match(def);
            if (m.Success)
            {
                var value = int.Parse(m.Groups[1].Value);
                bmsData.Player = (Player)value;
                return;
            }

            m = DefGenre.Match(def);
            if (m.Success)
            {
                bmsData.Genre = m.Groups[1].Value;
                return;
            }

            m = DefTitle.Match(def);
            if (m.Success)
            {
                bmsData.Title = m.Groups[1].Value;
                return;
            }

            m = DefArtist.Match(def);
            if (m.Success)
            {
                bmsData.Artist = m.Groups[1].Value;
                return;
            }

            m = DefBPM.Match(def);
            if (m.Success)
            {
                var value = int.Parse(m.Groups[1].Value);
                bmsData.BPM = value;
                return;
            }

            m = DefMidiFile.Match(def);
            if (m.Success)
            {
                bmsData.MidiFile = m.Groups[1].Value;
                return;
            }

            m = DefPlayLevel.Match(def);
            if (m.Success)
            {
                var value = int.Parse(m.Groups[1].Value);
                bmsData.PlayLevel = value;
                return;
            }

            m = DefRank.Match(def);
            if (m.Success)
            {
                var value = int.Parse(m.Groups[1].Value);
                bmsData.Rank = (Rank)value;
                return;
            }

            m = DefVolWav.Match(def);
            if (m.Success)
            {
                var value = int.Parse(m.Groups[1].Value);
                bmsData.VolWav = value;
                return;
            }

            m = DefTotal.Match(def);
            if (m.Success)
            {
                var value = double.Parse(m.Groups[1].Value);
                bmsData.Total = value;
                return;
            }

            m = DefWav.Match(def);
            if (m.Success)
            {
                var key   = (int)Base36.Decode(m.Groups[1].Value);
                var value = m.Groups[2].Value;
                bmsData.Wav.Add(key, value);
                return;
            }

            m = DefBmp.Match(def);
            if (m.Success)
            {
                var key   = (int)Base36.Decode(m.Groups[1].Value);
                var value = m.Groups[2].Value;
                bmsData.Bmp.Add(key, value);
                return;
            }

            m = DefObj.Match(def);
            if (m.Success)
            {
                var measure = int.Parse(m.Groups[1].Value);
                var channel = int.Parse(m.Groups[2].Value);
                var rawData = m.Groups[3].Value;
                var obj     = this.parseObject(measure, channel, rawData);
                if (obj == null)
                {
                    return;
                }
                bmsData.Objects.Add(obj);
                return;
            }
        }
Пример #3
0
 internal BMS(BMSData data)
 {
     this.data     = data;
     this.timeline = new Timeline(this);
 }