Пример #1
0
        public static DisplayBpm Deserialize(List <string> parameters)
        {
            var displayBpm = new DisplayBpm();

            if (parameters[0] == "*")
            {
                displayBpm.bpmType = DisplayBpmType.Random;
            }
            else
            {
                displayBpm.bpmType = DisplayBpmType.Specified;
                float.TryParse(parameters[1], out displayBpm.minBpm);
                if (parameters.Count > 2)
                {
                    float.TryParse(parameters[2], out displayBpm.maxBpm);
                }
                else
                {
                    displayBpm.maxBpm = displayBpm.minBpm;
                }
            }

            return(displayBpm);
        }
Пример #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);
        }