mirror of
https://github.com/ppy/osu
synced 2025-01-19 20:40:52 +00:00
fix test failures, improve button logic
This commit is contained in:
parent
878e2f24c4
commit
626f4b0dfd
@ -4,6 +4,7 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Screens.Select.FooterV2
|
||||
{
|
||||
@ -15,6 +16,7 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
Text = "Options";
|
||||
Icon = FontAwesome.Solid.Cog;
|
||||
AccentColour = colour.Purple1;
|
||||
Hotkey = GlobalAction.ToggleBeatmapOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,8 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
Text = rewindSpriteText.Text,
|
||||
AlwaysPresent = true, // make sure the button is sized large enough to always show this
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre
|
||||
Origin = Anchor.BottomCentre,
|
||||
Font = OsuFont.TorusAlternate.With(size: 19),
|
||||
});
|
||||
|
||||
fallingRewind.FadeOutFromOne(fade_time, Easing.In);
|
||||
|
@ -60,14 +60,14 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
set => text.Text = value;
|
||||
}
|
||||
|
||||
private SpriteText text = null!;
|
||||
private SpriteIcon icon = null!;
|
||||
protected Container TextContainer = null!;
|
||||
private Box bar = null!;
|
||||
private Box backgroundBox = null!;
|
||||
private readonly SpriteText text;
|
||||
private readonly SpriteIcon icon;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
protected Container TextContainer;
|
||||
private readonly Box bar;
|
||||
private readonly Box backgroundBox;
|
||||
|
||||
public FooterButtonV2()
|
||||
{
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
@ -146,46 +146,33 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
|
||||
public GlobalAction? Hotkey;
|
||||
|
||||
private bool isHovered;
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
isHovered = true;
|
||||
updateDisplay();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
isHovered = false;
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (!Enabled.Value)
|
||||
return true;
|
||||
|
||||
return base.OnMouseDown(e);
|
||||
return !Enabled.Value || base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (!Enabled.Value)
|
||||
return true;
|
||||
|
||||
return base.OnClick(e);
|
||||
return !Enabled.Value || base.OnClick(e);
|
||||
}
|
||||
|
||||
public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
{
|
||||
if (e.Action == Hotkey && !e.Repeat)
|
||||
{
|
||||
TriggerClick();
|
||||
return true;
|
||||
}
|
||||
if (e.Action != Hotkey || e.Repeat) return false;
|
||||
|
||||
return false;
|
||||
TriggerClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void OnReleased(KeyBindingReleaseEvent<GlobalAction> e) { }
|
||||
@ -198,19 +185,19 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
return;
|
||||
}
|
||||
|
||||
switch (OverlayState.Value)
|
||||
if (OverlayState.Value == Visibility.Visible)
|
||||
{
|
||||
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;
|
||||
backgroundBox.FadeColour(buttonAccentColour.Darken(0.5f), transition_length, Easing.OutQuint);
|
||||
return;
|
||||
}
|
||||
|
||||
//Hover logic.
|
||||
backgroundBox.FadeColour(isHovered && Enabled.Value ? colourProvider.Background3.Lighten(.3f) : colourProvider.Background3, transition_length, Easing.OutQuint);
|
||||
if (IsHovered)
|
||||
{
|
||||
backgroundBox.FadeColour(colourProvider.Background3.Lighten(0.3f), transition_length, Easing.OutQuint);
|
||||
return;
|
||||
}
|
||||
|
||||
backgroundBox.FadeColour(colourProvider.Background3, transition_length, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
|
||||
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
||||
|
||||
/// <param name="button">The button to be added.</param>
|
||||
/// <param name="overlay">The <see cref="OverlayContainer"/> to be toggled by this button.</param>
|
||||
public void AddButton(FooterButtonV2 button, OverlayContainer? overlay = null)
|
||||
{
|
||||
if (overlay != null)
|
||||
|
Loading…
Reference in New Issue
Block a user