1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-13 19:54:15 +08:00

Merge pull request #32606 from smoogipoo/fix-mod-overlay-panel-refresh

Refresh mod panel active states when recreated
This commit is contained in:
Bartłomiej Dach
2025-03-27 12:07:35 +01:00
committed by GitHub
Unverified
2 changed files with 32 additions and 0 deletions
@@ -1003,6 +1003,35 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("search still not focused", () => !this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
}
/// <summary>
/// Tests that recreating the mod panels (by setting the global available mods) also refreshes the active states.
/// </summary>
[Test]
public void TestActiveStatesRefreshedOnPanelsCreated()
{
createScreen();
changeRuleset(0);
Bindable<IReadOnlyList<Mod>> selectedMods = null!;
AddStep("bind mods to local bindable", () =>
{
selectedMods = new Bindable<IReadOnlyList<Mod>>([]);
modSelectOverlay.SelectedMods.UnbindFrom(SelectedMods);
modSelectOverlay.SelectedMods.BindTo(selectedMods);
});
AddStep("activate PF", () => selectedMods.Value = [new OsuModPerfect()]);
AddAssert("OsuModPerfect panel active", () => getPanelForMod(typeof(OsuModPerfect)).Active.Value);
changeRuleset(1);
AddAssert("TaikoModPerfect panel not active", () => !getPanelForMod(typeof(TaikoModPerfect)).Active.Value);
changeRuleset(0);
AddAssert("OsuModPerfect panel active", () => getPanelForMod(typeof(OsuModPerfect)).Active.Value);
}
private void waitForColumnLoad() => AddUntilStep("all column content loaded", () =>
modSelectOverlay.ChildrenOfType<ModColumn>().Any()
&& modSelectOverlay.ChildrenOfType<ModColumn>().All(column => column.IsLoaded && column.ItemsLoaded)
@@ -353,7 +353,10 @@ namespace osu.Game.Overlays.Mods
.ToArray();
foreach (var modState in modStates)
{
modState.Active.Value = SelectedMods.Value.Any(selected => selected.GetType() == modState.Mod.GetType());
modState.Active.BindValueChanged(_ => updateFromInternalSelection());
}
newLocalAvailableMods[modType] = modStates;
}