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

Add option to select all

This commit is contained in:
smoogipoo 2021-02-02 13:37:25 +09:00
parent 9c3c0895cf
commit 87f9e46b16
3 changed files with 53 additions and 8 deletions

View File

@ -91,7 +91,13 @@ namespace osu.Game.Overlays.Mods
return base.OnKeyDown(e);
}
public void DeselectAll() => DeselectTypes(buttons.Select(b => b.SelectedMod?.GetType()).Where(t => t != null));
public void SelectAll()
{
foreach (var button in buttons.Where(b => !b.Selected))
button.SelectAt(0);
}
public void DeselectAll(bool immediate = false) => DeselectTypes(buttons.Select(b => b.SelectedMod?.GetType()).Where(t => t != null), immediate);
/// <summary>
/// Deselect one or more mods in this section.

View File

@ -33,6 +33,7 @@ namespace osu.Game.Overlays.Mods
{
public const float HEIGHT = 510;
protected readonly FillFlowContainer FooterContainer;
protected readonly TriangleButton DeselectAllButton;
protected readonly TriangleButton CustomiseButton;
protected readonly TriangleButton CloseButton;
@ -85,8 +86,6 @@ namespace osu.Game.Overlays.Mods
private const float content_width = 0.8f;
private const float footer_button_spacing = 20;
private readonly FillFlowContainer footerContainer;
private SampleChannel sampleOn, sampleOff;
protected ModSelectOverlay()
@ -275,7 +274,7 @@ namespace osu.Game.Overlays.Mods
Colour = new Color4(172, 20, 116, 255),
Alpha = 0.5f,
},
footerContainer = new FillFlowContainer
FooterContainer = new FillFlowContainer
{
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
@ -385,8 +384,8 @@ namespace osu.Game.Overlays.Mods
{
base.PopOut();
footerContainer.MoveToX(content_width, WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
footerContainer.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
FooterContainer.MoveToX(content_width, WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
FooterContainer.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
foreach (var section in ModSectionsContainer.Children)
{
@ -400,8 +399,8 @@ namespace osu.Game.Overlays.Mods
{
base.PopIn();
footerContainer.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
footerContainer.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
FooterContainer.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
FooterContainer.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
foreach (var section in ModSectionsContainer.Children)
{

View File

@ -24,6 +24,46 @@ namespace osu.Game.Screens.OnlinePlay.Match
{
CustomiseButton.Alpha = 0;
MultiplierSection.Alpha = 0;
DeselectAllButton.Alpha = 0;
Drawable selectAllButton;
Drawable deselectAllButton;
FooterContainer.AddRange(new[]
{
selectAllButton = new TriangleButton
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Width = 180,
Text = "Select All",
Action = selectAll,
},
// Unlike the base mod select overlay, this button deselects mods instantaneously.
deselectAllButton = new TriangleButton
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Width = 180,
Text = "Deselect All",
Action = deselectAll,
},
});
FooterContainer.SetLayoutPosition(selectAllButton, -2);
FooterContainer.SetLayoutPosition(deselectAllButton, -1);
}
private void selectAll()
{
foreach (var section in ModSectionsContainer.Children)
section.SelectAll();
}
private void deselectAll()
{
foreach (var section in ModSectionsContainer.Children)
section.DeselectAll(true);
}
protected override ModSection CreateModSection(ModType type) => new FreeModSection(type);