1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-19 00:30:19 +08:00

Adjust styling of freestyle button

This commit is contained in:
Dan Balasescu
2026-01-05 14:35:34 +09:00
Unverified
parent ebf9c19ad3
commit 593cc37ea6
@@ -4,24 +4,15 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Screens.Footer;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.OnlinePlay
{
public partial class FooterButtonFreestyleV2 : ScreenFooterButton
{
private const float bar_height = 30f;
public readonly Bindable<bool> Freestyle = new Bindable<bool>();
public new Action Action
@@ -32,12 +23,6 @@ namespace osu.Game.Screens.OnlinePlay
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
private Drawable statusBackground = null!;
private OsuSpriteText statusText = null!;
public FooterButtonFreestyleV2()
{
// Overwrite any external behaviour as we delegate the main toggle action to a sub-button.
@@ -50,63 +35,15 @@ namespace osu.Game.Screens.OnlinePlay
Text = "Freestyle";
Icon = FontAwesome.Solid.ExchangeAlt;
AccentColour = colours.Lime1;
AddRange(new[]
{
new Container
{
Y = -5f,
Depth = float.MaxValue,
Origin = Anchor.BottomLeft,
Shear = OsuGame.SHEAR,
CornerRadius = CORNER_RADIUS,
Size = new Vector2(BUTTON_WIDTH, bar_height),
Masking = true,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Radius = 4,
// Figma says 50% opacity, but it does not match up visually if taken at face value, and looks bad.
Colour = Colour4.Black.Opacity(0.25f),
Offset = new Vector2(0, 2),
},
Children = new[]
{
statusBackground = new Box
{
Colour = colourProvider.Background3,
RelativeSizeAxes = Axes.Both,
},
statusText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.Torus.With(size: 14f, weight: FontWeight.Bold),
Shear = -OsuGame.SHEAR,
},
}
},
});
}
protected override void LoadComplete()
{
base.LoadComplete();
Freestyle.BindValueChanged(v =>
Freestyle.BindValueChanged(active =>
{
if (v.NewValue)
{
statusBackground.Colour = colours.Yellow;
statusText.Text = "ON";
statusText.Colour = Color4.Black;
}
else
{
statusBackground.Colour = colourProvider.Background3;
statusText.Text = "OFF";
statusText.Colour = Color4.White;
}
OverlayState.Value = active.NewValue ? Visibility.Visible : Visibility.Hidden;
}, true);
}
}