mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 20:12:56 +08:00
Add preset column to mod select test scene
This commit is contained in:
parent
adeabc632b
commit
5ff2e41a55
@ -1,14 +1,13 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
@ -29,10 +28,18 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneModSelectOverlay : OsuManualInputManagerTestScene
|
public class TestSceneModSelectOverlay : OsuManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
[Resolved]
|
protected override bool UseFreshStoragePerRun => true;
|
||||||
private RulesetStore rulesetStore { get; set; }
|
|
||||||
|
|
||||||
private UserModSelectOverlay modSelectOverlay;
|
private RulesetStore rulesetStore = null!;
|
||||||
|
|
||||||
|
private TestModSelectOverlay modSelectOverlay = null!;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Dependencies.Cache(rulesetStore = new RealmRulesetStore(Realm));
|
||||||
|
Dependencies.Cache(Realm);
|
||||||
|
}
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetUpSteps()
|
public void SetUpSteps()
|
||||||
@ -44,7 +51,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
private void createScreen()
|
private void createScreen()
|
||||||
{
|
{
|
||||||
AddStep("create screen", () => Child = modSelectOverlay = new UserModSelectOverlay
|
AddStep("create screen", () => Child = modSelectOverlay = new TestModSelectOverlay
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
State = { Value = Visibility.Visible },
|
State = { Value = Visibility.Visible },
|
||||||
@ -137,7 +144,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
AddUntilStep("any column dimmed", () => this.ChildrenOfType<ModColumn>().Any(column => !column.Active.Value));
|
AddUntilStep("any column dimmed", () => this.ChildrenOfType<ModColumn>().Any(column => !column.Active.Value));
|
||||||
|
|
||||||
ModSelectColumn lastColumn = null;
|
ModSelectColumn lastColumn = null!;
|
||||||
|
|
||||||
AddAssert("last column dimmed", () => !this.ChildrenOfType<ModColumn>().Last().Active.Value);
|
AddAssert("last column dimmed", () => !this.ChildrenOfType<ModColumn>().Last().Active.Value);
|
||||||
AddStep("request scroll to last column", () =>
|
AddStep("request scroll to last column", () =>
|
||||||
@ -170,7 +177,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
AddStep("dismiss mod customisation via toggle", () =>
|
AddStep("dismiss mod customisation via toggle", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType<ShearedToggleButton>().Single());
|
InputManager.MoveMouseTo(modSelectOverlay.CustomisationButton);
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
assertCustomisationToggleState(disabled: false, active: false);
|
assertCustomisationToggleState(disabled: false, active: false);
|
||||||
@ -224,8 +231,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestSettingsNotCrossPolluting()
|
public void TestSettingsNotCrossPolluting()
|
||||||
{
|
{
|
||||||
Bindable<IReadOnlyList<Mod>> selectedMods2 = null;
|
Bindable<IReadOnlyList<Mod>> selectedMods2 = null!;
|
||||||
ModSelectOverlay modSelectOverlay2 = null;
|
ModSelectOverlay modSelectOverlay2 = null!;
|
||||||
|
|
||||||
createScreen();
|
createScreen();
|
||||||
AddStep("select diff adjust", () => SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() });
|
AddStep("select diff adjust", () => SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() });
|
||||||
@ -353,7 +360,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
public void TestExternallySetModIsReplacedByOverlayInstance()
|
public void TestExternallySetModIsReplacedByOverlayInstance()
|
||||||
{
|
{
|
||||||
Mod external = new OsuModDoubleTime();
|
Mod external = new OsuModDoubleTime();
|
||||||
Mod overlayButtonMod = null;
|
Mod overlayButtonMod = null!;
|
||||||
|
|
||||||
createScreen();
|
createScreen();
|
||||||
changeRuleset(0);
|
changeRuleset(0);
|
||||||
@ -460,12 +467,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
AddStep("select difficulty adjust", () => SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() });
|
AddStep("select difficulty adjust", () => SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() });
|
||||||
assertCustomisationToggleState(disabled: false, active: true);
|
assertCustomisationToggleState(disabled: false, active: true);
|
||||||
AddAssert("back button disabled", () => !this.ChildrenOfType<ShearedButton>().First().Enabled.Value);
|
AddAssert("back button disabled", () => !modSelectOverlay.BackButton.Enabled.Value);
|
||||||
|
|
||||||
AddStep("dismiss customisation area", () => InputManager.Key(Key.Escape));
|
AddStep("dismiss customisation area", () => InputManager.Key(Key.Escape));
|
||||||
AddStep("click back button", () =>
|
AddStep("click back button", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(this.ChildrenOfType<ShearedButton>().First());
|
InputManager.MoveMouseTo(modSelectOverlay.BackButton);
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
AddAssert("mod select hidden", () => modSelectOverlay.State.Value == Visibility.Hidden);
|
AddAssert("mod select hidden", () => modSelectOverlay.State.Value == Visibility.Hidden);
|
||||||
@ -474,7 +481,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestColumnHiding()
|
public void TestColumnHiding()
|
||||||
{
|
{
|
||||||
AddStep("create screen", () => Child = modSelectOverlay = new UserModSelectOverlay
|
AddStep("create screen", () => Child = modSelectOverlay = new TestModSelectOverlay
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
State = { Value = Visibility.Visible },
|
State = { Value = Visibility.Visible },
|
||||||
@ -527,15 +534,21 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
private void assertCustomisationToggleState(bool disabled, bool active)
|
private void assertCustomisationToggleState(bool disabled, bool active)
|
||||||
{
|
{
|
||||||
ShearedToggleButton getToggle() => modSelectOverlay.ChildrenOfType<ShearedToggleButton>().Single();
|
AddAssert($"customisation toggle is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.CustomisationButton.AsNonNull().Active.Disabled == disabled);
|
||||||
|
AddAssert($"customisation toggle is {(active ? "" : "not ")}active", () => modSelectOverlay.CustomisationButton.AsNonNull().Active.Value == active);
|
||||||
AddAssert($"customisation toggle is {(disabled ? "" : "not ")}disabled", () => getToggle().Active.Disabled == disabled);
|
|
||||||
AddAssert($"customisation toggle is {(active ? "" : "not ")}active", () => getToggle().Active.Value == active);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ModPanel getPanelForMod(Type modType)
|
private ModPanel getPanelForMod(Type modType)
|
||||||
=> modSelectOverlay.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.GetType() == modType);
|
=> modSelectOverlay.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.GetType() == modType);
|
||||||
|
|
||||||
|
private class TestModSelectOverlay : UserModSelectOverlay
|
||||||
|
{
|
||||||
|
protected override bool ShowPresets => true;
|
||||||
|
|
||||||
|
public new ShearedButton BackButton => base.BackButton;
|
||||||
|
public new ShearedToggleButton? CustomisationButton => base.CustomisationButton;
|
||||||
|
}
|
||||||
|
|
||||||
private class TestUnimplementedMod : Mod
|
private class TestUnimplementedMod : Mod
|
||||||
{
|
{
|
||||||
public override string Name => "Unimplemented mod";
|
public override string Name => "Unimplemented mod";
|
||||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
if (AllowCustomisation)
|
if (AllowCustomisation)
|
||||||
{
|
{
|
||||||
yield return customisationButton = new ShearedToggleButton(BUTTON_WIDTH)
|
yield return CustomisationButton = new ShearedToggleButton(BUTTON_WIDTH)
|
||||||
{
|
{
|
||||||
Text = ModSelectOverlayStrings.ModCustomisation,
|
Text = ModSelectOverlayStrings.ModCustomisation,
|
||||||
Active = { BindTarget = customisationVisible }
|
Active = { BindTarget = customisationVisible }
|
||||||
@ -107,11 +107,11 @@ namespace osu.Game.Overlays.Mods
|
|||||||
private ColumnScrollContainer columnScroll = null!;
|
private ColumnScrollContainer columnScroll = null!;
|
||||||
private ColumnFlowContainer columnFlow = null!;
|
private ColumnFlowContainer columnFlow = null!;
|
||||||
private FillFlowContainer<ShearedButton> footerButtonFlow = null!;
|
private FillFlowContainer<ShearedButton> footerButtonFlow = null!;
|
||||||
private ShearedButton backButton = null!;
|
|
||||||
|
|
||||||
private DifficultyMultiplierDisplay? multiplierDisplay;
|
private DifficultyMultiplierDisplay? multiplierDisplay;
|
||||||
|
|
||||||
private ShearedToggleButton? customisationButton;
|
protected ShearedButton BackButton { get; private set; } = null!;
|
||||||
|
protected ShearedToggleButton? CustomisationButton { get; private set; }
|
||||||
|
|
||||||
private Sample? columnAppearSample;
|
private Sample? columnAppearSample;
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Horizontal = 70
|
Horizontal = 70
|
||||||
},
|
},
|
||||||
Spacing = new Vector2(10),
|
Spacing = new Vector2(10),
|
||||||
ChildrenEnumerable = CreateFooterButtons().Prepend(backButton = new ShearedButton(BUTTON_WIDTH)
|
ChildrenEnumerable = CreateFooterButtons().Prepend(BackButton = new ShearedButton(BUTTON_WIDTH)
|
||||||
{
|
{
|
||||||
Text = CommonStrings.Back,
|
Text = CommonStrings.Back,
|
||||||
Action = Hide,
|
Action = Hide,
|
||||||
@ -358,7 +358,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private void updateCustomisation(ValueChangedEvent<IReadOnlyList<Mod>> valueChangedEvent)
|
private void updateCustomisation(ValueChangedEvent<IReadOnlyList<Mod>> valueChangedEvent)
|
||||||
{
|
{
|
||||||
if (customisationButton == null)
|
if (CustomisationButton == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool anyCustomisableMod = false;
|
bool anyCustomisableMod = false;
|
||||||
@ -394,7 +394,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
foreach (var button in footerButtonFlow)
|
foreach (var button in footerButtonFlow)
|
||||||
{
|
{
|
||||||
if (button != customisationButton)
|
if (button != CustomisationButton)
|
||||||
button.Enabled.Value = !customisationVisible.Value;
|
button.Enabled.Value = !customisationVisible.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,14 +587,14 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
if (customisationVisible.Value)
|
if (customisationVisible.Value)
|
||||||
{
|
{
|
||||||
Debug.Assert(customisationButton != null);
|
Debug.Assert(CustomisationButton != null);
|
||||||
customisationButton.TriggerClick();
|
CustomisationButton.TriggerClick();
|
||||||
|
|
||||||
if (!immediate)
|
if (!immediate)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
backButton.TriggerClick();
|
BackButton.TriggerClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,7 +928,7 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SoloModSelectOverlay : UserModSelectOverlay
|
internal class SoloModSelectOverlay : UserModSelectOverlay
|
||||||
{
|
{
|
||||||
protected override bool ShowPresets => true;
|
protected override bool ShowPresets => true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user