mirror of
https://github.com/osukey/osukey.git
synced 2025-05-09 23:57:18 +09: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>
|
public class Button : AutoSizeContainer, IStateful<ButtonState>
|
||||||
{
|
{
|
||||||
private Container iconText;
|
private Container iconText;
|
||||||
private WedgedBox box;
|
private Box box;
|
||||||
private Color4 colour;
|
private Color4 colour;
|
||||||
private TextAwesome icon;
|
private TextAwesome icon;
|
||||||
private string internalName;
|
private string internalName;
|
||||||
@ -30,7 +30,10 @@ namespace osu.Game.GameModes.Menu
|
|||||||
private Key triggerKey;
|
private Key triggerKey;
|
||||||
private string text;
|
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)
|
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);
|
base.Load(game);
|
||||||
Alpha = 0;
|
Alpha = 0;
|
||||||
|
|
||||||
|
Vector2 boxSize = new Vector2(ButtonSystem.button_width + Math.Abs(extraWidth), ButtonSystem.button_area_height);
|
||||||
|
|
||||||
Children = new Drawable[]
|
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,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Colour = colour,
|
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
|
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
|
public enum ButtonState
|
||||||
|
Loading…
x
Reference in New Issue
Block a user