From 64e96c6d82772e19a4a8cc8733ef8a560eeb5ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 18 Jun 2023 14:03:26 +0200 Subject: [PATCH] Fix duplicate linq and reword comment --- osu.Game/Overlays/Mods/ModColumn.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModColumn.cs b/osu.Game/Overlays/Mods/ModColumn.cs index 0845edf7f8..60c1282a65 100644 --- a/osu.Game/Overlays/Mods/ModColumn.cs +++ b/osu.Game/Overlays/Mods/ModColumn.cs @@ -150,10 +150,12 @@ namespace osu.Game.Overlays.Mods if (toggleAllCheckbox != null && !SelectionAnimationRunning) { - toggleAllCheckbox.Alpha = availableMods.Any(panel => panel.Visible) ? 1 : 0; + bool anyPanelsVisible = availableMods.Any(panel => panel.Visible); - //Prevent checkbox from checking when column have on valid panels - if (availableMods.Any(panel => panel.Visible)) + toggleAllCheckbox.Alpha = anyPanelsVisible ? 1 : 0; + + // checking `anyPanelsVisible` is important since `.All()` returns `true` for empty enumerables. + if (anyPanelsVisible) toggleAllCheckbox.Current.Value = availableMods.Where(panel => panel.Visible).All(panel => panel.Active.Value); } }