mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09: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
|
public class SpriteIcon : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly Sprite spriteShadow;
|
private Sprite spriteShadow;
|
||||||
private readonly Sprite spriteMain;
|
private Sprite spriteMain;
|
||||||
|
|
||||||
private Cached layout = new Cached();
|
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[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
shadowVisibility = new Container
|
shadowVisibility = new Container
|
||||||
@ -39,7 +44,7 @@ namespace osu.Game.Graphics
|
|||||||
Y = 2,
|
Y = 2,
|
||||||
Colour = new Color4(0f, 0f, 0f, 0.2f),
|
Colour = new Color4(0f, 0f, 0f, 0.2f),
|
||||||
},
|
},
|
||||||
Alpha = 0,
|
Alpha = shadow ? 1 : 0,
|
||||||
},
|
},
|
||||||
spriteMain = new Sprite
|
spriteMain = new Sprite
|
||||||
{
|
{
|
||||||
@ -49,14 +54,7 @@ namespace osu.Game.Graphics
|
|||||||
FillMode = FillMode.Fit
|
FillMode = FillMode.Fit
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
private FontStore store;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(FontStore store)
|
|
||||||
{
|
|
||||||
this.store = store;
|
|
||||||
updateTexture();
|
updateTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,12 +103,15 @@ namespace osu.Game.Graphics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool shadow;
|
||||||
public bool Shadow
|
public bool Shadow
|
||||||
{
|
{
|
||||||
get { return spriteShadow.IsPresent; }
|
get { return shadow; }
|
||||||
set
|
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.Graphics.Containers;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
@ -72,16 +73,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(star_spacing),
|
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()
|
protected override void LoadComplete()
|
||||||
@ -147,15 +141,12 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
Size = new Vector2(star_size);
|
Size = new Vector2(star_size);
|
||||||
|
|
||||||
Children = new[]
|
Child = Icon = new SpriteIcon
|
||||||
{
|
{
|
||||||
Icon = new SpriteIcon
|
Size = new Vector2(star_size),
|
||||||
{
|
Icon = FontAwesome.fa_star,
|
||||||
Size = new Vector2(star_size),
|
Anchor = Anchor.Centre,
|
||||||
Icon = FontAwesome.fa_star,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user