Exemplo n.º 1
0
        public void TestDifficultyIconSelecting()
        {
            addRulesetImportStep(0);
            createSongSelect();

            DrawableCarouselBeatmapSet set = null;

            AddStep("Find the DrawableCarouselBeatmapSet", () =>
            {
                set = songSelect.Carousel.ChildrenOfType <DrawableCarouselBeatmapSet>().First();
            });

            FilterableDifficultyIcon difficultyIcon = null;

            AddUntilStep("Find an icon", () =>
            {
                return((difficultyIcon = set.ChildrenOfType <FilterableDifficultyIcon>()
                                         .FirstOrDefault(icon => getDifficultyIconIndex(set, icon) != getCurrentBeatmapIndex())) != null);
            });

            AddStep("Click on a difficulty", () =>
            {
                InputManager.MoveMouseTo(difficultyIcon);

                InputManager.Click(MouseButton.Left);
            });

            AddAssert("Selected beatmap correct", () => getCurrentBeatmapIndex() == getDifficultyIconIndex(set, difficultyIcon));

            double?maxBPM = null;

            AddStep("Filter some difficulties", () => songSelect.Carousel.Filter(new FilterCriteria
            {
                BPM = new FilterCriteria.OptionalRange <double>
                {
                    Min = maxBPM = songSelect.Carousel.SelectedBeatmapSet.MaxBPM,
                    IsLowerInclusive = true
                }
            }));

            BeatmapInfo filteredBeatmap           = null;
            FilterableDifficultyIcon filteredIcon = null;

            AddStep("Get filtered icon", () =>
            {
                var selectedSet          = songSelect.Carousel.SelectedBeatmapSet;
                filteredBeatmap          = selectedSet.Beatmaps.First(b => b.BPM < maxBPM);
                int filteredBeatmapIndex = getBeatmapIndex(selectedSet, filteredBeatmap);
                filteredIcon             = set.ChildrenOfType <FilterableDifficultyIcon>().ElementAt(filteredBeatmapIndex);
            });

            AddStep("Click on a filtered difficulty", () =>
            {
                InputManager.MoveMouseTo(filteredIcon);

                InputManager.Click(MouseButton.Left);
            });

            AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(filteredBeatmap));
        }
Exemplo n.º 2
0
        public void TestDifficultyIconSelecting()
        {
            addRulesetImportStep(0);
            createSongSelect();

            DrawableCarouselBeatmapSet set = null;

            AddStep("Find the DrawableCarouselBeatmapSet", () =>
            {
                set = songSelect.Carousel.ChildrenOfType <DrawableCarouselBeatmapSet>().First();
            });

            DrawableCarouselBeatmapSet.FilterableDifficultyIcon difficultyIcon = null;
            AddStep("Find an icon", () =>
            {
                difficultyIcon = set.ChildrenOfType <DrawableCarouselBeatmapSet.FilterableDifficultyIcon>()
                                 .First(icon => getDifficultyIconIndex(set, icon) != getCurrentBeatmapIndex());
            });
            AddStep("Click on a difficulty", () =>
            {
                InputManager.MoveMouseTo(difficultyIcon);

                InputManager.PressButton(MouseButton.Left);
                InputManager.ReleaseButton(MouseButton.Left);
            });
            AddAssert("Selected beatmap correct", () => getCurrentBeatmapIndex() == getDifficultyIconIndex(set, difficultyIcon));

            double?maxBPM = null;

            AddStep("Filter some difficulties", () => songSelect.Carousel.Filter(new FilterCriteria
            {
                BPM = new FilterCriteria.OptionalRange <double>
                {
                    Min = maxBPM = songSelect.Carousel.SelectedBeatmapSet.MaxBPM,
                    IsLowerInclusive = true
                }
            }));

            DrawableCarouselBeatmapSet.FilterableDifficultyIcon filteredIcon = null;
            AddStep("Get filtered icon", () =>
            {
                var filteredBeatmap      = songSelect.Carousel.SelectedBeatmapSet.Beatmaps.Find(b => b.BPM < maxBPM);
                int filteredBeatmapIndex = getBeatmapIndex(filteredBeatmap.BeatmapSet, filteredBeatmap);
                filteredIcon             = set.ChildrenOfType <DrawableCarouselBeatmapSet.FilterableDifficultyIcon>().ElementAt(filteredBeatmapIndex);
            });

            int?previousID = null;

            AddStep("Store current ID", () => previousID = songSelect.Carousel.SelectedBeatmap.ID);
            AddStep("Click on a filtered difficulty", () =>
            {
                InputManager.MoveMouseTo(filteredIcon);

                InputManager.PressButton(MouseButton.Left);
                InputManager.ReleaseButton(MouseButton.Left);
            });
            AddAssert("Selected beatmap has not changed", () => songSelect.Carousel.SelectedBeatmap.ID == previousID);
        }
Exemplo n.º 3
0
        public void TestDifficultyIconSelectingForDifferentRuleset()
        {
            changeRuleset(0);

            createSongSelect();

            AddStep("import multi-ruleset map", () =>
            {
                var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray();
                manager.Import(createTestBeatmapSet(usableRulesets)).Wait();
            });

            DrawableCarouselBeatmapSet set = null;

            AddUntilStep("Find the DrawableCarouselBeatmapSet", () =>
            {
                set = songSelect.Carousel.ChildrenOfType <DrawableCarouselBeatmapSet>().FirstOrDefault();
                return(set != null);
            });

            FilterableDifficultyIcon difficultyIcon = null;

            AddUntilStep("Find an icon for different ruleset", () =>
            {
                difficultyIcon = set.ChildrenOfType <FilterableDifficultyIcon>()
                                 .FirstOrDefault(icon => icon.Item.BeatmapInfo.Ruleset.ID == 3);
                return(difficultyIcon != null);
            });

            AddAssert("Check ruleset is osu!", () => Ruleset.Value.ID == 0);

            int previousSetID = 0;

            AddStep("record set ID", () => previousSetID = Beatmap.Value.BeatmapSetInfo.ID);

            AddStep("Click on a difficulty", () =>
            {
                InputManager.MoveMouseTo(difficultyIcon);

                InputManager.Click(MouseButton.Left);
            });

            AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);

            AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmapInfo.BeatmapSet.ID == previousSetID);
            AddAssert("Selected beatmap is mania", () => Beatmap.Value.BeatmapInfo.Ruleset.ID == 3);
        }
Exemplo n.º 4
0
        public void TestGroupedDifficultyIconSelecting()
        {
            changeRuleset(0);

            createSongSelect();

            BeatmapSetInfo imported = null;

            AddStep("import huge difficulty count map", () =>
            {
                var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray();
                imported           = manager.Import(createTestBeatmapSet(usableRulesets, 50)).Result;
            });

            AddStep("select the first beatmap of import", () => Beatmap.Value = manager.GetWorkingBeatmap(imported.Beatmaps.First()));

            DrawableCarouselBeatmapSet set = null;

            AddUntilStep("Find the DrawableCarouselBeatmapSet", () =>
            {
                set = songSelect.Carousel.ChildrenOfType <DrawableCarouselBeatmapSet>().FirstOrDefault();
                return(set != null);
            });

            FilterableGroupedDifficultyIcon groupIcon = null;

            AddStep("Find group icon for different ruleset", () =>
            {
                groupIcon = set.ChildrenOfType <FilterableGroupedDifficultyIcon>()
                            .First(icon => icon.Items.First().Beatmap.Ruleset.ID == 3);
            });

            AddAssert("Check ruleset is osu!", () => Ruleset.Value.ID == 0);

            AddStep("Click on group", () =>
            {
                InputManager.MoveMouseTo(groupIcon);

                InputManager.PressButton(MouseButton.Left);
                InputManager.ReleaseButton(MouseButton.Left);
            });

            AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);

            AddAssert("Check first item in group selected", () => Beatmap.Value.BeatmapInfo == groupIcon.Items.First().Beatmap);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Computes the target Y positions for every item in the carousel.
        /// </summary>
        /// <returns>The Y position of the currently selected item.</returns>
        private void updateItems()
        {
            Items = root.Drawables.ToList();

            yPositions.Clear();

            float currentY = DrawHeight / 2;
            DrawableCarouselBeatmapSet lastSet = null;

            scrollTarget = null;

            foreach (DrawableCarouselItem d in Items)
            {
                if (d.IsPresent)
                {
                    switch (d)
                    {
                    case DrawableCarouselBeatmapSet set:
                        lastSet = set;

                        set.MoveToX(set.Item.State == CarouselItemState.Selected ? -100 : 0, 500, Easing.OutExpo);
                        set.MoveToY(currentY, 750, Easing.OutExpo);
                        break;

                    case DrawableCarouselBeatmap beatmap:
                        if (beatmap.Item.State.Value == CarouselItemState.Selected)
                        {
                            scrollTarget = currentY + beatmap.DrawHeight / 2 - DrawHeight / 2;
                        }

                        void performMove(float y, float?startY = null)
                        {
                            if (startY != null)
                            {
                                beatmap.MoveTo(new Vector2(0, startY.Value));
                            }
                            beatmap.MoveToX(beatmap.Item.State == CarouselItemState.Selected ? -50 : 0, 500, Easing.OutExpo);
                            beatmap.MoveToY(y, 750, Easing.OutExpo);
                        }

                        Debug.Assert(lastSet != null);

                        float?setY = null;
                        if (!d.IsLoaded || beatmap.Alpha == 0)     // can't use IsPresent due to DrawableCarouselItem override.
                        // ReSharper disable once PossibleNullReferenceException (resharper broken?)
                        {
                            setY = lastSet.Y + lastSet.DrawHeight + 5;
                        }

                        if (d.IsLoaded)
                        {
                            performMove(currentY, setY);
                        }
                        else
                        {
                            float y = currentY;
                            d.OnLoadComplete = _ => performMove(y, setY);
                        }

                        break;
                    }
                }

                yPositions.Add(currentY);

                if (d.Item.Visible)
                {
                    currentY += d.DrawHeight + 5;
                }
            }

            currentY += DrawHeight / 2;
            scrollableContent.Height = currentY;

            if (initialLoadComplete && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
            {
                selectedBeatmapSet = null;
                SelectionChanged?.Invoke(null);
            }

            itemsCache.Validate();
        }
Exemplo n.º 6
0
 private int getDifficultyIconIndex(DrawableCarouselBeatmapSet set, FilterableDifficultyIcon icon)
 {
     return(set.ChildrenOfType <FilterableDifficultyIcon>().ToList().FindIndex(i => i == icon));
 }