Exemple #1
0
        private static List <StoryboardObject> GetStoryboardObjectsFromOsb(string path, int level)
        {
            OsuFileReader reader = new OsuFileReader(path);

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

            EventReader er = new EventReader(reader, collection);

            StoryboardReader StoryboardReader = new StoryboardReader(er);

            List <StoryboardObject> list;

            list = StoryboardReader.EnumValues().ToList();
            list.RemoveAll(c => c == null);

            foreach (var obj in list)
            {
                obj.CalculateAndApplyBaseFrameTime();
            }

            if (PlayerSetting.StoryboardObjectOptimzeLevel > 0)
            {
                if (!optimzer_add)
                {
                    InitOptimzerManager();
                }

                StoryboardOptimzerManager.Optimze(level, list);
            }

            return(list);
        }
Exemple #2
0
        private IEnumerable <StoryboardObject> GetObjects(byte[] data)
        {
            var stream = new MemoryStream(data);

            var reader = new OsuFileReader(stream);

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

            var er = new EventReader(reader, collection);

            var StoryboardReader = new StoryboardReader(er);

            var list = StoryboardReader.EnumValues().ToList();

            list.RemoveAll(c => c == null);

            foreach (var obj in list)
            {
                obj.CalculateAndApplyBaseFrameTime();
            }

            stream.Dispose();

            return(list);
        }
        public static List <StoryboardObject> GetStoryboardObjectsFromFile(string path)
        {
            OsuFileReader reader = new OsuFileReader(path);

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

            EventReader er = new EventReader(reader, collection);

            StoryboardReader StoryboardReader = new StoryboardReader(er);

            var list = StoryboardReader.EnumValues().OfType <StoryboardObject>().ToList();

            //计算每个物件的FrameStartTime
            foreach (var obj in list)
            {
                obj.CalculateAndApplyBaseFrameTime();
            }

            return(list);
        }
Exemple #4
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);
            }
        }
Exemple #5
0
 public SectionReader(Section section, OsuFileReader reader)
 {
     this.section = section;
     this.reader  = reader;
 }
 public VariableReader(OsuFileReader reader)
 {
     this.reader = new SectionReader(Section.Variables, reader);
 }
 public EventReader(OsuFileReader reader, VariableCollection variables)
 {
     Variables   = variables;
     this.reader = new SectionReader(Section.Events, reader);
 }