mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 22:27:25 +08:00
Merge pull request #191 from Tom94/beatmap-carousel-refactor
Beatmap carousel refactor
This commit is contained in:
commit
bb0424f83f
@ -1 +1 @@
|
||||
Subproject commit 34193c7f15aba3520f73f8ca36c0fbc9cd3951d4
|
||||
Subproject commit 1a521bb22cfd2c14f58d4cd60fbbfdb70ea8f87b
|
@ -36,18 +36,18 @@ namespace osu.Game.Screens.Backgrounds
|
||||
|
||||
newBackground.Preload(Game, delegate
|
||||
{
|
||||
Background oldBackground = background;
|
||||
float newDepth = 0;
|
||||
if (background != null)
|
||||
{
|
||||
newDepth = background.Depth - 1;
|
||||
background.Flush();
|
||||
background.FadeOut(250);
|
||||
background.Expire();
|
||||
}
|
||||
|
||||
newBackground.Depth = newDepth;
|
||||
Add(background = newBackground);
|
||||
background.BlurSigma = blurTarget;
|
||||
|
||||
if (oldBackground != null)
|
||||
{
|
||||
oldBackground.Depth = 1;
|
||||
oldBackground.Flush();
|
||||
oldBackground.FadeOut(250);
|
||||
oldBackground.Expire();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ namespace osu.Game.Screens.Select
|
||||
if (beatmap == null)
|
||||
return;
|
||||
|
||||
float newDepth = 0;
|
||||
if (beatmapInfoContainer != null)
|
||||
{
|
||||
Drawable oldWedgedBeatmapInfo = beatmapInfoContainer;
|
||||
oldWedgedBeatmapInfo.Depth = 1;
|
||||
oldWedgedBeatmapInfo.FadeOut(250);
|
||||
oldWedgedBeatmapInfo.Expire();
|
||||
newDepth = beatmapInfoContainer.Depth - 1;
|
||||
beatmapInfoContainer.FadeOut(250);
|
||||
beatmapInfoContainer.Expire();
|
||||
}
|
||||
|
||||
FadeIn(250);
|
||||
@ -34,6 +34,7 @@ namespace osu.Game.Screens.Select
|
||||
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
|
||||
Add(beatmapInfoContainer = new BufferedContainer
|
||||
{
|
||||
Depth = newDepth,
|
||||
PixelSnapping = true,
|
||||
CacheDrawnFrameBuffer = true,
|
||||
Shear = -Shear,
|
||||
|
@ -22,8 +22,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public BeatmapGroup SelectedGroup { get; private set; }
|
||||
public BeatmapPanel SelectedPanel { get; private set; }
|
||||
|
||||
private Cached yPositionsCached = new Cached();
|
||||
|
||||
private List<float> yPositions = new List<float>();
|
||||
|
||||
public CarouselContainer()
|
||||
@ -45,7 +44,7 @@ namespace osu.Game.Screens.Select
|
||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||
panels.Add(panel);
|
||||
|
||||
yPositionsCached.Invalidate();
|
||||
computeYPositions();
|
||||
}
|
||||
|
||||
private void movePanel(Panel panel, bool advance, ref float currentY)
|
||||
@ -57,7 +56,11 @@ namespace osu.Game.Screens.Select
|
||||
currentY += panel.DrawHeight + 5;
|
||||
}
|
||||
|
||||
private void computeYPositions()
|
||||
/// <summary>
|
||||
/// Computes the target Y positions for every panel in the carousel.
|
||||
/// </summary>
|
||||
/// <returns>The Y position of the currently selected panel.</returns>
|
||||
private float computeYPositions()
|
||||
{
|
||||
yPositions.Clear();
|
||||
|
||||
@ -92,7 +95,7 @@ namespace osu.Game.Screens.Select
|
||||
currentY += DrawHeight / 2;
|
||||
scrollableContent.Height = currentY;
|
||||
|
||||
ScrollTo(selectedY);
|
||||
return selectedY;
|
||||
}
|
||||
|
||||
public void SelectBeatmap(BeatmapInfo beatmap)
|
||||
@ -121,15 +124,8 @@ namespace osu.Game.Screens.Select
|
||||
panel.State = PanelSelectedState.Selected;
|
||||
SelectedPanel = panel;
|
||||
|
||||
yPositionsCached.Invalidate();
|
||||
}
|
||||
|
||||
protected override void UpdateLayout()
|
||||
{
|
||||
base.UpdateLayout();
|
||||
|
||||
if (!yPositionsCached.EnsureValid())
|
||||
yPositionsCached.Refresh(computeYPositions);
|
||||
float selectedY = computeYPositions();
|
||||
ScrollTo(selectedY);
|
||||
}
|
||||
|
||||
private static float offsetX(Panel panel, float dist, float halfHeight)
|
||||
@ -148,10 +144,11 @@ namespace osu.Game.Screens.Select
|
||||
if (panel.Hidden)
|
||||
return;
|
||||
|
||||
panel.Depth = index + (panel is BeatmapSetHeader ? panels.Count : 0);
|
||||
|
||||
if (!scrollableContent.Contains(panel))
|
||||
{
|
||||
panel.Depth = index + (panel is BeatmapSetHeader ? panels.Count : 0);
|
||||
scrollableContent.Add(panel);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
Loading…
Reference in New Issue
Block a user