1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 12:27:26 +08:00

Adds logic to prioritize selecting exact mod acronyms when they are searched

This commit is contained in:
jhk2601 2024-10-17 17:04:13 -04:00
parent bfad281f62
commit 2ef8720590

View File

@ -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<ModColumn>().FirstOrDefault(m => m.IsPresent)?.AvailableMods.FirstOrDefault(x => x.Visible);
ModState? matchingMod = columnFlow.Columns.OfType<ModColumn>().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();