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
|
|
|
|
|
2019-11-20 20:19:49 +08:00
|
|
|
|
using System;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-11-18 12:35:42 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2021-06-26 01:10:04 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2021-11-17 15:32:37 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2021-07-17 21:26:18 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-04-26 12:49:44 +08:00
|
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-11-17 15:32:37 +08:00
|
|
|
|
public class SupporterIcon : OsuClickableContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly Box background;
|
2018-12-22 23:51:24 +08:00
|
|
|
|
private readonly FillFlowContainer iconContainer;
|
2019-03-10 06:58:14 +08:00
|
|
|
|
private readonly CircularContainer content;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-11-17 15:32:37 +08:00
|
|
|
|
public override LocalisableString TooltipText => UsersStrings.ShowIsSupporter;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-04-28 19:11:36 +08:00
|
|
|
|
public int SupportLevel
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-12-22 23:51:24 +08:00
|
|
|
|
set
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-11-20 20:19:49 +08:00
|
|
|
|
int count = Math.Clamp(value, 0, 3);
|
2019-04-28 19:13:28 +08:00
|
|
|
|
|
|
|
|
|
if (count == 0)
|
2018-12-22 23:51:24 +08:00
|
|
|
|
{
|
2019-03-10 06:58:14 +08:00
|
|
|
|
content.Hide();
|
2018-12-22 23:51:24 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-03-10 06:58:14 +08:00
|
|
|
|
content.Show();
|
2018-12-22 23:51:24 +08:00
|
|
|
|
iconContainer.Clear();
|
2019-05-07 12:23:09 +08:00
|
|
|
|
|
2019-04-28 19:13:28 +08:00
|
|
|
|
for (int i = 0; i < count; i++)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-12-22 23:51:24 +08:00
|
|
|
|
iconContainer.Add(new SpriteIcon
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-12-22 23:51:24 +08:00
|
|
|
|
Width = 12,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2019-04-04 06:24:42 +08:00
|
|
|
|
Icon = FontAwesome.Solid.Heart,
|
2018-12-22 23:51:24 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-03-10 06:58:14 +08:00
|
|
|
|
|
|
|
|
|
iconContainer.Padding = new MarginPadding { Horizontal = DrawHeight / 2 };
|
2018-12-22 23:51:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SupporterIcon()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X;
|
|
|
|
|
|
2021-11-17 15:32:37 +08:00
|
|
|
|
Child = content = new CircularContainer
|
2018-12-22 23:51:24 +08:00
|
|
|
|
{
|
2019-03-10 06:58:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Children = new Drawable[]
|
2018-12-22 23:51:24 +08:00
|
|
|
|
{
|
2019-03-10 06:58:14 +08:00
|
|
|
|
background = new Box { RelativeSizeAxes = Axes.Both },
|
|
|
|
|
iconContainer = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = 0.6f,
|
|
|
|
|
Anchor = Anchor.Centre,
|
2019-04-04 06:24:42 +08:00
|
|
|
|
Origin = Anchor.Centre
|
2019-03-10 06:58:14 +08:00
|
|
|
|
}
|
2018-12-22 23:51:24 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-18 12:35:42 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
2021-11-17 15:32:37 +08:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2021-11-18 12:35:42 +08:00
|
|
|
|
private void load(OsuGame game)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
background.Colour = colours.Pink;
|
2021-11-17 15:32:37 +08:00
|
|
|
|
|
|
|
|
|
Action = () => game?.OpenUrlExternally(@"/home/support");
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2021-11-18 12:35:42 +08:00
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
|
|
|
|
background.FadeColour(colours.PinkLight, 500, Easing.OutQuint);
|
|
|
|
|
return base.OnHover(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
background.FadeColour(colours.Pink, 500, Easing.OutQuint);
|
|
|
|
|
base.OnHoverLost(e);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|