private BeatmapSetInfo createTestBeatmapSet(int i)
 {
     return(new BeatmapSetInfo
     {
         OnlineBeatmapSetID = 1234 + i,
         Hash = "d8e8fca2dc0f896fd7cb4cb0031ba249",
         Metadata = new BeatmapMetadata
         {
             OnlineBeatmapSetID = 1234 + i,
             // Create random metadata, then we can check if sorting works based on these
             Artist = "MONACA " + RNG.Next(0, 9),
             Title = "Black Song " + RNG.Next(0, 9),
             Author = "Some Guy " + RNG.Next(0, 9),
         },
         Beatmaps = new List <BeatmapInfo>(new[]
         {
             new BeatmapInfo
             {
                 OnlineBeatmapID = 1234 + i,
                 Ruleset = rulesets.Query <RulesetInfo>().First(),
                 Path = "normal.osu",
                 Version = "Normal",
                 Difficulty = new BeatmapDifficulty
                 {
                     OverallDifficulty = 3.5f,
                 }
             },
             new BeatmapInfo
             {
                 OnlineBeatmapID = 1235 + i,
                 Ruleset = rulesets.Query <RulesetInfo>().First(),
                 Path = "hard.osu",
                 Version = "Hard",
                 Difficulty = new BeatmapDifficulty
                 {
                     OverallDifficulty = 5,
                 }
             },
             new BeatmapInfo
             {
                 OnlineBeatmapID = 1236 + i,
                 Ruleset = rulesets.Query <RulesetInfo>().First(),
                 Path = "insane.osu",
                 Version = "Insane",
                 Difficulty = new BeatmapDifficulty
                 {
                     OverallDifficulty = 7,
                 }
             },
         }),
     });
 }
Пример #2
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Add(new Box
            {
                RelativeSizeAxes = Framework.Graphics.Axes.Both,
                Colour           = Color4.Black,
            });

            foreach (var r in rulesets.Query <RulesetInfo>())
            {
                AddStep(r.Name, () => loadPlayerFor(r));
            }

            loadPlayerFor(rulesets.Query <RulesetInfo>().First());
        }
Пример #3
0
        private void load(RulesetStore rulesets)
        {
            Add(new Box
            {
                RelativeSizeAxes = Framework.Graphics.Axes.Both,
                Colour           = Color4.Black,
            });

            string instantiation = ruleset?.AssemblyQualifiedName;

            foreach (var r in rulesets.Query <RulesetInfo>(rs => rs.Available && (instantiation == null || rs.InstantiationInfo == instantiation)))
            {
                AddStep(r.Name, () => loadPlayerFor(r));
            }
        }
Пример #4
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            var objects = new List <HitObject>();

            int time = 1500;

            for (int i = 0; i < 50; i++)
            {
                objects.Add(new HitCircle
                {
                    StartTime = time,
                    Position  = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : OsuPlayfield.BASE_SIZE.X,
                                            i % 4 < 2 ? 0 : OsuPlayfield.BASE_SIZE.Y),
                    NewCombo = i % 4 == 0
                });

                time += 500;
            }

            Beatmap b = new Beatmap
            {
                HitObjects  = objects,
                BeatmapInfo = new BeatmapInfo
                {
                    Difficulty = new BeatmapDifficulty(),
                    Ruleset    = rulesets.Query <RulesetInfo>().First(),
                    Metadata   = new BeatmapMetadata
                    {
                        Artist = @"Unknown",
                        Title  = @"Sample Beatmap",
                        Author = @"peppy",
                    }
                }
            };

            WorkingBeatmap beatmap = new TestWorkingBeatmap(b);

            Add(new Box
            {
                RelativeSizeAxes = Framework.Graphics.Axes.Both,
                Colour           = Color4.Black,
            });

            Add(Player = CreatePlayer(beatmap));
        }
Пример #5
0
        /// <summary>
        /// Import a beamap into our local <see cref="FileStore"/> storage.
        /// If the beatmap is already imported, the existing instance will be returned.
        /// </summary>
        /// <param name="reader">The beatmap archive to be read.</param>
        /// <returns>The imported beatmap, or an existing instance if it is already present.</returns>
        private BeatmapSetInfo importToStorage(ArchiveReader reader)
        {
            // let's make sure there are actually .osu files to import.
            string mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu"));

            if (string.IsNullOrEmpty(mapName))
            {
                throw new InvalidOperationException("No beatmap files found in the map folder.");
            }

            // for now, concatenate all .osu files in the set to create a unique hash.
            MemoryStream hashable = new MemoryStream();

            foreach (string file in reader.Filenames.Where(f => f.EndsWith(".osu")))
            {
                using (Stream s = reader.GetStream(file))
                    s.CopyTo(hashable);
            }

            var hash = hashable.ComputeSHA2Hash();

            // check if this beatmap has already been imported and exit early if so.
            BeatmapSetInfo beatmapSet;

            lock (beatmaps)
                beatmapSet = beatmaps.QueryAndPopulate <BeatmapSetInfo>(b => b.Hash == hash).FirstOrDefault();

            if (beatmapSet != null)
            {
                Undelete(beatmapSet);
                return(beatmapSet);
            }

            List <BeatmapSetFileInfo> fileInfos = new List <BeatmapSetFileInfo>();

            // import files to manager
            foreach (string file in reader.Filenames)
            {
                using (Stream s = reader.GetStream(file))
                    fileInfos.Add(new BeatmapSetFileInfo
                    {
                        Filename = file,
                        FileInfo = files.Add(s)
                    });
            }

            BeatmapMetadata metadata;

            using (var stream = new StreamReader(reader.GetStream(mapName)))
                metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;

            beatmapSet = new BeatmapSetInfo
            {
                OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
                Beatmaps           = new List <BeatmapInfo>(),
                Hash     = hash,
                Files    = fileInfos,
                Metadata = metadata
            };

            var mapNames = reader.Filenames.Where(f => f.EndsWith(".osu"));

            foreach (var name in mapNames)
            {
                using (var raw = reader.GetStream(name))
                    using (var ms = new MemoryStream()) //we need a memory stream so we can seek and shit
                        using (var sr = new StreamReader(ms))
                        {
                            raw.CopyTo(ms);
                            ms.Position = 0;

                            var     decoder = BeatmapDecoder.GetDecoder(sr);
                            Beatmap beatmap = decoder.Decode(sr);

                            beatmap.BeatmapInfo.Path    = name;
                            beatmap.BeatmapInfo.Hash    = ms.ComputeSHA2Hash();
                            beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();

                            // TODO: Diff beatmap metadata with set metadata and leave it here if necessary
                            beatmap.BeatmapInfo.Metadata = null;

                            // TODO: this should be done in a better place once we actually need to dynamically update it.
                            beatmap.BeatmapInfo.Ruleset        = rulesets.Query <RulesetInfo>().FirstOrDefault(r => r.ID == beatmap.BeatmapInfo.RulesetID);
                            beatmap.BeatmapInfo.StarDifficulty = rulesets.Query <RulesetInfo>().FirstOrDefault(r => r.ID == beatmap.BeatmapInfo.RulesetID)?.CreateInstance()?.CreateDifficultyCalculator(beatmap)
                                                                 .Calculate() ?? 0;

                            beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo);
                        }
            }

            return(beatmapSet);
        }
Пример #6
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            List <HitObject> objects = new List <HitObject>();

            int time = 500;

            for (int i = 0; i < 100; i++)
            {
                objects.Add(new HitCircle
                {
                    StartTime = time,
                    Position  = new Vector2(RNG.Next(0, (int)OsuPlayfield.BASE_SIZE.X), RNG.Next(0, (int)OsuPlayfield.BASE_SIZE.Y)),
                    Scale     = RNG.NextSingle(0.5f, 1.0f),
                });

                time += RNG.Next(50, 500);
            }

            var controlPointInfo = new ControlPointInfo();

            controlPointInfo.TimingPoints.Add(new TimingControlPoint
            {
                BeatLength = 200
            });

            WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap
            {
                HitObjects  = objects,
                BeatmapInfo = new BeatmapInfo
                {
                    Difficulty = new BeatmapDifficulty(),
                    Ruleset    = rulesets.Query <RulesetInfo>().First(),
                    Metadata   = new BeatmapMetadata
                    {
                        Artist = @"Unknown",
                        Title  = @"Sample Beatmap",
                        Author = @"peppy",
                    },
                },
                ControlPointInfo = controlPointInfo
            });

            AddRange(new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    //ensure we are at offset 0
                    Clock    = new FramedClock(),
                    Children = new Drawable[]
                    {
                        new OsuRulesetContainer(new OsuRuleset(new RulesetInfo()), beatmap, false)
                        {
                            Scale  = new Vector2(0.5f),
                            Anchor = Anchor.TopLeft,
                            Origin = Anchor.TopLeft
                        },
                        new TaikoRulesetContainer(new TaikoRuleset(new RulesetInfo()), beatmap, false)
                        {
                            Scale  = new Vector2(0.5f),
                            Anchor = Anchor.TopRight,
                            Origin = Anchor.TopRight
                        },
                        new CatchRulesetContainer(new CatchRuleset(new RulesetInfo()), beatmap, false)
                        {
                            Scale  = new Vector2(0.5f),
                            Anchor = Anchor.BottomLeft,
                            Origin = Anchor.BottomLeft
                        },
                        new ManiaRulesetContainer(new ManiaRuleset(new RulesetInfo()), beatmap, false)
                        {
                            Scale  = new Vector2(0.5f),
                            Anchor = Anchor.BottomRight,
                            Origin = Anchor.BottomRight
                        }
                    }
                }
            });
        }