mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Remove implementation of WedgedBox and use Shear transformation instead.
This commit is contained in:
parent
7751a85e14
commit
b3e531b98c
@ -20,7 +20,7 @@ namespace osu.Game.GameModes.Menu
|
||||
public class Button : AutoSizeContainer, IStateful<ButtonState>
|
||||
{
|
||||
private Container iconText;
|
||||
private WedgedBox box;
|
||||
private Box box;
|
||||
private Color4 colour;
|
||||
private TextAwesome icon;
|
||||
private string internalName;
|
||||
@ -30,7 +30,10 @@ namespace osu.Game.GameModes.Menu
|
||||
private Key triggerKey;
|
||||
private string text;
|
||||
|
||||
public override Quad ScreenSpaceInputQuad => box.ScreenSpaceInputQuad;
|
||||
public override bool Contains(Vector2 screenSpacePos)
|
||||
{
|
||||
return box.Contains(screenSpacePos);
|
||||
}
|
||||
|
||||
public Button(string text, string internalName, FontAwesome symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, Key triggerKey = Key.Unknown)
|
||||
{
|
||||
@ -48,14 +51,18 @@ namespace osu.Game.GameModes.Menu
|
||||
base.Load(game);
|
||||
Alpha = 0;
|
||||
|
||||
Vector2 boxSize = new Vector2(ButtonSystem.button_width + Math.Abs(extraWidth), ButtonSystem.button_area_height);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
box = new WedgedBox(new Vector2(ButtonSystem.button_width + Math.Abs(extraWidth), ButtonSystem.button_area_height), ButtonSystem.wedge_width)
|
||||
box = new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = colour,
|
||||
Scale = new Vector2(0, 1)
|
||||
Scale = new Vector2(0, 1),
|
||||
Size = boxSize,
|
||||
Shear = new Vector2(ButtonSystem.wedge_width / boxSize.Y, 0),
|
||||
},
|
||||
iconText = new AutoSizeContainer
|
||||
{
|
||||
@ -266,42 +273,6 @@ namespace osu.Game.GameModes.Menu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ________
|
||||
/// / /
|
||||
/// / /
|
||||
/// /_______/
|
||||
/// </summary>
|
||||
class WedgedBox : Box
|
||||
{
|
||||
float wedgeWidth;
|
||||
|
||||
public WedgedBox(Vector2 boxSize, float wedgeWidth)
|
||||
{
|
||||
Size = boxSize;
|
||||
this.wedgeWidth = wedgeWidth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom DrawQuad used to create the slanted effect.
|
||||
/// </summary>
|
||||
protected override Quad DrawQuad
|
||||
{
|
||||
get
|
||||
{
|
||||
Quad q = base.DrawQuad;
|
||||
|
||||
//Will become infinite if we don't limit its maximum size.
|
||||
float wedge = Math.Min(q.Width, wedgeWidth / Scale.X);
|
||||
|
||||
q.TopLeft.X += wedge;
|
||||
q.BottomRight.X -= wedge;
|
||||
|
||||
return q;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ButtonState
|
||||
|
Loading…
Reference in New Issue
Block a user