mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 04:02:59 +08:00
Simplify StarCounter and SpriteIcon
This commit is contained in:
parent
acfdd32783
commit
fd9d900ae0
@ -15,14 +15,19 @@ namespace osu.Game.Graphics
|
||||
{
|
||||
public class SpriteIcon : CompositeDrawable
|
||||
{
|
||||
private readonly Sprite spriteShadow;
|
||||
private readonly Sprite spriteMain;
|
||||
private Sprite spriteShadow;
|
||||
private Sprite spriteMain;
|
||||
|
||||
private Cached layout = new Cached();
|
||||
private readonly Container shadowVisibility;
|
||||
private Container shadowVisibility;
|
||||
|
||||
public SpriteIcon()
|
||||
private FontStore store;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(FontStore store)
|
||||
{
|
||||
this.store = store;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
shadowVisibility = new Container
|
||||
@ -39,7 +44,7 @@ namespace osu.Game.Graphics
|
||||
Y = 2,
|
||||
Colour = new Color4(0f, 0f, 0f, 0.2f),
|
||||
},
|
||||
Alpha = 0,
|
||||
Alpha = shadow ? 1 : 0,
|
||||
},
|
||||
spriteMain = new Sprite
|
||||
{
|
||||
@ -49,14 +54,7 @@ namespace osu.Game.Graphics
|
||||
FillMode = FillMode.Fit
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private FontStore store;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(FontStore store)
|
||||
{
|
||||
this.store = store;
|
||||
updateTexture();
|
||||
}
|
||||
|
||||
@ -105,12 +103,15 @@ namespace osu.Game.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
private bool shadow;
|
||||
public bool Shadow
|
||||
{
|
||||
get { return spriteShadow.IsPresent; }
|
||||
get { return shadow; }
|
||||
set
|
||||
{
|
||||
shadowVisibility.Alpha = value ? 1 : 0;
|
||||
shadow = value;
|
||||
if (shadowVisibility != null)
|
||||
shadowVisibility.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.MathUtils;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@ -72,16 +73,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(star_spacing),
|
||||
ChildrenEnumerable = Enumerable.Range(0, StarCount).Select(i => new Star { Alpha = minStarAlpha })
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < StarCount; i++)
|
||||
{
|
||||
stars.Add(new Star
|
||||
{
|
||||
Alpha = minStarAlpha,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -147,15 +141,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Size = new Vector2(star_size);
|
||||
|
||||
Children = new[]
|
||||
Child = Icon = new SpriteIcon
|
||||
{
|
||||
Icon = new SpriteIcon
|
||||
{
|
||||
Size = new Vector2(star_size),
|
||||
Icon = FontAwesome.fa_star,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
Size = new Vector2(star_size),
|
||||
Icon = FontAwesome.fa_star,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user