예제 #1
0
        public Beatmap(string aCode, float?aStarRating = null, string aSongPath = null, string aMapPath = null)
        {
            code     = aCode;
            songPath = aSongPath;
            mapPath  = aMapPath;

            string[] lines = aCode.Split(new string[] { "\n" }, StringSplitOptions.None);

            generalSettings    = ParserStatic.GetSettings(lines, "General", aSectionLines => new GeneralSettings(aSectionLines));
            metadataSettings   = ParserStatic.GetSettings(lines, "Metadata", aSectionLines => new MetadataSettings(aSectionLines));
            difficultySettings = ParserStatic.GetSettings(lines, "Difficulty", aSectionLines => new DifficultySettings(aSectionLines));
            colourSettings     = ParserStatic.GetSettings(lines, "Colours", aSectionLines => new ColourSettings(aSectionLines));

            // event type 3 seems to be "background colour transformation" https://i.imgur.com/Tqlz3s5.png

            backgrounds = GetEvents(lines, new List <string>()
            {
                "Background", "0"
            }, anArgs => new Background(anArgs));
            videos = GetEvents(lines, new List <string>()
            {
                "Video", "1"
            }, anArgs => new Video(anArgs));
            breaks = GetEvents(lines, new List <string>()
            {
                "Break", "2"
            }, anArgs => new Break(anArgs));
            sprites = GetEvents(lines, new List <string>()
            {
                "Sprite", "4"
            }, anArgs => new Sprite(anArgs));
            storyHitSounds = GetEvents(lines, new List <string>()
            {
                "Sample", "5"
            }, anArgs => new StoryHitSound(anArgs));
            animations = GetEvents(lines, new List <string>()
            {
                "Animation", "6"
            }, anArgs => new Animation(anArgs));

            timingLines = GetTimingLines(lines);
            hitObjects  = GetHitobjects(lines);

            if (generalSettings.mode == Mode.Standard)
            {
                // Stacking is standard-only.
                ApplyStacking();

                starRating = aStarRating ?? (float)StandardDifficultyCalculator.Calculate(this).Item3;
            }
        }
예제 #2
0
        public Beatmap(string code, double?starRating = null, string songPath = null, string mapPath = null)
        {
            this.code     = code;
            this.songPath = songPath;
            this.mapPath  = mapPath;

            string[] lines = code.Split(new string[] { "\n" }, StringSplitOptions.None);

            generalSettings    = ParserStatic.GetSettings(lines, "General", sectionLines => new GeneralSettings(sectionLines));
            metadataSettings   = ParserStatic.GetSettings(lines, "Metadata", sectionLines => new MetadataSettings(sectionLines));
            difficultySettings = ParserStatic.GetSettings(lines, "Difficulty", sectionLines => new DifficultySettings(sectionLines));
            colourSettings     = ParserStatic.GetSettings(lines, "Colours", sectionLines => new ColourSettings(sectionLines));

            // event type 3 seems to be "background colour transformation" https://i.imgur.com/Tqlz3s5.png

            backgrounds = GetEvents(lines, new List <string>()
            {
                "Background", "0"
            }, args => new Background(args));
            videos = GetEvents(lines, new List <string>()
            {
                "Video", "1"
            }, args => new Video(args));
            breaks = GetEvents(lines, new List <string>()
            {
                "Break", "2"
            }, args => new Break(args));
            sprites = GetEvents(lines, new List <string>()
            {
                "Sprite", "4"
            }, args => new Sprite(args));
            samples = GetEvents(lines, new List <string>()
            {
                "Sample", "5"
            }, args => new Sample(args));
            animations = GetEvents(lines, new List <string>()
            {
                "Animation", "6"
            }, args => new Animation(args));

            timingLines = GetTimingLines(lines);
            hitObjects  = GetHitobjects(lines);

            if (generalSettings.mode != Mode.Standard)
            {
                return;
            }

            // Stacking is standard-only.
            ApplyStacking();

            if (starRating != null)
            {
                this.starRating = starRating.Value;
            }
            else
            {
                DifficultyAttributes attributes = new OsuDifficultyCalculator(this).Calculate();
                difficultyAttributes = attributes;
                this.starRating      = attributes.StarRating;
            }
        }