Exemple #1
0
        //将解析好的内容再序列化成osb文件格式的文本内容
        private static void SerializeDecodeStoryboardContent(string beatmap_folder, bool parse_osb, string output_path)
        {
            try
            {
                var info       = BeatmapFolderInfoEx.Parse(beatmap_folder, null);
                var input_file = parse_osb ? info.osb_file_path : info.osu_file_path;
                output_path = string.IsNullOrWhiteSpace(output_path) ? input_file + ".parse_output" : output_path;

                Log.User($"Start serialize {input_file} ....");
                using (var writer = new StreamWriter(File.OpenWrite(output_path)))
                {
                    writer.WriteLine($"[{Section.Events.ToString()}]");

                    OsuFileReader reader = new OsuFileReader(input_file);

                    VariableCollection collection = new VariableCollection(new VariableReader(reader).EnumValues());

                    SectionReader section = new SectionReader(Section.Events, reader);

                    EventReader event_section = new EventReader(reader, collection);

                    foreach (var line in section.EnumValues())
                    {
                        var decode_line = event_section.LineProcessVariable(line);
                        writer.WriteLine(decode_line);
                    }
                }

                Log.User("Serialize successfully! it output to " + output_path);
                Exit("Serialize successfully! it output to " + output_path);
            }
            catch (Exception e)
            {
                Log.Error("Serialize failed!" + e.Message);
                Exit("Serialize failed!" + e.Message);
            }
        }