Move incompatible mod deselection to SoloModOverlay

This commit is contained in:
smoogipoo 2021-02-02 21:06:32 +09:00
parent e58ece9e10
commit 728f8599b2
2 changed files with 18 additions and 14 deletions

View File

@ -349,19 +349,6 @@ namespace osu.Game.Overlays.Mods
refreshSelectedMods();
}
/// <summary>
/// Deselect one or more mods.
/// </summary>
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be deselected.</param>
/// <param name="immediate">Set to true to bypass animations and update selections immediately.</param>
private void deselectTypes(Type[] modTypes, bool immediate = false)
{
if (modTypes.Length == 0) return;
foreach (var section in ModSectionsContainer.Children)
section.DeselectTypes(modTypes, immediate);
}
protected override void LoadComplete()
{
base.LoadComplete();
@ -496,7 +483,7 @@ namespace osu.Game.Overlays.Mods
{
if (State.Value == Visibility.Visible) sampleOn?.Play();
deselectTypes(selectedMod.IncompatibleMods, true);
OnModSelected(selectedMod);
if (selectedMod.RequiresConfiguration) ModSettingsContainer.Show();
}
@ -508,6 +495,14 @@ namespace osu.Game.Overlays.Mods
refreshSelectedMods();
}
/// <summary>
/// Invoked when a new <see cref="Mod"/> has been selected.
/// </summary>
/// <param name="mod">The <see cref="Mod"/> that has been selected.</param>
protected virtual void OnModSelected(Mod mod)
{
}
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
#region Disposal

View File

@ -1,9 +1,18 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Mods;
namespace osu.Game.Overlays.Mods
{
public class SoloModSelectOverlay : ModSelectOverlay
{
protected override void OnModSelected(Mod mod)
{
base.OnModSelected(mod);
foreach (var section in ModSectionsContainer.Children)
section.DeselectTypes(mod.IncompatibleMods, true);
}
}
}