From 8458622c4d4b82754004be7832e7e120309d16ee Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 29 Jul 2017 16:03:17 +0300 Subject: [PATCH 1/5] Add ScrollToSelected method --- osu.Game/Screens/Select/BeatmapCarousel.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 743a0a0f63..1177d820c3 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -281,6 +281,12 @@ public void Filter(FilterCriteria newCriteria = null, bool debounce = true) 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) @@ -420,8 +426,7 @@ private void selectGroup(BeatmapGroup group, BeatmapPanel panel = null, bool ani } finally { - float selectedY = computeYPositions(animated); - ScrollTo(selectedY, animated); + ScrollToSelected(animated); } } From e121b119be21d896b8754c43e5fdf3daf2433d0c Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 29 Jul 2017 17:33:20 +0300 Subject: [PATCH 2/5] Added "scroll to" container --- osu.Game/Screens/Select/SongSelect.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index bbd292870e..57e2183853 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -31,6 +31,7 @@ public abstract class SongSelect : OsuScreen private BeatmapManager manager; protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(); + private readonly ActionContainer actionContainer; private readonly BeatmapCarousel carousel; private DialogOverlay dialogOverlay; @@ -129,6 +130,12 @@ protected SongSelect() Right = left_area_padding, }, }); + Add(actionContainer = new ActionContainer + { + RelativeSizeAxes = Axes.Y, + Width = 250, + OnHoverAction = () => carousel.ScrollToSelected(), + }); if (ShowFooter) { @@ -409,5 +416,16 @@ protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) return base.OnKeyDown(state, args); } + + private class ActionContainer : Container + { + public Action OnHoverAction; + + protected override bool OnHover(InputState state) + { + OnHoverAction?.Invoke(); + return base.OnHover(state); + } + } } } From 6b3a81f5671b064e9ab067819f94a6c4ac675673 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 29 Jul 2017 17:42:32 +0300 Subject: [PATCH 3/5] Fix hard crash when pressing random if no beatmaps avaliable --- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 1177d820c3..9e5446a573 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -181,12 +181,12 @@ public void SelectNextRandom() if (groups.Count == 0) return; - randomSelectedBeatmaps.Push(new KeyValuePair(selectedGroup, selectedGroup.SelectedPanel)); - var visibleGroups = getVisibleGroups(); if (!visibleGroups.Any()) return; + randomSelectedBeatmaps.Push(new KeyValuePair(selectedGroup, selectedGroup.SelectedPanel)); + BeatmapGroup group; if (randomType == SelectionRandomType.RandomPermutation) From 62365090add453e1120d21090e100d605f3f7d01 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 29 Jul 2017 17:51:11 +0300 Subject: [PATCH 4/5] Removed useless variable --- osu.Game/Screens/Select/SongSelect.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 57e2183853..94740c0216 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -31,7 +31,6 @@ public abstract class SongSelect : OsuScreen private BeatmapManager manager; protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(); - private readonly ActionContainer actionContainer; private readonly BeatmapCarousel carousel; private DialogOverlay dialogOverlay; @@ -130,7 +129,7 @@ protected SongSelect() Right = left_area_padding, }, }); - Add(actionContainer = new ActionContainer + Add(new ActionContainer { RelativeSizeAxes = Axes.Y, Width = 250, From 700c7753c3d2096741aeefa9718506fb8a3196a9 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Mon, 31 Jul 2017 14:20:12 +0300 Subject: [PATCH 5/5] Applied suggestions --- osu.Game/Screens/Select/SongSelect.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 94740c0216..fd314e1559 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -129,11 +129,10 @@ protected SongSelect() Right = left_area_padding, }, }); - Add(new ActionContainer + Add(new ResetScrollContainer(() => carousel.ScrollToSelected()) { RelativeSizeAxes = Axes.Y, Width = 250, - OnHoverAction = () => carousel.ScrollToSelected(), }); if (ShowFooter) @@ -416,13 +415,18 @@ protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) return base.OnKeyDown(state, args); } - private class ActionContainer : Container + private class ResetScrollContainer : Container { - public Action OnHoverAction; + private readonly Action onHoverAction; + + public ResetScrollContainer(Action onHoverAction) + { + this.onHoverAction = onHoverAction; + } protected override bool OnHover(InputState state) { - OnHoverAction?.Invoke(); + onHoverAction?.Invoke(); return base.OnHover(state); } }