1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:52:54 +08:00

Use OverlayColourProvider and fix font weight

This commit is contained in:
Dean Herbert 2022-01-04 18:14:42 +09:00
parent d10b8c79b3
commit 5a11ee7810
4 changed files with 24 additions and 31 deletions

View File

@ -2,13 +2,18 @@
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface.PageSelector;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestScenePageSelector : OsuTestScene
{
[Cached]
private OverlayColourProvider provider { get; } = new OverlayColourProvider(OverlayColourScheme.Green);
private readonly PageSelector pageSelector;
public TestScenePageSelector()

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers;
using osu.Framework.Input.Events;
using JetBrains.Annotations;
using osu.Game.Overlays;
namespace osu.Game.Graphics.UserInterface.PageSelector
{
@ -16,12 +17,10 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
protected const int DURATION = 200;
[Resolved]
protected OsuColour Colours { get; private set; }
protected OverlayColourProvider ColourProvider { get; private set; }
protected Box Background;
public CircularContainer CircularContent { get; private set; }
protected PageSelectorButton()
{
AutoSizeAxes = Axes.X;
@ -31,7 +30,7 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
[BackgroundDependencyLoader]
private void load()
{
Add(CircularContent = new CircularContainer
Add(new CircularContainer
{
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,

View File

@ -4,7 +4,6 @@
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface.PageSelector
@ -35,14 +34,14 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
protected override Drawable CreateContent() => text = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 12),
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
Text = Page.ToString(),
};
[BackgroundDependencyLoader]
private void load()
{
Background.Colour = Colours.Lime;
Background.Colour = ColourProvider.Highlight1;
Background.Alpha = 0;
}
@ -55,7 +54,7 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
private void onSelectedChanged(ValueChangedEvent<bool> selected)
{
Background.FadeTo(selected.NewValue ? 1 : 0, DURATION, Easing.OutQuint);
text.FadeColour(selected.NewValue ? Colours.GreySeaFoamDarker : Colours.Lime, DURATION, Easing.OutQuint);
text.FadeColour(selected.NewValue ? ColourProvider.Dark4 : ColourProvider.Light3, DURATION, Easing.OutQuint);
}
protected override void UpdateHoverState()
@ -63,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
if (selected.Value)
return;
text.FadeColour(IsHovered ? Colours.Lime.Lighten(20f) : Colours.Lime, DURATION, Easing.OutQuint);
text.FadeColour(IsHovered ? ColourProvider.Light2 : ColourProvider.Light1, DURATION, Easing.OutQuint);
}
}
}

View File

@ -2,31 +2,26 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Sprites;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Graphics.UserInterface.PageSelector
{
public class PageSelectorPrevNextButton : PageSelectorButton
{
private readonly bool rightAligned;
private readonly string text;
private Box fadeBox;
private SpriteIcon icon;
private OsuSpriteText name;
private readonly Anchor alignment;
public PageSelectorPrevNextButton(bool rightAligned, string text)
{
this.rightAligned = rightAligned;
this.text = text;
alignment = rightAligned ? Anchor.x0 : Anchor.x2;
}
protected override Drawable CreateContent() => new Container
@ -47,16 +42,16 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
name = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 12),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Anchor = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
Origin = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
Text = text.ToUpper(),
},
icon = new SpriteIcon
{
Icon = alignment == Anchor.x2 ? FontAwesome.Solid.ChevronLeft : FontAwesome.Solid.ChevronRight,
Icon = rightAligned ? FontAwesome.Solid.ChevronRight : FontAwesome.Solid.ChevronLeft,
Size = new Vector2(8),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Anchor = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
Origin = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
},
}
},
@ -66,23 +61,18 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
[BackgroundDependencyLoader]
private void load()
{
Background.Colour = Colours.GreySeaFoamDark;
name.Colour = icon.Colour = Colours.Lime;
Background.Colour = ColourProvider.Dark4;
name.Colour = icon.Colour = ColourProvider.Light1;
}
protected override void LoadComplete()
{
base.LoadComplete();
CircularContent.Add(fadeBox = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(100)
});
Enabled.BindValueChanged(enabled => fadeBox.FadeTo(enabled.NewValue ? 0 : 1, DURATION), true);
Enabled.BindValueChanged(enabled => Background.FadeTo(enabled.NewValue ? 1 : 0.5f, DURATION), true);
}
protected override void UpdateHoverState() => Background.FadeColour(IsHovered ? Colours.GreySeaFoam : Colours.GreySeaFoamDark, DURATION, Easing.OutQuint);
protected override void UpdateHoverState() =>
Background.FadeColour(IsHovered ? ColourProvider.Dark3 : ColourProvider.Dark4, DURATION, Easing.OutQuint);
}
}