From ddc1f03a96c40b17095cbdd97151d746fe74d70b Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Mon, 12 Mar 2018 22:35:45 +0100 Subject: [PATCH 1/4] deselect autoplay button after ctrl-enter play before, the mod was removed, but the button was still active --- osu.Game/Screens/Select/PlaySongSelect.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index c347bfe70f..495292a154 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -100,6 +100,7 @@ namespace osu.Game.Screens.Select { var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType(); SelectedMods.Value = SelectedMods.Value.Where(m => m.GetType() != autoType).ToArray(); + modSelect.DeselectTypes(new[] { autoType }, true); removeAutoModOnResume = false; } From 95c84ea7feb596e45e8cdf721c45c9cfe5515d4d Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Mon, 12 Mar 2018 23:00:06 +0100 Subject: [PATCH 2/4] remove (now) unnecessary line --- osu.Game/Screens/Select/PlaySongSelect.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 495292a154..09524d2eac 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -99,7 +99,6 @@ namespace osu.Game.Screens.Select if (removeAutoModOnResume) { var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType(); - SelectedMods.Value = SelectedMods.Value.Where(m => m.GetType() != autoType).ToArray(); modSelect.DeselectTypes(new[] { autoType }, true); removeAutoModOnResume = false; } From a438e45434502d7c239176b558d2baec228b4414 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Wed, 14 Mar 2018 12:33:08 +0100 Subject: [PATCH 3/4] make SelectTypes set mods instead of only adding new ones also made the method actually take types as parameter to make it consistent --- osu.Game/Overlays/Mods/ModSection.cs | 18 +++++++++--------- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 03c1f0468c..0986931d00 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -114,19 +114,19 @@ namespace osu.Game.Overlays.Mods } /// - /// Select one or more mods in this section. + /// Select one or more mods in this section and deselects all other ones. /// - /// The types of s which should be deselected. - public void SelectTypes(IEnumerable mods) + /// The types of s which should be selected. + public void SelectTypes(IEnumerable modTypes) { foreach (var button in buttons) { - for (int i = 0; i < button.Mods.Length; i++) - { - foreach (var mod in mods) - if (mod.GetType().IsInstanceOfType(button.Mods[i])) - button.SelectAt(i); - } + int i = Array.FindIndex(button.Mods, m => modTypes.Any(t => t.IsInstanceOfType(m))); + + if (i >= 0) + button.SelectAt(i); + else + button.Deselect(); } } diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index d0a507be98..cc4b354fa2 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -76,7 +76,7 @@ namespace osu.Game.Overlays.Mods private void selectedModsChanged(IEnumerable obj) { foreach (ModSection section in ModSectionsContainer.Children) - section.SelectTypes(obj); + section.SelectTypes(obj.Select(m => m.GetType()).ToList()); updateMods(); } From 070decf8902eb83025ba7ed2009fe3587649be5f Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Wed, 14 Mar 2018 12:38:22 +0100 Subject: [PATCH 4/4] small code cleanups --- osu.Game/Overlays/Mods/ModSection.cs | 31 ++++++++++------------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 0986931d00..4765787caf 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -27,14 +27,8 @@ namespace osu.Game.Overlays.Mods public string Header { - get - { - return headerLabel.Text; - } - set - { - headerLabel.Text = value; - } + get => headerLabel.Text; + set => headerLabel.Text = value; } public IEnumerable SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null); @@ -47,12 +41,12 @@ namespace osu.Game.Overlays.Mods { if (m == null) return new ModButtonEmpty(); - else - return new ModButton(m) - { - SelectedColour = selectedColour, - SelectionChanged = Action, - }; + + return new ModButton(m) + { + SelectedColour = selectedColour, + SelectionChanged = Action, + }; }).ToArray(); ButtonsContainer.Children = modContainers; @@ -65,10 +59,7 @@ namespace osu.Game.Overlays.Mods private Color4 selectedColour = Color4.White; public Color4 SelectedColour { - get - { - return selectedColour; - } + get => selectedColour; set { if (value == selectedColour) return; @@ -102,13 +93,13 @@ namespace osu.Game.Overlays.Mods { Mod selected = button.SelectedMod; if (selected == null) continue; - foreach (Type type in modTypes) + foreach (var type in modTypes) if (type.IsInstanceOfType(selected)) { if (immediate) button.Deselect(); else - Scheduler.AddDelayed(() => button.Deselect(), delay += 50); + Scheduler.AddDelayed(button.Deselect, delay += 50); } } }