mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 11:02:57 +08:00
Add animation and depth control
This commit is contained in:
parent
7e8a80a0e5
commit
cc8941a94a
@ -45,13 +45,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
detachedBeatmaps.BindCollectionChanged(beatmapSetsChanged, true);
|
||||
}
|
||||
|
||||
protected override Drawable GetDrawableForDisplay(CarouselItem item)
|
||||
{
|
||||
var drawable = carouselPanelPool.Get();
|
||||
drawable.FlashColour(Color4.Red, 2000);
|
||||
|
||||
return drawable;
|
||||
}
|
||||
protected override Drawable GetDrawableForDisplay(CarouselItem item) => carouselPanelPool.Get();
|
||||
|
||||
protected override CarouselItem CreateCarouselItemForModel(BeatmapInfo model) => new BeatmapCarouselItem(model);
|
||||
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
@ -67,6 +68,8 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
Debug.Assert(Item != null);
|
||||
|
||||
DrawYPosition = Item.CarouselYPosition;
|
||||
|
||||
Size = new Vector2(500, Item.DrawHeight);
|
||||
Masking = true;
|
||||
|
||||
@ -85,6 +88,8 @@ namespace osu.Game.Screens.SelectV2
|
||||
Origin = Anchor.CentreLeft,
|
||||
}
|
||||
};
|
||||
|
||||
this.FadeInFromZero(500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
@ -92,5 +97,19 @@ namespace osu.Game.Screens.SelectV2
|
||||
carousel.CurrentSelection = Item!.Model;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Debug.Assert(Item != null);
|
||||
|
||||
if (DrawYPosition != Item.CarouselYPosition)
|
||||
{
|
||||
DrawYPosition = Interpolation.DampContinuously(DrawYPosition, Item.CarouselYPosition, 50, Time.Elapsed);
|
||||
}
|
||||
}
|
||||
|
||||
public double DrawYPosition { get; private set; }
|
||||
}
|
||||
}
|
||||
|
@ -291,6 +291,14 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
updateDisplayedRange(range);
|
||||
}
|
||||
|
||||
foreach (var panel in scroll.Panels)
|
||||
{
|
||||
var carouselPanel = (ICarouselPanel)panel;
|
||||
|
||||
if (panel.Depth != carouselPanel.DrawYPosition)
|
||||
scroll.Panels.ChangeChildDepth(panel, (float)carouselPanel.DrawYPosition);
|
||||
}
|
||||
}
|
||||
|
||||
private DisplayRange getDisplayRange()
|
||||
@ -415,7 +423,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
if (d is not ICarouselPanel panel)
|
||||
return base.GetChildPosInContent(d, offset);
|
||||
|
||||
return panel.YPosition + offset.X;
|
||||
return panel.DrawYPosition + offset.X;
|
||||
}
|
||||
|
||||
protected override void ApplyCurrentToContent()
|
||||
@ -425,7 +433,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
double scrollableExtent = -Current + ScrollableExtent * ScrollContent.RelativeAnchorPosition.Y;
|
||||
|
||||
foreach (var d in Panels)
|
||||
d.Y = (float)(((ICarouselPanel)d).YPosition + scrollableExtent);
|
||||
d.Y = (float)(((ICarouselPanel)d).DrawYPosition + scrollableExtent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
/// <summary>
|
||||
/// The Y position which should be used for displaying this item within the carousel.
|
||||
/// </summary>
|
||||
double YPosition => Item!.CarouselYPosition;
|
||||
double DrawYPosition { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The carousel item this drawable is representing. This is managed by <see cref="Carousel{T}"/> and should not be set manually.
|
||||
|
Loading…
Reference in New Issue
Block a user