2020-01-05 00:36:05 +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.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
|
|
|
|
|
{
|
2020-01-05 02:14:56 +08:00
|
|
|
|
public class DrawablePage : PageSelectorItem
|
2020-01-05 00:36:05 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly BindableBool selected = new BindableBool();
|
|
|
|
|
|
|
|
|
|
public bool Selected
|
|
|
|
|
{
|
|
|
|
|
get => selected.Value;
|
|
|
|
|
set => selected.Value = value;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-05 02:14:56 +08:00
|
|
|
|
public int Page { get; private set; }
|
2020-01-05 00:36:05 +08:00
|
|
|
|
|
2020-01-05 02:14:56 +08:00
|
|
|
|
private OsuSpriteText text;
|
2020-01-05 00:36:05 +08:00
|
|
|
|
|
|
|
|
|
public DrawablePage(int page)
|
|
|
|
|
{
|
2020-01-05 02:14:56 +08:00
|
|
|
|
Page = page;
|
|
|
|
|
text.Text = page.ToString();
|
|
|
|
|
|
|
|
|
|
Background.Alpha = 0;
|
|
|
|
|
|
|
|
|
|
Action = () =>
|
2020-01-05 00:36:05 +08:00
|
|
|
|
{
|
2020-01-05 02:14:56 +08:00
|
|
|
|
if (!selected.Value)
|
|
|
|
|
selected.Value = true;
|
2020-01-05 00:36:05 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-05 02:14:56 +08:00
|
|
|
|
protected override Drawable CreateContent() => text = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 12),
|
|
|
|
|
};
|
|
|
|
|
|
2020-01-05 00:36:05 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2020-01-05 02:14:56 +08:00
|
|
|
|
Background.Colour = Colours.Lime;
|
2020-01-05 00:36:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
selected.BindValueChanged(onSelectedChanged, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onSelectedChanged(ValueChangedEvent<bool> selected)
|
|
|
|
|
{
|
2020-01-05 02:14:56 +08:00
|
|
|
|
Background.FadeTo(selected.NewValue ? 1 : 0, DURATION, Easing.OutQuint);
|
|
|
|
|
text.FadeColour(selected.NewValue ? Colours.GreySeafoamDarker : Colours.Lime, DURATION, Easing.OutQuint);
|
2020-01-05 00:36:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-05 02:14:56 +08:00
|
|
|
|
protected override void UpdateHoverState()
|
2020-01-05 00:36:05 +08:00
|
|
|
|
{
|
|
|
|
|
if (selected.Value)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-01-05 02:14:56 +08:00
|
|
|
|
text.FadeColour(IsHovered ? Colours.Lime.Lighten(20f) : Colours.Lime, DURATION, Easing.OutQuint);
|
2020-01-05 00:36:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|