2017-03-02 20:40:55 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-03-14 21:13:57 +08:00
|
|
|
|
using OpenTK.Input;
|
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;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
|
2017-03-03 09:20:30 +08:00
|
|
|
|
namespace osu.Game.Screens.Select.Options
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
public class BeatmapOptionsButton : ClickableContainer
|
|
|
|
|
{
|
2017-03-23 12:52:38 +08:00
|
|
|
|
private const float width = 130;
|
2017-03-02 21:05:10 +08:00
|
|
|
|
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly Box background;
|
|
|
|
|
private readonly Box flash;
|
|
|
|
|
private readonly TextAwesome iconText;
|
|
|
|
|
private readonly OsuSpriteText firstLine;
|
|
|
|
|
private readonly OsuSpriteText secondLine;
|
|
|
|
|
private readonly Container box;
|
2017-03-02 20:40:55 +08:00
|
|
|
|
|
|
|
|
|
public Color4 ButtonColour
|
|
|
|
|
{
|
|
|
|
|
get { return background.Colour; }
|
|
|
|
|
set { background.Colour = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FontAwesome Icon
|
|
|
|
|
{
|
|
|
|
|
get { return iconText.Icon; }
|
|
|
|
|
set { iconText.Icon = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string FirstLineText
|
|
|
|
|
{
|
|
|
|
|
get { return firstLine.Text; }
|
|
|
|
|
set { firstLine.Text = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SecondLineText
|
|
|
|
|
{
|
|
|
|
|
get { return secondLine.Text; }
|
|
|
|
|
set { secondLine.Text = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 21:13:57 +08:00
|
|
|
|
public Key? HotKey;
|
|
|
|
|
|
2017-03-02 20:40:55 +08:00
|
|
|
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
flash.FadeTo(0.1f, 1000, EasingTypes.OutQuint);
|
|
|
|
|
return base.OnMouseDown(state, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
flash.FadeTo(0, 1000, EasingTypes.OutQuint);
|
|
|
|
|
return base.OnMouseUp(state, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
|
{
|
|
|
|
|
flash.ClearTransforms();
|
|
|
|
|
flash.Alpha = 0.9f;
|
|
|
|
|
flash.FadeOut(800, EasingTypes.OutExpo);
|
|
|
|
|
|
|
|
|
|
return base.OnClick(state);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 21:13:57 +08:00
|
|
|
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (!args.Repeat && args.Key == HotKey)
|
|
|
|
|
{
|
|
|
|
|
OnClick(state);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 16:38:36 +08:00
|
|
|
|
protected override bool InternalContains(Vector2 screenSpacePos) => box.Contains(screenSpacePos);
|
2017-03-03 15:54:43 +08:00
|
|
|
|
|
2017-03-02 20:40:55 +08:00
|
|
|
|
public BeatmapOptionsButton()
|
|
|
|
|
{
|
2017-03-03 12:53:17 +08:00
|
|
|
|
Width = width;
|
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
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,
|
|
|
|
|
EdgeEffect = new EdgeEffect
|
|
|
|
|
{
|
|
|
|
|
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),
|
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
|
|
|
|
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[]
|
|
|
|
|
{
|
|
|
|
|
iconText = new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
TextSize = 30,
|
|
|
|
|
Shadow = true,
|
|
|
|
|
Icon = FontAwesome.fa_close,
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Bottom = 5,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
firstLine = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
Text = @"",
|
|
|
|
|
},
|
|
|
|
|
secondLine = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
Text = @"",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|