private void handleHitObject(string line)
        {
            // If the ruleset wasn't specified, assume the osu!standard ruleset.
            parser ??= new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(getOffsetTime(), FormatVersion);

            var obj = parser.Parse(line);

            if (obj != null)
            {
                beatmap.HitObjects.Add(obj);
            }
        }
Ejemplo n.º 2
0
        private void handleHitObject(string line)
        {
            // If the ruleset wasn't specified, assume the osu!standard ruleset.
            parser ??= new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(getOffsetTime(), FormatVersion);

            var obj = parser.Parse(line);

            if (obj != null)
            {
                obj.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);

                beatmap.HitObjects.Add(obj);
            }
        }
Ejemplo n.º 3
0
        private void handleHitObjects(string line)
        {
            // If the ruleset wasn't specified, assume the osu!standard ruleset.
            if (parser == null)
            {
                parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
            }

            var obj = parser.Parse(line);

            if (obj != null)
            {
                beatmap.HitObjects.Add(obj);
            }
        }
Ejemplo n.º 4
0
        protected override void ParseFile(StreamReader stream, Beatmap beatmap)
        {
            beatmap.BeatmapInfo.BeatmapVersion = beatmapVersion;

            Section              section          = Section.None;
            bool                 hasCustomColours = false;
            StoryboardSprite     storyboardSprite = null;
            CommandTimelineGroup timelineGroup    = null;

            string line;

            while ((line = stream.ReadLine()) != null)
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                if (line.StartsWith("//"))
                {
                    continue;
                }

                if (line.StartsWith(@"osu file format v"))
                {
                    beatmap.BeatmapInfo.BeatmapVersion = int.Parse(line.Substring(17));
                    continue;
                }

                if (line.StartsWith(@"[") && line.EndsWith(@"]"))
                {
                    if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
                    {
                        throw new InvalidDataException($@"Unknown osu section {line}");
                    }
                    continue;
                }

                switch (section)
                {
                case Section.General:
                    handleGeneral(beatmap, line);
                    break;

                case Section.Editor:
                    handleEditor(beatmap, line);
                    break;

                case Section.Metadata:
                    handleMetadata(beatmap, line);
                    break;

                case Section.Difficulty:
                    handleDifficulty(beatmap, line);
                    break;

                case Section.Events:
                    handleEvents(beatmap, line, ref storyboardSprite, ref timelineGroup);
                    break;

                case Section.TimingPoints:
                    handleTimingPoints(beatmap, line);
                    break;

                case Section.Colours:
                    handleColours(beatmap, line, ref hasCustomColours);
                    break;

                case Section.HitObjects:

                    // If the ruleset wasn't specified, assume the osu!standard ruleset.
                    if (parser == null)
                    {
                        parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
                    }

                    var obj = parser.Parse(line);

                    if (obj != null)
                    {
                        beatmap.HitObjects.Add(obj);
                    }

                    break;

                case Section.Variables:
                    handleVariables(line);
                    break;
                }
            }

            foreach (var hitObject in beatmap.HitObjects)
            {
                hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
            }
        }
Ejemplo n.º 5
0
        protected override void ParseFile(StreamReader stream, Beatmap beatmap)
        {
            beatmap.BeatmapInfo.BeatmapVersion = beatmapVersion;

            Section section          = Section.None;
            bool    hasCustomColours = false;

            string line;

            while ((line = stream.ReadLine()) != null)
            {
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                if (line.StartsWith(@"osu file format v"))
                {
                    beatmap.BeatmapInfo.BeatmapVersion = int.Parse(line.Substring(17));
                    continue;
                }

                if (line.StartsWith(@"[") && line.EndsWith(@"]"))
                {
                    if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
                    {
                        throw new InvalidDataException($@"Unknown osu section {line}");
                    }
                    continue;
                }

                string val = line, key = null;
                if (section != Section.Events && section != Section.TimingPoints && section != Section.HitObjects)
                {
                    key = val.Remove(val.IndexOf(':')).Trim();
                    val = val.Substring(val.IndexOf(':') + 1).Trim();
                }
                switch (section)
                {
                case Section.General:
                    handleGeneral(beatmap, key, val);
                    break;

                case Section.Editor:
                    handleEditor(beatmap, key, val);
                    break;

                case Section.Metadata:
                    handleMetadata(beatmap, key, val);
                    break;

                case Section.Difficulty:
                    handleDifficulty(beatmap, key, val);
                    break;

                case Section.Events:
                    handleEvents(beatmap, val);
                    break;

                case Section.TimingPoints:
                    handleTimingPoints(beatmap, val);
                    break;

                case Section.Colours:
                    handleColours(beatmap, key, val, ref hasCustomColours);
                    break;

                case Section.HitObjects:
                    var obj = parser.Parse(val);

                    if (obj != null)
                    {
                        beatmap.HitObjects.Add(obj);
                    }

                    break;
                }
            }
        }
Ejemplo n.º 6
0
        protected override void ParseFile(StreamReader stream, Beatmap beatmap)
        {
            beatmap.BeatmapInfo.BeatmapVersion = beatmapVersion;

            Section section          = Section.None;
            bool    hasCustomColours = false;

            string line;

            while ((line = stream.ReadLine()) != null)
            {
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                if (line.StartsWith(" ") || line.StartsWith("_") || line.StartsWith("//"))
                {
                    continue;
                }

                if (line.StartsWith(@"osu file format v"))
                {
                    beatmap.BeatmapInfo.BeatmapVersion = int.Parse(line.Substring(17));
                    continue;
                }

                if (line.StartsWith(@"[") && line.EndsWith(@"]"))
                {
                    if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
                    {
                        throw new InvalidDataException($@"Unknown osu section {line}");
                    }
                    continue;
                }

                switch (section)
                {
                case Section.General:
                    handleGeneral(beatmap, line);
                    break;

                case Section.Editor:
                    handleEditor(beatmap, line);
                    break;

                case Section.Metadata:
                    handleMetadata(beatmap, line);
                    break;

                case Section.Difficulty:
                    handleDifficulty(beatmap, line);
                    break;

                case Section.Events:
                    handleEvents(beatmap, line);
                    break;

                case Section.TimingPoints:
                    handleTimingPoints(beatmap, line);
                    break;

                case Section.Colours:
                    handleColours(beatmap, line, ref hasCustomColours);
                    break;

                case Section.HitObjects:
                    var obj = parser.Parse(line);

                    if (obj != null)
                    {
                        beatmap.HitObjects.Add(obj);
                    }

                    break;

                case Section.Variables:
                    handleVariables(line);
                    break;
                }
            }

            foreach (var hitObject in beatmap.HitObjects)
            {
                hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.Difficulty);
            }
        }