1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

Remove direct drawable storage from carousel models

This commit is contained in:
Dean Herbert 2020-10-12 12:37:32 +09:00
parent b08e7ce1f5
commit a393bbe8f7
4 changed files with 5 additions and 40 deletions

View File

@ -18,7 +18,7 @@ namespace osu.Game.Screens.Select.Carousel
State.Value = CarouselItemState.Collapsed;
}
protected override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmap(this);
public override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmap(this);
public override void Filter(FilterCriteria criteria)
{

View File

@ -28,7 +28,7 @@ namespace osu.Game.Screens.Select.Carousel
.ForEach(AddChild);
}
protected override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmapSet(this);
public override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmapSet(this);
protected override CarouselItem GetNextToSelect()
{

View File

@ -11,7 +11,7 @@ namespace osu.Game.Screens.Select.Carousel
/// </summary>
public class CarouselGroup : CarouselItem
{
protected override DrawableCarouselItem CreateDrawableRepresentation() => null;
public override DrawableCarouselItem CreateDrawableRepresentation() => null;
public IReadOnlyList<CarouselItem> Children => InternalChildren;
@ -23,22 +23,6 @@ namespace osu.Game.Screens.Select.Carousel
/// </summary>
private ulong currentChildID;
public override List<DrawableCarouselItem> Drawables
{
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;
}
}
public virtual void RemoveChild(CarouselItem i)
{
InternalChildren.Remove(i);

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Bindables;
namespace osu.Game.Screens.Select.Carousel
@ -18,23 +16,8 @@ namespace osu.Game.Screens.Select.Carousel
/// </summary>
public bool Visible => State.Value != CarouselItemState.Collapsed && !Filtered.Value;
public virtual List<DrawableCarouselItem> Drawables
{
get
{
var items = new List<DrawableCarouselItem>();
var self = DrawableRepresentation.Value;
if (self?.IsPresent == true) items.Add(self);
return items;
}
}
protected CarouselItem()
{
DrawableRepresentation = new Lazy<DrawableCarouselItem>(CreateDrawableRepresentation);
Filtered.ValueChanged += filtered =>
{
if (filtered.NewValue && State.Value == CarouselItemState.Selected)
@ -42,17 +25,15 @@ namespace osu.Game.Screens.Select.Carousel
};
}
protected readonly Lazy<DrawableCarouselItem> DrawableRepresentation;
/// <summary>
/// Used as a default sort method for <see cref="CarouselItem"/>s of differing types.
/// </summary>
internal ulong ChildID;
/// <summary>
/// Create a fresh drawable version of this item. If you wish to consume the current representation, use <see cref="DrawableRepresentation"/> instead.
/// Create a fresh drawable version of this item.
/// </summary>
protected abstract DrawableCarouselItem CreateDrawableRepresentation();
public abstract DrawableCarouselItem CreateDrawableRepresentation();
public virtual void Filter(FilterCriteria criteria)
{