Simplify StarCounter and SpriteIcon

This commit is contained in:
Dean Herbert
2017-12-15 18:40:03 +09:00
parent acfdd32783
commit fd9d900ae0
2 changed files with 22 additions and 30 deletions

View File

@ -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;
}
}