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
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-04-02 13:51:28 +08:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-10-02 11:02:47 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2021-02-22 16:14:00 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2017-06-27 20:05:49 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2021-07-30 20:23:49 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-03 09:20:30 +08:00
|
|
|
|
namespace osu.Game.Screens.Select.Options
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class BeatmapOptionsButton : OsuClickableContainer
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2017-03-23 12:52:38 +08:00
|
|
|
|
private const float width = 130;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly Box background;
|
|
|
|
|
private readonly Box flash;
|
2017-08-03 13:36:21 +08:00
|
|
|
|
private readonly SpriteIcon iconText;
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly OsuSpriteText firstLine;
|
|
|
|
|
private readonly OsuSpriteText secondLine;
|
|
|
|
|
private readonly Container box;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-02 20:40:55 +08:00
|
|
|
|
public Color4 ButtonColour
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => background.Colour;
|
|
|
|
|
set => background.Colour = value;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-03-27 18:29:27 +08:00
|
|
|
|
public IconUsage Icon
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => iconText.Icon;
|
|
|
|
|
set => iconText.Icon = value;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-22 16:14:00 +08:00
|
|
|
|
public LocalisableString FirstLineText
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => firstLine.Text;
|
|
|
|
|
set => firstLine.Text = value;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-22 16:14:00 +08:00
|
|
|
|
public LocalisableString SecondLineText
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => secondLine.Text;
|
|
|
|
|
set => secondLine.Text = value;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override bool OnMouseDown(MouseDownEvent e)
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
flash.FadeTo(0.1f, 1000, Easing.OutQuint);
|
2018-10-02 11:02:47 +08:00
|
|
|
|
return base.OnMouseDown(e);
|
2017-03-02 20:40:55 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-01-20 17:17:21 +08:00
|
|
|
|
protected override void OnMouseUp(MouseUpEvent e)
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
flash.FadeTo(0, 1000, Easing.OutQuint);
|
2020-01-20 17:17:21 +08:00
|
|
|
|
base.OnMouseUp(e);
|
2017-03-02 20:40:55 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
flash.ClearTransforms();
|
|
|
|
|
flash.Alpha = 0.9f;
|
2017-07-23 02:50:25 +08:00
|
|
|
|
flash.FadeOut(800, Easing.OutExpo);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
return base.OnClick(e);
|
2017-03-02 20:40:55 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-09-26 13:01:15 +08:00
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-02 20:40:55 +08:00
|
|
|
|
public BeatmapOptionsButton()
|
2022-06-01 20:00:14 +08:00
|
|
|
|
: base(HoverSampleSet.Button)
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2017-03-03 12:53:17 +08:00
|
|
|
|
Width = width;
|
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-02 20:40:55 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-03-03 15:54:43 +08:00
|
|
|
|
box = new Container
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
2017-03-03 12:58:01 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-03-02 20:40:55 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Shear = new Vector2(0.2f, 0f),
|
|
|
|
|
Masking = true,
|
2017-06-12 11:48:47 +08:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.2f),
|
|
|
|
|
Roundness = 5,
|
|
|
|
|
Radius = 8,
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
EdgeSmoothness = new Vector2(1.5f, 0),
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
},
|
|
|
|
|
flash = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
EdgeSmoothness = new Vector2(1.5f, 0),
|
2019-08-21 12:29:50 +08:00
|
|
|
|
Blending = BlendingParameters.Additive,
|
2017-03-02 20:40:55 +08:00
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2017-03-02 20:40:55 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-08-03 13:36:21 +08:00
|
|
|
|
iconText = new SpriteIcon
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2017-08-03 13:36:21 +08:00
|
|
|
|
Size = new Vector2(30),
|
2017-03-02 20:40:55 +08:00
|
|
|
|
Shadow = true,
|
2019-04-02 18:55:24 +08:00
|
|
|
|
Icon = FontAwesome.Solid.TimesCircle,
|
2017-03-02 20:40:55 +08:00
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Bottom = 5,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
firstLine = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2019-02-12 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold),
|
2017-03-02 20:40:55 +08:00
|
|
|
|
Text = @"",
|
|
|
|
|
},
|
|
|
|
|
secondLine = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2019-02-12 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold),
|
2017-03-02 20:40:55 +08:00
|
|
|
|
Text = @"",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|