mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Rename button classes to make more sense
This commit is contained in:
@ -0,0 +1,69 @@
|
||||
// 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
|
||||
{
|
||||
public class PageSelectorPageButton : PageSelectorButton
|
||||
{
|
||||
private readonly BindableBool selected = new BindableBool();
|
||||
|
||||
public bool Selected
|
||||
{
|
||||
set => selected.Value = value;
|
||||
}
|
||||
|
||||
public int Page { get; }
|
||||
|
||||
private OsuSpriteText text;
|
||||
|
||||
public PageSelectorPageButton(int page)
|
||||
{
|
||||
Page = page;
|
||||
|
||||
Action = () =>
|
||||
{
|
||||
if (!selected.Value)
|
||||
selected.Value = true;
|
||||
};
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent() => text = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 12),
|
||||
Text = Page.ToString(),
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Background.Colour = Colours.Lime;
|
||||
Background.Alpha = 0;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
selected.BindValueChanged(onSelectedChanged, true);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
protected override void UpdateHoverState()
|
||||
{
|
||||
if (selected.Value)
|
||||
return;
|
||||
|
||||
text.FadeColour(IsHovered ? Colours.Lime.Lighten(20f) : Colours.Lime, DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user