mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Adjust visual tree of counter.
This commit is contained in:
parent
0da0d4f35e
commit
f4ac1f630d
@ -9,10 +9,11 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public abstract class KeyCounter : AutoSizeContainer
|
public abstract class KeyCounter : Container
|
||||||
{
|
{
|
||||||
private Sprite buttonSprite;
|
private Sprite buttonSprite;
|
||||||
private Sprite glowSprite;
|
private Sprite glowSprite;
|
||||||
|
private Container textLayer;
|
||||||
private SpriteText keySpriteText;
|
private SpriteText keySpriteText;
|
||||||
private SpriteText countSpriteText;
|
private SpriteText countSpriteText;
|
||||||
|
|
||||||
@ -54,34 +55,43 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Texture = Game.Textures.Get(@"KeyCounter/key-up"),
|
Texture = Game.Textures.Get(@"KeyCounter/key-up"),
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
},
|
||||||
|
glowSprite = new Sprite
|
||||||
|
{
|
||||||
|
Texture = Game.Textures.Get(@"KeyCounter/key-glow"),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Alpha = 0
|
||||||
|
},
|
||||||
|
textLayer = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
glowSprite = new Sprite
|
keySpriteText = new SpriteText
|
||||||
{
|
{
|
||||||
Texture = Game.Textures.Get(@"KeyCounter/key-glow"),
|
Text = Name,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
Position = new Vector2(0, -buttonSprite.Height / 4),
|
||||||
|
Colour = KeyUpTextColor
|
||||||
|
},
|
||||||
|
countSpriteText = new SpriteText
|
||||||
|
{
|
||||||
|
Text = Count.ToString(),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Position = new Vector2(0, buttonSprite.Height / 4),
|
||||||
|
Colour = KeyUpTextColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
keySpriteText = new SpriteText
|
|
||||||
{
|
|
||||||
Text = Name,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Position = new Vector2(0, -buttonSprite.Height / 4),
|
|
||||||
Colour = KeyUpTextColor
|
|
||||||
},
|
|
||||||
countSpriteText = new SpriteText
|
|
||||||
{
|
|
||||||
Text = Count.ToString(),
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Position = new Vector2(0, buttonSprite.Height / 4),
|
|
||||||
Colour = KeyUpTextColor
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
glowSprite.Hide();
|
//Set this manually because an element with Alpha=0 won't take it size to AutoSizeContainer,
|
||||||
|
//so the size can be changing between buttonSpirit and glowSpirit.
|
||||||
|
Height = buttonSprite.Height;
|
||||||
|
Width = buttonSprite.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateGlowSprite()
|
private void UpdateGlowSprite()
|
||||||
@ -89,15 +99,13 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
//can have a FadeTime property or const
|
//can have a FadeTime property or const
|
||||||
if (IsLit)
|
if (IsLit)
|
||||||
{
|
{
|
||||||
glowSprite.Show();
|
glowSprite.FadeIn();
|
||||||
countSpriteText.FadeColour(KeyDownTextColor, 0);
|
textLayer.FadeColour(KeyDownTextColor, 0);
|
||||||
keySpriteText.FadeColour(KeyDownTextColor, 0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glowSprite.Hide();
|
glowSprite.FadeOut();
|
||||||
countSpriteText.FadeColour(KeyUpTextColor, 0);
|
textLayer.FadeColour(KeyUpTextColor, 0);
|
||||||
keySpriteText.FadeColour(KeyUpTextColor, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user