Allow Rulesets to create a non-FontAwesome icon

This also
- Renames TextAwesome to SpriteIcon.
- Removes the default size of "20" from SpriteIcon (now defaults to the underlying texture size).
This commit is contained in:
Dean Herbert
2017-08-03 14:36:21 +09:00
parent d72a479d9d
commit 0d9ea97828
55 changed files with 317 additions and 187 deletions

View File

@ -35,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface
private class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
{
public readonly TextAwesome Chevron;
public readonly SpriteIcon Chevron;
//don't allow clicking between transitions and don't make the chevron clickable
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Alpha == 1f && Text.ReceiveMouseInputAt(screenSpacePos);
@ -69,11 +69,11 @@ namespace osu.Game.Graphics.UserInterface
{
Text.TextSize = 16;
Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width
Add(Chevron = new TextAwesome
Add(Chevron = new SpriteIcon
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
TextSize = 12,
Size = new Vector2(12),
Icon = FontAwesome.fa_chevron_right,
Margin = new MarginPadding { Left = padding },
Alpha = 0f,

View File

@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface
{
public class IconButton : OsuClickableContainer
{
private readonly TextAwesome icon;
private readonly SpriteIcon icon;
private readonly Box hover;
private readonly Container content;
@ -47,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Size = new Vector2 (button_size),
Size = new Vector2(button_size),
CornerRadius = 5,
Masking = true,
@ -64,11 +64,11 @@ namespace osu.Game.Graphics.UserInterface
RelativeSizeAxes = Axes.Both,
Alpha = 0,
},
icon = new TextAwesome
icon = new SpriteIcon
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
TextSize = 18,
Size = new Vector2(18),
}
}
}

View File

@ -9,7 +9,7 @@ namespace osu.Game.Graphics.UserInterface
{
public class LoadingAnimation : VisibilityContainer
{
private readonly TextAwesome spinner;
private readonly SpriteIcon spinner;
public LoadingAnimation()
{
@ -20,9 +20,9 @@ namespace osu.Game.Graphics.UserInterface
Children = new Drawable[]
{
spinner = new TextAwesome
spinner = new SpriteIcon
{
TextSize = 20,
Size = new Vector2(20),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.fa_spinner

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using OpenTK;
namespace osu.Game.Graphics.UserInterface
{
@ -60,14 +61,13 @@ namespace osu.Game.Graphics.UserInterface
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
Chevron = new TextAwesome
Chevron = new SpriteIcon
{
AlwaysPresent = true,
Icon = FontAwesome.fa_chevron_right,
UseFullGlyphHeight = false,
Colour = Color4.Black,
Alpha = 0.5f,
TextSize = 8,
Size = new Vector2(8),
Margin = new MarginPadding { Left = 3, Right = 3 },
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
@ -84,7 +84,7 @@ namespace osu.Game.Graphics.UserInterface
private Color4? accentColour;
protected readonly TextAwesome Chevron;
protected readonly SpriteIcon Chevron;
protected readonly OsuSpriteText Label;
protected override void FormatForeground(bool hover = false)
@ -123,7 +123,7 @@ namespace osu.Game.Graphics.UserInterface
set { Text.Text = value; }
}
protected readonly TextAwesome Icon;
protected readonly SpriteIcon Icon;
private Color4? accentColour;
public virtual Color4 AccentColour
@ -152,13 +152,13 @@ namespace osu.Game.Graphics.UserInterface
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
Icon = new TextAwesome
Icon = new SpriteIcon
{
Icon = FontAwesome.fa_chevron_down,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding { Right = 4 },
TextSize = 20
Size = new Vector2(20),
}
};
}

View File

@ -209,10 +209,10 @@ namespace osu.Game.Graphics.UserInterface
Foreground.Children = new Drawable[]
{
new TextAwesome
new SpriteIcon
{
Icon = FontAwesome.fa_ellipsis_h,
TextSize = 14,
Size = new Vector2(14),
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
}

View File

@ -21,7 +21,7 @@ namespace osu.Game.Graphics.UserInterface
{
private readonly Box box;
private readonly SpriteText text;
private readonly TextAwesome icon;
private readonly SpriteIcon icon;
private Color4? accentColour;
public Color4 AccentColour
@ -99,9 +99,9 @@ namespace osu.Game.Graphics.UserInterface
TextSize = 14,
Font = @"Exo2.0-Bold",
},
icon = new TextAwesome
icon = new SpriteIcon
{
TextSize = 14,
Size = new Vector2(14),
Icon = FontAwesome.fa_circle_o,
Shadow = true,
},

View File

@ -3,6 +3,7 @@
using osu.Framework.Graphics;
using osu.Framework.Input;
using OpenTK;
using OpenTK.Input;
namespace osu.Game.Graphics.UserInterface
@ -19,13 +20,13 @@ namespace osu.Game.Graphics.UserInterface
Height = 35;
AddRange(new Drawable[]
{
new TextAwesome
new SpriteIcon
{
Icon = FontAwesome.fa_search,
Origin = Anchor.CentreRight,
Anchor = Anchor.CentreRight,
Margin = new MarginPadding { Right = 10 },
TextSize = 20
Size = new Vector2(20),
}
});

View File

@ -142,16 +142,16 @@ namespace osu.Game.Graphics.UserInterface
private class Star : Container
{
public readonly TextAwesome Icon;
public readonly SpriteIcon Icon;
public Star()
{
Size = new Vector2(star_size);
Children = new[]
{
Icon = new TextAwesome
Icon = new SpriteIcon
{
TextSize = star_size,
Size = new Vector2(star_size),
Icon = FontAwesome.fa_star,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -215,7 +215,7 @@ namespace osu.Game.Graphics.UserInterface
{
private const double beat_in_time = 60;
private readonly TextAwesome icon;
private readonly SpriteIcon icon;
public FontAwesome Icon { set { icon.Icon = value; } }
@ -226,11 +226,11 @@ namespace osu.Game.Graphics.UserInterface
Children = new Drawable[]
{
icon = new TextAwesome
icon = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 25
Size = new Vector2(25),
}
};
}