Beispiel #1
0
        public static MsdFile Deserialize(StreamReader reader)
        {
            var file = new MsdFile();

            var text = reader.ReadToEnd();
            var tags = ReadTags(text);

            file.values = ReadMsdValues(tags);

            return(file);
        }
Beispiel #2
0
        public static SmFile Deserialize(StreamReader reader)
        {
            var file = new SmFile();

            var msdFile = MsdFile.Deserialize(reader);

            foreach (var value in msdFile.values)
            {
                var parameters = value.parameters;
                var tag        = parameters[0].ToUpper();
                switch (tag)
                {
                case "TITLE":
                    file.title = parameters[1];
                    break;

                case "SUBTITLE":
                    file.subtitle = parameters[1];
                    break;

                case "ARTIST":
                    file.artist = parameters[1];
                    break;

                case "TITLETRANSLIT":
                    file.titleTranslit = parameters[1];
                    break;

                case "SUBTITLETRANSLIT":
                    file.subtitleTranslit = parameters[1];
                    break;

                case "ARTISTTRANSLIT":
                    file.artistTranslit = parameters[1];
                    break;

                case "GENRE":
                    file.genre = parameters[1];
                    break;

                case "CREDIT":
                    file.credit = parameters[1];
                    break;

                case "BANNER":
                    file.background = parameters[1];
                    break;

                case "BACKGROUND":
                    file.background = parameters[1];
                    break;

                case "LYRICSPATH":
                    file.lyricsPath = parameters[1];
                    break;

                case "CDTITLE":
                    file.cdTitle = parameters[1];
                    break;

                case "MUSIC":
                    file.music = parameters[1];
                    break;

                case "OFFSET":
                    float.TryParse(parameters[1], out file.offset);
                    break;

                case "BPMS":
                    file.bpms = Bpms.Deserialize(parameters);
                    break;

                case "STOPS":
                    file.stops = Stops.Deserialize(parameters);
                    break;

                case "SAMPLESTART":
                    float.TryParse(parameters[1], out file.sampleStart);
                    break;

                case "SAMPLELENGTH":
                    float.TryParse(parameters[1], out file.sampleLength);
                    break;

                case "DISPLAYBPM":
                    file.displayBpm = DisplayBpm.Deserialize(parameters);
                    break;

                case "SELECTABLE":
                    file.selectable = IsSelectable(parameters);
                    break;

                case "BGCHANGES":
                    file.bgChanges = BackgroundChanges.Deserialize(parameters);
                    break;

                case "FGCHANGES":
                    file.fgChanges = BackgroundChanges.Deserialize(parameters);
                    break;

                case "NOTES":
                    file.charts.Add(Chart.Deserialize(parameters));
                    break;

                default:
                    Console.Out.WriteLine("Invalid tag: " + tag);
                    break;
                }
            }

            return(file);
        }