mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 19:22:58 +08:00
Simplify Y position computations and do not scroll to selected beatmap whenever Y positions are recomputed.
This commit is contained in:
parent
bd4ba32ebc
commit
3e4ff27865
@ -23,7 +23,6 @@ namespace osu.Game.Screens.Select
|
|||||||
public BeatmapGroup SelectedGroup { get; private set; }
|
public BeatmapGroup SelectedGroup { get; private set; }
|
||||||
public BeatmapPanel SelectedPanel { get; private set; }
|
public BeatmapPanel SelectedPanel { get; private set; }
|
||||||
|
|
||||||
private Cached yPositionsCached = new Cached();
|
|
||||||
private List<float> yPositions = new List<float>();
|
private List<float> yPositions = new List<float>();
|
||||||
|
|
||||||
public CarouselContainer()
|
public CarouselContainer()
|
||||||
@ -45,7 +44,7 @@ namespace osu.Game.Screens.Select
|
|||||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||||
panels.Add(panel);
|
panels.Add(panel);
|
||||||
|
|
||||||
yPositionsCached.Invalidate();
|
computeYPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void movePanel(Panel panel, bool advance, ref float currentY)
|
private void movePanel(Panel panel, bool advance, ref float currentY)
|
||||||
@ -57,7 +56,11 @@ namespace osu.Game.Screens.Select
|
|||||||
currentY += panel.DrawHeight + 5;
|
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();
|
yPositions.Clear();
|
||||||
|
|
||||||
@ -92,7 +95,7 @@ namespace osu.Game.Screens.Select
|
|||||||
currentY += DrawHeight / 2;
|
currentY += DrawHeight / 2;
|
||||||
scrollableContent.Height = currentY;
|
scrollableContent.Height = currentY;
|
||||||
|
|
||||||
ScrollTo(selectedY);
|
return selectedY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectBeatmap(BeatmapInfo beatmap)
|
public void SelectBeatmap(BeatmapInfo beatmap)
|
||||||
@ -121,15 +124,8 @@ namespace osu.Game.Screens.Select
|
|||||||
panel.State = PanelSelectedState.Selected;
|
panel.State = PanelSelectedState.Selected;
|
||||||
SelectedPanel = panel;
|
SelectedPanel = panel;
|
||||||
|
|
||||||
yPositionsCached.Invalidate();
|
float selectedY = computeYPositions();
|
||||||
}
|
ScrollTo(selectedY);
|
||||||
|
|
||||||
protected override void UpdateLayout()
|
|
||||||
{
|
|
||||||
base.UpdateLayout();
|
|
||||||
|
|
||||||
if (!yPositionsCached.EnsureValid())
|
|
||||||
yPositionsCached.Refresh(computeYPositions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float offsetX(Panel panel, float dist, float halfHeight)
|
private static float offsetX(Panel panel, float dist, float halfHeight)
|
||||||
|
Loading…
Reference in New Issue
Block a user