From 81d67cbe06381b596b48263f686c675eb7f6f1b3 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 5 May 2017 01:59:24 -0300 Subject: [PATCH 1/3] Play first visible set in playlist when commiting in the search field. --- osu.Game/Overlays/Music/FilterControl.cs | 1 + osu.Game/Overlays/Music/PlaylistItem.cs | 4 ++++ osu.Game/Overlays/Music/PlaylistList.cs | 2 ++ osu.Game/Overlays/Music/PlaylistOverlay.cs | 5 +++++ osu.Game/Screens/Select/SearchTextBox.cs | 7 ++++++- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/FilterControl.cs b/osu.Game/Overlays/Music/FilterControl.cs index c6572c5ed2..5b528b7e89 100644 --- a/osu.Game/Overlays/Music/FilterControl.cs +++ b/osu.Game/Overlays/Music/FilterControl.cs @@ -62,6 +62,7 @@ namespace osu.Game.Overlays.Music protected override Color4 BackgroundUnfocused => backgroundColour; protected override Color4 BackgroundFocused => backgroundColour; + protected override bool AllowCommit => true; public FilterTextBox() { diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index da31e94e22..c2413956b4 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -132,6 +132,10 @@ namespace osu.Game.Overlays.Music FadeTo(matching ? 1 : 0, 200); } + get + { + return matching; + } } } } diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index c7909f1a63..ffe59a9d93 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -22,6 +22,8 @@ namespace osu.Game.Overlays.Music } } + public BeatmapSetInfo FirstVisibleSet => items.Children.FirstOrDefault(i => i.MatchingCurrentFilter)?.BeatmapSetInfo; + private void itemSelected(BeatmapSetInfo b) { OnSelect?.Invoke(b); diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 92b8addd97..00d66053a7 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -84,6 +84,11 @@ namespace osu.Game.Overlays.Music list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren().ToList(); beatmapBacking.BindTo(game.Beatmap); + + filter.Search.OnCommit = delegate { + var beatmap = list.FirstVisibleSet?.Beatmaps?.ValueAtOrDefault(0); + if (beatmap != null) playSpecified(beatmap); + }; } protected override void LoadComplete() diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index 4f2ab221cb..743b1fc5c7 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -15,6 +15,8 @@ namespace osu.Game.Screens.Select /// public class SearchTextBox : FocusedTextBox { + protected virtual bool AllowCommit => false; + public SearchTextBox() { Height = 35; @@ -45,8 +47,11 @@ namespace osu.Game.Screens.Select case Key.Right: case Key.Up: case Key.Down: - case Key.Enter: return false; + + case Key.Enter: + if (!AllowCommit) return false; + break; } } From de8428c95bf09b7323e9e12af99bca15ed7afb65 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 7 May 2017 22:23:33 -0300 Subject: [PATCH 2/3] Make requested changes --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 2 +- osu.Game/Screens/Select/SearchTextBox.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 00d66053a7..0cae9db2e6 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -85,7 +85,7 @@ namespace osu.Game.Overlays.Music beatmapBacking.BindTo(game.Beatmap); - filter.Search.OnCommit = delegate { + filter.Search.OnCommit = (sender, newText) => { var beatmap = list.FirstVisibleSet?.Beatmaps?.ValueAtOrDefault(0); if (beatmap != null) playSpecified(beatmap); }; diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index 743b1fc5c7..d451f63a96 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -48,7 +48,6 @@ namespace osu.Game.Screens.Select case Key.Up: case Key.Down: return false; - case Key.Enter: if (!AllowCommit) return false; break; From fd9218b6d541795038c9311415523fbdac88837e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 May 2017 20:48:25 +0900 Subject: [PATCH 3/3] Use FirstOrDefault --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 0cae9db2e6..eb5dff57b3 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -86,7 +86,7 @@ namespace osu.Game.Overlays.Music beatmapBacking.BindTo(game.Beatmap); filter.Search.OnCommit = (sender, newText) => { - var beatmap = list.FirstVisibleSet?.Beatmaps?.ValueAtOrDefault(0); + var beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault(); if (beatmap != null) playSpecified(beatmap); }; }