Exemplo n.º 1
0
        public void TestLargeDatabase()
        {
            Stopwatch timer = new Stopwatch();

            using (BeatmapDatabase database = new BeatmapDatabase("large_database"))
            {
                string testPath = Environment.CurrentDirectory; // Note: replace this with your own large KShoot folder for this test to be useful

                timer.Start();
                database.AddSearchPath(testPath);
                database.StartSearching();
                while (database.IsSearchRunning)
                {
                    Thread.Sleep(10);
                    database.Update();
                }

                // Make sure all tasks completed
                Thread.Sleep(10);
                database.Update();

                timer.Stop();
                Debug.WriteLine($"Finished scanning in {timer.Elapsed}, found {database.Sets.Count} maps and {database.Difficulties.Count} difficulties");
            }
        }
Exemplo n.º 2
0
        private void load(AudioManager audio, OsuConfigManager config, BeatmapDatabase beatmaps, Framework.Game game)
        {
            menuVoice = config.GetBindable <bool>(OsuSetting.MenuVoice);
            menuMusic = config.GetBindable <bool>(OsuSetting.MenuMusic);

            var trackManager = audio.Track;

            BeatmapSetInfo setInfo = null;

            if (!menuMusic)
            {
                var query = beatmaps.Query <BeatmapSetInfo>().Where(b => !b.DeletePending);
                int count = query.Count();
                if (count > 0)
                {
                    setInfo = query.ElementAt(RNG.Next(0, count - 1));
                }
            }

            if (setInfo == null)
            {
                var query = beatmaps.Query <BeatmapSetInfo>().Where(b => b.Hash == MENU_MUSIC_BEATMAP_HASH);

                setInfo = query.FirstOrDefault();

                if (setInfo == null)
                {
                    // we need to import the default menu background beatmap
                    beatmaps.Import(new OszArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz")));

                    setInfo = query.First();

                    setInfo.DeletePending = true;
                    beatmaps.Update(setInfo, false);
                }
            }

            beatmaps.GetChildren(setInfo);
            Beatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);

            track = Beatmap.Track;
            trackManager.SetExclusive(track);

            welcome = audio.Sample.Get(@"welcome");
            seeya   = audio.Sample.Get(@"seeya");
        }
Exemplo n.º 3
0
        public void TestScanningAndReloading()
        {
            SetIndex testSet;

            using (BeatmapDatabase database = new BeatmapDatabase("test_database", true))
            {
                string testPath = Path.Combine(Environment.CurrentDirectory, "TestMaps");

                // Record changes so they can be verified for this test
                HashSet <DifficultyIndex> difficulties = new HashSet <DifficultyIndex>();
                HashSet <SetIndex>        sets         = new HashSet <SetIndex>();

                database.DifficultyChanged += (sender, args) =>
                {
                    if (args.Type == DatabaseEventType.Added)
                    {
                        difficulties.Add(args.Difficulty);
                    }
                };

                database.SetChanged += (sender, args) =>
                {
                    if (args.Type == DatabaseEventType.Added)
                    {
                        sets.Add(args.Set);
                    }
                };

                database.AddSearchPath(testPath);
                database.StartSearching();
                while (database.IsSearchRunning)
                {
                    Thread.Sleep(10);
                    database.Update();
                }

                // Make sure all tasks completed
                Thread.Sleep(10);
                database.Update();

                testSet = database.Sets[0];

                // Ensure all 4 test sets are detected
                Assert.AreEqual(4, sets.Count);
            }

            // Test database reloads
            using (BeatmapDatabase database = new BeatmapDatabase("test_database"))
            {
                // Ensure all 4 test sets are detected
                Assert.AreEqual(4, database.Sets.Count);

                var testSet1 = database.Sets[0];

                Assert.AreEqual(testSet1.Difficulties.Count, testSet.Difficulties.Count);

                var diff  = testSet.Difficulties[0];
                var diff1 = testSet1.Difficulties[0];

                Assert.AreEqual(diff.Path, diff1.Path);
                Assert.AreEqual(diff.MetaData.Artist, diff1.MetaData.Artist);
                Assert.AreEqual(diff.LastWriteTime, diff1.LastWriteTime);
            }
        }