mirror of
https://github.com/ppy/osu.git
synced 2024-09-22 09:27:34 +08:00
Remove direct drawable storage from carousel models
This commit is contained in:
parent
b08e7ce1f5
commit
a393bbe8f7
@ -18,7 +18,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
State.Value = CarouselItemState.Collapsed;
|
State.Value = CarouselItemState.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmap(this);
|
public override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmap(this);
|
||||||
|
|
||||||
public override void Filter(FilterCriteria criteria)
|
public override void Filter(FilterCriteria criteria)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
.ForEach(AddChild);
|
.ForEach(AddChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmapSet(this);
|
public override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmapSet(this);
|
||||||
|
|
||||||
protected override CarouselItem GetNextToSelect()
|
protected override CarouselItem GetNextToSelect()
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class CarouselGroup : CarouselItem
|
public class CarouselGroup : CarouselItem
|
||||||
{
|
{
|
||||||
protected override DrawableCarouselItem CreateDrawableRepresentation() => null;
|
public override DrawableCarouselItem CreateDrawableRepresentation() => null;
|
||||||
|
|
||||||
public IReadOnlyList<CarouselItem> Children => InternalChildren;
|
public IReadOnlyList<CarouselItem> Children => InternalChildren;
|
||||||
|
|
||||||
@ -23,22 +23,6 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ulong currentChildID;
|
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)
|
public virtual void RemoveChild(CarouselItem i)
|
||||||
{
|
{
|
||||||
InternalChildren.Remove(i);
|
InternalChildren.Remove(i);
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Carousel
|
namespace osu.Game.Screens.Select.Carousel
|
||||||
@ -18,23 +16,8 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Visible => State.Value != CarouselItemState.Collapsed && !Filtered.Value;
|
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()
|
protected CarouselItem()
|
||||||
{
|
{
|
||||||
DrawableRepresentation = new Lazy<DrawableCarouselItem>(CreateDrawableRepresentation);
|
|
||||||
|
|
||||||
Filtered.ValueChanged += filtered =>
|
Filtered.ValueChanged += filtered =>
|
||||||
{
|
{
|
||||||
if (filtered.NewValue && State.Value == CarouselItemState.Selected)
|
if (filtered.NewValue && State.Value == CarouselItemState.Selected)
|
||||||
@ -42,17 +25,15 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly Lazy<DrawableCarouselItem> DrawableRepresentation;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used as a default sort method for <see cref="CarouselItem"/>s of differing types.
|
/// Used as a default sort method for <see cref="CarouselItem"/>s of differing types.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal ulong ChildID;
|
internal ulong ChildID;
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
protected abstract DrawableCarouselItem CreateDrawableRepresentation();
|
public abstract DrawableCarouselItem CreateDrawableRepresentation();
|
||||||
|
|
||||||
public virtual void Filter(FilterCriteria criteria)
|
public virtual void Filter(FilterCriteria criteria)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user