Add button "accent" colour, bottom bar, icon, text

This commit is contained in:
mk56-spn
2022-12-01 15:34:09 +01:00
parent 774eb178a1
commit 1530495e7c
7 changed files with 155 additions and 4 deletions

View File

@ -20,7 +20,9 @@ namespace osu.Game.Tests.Visual.SongSelect
Origin = Anchor.Centre Origin = Anchor.Centre
}; };
footer.AddButton(new FooterButtonV2()); footer.AddButton(new FooterButtonModsV2());
footer.AddButton(new FooterButtonRandomV2());
footer.AddButton(new FooterButtonOptionsV2());
}); });
[Test] [Test]

View File

@ -0,0 +1,21 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
namespace osu.Game.Screens.Select.FooterV2
{
public partial class FooterButtonFreeModsV2 : FooterButtonV2
{
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
//No design exists for this button!
Icon = FontAwesome.Solid.ExpandArrowsAlt;
Text = "Freemods";
AccentColour = colour.Yellow;
}
}
}

View File

@ -0,0 +1,20 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Screens.Select.FooterV2
{
public partial class FooterButtonModsV2 : FooterButtonV2
{
[BackgroundDependencyLoader]
private void load()
{
Text = "Mods";
Icon = FontAwesome.Solid.ArrowsAlt;
AccentColour = Colour4.FromHex("#B2FF66");
}
}
}

View File

@ -0,0 +1,20 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Screens.Select.FooterV2
{
public partial class FooterButtonOptionsV2 : FooterButtonV2
{
[BackgroundDependencyLoader]
private void load()
{
Text = "Options";
Icon = FontAwesome.Solid.Cog;
AccentColour = Colour4.FromHex("#8C66FF");
}
}
}

View File

@ -0,0 +1,20 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Screens.Select.FooterV2
{
public partial class FooterButtonRandomV2 : FooterButtonV2
{
[BackgroundDependencyLoader]
private void load()
{
Text = "Random";
Icon = FontAwesome.Solid.Random;
AccentColour = Colour4.FromHex("#66CCFF");
}
}
}

View File

@ -5,10 +5,13 @@ using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Overlays; using osu.Game.Overlays;
using osuTK; using osuTK;
@ -23,14 +26,47 @@ namespace osu.Game.Screens.Select.FooterV2
public const float SHEAR_WIDTH = 16; public const float SHEAR_WIDTH = 16;
protected static readonly Vector2 SHEAR = new Vector2(SHEAR_WIDTH / button_height, 0);
[Cached] [Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine); private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
protected static readonly Vector2 SHEAR = new Vector2(SHEAR_WIDTH / button_height, 0); private Colour4 buttonAccentColour;
protected Colour4 AccentColour
{
set
{
buttonAccentColour = value;
bar.Colour = buttonAccentColour;
icon.Colour = buttonAccentColour;
}
}
protected IconUsage Icon
{
set => icon.Icon = value;
}
protected string Text
{
set => text.Text = value;
}
private SpriteIcon icon = null!;
private OsuSpriteText text = null!;
private Box bar = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Radius = 5,
Roundness = 10,
Colour = Colour4.Black.Opacity(0.25f)
};
Shear = SHEAR; Shear = SHEAR;
Size = new Vector2(button_width, button_height); Size = new Vector2(button_width, button_height);
Masking = true; Masking = true;
@ -46,7 +82,39 @@ namespace osu.Game.Screens.Select.FooterV2
//For elements that should not be sheared. //For elements that should not be sheared.
new Container new Container
{ {
Shear = -SHEAR Shear = -SHEAR,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
icon = new SpriteIcon
{
//We want to offset this by the same amount as the text for aesthetic purposes
Position = new Vector2(-SHEAR_WIDTH * (52f / button_height), 12),
Size = new Vector2(20),
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre
},
text = new OsuSpriteText
{
Position = new Vector2(-SHEAR_WIDTH * (52f / button_height), 42),
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre
},
new Container
{
//Offset the bar to centre it with consideration for the shearing
Position = new Vector2(-SHEAR_WIDTH * (80f / button_height), -40),
Anchor = Anchor.BottomCentre,
Origin = Anchor.Centre,
Size = new Vector2(120, 6),
Masking = true,
CornerRadius = 3,
Child = bar = new Box
{
RelativeSizeAxes = Axes.Both,
}
}
}
} }
}; };
} }

View File

@ -73,7 +73,7 @@ namespace osu.Game.Screens.Select.FooterV2
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(-FooterButtonV2.SHEAR_WIDTH, 5), Spacing = new Vector2(-FooterButtonV2.SHEAR_WIDTH + 7, 0),
AutoSizeAxes = Axes.Both AutoSizeAxes = Axes.Both
} }
} }