Exemple #1
0
 private void load(BeatmapManager beatmaps)
 {
     Children = new Drawable[]
     {
         importButton = new OsuButton
         {
             RelativeSizeAxes = Axes.X,
             Text             = "Import beatmaps from stable",
             Action           = () =>
             {
                 importButton.Enabled.Value = false;
                 Task.Run(() => beatmaps.ImportFromStable()).ContinueWith(t => Schedule(() => importButton.Enabled.Value = true));
             }
         },
         deleteButton = new OsuButton
         {
             RelativeSizeAxes = Axes.X,
             Text             = "Delete ALL beatmaps",
             Action           = () =>
             {
                 deleteButton.Enabled.Value = false;
                 Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
             }
         },
     };
 }
Exemple #2
0
        private void load(OsuGameBase game)
        {
            TestSongSelect songSelect = null;

            var storage = new TestStorage(@"TestCasePlaySongSelect");

            // this is by no means clean. should be replacing inside of OsuGameBase somehow.
            IDatabaseContextFactory factory = new SingletonContextFactory(new OsuDbContext());

            dependencies.Cache(rulesets = new RulesetStore(factory));
            dependencies.Cache(manager  = new BeatmapManager(storage, factory, rulesets, null)
            {
                DefaultBeatmap = defaultBeatmap = game.Beatmap.Default
            });

            void loadNewSongSelect(bool deleteMaps = false) => AddStep("reload song select", () =>
            {
                if (deleteMaps)
                {
                    manager.DeleteAll();
                    game.Beatmap.SetDefault();
                }

                if (songSelect != null)
                {
                    Remove(songSelect);
                    songSelect.Dispose();
                }

                Add(songSelect = new TestSongSelect());
            });

            loadNewSongSelect(true);

            AddWaitStep(3);

            AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);

            AddAssert("dummy shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap == defaultBeatmap);

            AddStep("import test maps", () =>
            {
                for (int i = 0; i < 100; i += 10)
                {
                    manager.Import(createTestBeatmapSet(i));
                }
            });

            AddWaitStep(3);
            AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);

            loadNewSongSelect();
            AddWaitStep(3);
            AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);

            AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
            AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
            AddStep(@"Sort by Author", delegate { songSelect.FilterControl.Sort = SortMode.Author; });
            AddStep(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; });
        }
 private void load(BeatmapManager beatmaps, DialogOverlay dialogOverlay)
 {
     Children = new Drawable[]
     {
         importButton = new SettingsButton
         {
             Text   = "Import beatmaps from stable",
             Action = () =>
             {
                 importButton.Enabled.Value = false;
                 Task.Factory.StartNew(beatmaps.ImportFromStable)
                 .ContinueWith(t => Schedule(() => importButton.Enabled.Value = true), TaskContinuationOptions.LongRunning);
             }
         },
         deleteButton = new DangerousSettingsButton
         {
             Text   = "Delete ALL beatmaps",
             Action = () =>
             {
                 dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() =>
                 {
                     deleteButton.Enabled.Value = false;
                     Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
                 }));
             }
         },
         restoreButton = new SettingsButton
         {
             Text   = "Restore all hidden difficulties",
             Action = () =>
             {
                 restoreButton.Enabled.Value = false;
                 Task.Run(() =>
                 {
                     foreach (var b in beatmaps.QueryBeatmaps(b => b.Hidden).ToList())
                     {
                         beatmaps.Restore(b);
                     }
                 }).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true));
             }
         },
         undeleteButton = new SettingsButton
         {
             Text   = "Restore all recently deleted beatmaps",
             Action = () =>
             {
                 undeleteButton.Enabled.Value = false;
                 Task.Run(() => beatmaps.UndeleteAll()).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true));
             }
         },
     };
 }
Exemple #4
0
 private void load(BeatmapManager beatmaps)
 {
     Children = new Drawable[]
     {
         importButton = new OsuButton
         {
             RelativeSizeAxes = Axes.X,
             Text             = "Import beatmaps from stable",
             Action           = () =>
             {
                 importButton.Enabled.Value = false;
                 Task.Run(() => beatmaps.ImportFromStable()).ContinueWith(t => Schedule(() => importButton.Enabled.Value = true));
             }
         },
         deleteButton = new OsuButton
         {
             RelativeSizeAxes = Axes.X,
             Text             = "Delete ALL beatmaps",
             Action           = () =>
             {
                 deleteButton.Enabled.Value = false;
                 Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
             }
         },
         restoreButton = new OsuButton
         {
             RelativeSizeAxes = Axes.X,
             Text             = "Restore all hidden difficulties",
             Action           = () =>
             {
                 restoreButton.Enabled.Value = false;
                 Task.Run(() =>
                 {
                     foreach (var b in beatmaps.QueryBeatmaps(b => b.Hidden))
                     {
                         beatmaps.Restore(b);
                     }
                 }).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true));
             }
         },
     };
 }