2019-06-04 23:14:03 +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.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
|
|
|
|
{
|
2019-06-27 13:54:31 +08:00
|
|
|
|
public class ProfileRulesetTabItem : TabItem<RulesetInfo>
|
2019-06-04 23:14:03 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly OsuSpriteText text;
|
|
|
|
|
private readonly SpriteIcon icon;
|
|
|
|
|
|
|
|
|
|
private Color4 accentColour;
|
|
|
|
|
|
|
|
|
|
public Color4 AccentColour
|
|
|
|
|
{
|
|
|
|
|
get => accentColour;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (accentColour == value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
accentColour = value;
|
|
|
|
|
|
|
|
|
|
updateState();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isDefault;
|
|
|
|
|
|
|
|
|
|
public bool IsDefault
|
|
|
|
|
{
|
|
|
|
|
get => isDefault;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (isDefault == value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
isDefault = value;
|
|
|
|
|
|
2019-06-04 23:37:31 +08:00
|
|
|
|
icon.FadeTo(isDefault ? 1 : 0, 200, Easing.OutQuint);
|
2019-06-04 23:14:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-27 13:54:31 +08:00
|
|
|
|
public ProfileRulesetTabItem(RulesetInfo value)
|
2019-06-04 23:14:03 +08:00
|
|
|
|
: base(value)
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-06-04 23:37:31 +08:00
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(3, 0),
|
|
|
|
|
Children = new Drawable[]
|
2019-06-04 23:14:03 +08:00
|
|
|
|
{
|
2019-06-04 23:37:31 +08:00
|
|
|
|
text = new OsuSpriteText
|
2019-06-04 23:14:03 +08:00
|
|
|
|
{
|
2019-06-04 23:37:31 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Text = value.Name,
|
|
|
|
|
Font = OsuFont.GetFont()
|
|
|
|
|
},
|
|
|
|
|
icon = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
AlwaysPresent = true,
|
|
|
|
|
Icon = FontAwesome.Solid.Star,
|
|
|
|
|
Size = new Vector2(12),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new HoverClickSounds()
|
2019-06-04 23:14:03 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHover(e);
|
|
|
|
|
|
2019-06-26 23:56:40 +08:00
|
|
|
|
if (!Active.Value)
|
|
|
|
|
hoverAction();
|
2019-06-04 23:14:03 +08:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHoverLost(e);
|
|
|
|
|
|
2019-06-26 23:56:40 +08:00
|
|
|
|
if (!Active.Value)
|
|
|
|
|
unhoverAction();
|
2019-06-04 23:14:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-26 23:56:40 +08:00
|
|
|
|
protected override void OnActivated()
|
|
|
|
|
{
|
|
|
|
|
hoverAction();
|
|
|
|
|
text.Font = text.Font.With(weight: FontWeight.Bold);
|
|
|
|
|
}
|
2019-06-04 23:14:03 +08:00
|
|
|
|
|
2019-06-26 23:56:40 +08:00
|
|
|
|
protected override void OnDeactivated()
|
|
|
|
|
{
|
|
|
|
|
unhoverAction();
|
|
|
|
|
text.Font = text.Font.With(weight: FontWeight.Medium);
|
|
|
|
|
}
|
2019-06-04 23:14:03 +08:00
|
|
|
|
|
|
|
|
|
private void updateState()
|
|
|
|
|
{
|
2019-06-26 23:56:40 +08:00
|
|
|
|
if (Active.Value)
|
|
|
|
|
OnActivated();
|
2019-06-04 23:14:03 +08:00
|
|
|
|
else
|
2019-06-26 23:56:40 +08:00
|
|
|
|
OnDeactivated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void hoverAction()
|
|
|
|
|
{
|
|
|
|
|
text.FadeColour(Color4.White, 120, Easing.InQuad);
|
|
|
|
|
icon.FadeColour(Color4.White, 120, Easing.InQuad);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void unhoverAction()
|
|
|
|
|
{
|
|
|
|
|
text.FadeColour(AccentColour, 120, Easing.InQuad);
|
|
|
|
|
icon.FadeColour(AccentColour, 120, Easing.InQuad);
|
2019-06-04 23:14:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|