From 2ef87205900b687df9e30926db1ce02d87075f43 Mon Sep 17 00:00:00 2001 From: jhk2601 Date: Thu, 17 Oct 2024 17:04:13 -0400 Subject: [PATCH] Adds logic to prioritize selecting exact mod acronyms when they are searched --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index cdc0fbbd96..30f50e7065 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -590,9 +590,16 @@ namespace osu.Game.Overlays.Mods return true; } + //matchingMod ensures that if an exact mod acronym is typed, it will be selected when Select is pressed (as opposed to being prioritized in arbitrary column order) ModState? firstMod = columnFlow.Columns.OfType().FirstOrDefault(m => m.IsPresent)?.AvailableMods.FirstOrDefault(x => x.Visible); + ModState? matchingMod = columnFlow.Columns.OfType().SelectMany(m => m.AvailableMods).FirstOrDefault(x => x.Mod.Acronym.Equals(SearchTerm, StringComparison.OrdinalIgnoreCase)); - if (firstMod is not null) + if (matchingMod is not null) + { + matchingMod.Active.Value = !matchingMod.Active.Value; + SearchTextBox.SelectAll(); + } + else if (firstMod is not null) { firstMod.Active.Value = !firstMod.Active.Value; SearchTextBox.SelectAll();