Fix regression in panel select animation.

Currently we are required to update computeYPositions twice per selection. Without doing this, panels are in the wrong place when using keyboard selection.

There's still a bit of work to be done to make this work correctly. It's caused by a race condition of state application for panels which have not yet been presented (and get their state applied in LoadComplete which breaks the order of things).
This commit is contained in:
Dean Herbert 2017-04-28 22:17:35 +09:00
parent 70e81115f4
commit 4e65da0fd1

View File

@ -328,25 +328,31 @@ namespace osu.Game.Screens.Select
private void selectGroup(BeatmapGroup group, BeatmapPanel panel = null, bool animated = true)
{
if (panel == null)
panel = group.BeatmapPanels.First();
try
{
if (panel == null)
panel = group.BeatmapPanels.First();
if (selectedPanel == panel) return;
if (selectedPanel == panel) return;
Trace.Assert(group.BeatmapPanels.Contains(panel), @"Selected panel must be in provided group");
Trace.Assert(group.BeatmapPanels.Contains(panel), @"Selected panel must be in provided group");
if (selectedGroup != null && selectedGroup != group && selectedGroup.State != BeatmapGroupState.Hidden)
selectedGroup.State = BeatmapGroupState.Collapsed;
if (selectedGroup != null && selectedGroup != group && selectedGroup.State != BeatmapGroupState.Hidden)
selectedGroup.State = BeatmapGroupState.Collapsed;
group.State = BeatmapGroupState.Expanded;
selectedGroup = group;
panel.State = PanelSelectedState.Selected;
selectedPanel = panel;
group.State = BeatmapGroupState.Expanded;
panel.State = PanelSelectedState.Selected;
float selectedY = computeYPositions(animated);
ScrollTo(selectedY, animated);
selectedPanel = panel;
selectedGroup = group;
SelectionChanged?.Invoke(panel.Beatmap);
SelectionChanged?.Invoke(panel.Beatmap);
}
finally
{
float selectedY = computeYPositions(animated);
ScrollTo(selectedY, animated);
}
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)