Implement KeyCounter and base Count class.

This commit is contained in:
Huo Yaoyuan 2016-09-23 18:29:25 +08:00
parent 8a168f2d29
commit 55a1a3827a
3 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,74 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface
{
abstract class Count : AutoSizeContainer
{
private Sprite buttonSprite;
private Sprite glowSprite;
private SpriteText keySpriteText;
private SpriteText countSpriteText;
public override string Name { get; }
public bool IsCounting { get; set; }
public int Counts { get; private set; }
private bool isLit;
public bool IsLit
{
get { return isLit; }
set
{
if (value && !isLit && IsCounting)
Counts++;
isLit = value;
}
}
protected Count(string name)
{
Name = name;
}
public override void Load()
{
base.Load();
Children = new Drawable[]
{
buttonSprite = new Sprite
{
Texture = Game.Textures.Get(@"KeyCounter/key-up"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
glowSprite = new Sprite
{
Texture = Game.Textures.Get(@"KeyCounter/key-glow"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
}
},
keySpriteText = new SpriteText
{
Text = Name,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre
},
countSpriteText = new SpriteText
{
Text = Counts.ToString(),
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre
}
};
glowSprite.Hide();
}
}
}

View File

@ -0,0 +1,17 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Containers;
namespace osu.Game.Graphics.UserInterface
{
class KeyCounter : FlowContainer
{
public KeyCounter()
{
Direction = FlowDirection.HorizontalOnly;
}
public void AddKey(Count key) => base.Add(key);
}
}

View File

@ -53,6 +53,8 @@
<Compile Include="Graphics\Containers\OsuLargeComponent.cs" /> <Compile Include="Graphics\Containers\OsuLargeComponent.cs" />
<Compile Include="Graphics\Processing\RatioAdjust.cs" /> <Compile Include="Graphics\Processing\RatioAdjust.cs" />
<Compile Include="Graphics\TextAwesome.cs" /> <Compile Include="Graphics\TextAwesome.cs" />
<Compile Include="Graphics\UserInterface\Counter.cs" />
<Compile Include="Graphics\UserInterface\KeyCounter.cs" />
<Compile Include="Online\API\APIAccess.cs" /> <Compile Include="Online\API\APIAccess.cs" />
<Compile Include="Online\API\APIRequest.cs" /> <Compile Include="Online\API\APIRequest.cs" />
<Compile Include="Online\API\OAuth.cs" /> <Compile Include="Online\API\OAuth.cs" />