2022-01-04 16:52:40 +08:00
|
|
|
|
// 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;
|
2022-01-28 12:53:48 +08:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2022-01-04 16:52:40 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-01-28 12:53:48 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2022-01-04 16:52:40 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface.PageSelector
|
|
|
|
|
{
|
|
|
|
|
public class PageSelectorPrevNextButton : PageSelectorButton
|
|
|
|
|
{
|
2022-01-04 17:14:42 +08:00
|
|
|
|
private readonly bool rightAligned;
|
2022-01-28 12:53:48 +08:00
|
|
|
|
private readonly LocalisableString text;
|
2022-01-04 16:52:40 +08:00
|
|
|
|
|
|
|
|
|
private SpriteIcon icon;
|
|
|
|
|
private OsuSpriteText name;
|
|
|
|
|
|
2022-01-28 12:53:48 +08:00
|
|
|
|
public PageSelectorPrevNextButton(bool rightAligned, LocalisableString text)
|
2022-01-04 16:52:40 +08:00
|
|
|
|
{
|
2022-01-04 17:14:42 +08:00
|
|
|
|
this.rightAligned = rightAligned;
|
2022-01-04 16:52:40 +08:00
|
|
|
|
this.text = text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Drawable CreateContent() => new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Spacing = new Vector2(3, 0),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
name = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 12),
|
2022-01-04 17:14:42 +08:00
|
|
|
|
Anchor = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
|
|
|
Origin = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
|
2022-01-04 16:52:40 +08:00
|
|
|
|
Text = text.ToUpper(),
|
|
|
|
|
},
|
|
|
|
|
icon = new SpriteIcon
|
|
|
|
|
{
|
2022-01-04 17:14:42 +08:00
|
|
|
|
Icon = rightAligned ? FontAwesome.Solid.ChevronRight : FontAwesome.Solid.ChevronLeft,
|
2022-01-04 16:52:40 +08:00
|
|
|
|
Size = new Vector2(8),
|
2022-01-04 17:14:42 +08:00
|
|
|
|
Anchor = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
|
|
|
Origin = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
|
2022-01-04 16:52:40 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2022-01-04 17:14:42 +08:00
|
|
|
|
Background.Colour = ColourProvider.Dark4;
|
|
|
|
|
name.Colour = icon.Colour = ColourProvider.Light1;
|
2022-01-04 16:52:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2022-01-04 17:14:42 +08:00
|
|
|
|
Enabled.BindValueChanged(enabled => Background.FadeTo(enabled.NewValue ? 1 : 0.5f, DURATION), true);
|
2022-01-04 16:52:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-04 17:14:42 +08:00
|
|
|
|
protected override void UpdateHoverState() =>
|
|
|
|
|
Background.FadeColour(IsHovered ? ColourProvider.Dark3 : ColourProvider.Dark4, DURATION, Easing.OutQuint);
|
2022-01-04 16:52:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|