mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Abstractify ModSelectOverlay
This commit is contained in:
parent
0ff300628e
commit
91d34d86f7
@ -265,7 +265,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
private void checkLabelColor(Func<Color4> getColour) => AddAssert("check label has expected colour", () => modSelect.MultiplierLabel.Colour.AverageColour == getColour());
|
private void checkLabelColor(Func<Color4> getColour) => AddAssert("check label has expected colour", () => modSelect.MultiplierLabel.Colour.AverageColour == getColour());
|
||||||
|
|
||||||
private class TestModSelectOverlay : ModSelectOverlay
|
private class TestModSelectOverlay : SoloModSelectOverlay
|
||||||
{
|
{
|
||||||
public new Bindable<IReadOnlyList<Mod>> SelectedMods => base.SelectedMods;
|
public new Bindable<IReadOnlyList<Mod>> SelectedMods => base.SelectedMods;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ using osuTK.Input;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
public class ModSelectOverlay : WaveOverlayContainer
|
public abstract class ModSelectOverlay : WaveOverlayContainer
|
||||||
{
|
{
|
||||||
private readonly Func<Mod, bool> isValidMod;
|
private readonly Func<Mod, bool> isValidMod;
|
||||||
public const float HEIGHT = 510;
|
public const float HEIGHT = 510;
|
||||||
@ -60,7 +60,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private SampleChannel sampleOn, sampleOff;
|
private SampleChannel sampleOn, sampleOff;
|
||||||
|
|
||||||
public ModSelectOverlay(Func<Mod, bool> isValidMod = null)
|
protected ModSelectOverlay(Func<Mod, bool> isValidMod = null)
|
||||||
{
|
{
|
||||||
this.isValidMod = isValidMod ?? (m => true);
|
this.isValidMod = isValidMod ?? (m => true);
|
||||||
|
|
||||||
@ -346,19 +346,6 @@ namespace osu.Game.Overlays.Mods
|
|||||||
refreshSelectedMods();
|
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()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -458,7 +445,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
if (State.Value == Visibility.Visible) sampleOn?.Play();
|
if (State.Value == Visibility.Visible) sampleOn?.Play();
|
||||||
|
|
||||||
deselectTypes(selectedMod.IncompatibleMods, true);
|
OnModSelected(selectedMod);
|
||||||
|
|
||||||
if (selectedMod.RequiresConfiguration) ModSettingsContainer.Show();
|
if (selectedMod.RequiresConfiguration) ModSettingsContainer.Show();
|
||||||
}
|
}
|
||||||
@ -470,6 +457,10 @@ namespace osu.Game.Overlays.Mods
|
|||||||
refreshSelectedMods();
|
refreshSelectedMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void OnModSelected(Mod mod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
|
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
|
||||||
|
|
||||||
protected virtual ModSection CreateModSection(ModType type) => new ModSection(type);
|
protected virtual ModSection CreateModSection(ModType type) => new ModSection(type);
|
||||||
|
24
osu.Game/Overlays/Mods/SoloModSelectOverlay.cs
Normal file
24
osu.Game/Overlays/Mods/SoloModSelectOverlay.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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 System;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Mods
|
||||||
|
{
|
||||||
|
public class SoloModSelectOverlay : ModSelectOverlay
|
||||||
|
{
|
||||||
|
public SoloModSelectOverlay(Func<Mod, bool> isValidMod = null)
|
||||||
|
: base(isValidMod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModSelected(Mod mod)
|
||||||
|
{
|
||||||
|
base.OnModSelected(mod);
|
||||||
|
|
||||||
|
foreach (var section in ModSectionsContainer.Children)
|
||||||
|
section.DeselectTypes(mod.IncompatibleMods, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -81,7 +81,7 @@ namespace osu.Game.Screens.Select
|
|||||||
item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy()));
|
item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ModSelectOverlay CreateModSelectOverlay() => new ModSelectOverlay(isValidMod);
|
protected override ModSelectOverlay CreateModSelectOverlay() => new SoloModSelectOverlay(isValidMod);
|
||||||
|
|
||||||
private bool isValidMod(Mod mod) => !(mod is ModAutoplay) && (mod as MultiMod)?.Mods.Any(mm => mm is ModAutoplay) != true;
|
private bool isValidMod(Mod mod) => !(mod is ModAutoplay) && (mod as MultiMod)?.Mods.Any(mm => mm is ModAutoplay) != true;
|
||||||
}
|
}
|
||||||
|
@ -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)
|
protected virtual void ApplyFilterToCarousel(FilterCriteria criteria)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user