Ejemplo n.º 1
0
        public BmsHeader Parse(Stream s)
        {
            var bmsData = new BmsHeader();

            using (StreamReader sr = new StreamReader(s, Encoding.GetEncoding(932)))
            {
                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(bmsData);
        }
Ejemplo n.º 2
0
        private Dictionary <string, string> GetInfoFromBMS(string bmsPath)
        {
            try
            {
                using (FileStream stream = File.OpenRead(bmsPath))
                {
                    BmsParser parser = new BmsParser();
                    BmsHeader bms    = parser.Parse(stream);

                    Dictionary <string, string> dic = new Dictionary <string, string>
                    {
                        { "{genre}", bms.Genre },
                        { "{title}", bms.Title },
                        { "{artist}", bms.Artist },
                        { "{tags}", bms.Total.HasValue ? "TOTAL " + bms.Total : "" }
                    };

                    return(dic);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                return(new Dictionary <string, string>());
            }
        }
Ejemplo n.º 3
0
        void ParseDef(BmsHeader bmsData, string def)
        {
            Match m;

            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 = DefPlayLevel.Match(def);
            if (m.Success)
            {
                var value = int.Parse(m.Groups[1].Value);
                bmsData.PlayLevel = value;
                return;
            }

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