public override int CompareTo(FilterCriteria criteria, CarouselItem other)
        {
            if (!(other is CarouselBeatmapSet otherSet))
            {
                return(base.CompareTo(criteria, other));
            }

            switch (criteria.Sort)
            {
            default:
            case SortMode.Artist:
                return(string.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase));

            case SortMode.Title:
                return(string.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase));

            case SortMode.Author:
                return(string.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username, StringComparison.InvariantCultureIgnoreCase));

            case SortMode.DateAdded:
                return(otherSet.BeatmapSet.DateAdded.CompareTo(BeatmapSet.DateAdded));

            case SortMode.BPM:
                return(compareUsingAggregateMax(otherSet, b => b.BPM));

            case SortMode.Length:
                return(compareUsingAggregateMax(otherSet, b => b.Length));

            case SortMode.Difficulty:
                return(compareUsingAggregateMax(otherSet, b => b.StarDifficulty));
            }
        }
示例#2
0
        private void attemptSelection()
        {
            if (filteringChildren)
            {
                return;
            }

            // we only perform eager selection if we are a currently selected group.
            if (State != CarouselItemState.Selected)
            {
                return;
            }

            // we only perform eager selection if none of our children are in a selected state already.
            if (Children.Any(i => i.State == CarouselItemState.Selected))
            {
                return;
            }

            CarouselItem nextToSelect =
                Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered) ??
                Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered);

            if (nextToSelect != null)
            {
                nextToSelect.State.Value = CarouselItemState.Selected;
            }
            else
            {
                updateSelected(null);
            }
        }
示例#3
0
        protected DrawableCarouselItem(CarouselItem item)
        {
            Item = item;

            Height           = MAX_HEIGHT;
            RelativeSizeAxes = Axes.X;
            Alpha            = 0;
        }
 public override void AddChild(CarouselItem i)
 {
     base.AddChild(i);
     if (!addingChildren)
     {
         attemptSelection();
     }
 }
示例#5
0
        public virtual void RemoveChild(CarouselItem i)
        {
            InternalChildren.Remove(i);

            // it's important we do the deselection after removing, so any further actions based on
            // State.ValueChanged make decisions post-removal.
            i.State.Value = CarouselItemState.Collapsed;
        }
 private void updateSelected(CarouselItem newSelection)
 {
     if (newSelection != null)
     {
         LastSelected = newSelection;
     }
     updateSelectedIndex();
 }
        public override void RemoveChild(CarouselItem i)
        {
            base.RemoveChild(i);

            if (i != LastSelected)
            {
                updateSelectedIndex();
            }
        }
        protected virtual void PerformSelection()
        {
            CarouselItem nextToSelect = GetNextToSelect();

            if (nextToSelect != null)
            {
                nextToSelect.State.Value = CarouselItemState.Selected;
            }
            else
            {
                updateSelected(null);
            }
        }
示例#9
0
        protected virtual void PerformSelection()
        {
            CarouselItem nextToSelect =
                Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value) ??
                Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value);

            if (nextToSelect != null)
            {
                nextToSelect.State.Value = CarouselItemState.Selected;
            }
            else
            {
                updateSelected(null);
            }
        }
        protected override void ChildItemStateChanged(CarouselItem item, CarouselItemState value)
        {
            base.ChildItemStateChanged(item, value);

            switch (value)
            {
            case CarouselItemState.Selected:
                updateSelected(item);
                break;

            case CarouselItemState.NotSelected:
            case CarouselItemState.Collapsed:
                attemptSelection();
                break;
            }
        }
示例#11
0
        protected virtual void ChildItemStateChanged(CarouselItem item, CarouselItemState value)
        {
            // ensure we are the only item selected
            if (value == CarouselItemState.Selected)
            {
                foreach (var b in InternalChildren)
                {
                    if (item == b)
                    {
                        continue;
                    }
                    b.State.Value = CarouselItemState.NotSelected;
                }

                State.Value = CarouselItemState.Selected;
            }
        }
示例#12
0
        public override int CompareTo(FilterCriteria criteria, CarouselItem other)
        {
            if (!(other is CarouselBeatmap otherBeatmap))
            {
                return(base.CompareTo(criteria, other));
            }

            switch (criteria.Sort)
            {
            default:
            case SortMode.Difficulty:
                var ruleset = Beatmap.RulesetID.CompareTo(otherBeatmap.Beatmap.RulesetID);
                if (ruleset != 0)
                {
                    return(ruleset);
                }

                return(Beatmap.StarDifficulty.CompareTo(otherBeatmap.Beatmap.StarDifficulty));
            }
        }
示例#13
0
        public virtual void AddChild(CarouselItem i)
        {
            i.State.ValueChanged += state => ChildItemStateChanged(i, state.NewValue);
            i.ChildID             = ++currentChildID;

            if (lastCriteria != null)
            {
                i.Filter(lastCriteria);

                int index = InternalChildren.BinarySearch(i, criteriaComparer);
                if (index < 0)
                {
                    index = ~index;            // BinarySearch hacks multiple return values with 2's complement.
                }
                InternalChildren.Insert(index, i);
            }
            else
            {
                // criteria may be null for initial population. the filtering will be applied post-add.
                InternalChildren.Add(i);
            }
        }
示例#14
0
        public override int CompareTo(FilterCriteria criteria, CarouselItem other)
        {
            if (!(other is CarouselBeatmapSet otherSet))
            {
                return(base.CompareTo(criteria, other));
            }

            switch (criteria.Sort)
            {
            default:
            case SortMode.Artist:
                return(string.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase));

            case SortMode.Title:
                return(string.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase));

            case SortMode.Author:
                return(string.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username, StringComparison.InvariantCultureIgnoreCase));

            case SortMode.Difficulty:
                return(BeatmapSet.MaxStarDifficulty.CompareTo(otherSet.BeatmapSet.MaxStarDifficulty));
            }
        }
示例#15
0
 public virtual void AddChild(CarouselItem i)
 {
     i.State.ValueChanged += state => ChildItemStateChanged(i, state.NewValue);
     i.ChildID             = ++currentChildID;
     InternalChildren.Add(i);
 }
示例#16
0
 public virtual void AddChild(CarouselItem i)
 {
     i.State.ValueChanged += v => ChildItemStateChanged(i, v);
     InternalChildren.Add(i);
 }
示例#17
0
 private void updateSelected(CarouselItem newSelection)
 {
     LastSelected = newSelection;
     updateSelectedIndex();
 }
示例#18
0
 public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => ChildID.CompareTo(other.ChildID);
示例#19
0
 public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => GetHashCode().CompareTo(other.GetHashCode());
 public override void AddChild(CarouselItem i)
 {
     base.AddChild(i);
     attemptSelection();
 }