From 4e65da0fd116a05f1ba6cd6a01bc8d7bd5eeb3f7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Apr 2017 22:17:35 +0900 Subject: [PATCH] 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). --- osu.Game/Screens/Select/BeatmapCarousel.cs | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index c2c5aca0de..3710880dfe 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -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)