From 3886e75959d1c8c0d8b6760f13d8c51467d764a5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 24 Apr 2018 01:52:25 +0900 Subject: [PATCH] Fix potentially missing group headers in beatmap carousel --- osu.Game/Screens/Select/Carousel/CarouselGroup.cs | 5 +++++ osu.Game/Screens/Select/Carousel/CarouselItem.cs | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/Carousel/CarouselGroup.cs b/osu.Game/Screens/Select/Carousel/CarouselGroup.cs index a1f44763d6..2118cfdc78 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselGroup.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselGroup.cs @@ -27,6 +27,11 @@ namespace osu.Game.Screens.Select.Carousel get { var drawables = base.Drawables; + + // if we are explicitly not present, don't ever present children. + // without this check, children drawables can potentially be presented without their group header. + if (DrawableRepresentation.Value?.IsPresent == false) return drawables; + foreach (var c in InternalChildren) drawables.AddRange(c.Drawables); return drawables; diff --git a/osu.Game/Screens/Select/Carousel/CarouselItem.cs b/osu.Game/Screens/Select/Carousel/CarouselItem.cs index 0de32c12f1..c0781f09c0 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselItem.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselItem.cs @@ -24,7 +24,7 @@ namespace osu.Game.Screens.Select.Carousel { var items = new List(); - var self = drawableRepresentation.Value; + var self = DrawableRepresentation.Value; if (self?.IsPresent == true) items.Add(self); return items; @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Select.Carousel protected CarouselItem() { - drawableRepresentation = new Lazy(CreateDrawableRepresentation); + DrawableRepresentation = new Lazy(CreateDrawableRepresentation); Filtered.ValueChanged += v => { @@ -44,13 +44,16 @@ namespace osu.Game.Screens.Select.Carousel }; } - private readonly Lazy drawableRepresentation; + protected readonly Lazy DrawableRepresentation; /// /// Used as a default sort method for s of differing types. /// internal ulong ChildID; + /// + /// Create a fresh drawable version of this item. If you wish to consume the current representation, use instead. + /// protected abstract DrawableCarouselItem CreateDrawableRepresentation(); public virtual void Filter(FilterCriteria criteria)