2019-01-24 16:43: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-12-22 15:30:06 +08:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Game.Graphics;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Ranking
|
|
|
|
{
|
2018-12-22 15:30:06 +08:00
|
|
|
public class ResultModeButton : TabItem<IResultPageInfo>, IHasTooltip
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
private readonly FontAwesome icon;
|
|
|
|
private Color4 activeColour;
|
|
|
|
private Color4 inactiveColour;
|
|
|
|
private CircularContainer colouredPart;
|
|
|
|
|
2018-12-22 14:51:00 +08:00
|
|
|
public ResultModeButton(IResultPageInfo mode)
|
2018-12-21 15:28:33 +08:00
|
|
|
: base(mode)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-12-21 15:28:33 +08:00
|
|
|
icon = mode.Icon;
|
2018-12-22 15:30:06 +08:00
|
|
|
TooltipText = mode.Name;
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
Size = new Vector2(50);
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 25;
|
|
|
|
|
|
|
|
activeColour = colours.PinkDarker;
|
|
|
|
inactiveColour = OsuColour.Gray(0.8f);
|
|
|
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Colour = Color4.Black.Opacity(0.4f),
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Radius = 5,
|
|
|
|
};
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.White,
|
|
|
|
},
|
|
|
|
colouredPart = new CircularContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Size = new Vector2(0.8f),
|
|
|
|
BorderThickness = 4,
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
Colour = inactiveColour,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
AlwaysPresent = true, //for border rendering
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Transparent,
|
|
|
|
},
|
|
|
|
new SpriteIcon
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Shadow = false,
|
|
|
|
Colour = OsuColour.Gray(0.95f),
|
|
|
|
Icon = icon,
|
|
|
|
Size = new Vector2(20),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnActivated() => colouredPart.FadeColour(activeColour, 200, Easing.OutQuint);
|
|
|
|
|
|
|
|
protected override void OnDeactivated() => colouredPart.FadeColour(inactiveColour, 200, Easing.OutQuint);
|
2018-12-22 15:30:06 +08:00
|
|
|
|
|
|
|
public string TooltipText { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|