From 9b44f447caa984fb55de7d5cdbc713b4bf185e0b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Feb 2018 17:50:26 +0900 Subject: [PATCH 1/4] Fix song select iteration when all panels are filtered Resolves #2069. --- osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs | 6 ++++++ osu.Game/Screens/Select/BeatmapCarousel.cs | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs index 901d24e531..e50dc4b8fc 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs @@ -207,6 +207,12 @@ namespace osu.Game.Tests.Visual checkVisibleItemCount(true, 0); AddAssert("Selection is null", () => currentSelection == null); + advanceSelection(true); + AddAssert("Selection is null", () => currentSelection == null); + + advanceSelection(false); + AddAssert("Selection is null", () => currentSelection == null); + AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false)); AddAssert("Selection is non-null", () => currentSelection != null); diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 6a6042d7d4..3b837ffe7c 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -192,7 +192,9 @@ namespace osu.Game.Screens.Select /// Whether to skip individual difficulties and only increment over full groups. public void SelectNext(int direction = 1, bool skipDifficulties = true) { - if (!Items.Any()) + var visibleItems = Items.Where(s => !s.Item.Filtered).ToList(); + + if (!visibleItems.Any()) return; DrawableCarouselItem drawable = null; @@ -202,15 +204,15 @@ namespace osu.Game.Screens.Select // we can fix this by changing this method to not reference drawables / Items in the first place. return; - int originalIndex = Items.IndexOf(drawable); + int originalIndex = visibleItems.IndexOf(drawable); int currentIndex = originalIndex; // local function to increment the index in the required direction, wrapping over extremities. - int incrementIndex() => currentIndex = (currentIndex + direction + Items.Count) % Items.Count; + int incrementIndex() => currentIndex = (currentIndex + direction + visibleItems.Count) % visibleItems.Count; while (incrementIndex() != originalIndex) { - var item = Items[currentIndex].Item; + var item = visibleItems[currentIndex].Item; if (item.Filtered || item.State == CarouselItemState.Selected) continue; From 034875be47fb6cd9fdbb9ccc30bf3bb72fb5e2f3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Feb 2018 20:45:32 +0900 Subject: [PATCH 2/4] Fix bindings not being unbound on ModSelect Resolves #2018. Closes #2079. --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 8 ++++++++ osu.Game/Screens/Select/PlaySongSelect.cs | 16 ++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index d7268fb186..d0a507be98 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -65,6 +65,14 @@ namespace osu.Game.Overlays.Mods Ruleset.TriggerChange(); } + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + Ruleset.UnbindAll(); + SelectedMods.UnbindAll(); + } + private void selectedModsChanged(IEnumerable obj) { foreach (ModSection section in ModSectionsContainer.Children) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 739bc39269..71aa85b116 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -1,11 +1,13 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; using System.Linq; using OpenTK.Input; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Screens; @@ -47,13 +49,15 @@ namespace osu.Game.Screens.Select private SampleChannel sampleConfirm; + public readonly Bindable> SelectedMods = new Bindable>(new List()); + [BackgroundDependencyLoader(true)] private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame game) { - sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection"); + SelectedMods.BindTo(game.SelectedMods); + modSelect.SelectedMods.BindTo(SelectedMods); - if (game != null) - modSelect.SelectedMods.BindTo(game.SelectedMods); + sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection"); Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue); @@ -80,7 +84,7 @@ namespace osu.Game.Screens.Select { base.UpdateBeatmap(beatmap); - beatmap.Mods.BindTo(modSelect.SelectedMods); + beatmap.Mods.BindTo(SelectedMods); BeatmapDetails.Beatmap = beatmap; @@ -95,7 +99,7 @@ namespace osu.Game.Screens.Select if (removeAutoModOnResume) { var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType(); - modSelect.SelectedMods.Value = modSelect.SelectedMods.Value.Where(m => m.GetType() != autoType).ToArray(); + SelectedMods.Value = SelectedMods.Value.Where(m => m.GetType() != autoType).ToArray(); removeAutoModOnResume = false; } @@ -125,7 +129,7 @@ namespace osu.Game.Screens.Select if (Beatmap.Value.Track != null) Beatmap.Value.Track.Looping = false; - Beatmap.Value.Mods.UnbindBindings(); + SelectedMods.UnbindAll(); Beatmap.Value.Mods.Value = new Mod[] { }; return false; From 84a8fbe0b3a66194f5f46ea29b6d6f39cafa50b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Feb 2018 21:26:06 +0900 Subject: [PATCH 3/4] Fix null ref --- osu.Game/Screens/Select/PlaySongSelect.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 71aa85b116..c347bfe70f 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -52,9 +52,9 @@ namespace osu.Game.Screens.Select public readonly Bindable> SelectedMods = new Bindable>(new List()); [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame game) + private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame osu) { - SelectedMods.BindTo(game.SelectedMods); + if (osu != null) SelectedMods.BindTo(osu.SelectedMods); modSelect.SelectedMods.BindTo(SelectedMods); sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection"); From f64afc738dd3773e6081effba6376baf9dba1409 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Feb 2018 23:59:07 +0900 Subject: [PATCH 4/4] Fix incorrect exit block conditional Resolves #2130. --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 4954618ef9..b8d455a9c2 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -351,7 +351,7 @@ namespace osu.Game.Screens.Play protected override bool OnExiting(Screen next) { - if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused != false || RulesetContainer?.HasReplayLoaded != false) && (!pauseContainer?.IsResuming ?? false)) + if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused != false || RulesetContainer?.HasReplayLoaded != false) && (!pauseContainer?.IsResuming ?? true)) { // In the case of replays, we may have changed the playback rate. applyRateFromMods();