1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-23 22:57:42 +08:00

Hack around the border looking ugly

This is an o!f issue because borders are applied into the individual
sprites of the container via masking, rather than being isolated to the
container itself. In this case, it'll be applied to the "flash" sprite,
which is using additive blending, causing further issues.
This commit is contained in:
Dan Balasescu 2024-08-09 19:55:56 +09:00
parent fa9a835eb5
commit 179a3ad8dd
No known key found for this signature in database

View File

@ -7,13 +7,13 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.Volume
{
@ -33,29 +33,28 @@ namespace osu.Game.Overlays.Volume
}
}
private Color4 hoveredColour, unhoveredColour;
private ColourInfo hoveredBorderColour;
private ColourInfo unhoveredBorderColour;
private CompositeDrawable border = null!;
public MuteButton()
{
const float width = 30;
const float height = 30;
Content.BorderThickness = 3;
Size = new Vector2(width, height);
Content.CornerRadius = height / 2;
Content.CornerExponent = 2;
Size = new Vector2(width, height);
Action = () => Current.Value = !Current.Value;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
hoveredColour = colours.PinkLight;
Content.BorderColour = unhoveredColour = colours.Gray1;
BackgroundColour = colours.Gray1;
hoveredBorderColour = colours.PinkLight;
unhoveredBorderColour = colours.Gray1;
SpriteIcon icon;
@ -65,6 +64,19 @@ namespace osu.Game.Overlays.Volume
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
border = new CircularContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = 3,
BorderColour = unhoveredBorderColour,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
}
}
});
@ -78,13 +90,13 @@ namespace osu.Game.Overlays.Volume
protected override bool OnHover(HoverEvent e)
{
Content.TransformTo<Container<Drawable>, ColourInfo>("BorderColour", hoveredColour, 500, Easing.OutQuint);
border.TransformTo(nameof(BorderColour), hoveredBorderColour, 500, Easing.OutQuint);
return false;
}
protected override void OnHoverLost(HoverLostEvent e)
{
Content.TransformTo<Container<Drawable>, ColourInfo>("BorderColour", unhoveredColour, 500, Easing.OutQuint);
border.TransformTo(nameof(BorderColour), unhoveredBorderColour, 500, Easing.OutQuint);
}
protected override bool OnMouseDown(MouseDownEvent e)