mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
Add button colouring whilst corresponding overlay is present
This commit is contained in:
parent
ea882f6874
commit
c5bad816db
@ -3,8 +3,12 @@
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Screens.Select.FooterV2;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
@ -14,10 +18,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
public partial class TestSceneSongSelectFooterV2 : OsuManualInputManagerTestScene
|
||||
{
|
||||
private FooterButtonRandomV2 randomButton = null!;
|
||||
private FooterButtonModsV2 modsButton = null!;
|
||||
|
||||
private bool nextRandomCalled;
|
||||
private bool previousRandomCalled;
|
||||
|
||||
private DummyOverlay overlay = null!;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
@ -26,13 +33,17 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
FooterV2 footer;
|
||||
|
||||
Child = footer = new FooterV2
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
footer = new FooterV2
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
overlay = new DummyOverlay()
|
||||
};
|
||||
|
||||
footer.AddButton(new FooterButtonModsV2());
|
||||
footer.AddButton(modsButton = new FooterButtonModsV2(), overlay);
|
||||
footer.AddButton(randomButton = new FooterButtonRandomV2
|
||||
{
|
||||
NextRandom = () => nextRandomCalled = true,
|
||||
@ -41,6 +52,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
footer.AddButton(new FooterButtonOptionsV2());
|
||||
|
||||
InputManager.MoveMouseTo(Vector2.Zero);
|
||||
|
||||
overlay.Hide();
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -103,5 +116,31 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
});
|
||||
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOverlayPresent()
|
||||
{
|
||||
AddStep("Press F1", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(modsButton);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddAssert("Overlay visible", () => overlay.State.Value == Visibility.Visible);
|
||||
AddStep("Hide", () => overlay.Hide());
|
||||
}
|
||||
|
||||
private partial class DummyOverlay : ShearedOverlayContainer
|
||||
{
|
||||
public DummyOverlay()
|
||||
: base(OverlayColourScheme.Green)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Header.Title = "An overlay";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -25,9 +26,12 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
private const int button_height = 120;
|
||||
private const int button_width = 140;
|
||||
private const int corner_radius = 10;
|
||||
private const int transition_length = 500;
|
||||
|
||||
public const float SHEAR_WIDTH = 16;
|
||||
|
||||
public Bindable<Visibility> OverlayState = new Bindable<Visibility>();
|
||||
|
||||
protected static readonly Vector2 SHEAR = new Vector2(SHEAR_WIDTH / button_height, 0);
|
||||
|
||||
[Cached]
|
||||
@ -133,6 +137,7 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
{
|
||||
base.LoadComplete();
|
||||
Enabled.BindValueChanged(_ => updateDisplay(), true);
|
||||
OverlayState.BindValueChanged(_ => updateDisplay());
|
||||
}
|
||||
|
||||
public GlobalAction? Hotkey;
|
||||
@ -185,12 +190,23 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
{
|
||||
if (!Enabled.Value)
|
||||
{
|
||||
backGroundBox.FadeColour(colourProvider.Background3.Darken(.3f));
|
||||
backGroundBox.FadeColour(colourProvider.Background3.Darken(0.3f), transition_length, Easing.OutQuint);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (OverlayState.Value)
|
||||
{
|
||||
case Visibility.Visible:
|
||||
backGroundBox.FadeColour(buttonAccentColour.Darken(0.5f), transition_length, Easing.OutQuint);
|
||||
return;
|
||||
|
||||
case Visibility.Hidden:
|
||||
backGroundBox.FadeColour(buttonAccentColour, transition_length, Easing.OutQuint);
|
||||
break;
|
||||
}
|
||||
|
||||
//Hover logic.
|
||||
backGroundBox.FadeColour(isHovered && Enabled.Value ? colourProvider.Background3.Lighten(.3f) : colourProvider.Background3, 500, Easing.OutQuint);
|
||||
backGroundBox.FadeColour(isHovered && Enabled.Value ? colourProvider.Background3.Lighten(.3f) : colourProvider.Background3, transition_length, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
{
|
||||
overlays.Add(overlay);
|
||||
button.Action = () => showOverlay(overlay);
|
||||
button.OverlayState.BindTo(overlay.State);
|
||||
}
|
||||
|
||||
buttons.Add(button);
|
||||
|
Loading…
Reference in New Issue
Block a user