mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 19:12:59 +08:00
Merge pull request #28095 from cdwcgt/preset-td-autoplay
Do not attempt to preserve incompatible system mods when activating mod presets
This commit is contained in:
commit
3e36412899
@ -123,6 +123,43 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
assertSelectedModsEquivalentTo(new Mod[] { new OsuModTouchDevice(), new OsuModHardRock(), new OsuModDoubleTime { SpeedChange = { Value = 1.5 } } });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSystemModsNotPreservedIfIncompatibleWithPresetMods()
|
||||
{
|
||||
ModPresetPanel? panel = null;
|
||||
|
||||
AddStep("create panel", () => Child = panel = new ModPresetPanel(new ModPreset
|
||||
{
|
||||
Name = "Autopilot included",
|
||||
Description = "no way",
|
||||
Mods = new Mod[]
|
||||
{
|
||||
new OsuModAutopilot()
|
||||
},
|
||||
Ruleset = new OsuRuleset().RulesetInfo
|
||||
}.ToLiveUnmanaged())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 0.5f
|
||||
});
|
||||
|
||||
AddStep("Add touch device to selected mods", () => SelectedMods.Value = new Mod[] { new OsuModTouchDevice() });
|
||||
AddStep("activate panel", () => panel.AsNonNull().TriggerClick());
|
||||
|
||||
// touch device should be removed due to incompatibility with autopilot.
|
||||
assertSelectedModsEquivalentTo(new Mod[] { new OsuModAutopilot() });
|
||||
|
||||
AddStep("deactivate panel", () => panel.AsNonNull().TriggerClick());
|
||||
assertSelectedModsEquivalentTo(Array.Empty<Mod>());
|
||||
|
||||
// just for test purposes, can't/shouldn't happen in reality
|
||||
AddStep("Add score v2 to selected mod", () => SelectedMods.Value = new Mod[] { new ModScoreV2() });
|
||||
AddStep("activate panel", () => panel.AsNonNull().TriggerClick());
|
||||
|
||||
assertSelectedModsEquivalentTo(new Mod[] { new OsuModAutopilot(), new ModScoreV2() });
|
||||
}
|
||||
|
||||
private void assertSelectedModsEquivalentTo(IEnumerable<Mod> mods)
|
||||
=> AddAssert("selected mods changed correctly", () => new HashSet<Mod>(SelectedMods.Value).SetEquals(mods));
|
||||
|
||||
|
@ -55,7 +55,12 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
protected override void Select()
|
||||
{
|
||||
var selectedSystemMods = selectedMods.Value.Where(mod => mod.Type == ModType.System);
|
||||
// this implicitly presumes that if a system mod declares incompatibility with a non-system mod,
|
||||
// the non-system mod should take precedence.
|
||||
// if this assumption is ever broken, this should be reconsidered.
|
||||
var selectedSystemMods = selectedMods.Value.Where(mod => mod.Type == ModType.System &&
|
||||
!mod.IncompatibleMods.Any(t => Preset.Value.Mods.Any(t.IsInstanceOfType)));
|
||||
|
||||
// will also have the side effect of activating the preset (see `updateActiveState()`).
|
||||
selectedMods.Value = Preset.Value.Mods.Concat(selectedSystemMods).ToArray();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user