1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:43:04 +08:00

Adjust footer button colour handling to read better and take into account mouse down

This commit is contained in:
Dean Herbert 2023-02-03 16:24:19 +09:00
parent 80fd1a0bc7
commit a1200b8fe8
2 changed files with 33 additions and 17 deletions

View File

@ -10,7 +10,6 @@ using osu.Framework.Testing;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Screens.Select.FooterV2;
using osuTK;
using osuTK.Input;
namespace osu.Game.Tests.Visual.SongSelect
@ -51,15 +50,13 @@ namespace osu.Game.Tests.Visual.SongSelect
});
footer.AddButton(new FooterButtonOptionsV2());
InputManager.MoveMouseTo(Vector2.Zero);
overlay.Hide();
});
[Test]
public void TestState()
{
AddRepeatStep("toggle options state", () => this.ChildrenOfType<FooterButtonV2>().Last().Enabled.Toggle(), 20);
AddToggleStep("set options enabled state", state => this.ChildrenOfType<FooterButtonV2>().Last().Enabled.Value = state);
}
[Test]

View File

@ -18,6 +18,7 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Select.FooterV2
{
@ -148,12 +149,28 @@ namespace osu.Game.Screens.Select.FooterV2
public GlobalAction? Hotkey;
private bool handlingMouse;
protected override bool OnHover(HoverEvent e)
{
updateDisplay();
return true;
}
protected override bool OnMouseDown(MouseDownEvent e)
{
handlingMouse = true;
updateDisplay();
return base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseUpEvent e)
{
handlingMouse = false;
updateDisplay();
base.OnMouseUp(e);
}
protected override void OnHoverLost(HoverLostEvent e) => updateDisplay();
public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
@ -168,25 +185,27 @@ namespace osu.Game.Screens.Select.FooterV2
private void updateDisplay()
{
Color4 backgroundColour = colourProvider.Background3;
if (!Enabled.Value)
{
backgroundBox.FadeColour(colourProvider.Background3.Darken(0.3f), transition_length, Easing.OutQuint);
return;
backgroundColour = colourProvider.Background3.Darken(0.4f);
}
if (OverlayState.Value == Visibility.Visible)
else
{
backgroundBox.FadeColour(buttonAccentColour.Darken(0.5f), transition_length, Easing.OutQuint);
return;
}
if (OverlayState.Value == Visibility.Visible)
backgroundColour = buttonAccentColour.Darken(0.5f);
if (IsHovered)
{
backgroundBox.FadeColour(colourProvider.Background3.Lighten(0.3f), transition_length, Easing.OutQuint);
return;
backgroundColour = backgroundColour.Lighten(0.3f);
if (handlingMouse)
backgroundColour = backgroundColour.Lighten(0.3f);
}
}
backgroundBox.FadeColour(colourProvider.Background3, transition_length, Easing.OutQuint);
backgroundBox.FadeColour(backgroundColour, transition_length, Easing.OutQuint);
}
}
}