1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 13:33:03 +08:00

Merge pull request #11665 from smoogipoo/solo-mod-select-overlay

This commit is contained in:
Bartłomiej Dach 2021-02-03 22:18:36 +01:00 committed by GitHub
commit 8a176e32d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 21 deletions

View File

@ -306,7 +306,7 @@ namespace osu.Game.Tests.Visual.UserInterface
};
}
private class TestModSelectOverlay : ModSelectOverlay
private class TestModSelectOverlay : SoloModSelectOverlay
{
public new Bindable<IReadOnlyList<Mod>> SelectedMods => base.SelectedMods;

View File

@ -151,7 +151,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddUntilStep("wait for ready", () => modSelect.State.Value == Visibility.Visible && modSelect.ButtonsLoaded);
}
private class TestModSelectOverlay : ModSelectOverlay
private class TestModSelectOverlay : SoloModSelectOverlay
{
public new VisibilityContainer ModSettingsContainer => base.ModSettingsContainer;
public new TriangleButton CustomiseButton => base.CustomiseButton;

View File

@ -29,7 +29,7 @@ using osuTK.Input;
namespace osu.Game.Overlays.Mods
{
public class ModSelectOverlay : WaveOverlayContainer
public abstract class ModSelectOverlay : WaveOverlayContainer
{
public const float HEIGHT = 510;
@ -83,7 +83,7 @@ namespace osu.Game.Overlays.Mods
private SampleChannel sampleOn, sampleOff;
public ModSelectOverlay()
protected ModSelectOverlay()
{
Waves.FirstWaveColour = Color4Extensions.FromHex(@"19b0e2");
Waves.SecondWaveColour = Color4Extensions.FromHex(@"2280a2");
@ -366,19 +366,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();
@ -513,7 +500,7 @@ namespace osu.Game.Overlays.Mods
{
if (State.Value == Visibility.Visible) sampleOn?.Play();
deselectTypes(selectedMod.IncompatibleMods, true);
OnModSelected(selectedMod);
if (selectedMod.RequiresConfiguration) ModSettingsContainer.Show();
}
@ -525,6 +512,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();
/// <summary>

View File

@ -0,0 +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);
}
}
}

View File

@ -111,7 +111,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new PlayBeatmapDetailArea();
protected override ModSelectOverlay CreateModSelectOverlay() => new ModSelectOverlay { IsValidMod = isValidMod };
protected override ModSelectOverlay CreateModSelectOverlay() => new SoloModSelectOverlay { IsValidMod = isValidMod };
private bool isValidMod(Mod mod) => !(mod is ModAutoplay) && (mod as MultiMod)?.Mods.Any(mm => mm is ModAutoplay) != true;
}

View File

@ -81,7 +81,7 @@ namespace osu.Game.Screens.Select
item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy()));
}
protected override ModSelectOverlay CreateModSelectOverlay() => new ModSelectOverlay { IsValidMod = isValidMod };
protected override ModSelectOverlay CreateModSelectOverlay() => new SoloModSelectOverlay { IsValidMod = isValidMod };
private bool isValidMod(Mod mod) => !(mod is ModAutoplay) && (mod as MultiMod)?.Mods.Any(mm => mm is ModAutoplay) != true;
}

View File

@ -301,7 +301,7 @@ namespace osu.Game.Screens.Select
}
}
protected virtual ModSelectOverlay CreateModSelectOverlay() => new ModSelectOverlay();
protected virtual ModSelectOverlay CreateModSelectOverlay() => new SoloModSelectOverlay();
protected virtual void ApplyFilterToCarousel(FilterCriteria criteria)
{