mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Merge pull request #1072 from EVAST9919/scroll_to_selected
Reset carousel position when mouse leaves the carousel area
This commit is contained in:
commit
ab4be26ec3
@ -187,12 +187,12 @@ namespace osu.Game.Screens.Select
|
||||
if (groups.Count == 0)
|
||||
return;
|
||||
|
||||
randomSelectedBeatmaps.Push(new KeyValuePair<BeatmapGroup, BeatmapPanel>(selectedGroup, selectedGroup.SelectedPanel));
|
||||
|
||||
var visibleGroups = getVisibleGroups();
|
||||
if (!visibleGroups.Any())
|
||||
return;
|
||||
|
||||
randomSelectedBeatmaps.Push(new KeyValuePair<BeatmapGroup, BeatmapPanel>(selectedGroup, selectedGroup.SelectedPanel));
|
||||
|
||||
BeatmapGroup group;
|
||||
|
||||
if (randomType == SelectionRandomType.RandomPermutation)
|
||||
@ -287,6 +287,12 @@ namespace osu.Game.Screens.Select
|
||||
perform();
|
||||
}
|
||||
|
||||
public void ScrollToSelected(bool animated = true)
|
||||
{
|
||||
float selectedY = computeYPositions(animated);
|
||||
ScrollTo(selectedY, animated);
|
||||
}
|
||||
|
||||
private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
foreach (var b in beatmapSet.Beatmaps)
|
||||
@ -426,8 +432,7 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
finally
|
||||
{
|
||||
float selectedY = computeYPositions(animated);
|
||||
ScrollTo(selectedY, animated);
|
||||
ScrollToSelected(animated);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,11 @@ namespace osu.Game.Screens.Select
|
||||
Right = left_area_padding,
|
||||
},
|
||||
});
|
||||
Add(new ResetScrollContainer(() => carousel.ScrollToSelected())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 250,
|
||||
});
|
||||
|
||||
if (ShowFooter)
|
||||
{
|
||||
@ -414,5 +419,21 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
private class ResetScrollContainer : Container
|
||||
{
|
||||
private readonly Action onHoverAction;
|
||||
|
||||
public ResetScrollContainer(Action onHoverAction)
|
||||
{
|
||||
this.onHoverAction = onHoverAction;
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
onHoverAction?.Invoke();
|
||||
return base.OnHover(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user