mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 21:23:04 +08:00
consolidate halfheight as well
This commit is contained in:
parent
6765e9f7fa
commit
0f6c6c7de0
@ -342,13 +342,13 @@ namespace osu.Game.Screens.Select
|
|||||||
public bool AllowSelection = true;
|
public bool AllowSelection = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The total height of the displayable portion of the Beatmap Carousel.
|
/// Half the height of the visible content.
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This is different from <see cref="ScrollContainer{T}.displayableContent"/>, since
|
/// This is different from the height of <see cref="ScrollContainer{T}.displayableContent"/>, since
|
||||||
/// the beatmap carousel bleeds into the <see cref="FilterControl"/> and the <see cref="Footer"/>
|
/// the beatmap carousel bleeds into the <see cref="FilterControl"/> and the <see cref="Footer"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private float visibleHeight => DrawHeight + bleed_bottom + bleed_top;
|
private float visibleHalfHeight => (DrawHeight + bleed_bottom + bleed_top) / 2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The position of the lower visible bound with respect to the current scroll position.
|
/// The position of the lower visible bound with respect to the current scroll position.
|
||||||
@ -508,9 +508,8 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
// Update externally controlled state of currently visible items
|
// Update externally controlled state of currently visible items
|
||||||
// (e.g. x-offset and opacity).
|
// (e.g. x-offset and opacity).
|
||||||
float halfHeight = visibleHeight / 2;
|
|
||||||
foreach (DrawableCarouselItem p in scrollableContent.Children)
|
foreach (DrawableCarouselItem p in scrollableContent.Children)
|
||||||
updateItem(p, halfHeight);
|
updateItem(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
@ -564,7 +563,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
yPositions.Clear();
|
yPositions.Clear();
|
||||||
|
|
||||||
float currentY = visibleHeight / 2;
|
float currentY = visibleHalfHeight;
|
||||||
DrawableCarouselBeatmapSet lastSet = null;
|
DrawableCarouselBeatmapSet lastSet = null;
|
||||||
|
|
||||||
scrollTarget = null;
|
scrollTarget = null;
|
||||||
@ -617,7 +616,7 @@ namespace osu.Game.Screens.Select
|
|||||||
currentY += d.DrawHeight + 5;
|
currentY += d.DrawHeight + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentY += visibleHeight / 2;
|
currentY += visibleHalfHeight;
|
||||||
scrollableContent.Height = currentY;
|
scrollableContent.Height = currentY;
|
||||||
|
|
||||||
if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
|
if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
|
||||||
@ -658,16 +657,15 @@ namespace osu.Game.Screens.Select
|
|||||||
/// the current scroll position.
|
/// the current scroll position.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="p">The item to be updated.</param>
|
/// <param name="p">The item to be updated.</param>
|
||||||
/// <param name="halfHeight">Half the draw height of the carousel container's parent.</param>
|
private void updateItem(DrawableCarouselItem p)
|
||||||
private void updateItem(DrawableCarouselItem p, float halfHeight)
|
|
||||||
{
|
{
|
||||||
float itemDrawY = p.Position.Y - visibleUpperBound + p.DrawHeight / 2;
|
float itemDrawY = p.Position.Y - visibleUpperBound + p.DrawHeight / 2;
|
||||||
float dist = Math.Abs(1f - itemDrawY / halfHeight);
|
float dist = Math.Abs(1f - itemDrawY / visibleHalfHeight);
|
||||||
|
|
||||||
// Setting the origin position serves as an additive position on top of potential
|
// Setting the origin position serves as an additive position on top of potential
|
||||||
// local transformation we may want to apply (e.g. when a item gets selected, we
|
// local transformation we may want to apply (e.g. when a item gets selected, we
|
||||||
// may want to smoothly transform it leftwards.)
|
// may want to smoothly transform it leftwards.)
|
||||||
p.OriginPosition = new Vector2(-offsetX(dist, halfHeight), 0);
|
p.OriginPosition = new Vector2(-offsetX(dist, visibleHalfHeight), 0);
|
||||||
|
|
||||||
// We are applying a multiplicative alpha (which is internally done by nesting an
|
// We are applying a multiplicative alpha (which is internally done by nesting an
|
||||||
// additional container and setting that container's alpha) such that we can
|
// additional container and setting that container's alpha) such that we can
|
||||||
|
Loading…
Reference in New Issue
Block a user