1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 19:27:24 +08:00

Add FadeTime and allow setting custom styles directly from container.

This commit is contained in:
Huo Yaoyuan 2016-09-24 10:26:42 +08:00
parent f4ac1f630d
commit ed4fae53cb
2 changed files with 61 additions and 7 deletions

View File

@ -37,8 +37,10 @@ namespace osu.Game.Graphics.UserInterface
}
}
//further: change default values here and in KeyCounterCollection if needed, instead of passing them in every constructor
public Color4 KeyDownTextColor { get; set; } = Color4.DarkGray;
public Color4 KeyUpTextColor { get; set; } = Color4.White;
public int FadeTime { get; set; } = 0;
protected KeyCounter(string name)
{
@ -96,16 +98,15 @@ namespace osu.Game.Graphics.UserInterface
private void UpdateGlowSprite()
{
//can have a FadeTime property or const
if (IsLit)
{
glowSprite.FadeIn();
textLayer.FadeColour(KeyDownTextColor, 0);
glowSprite.FadeIn(FadeTime);
textLayer.FadeColour(KeyDownTextColor, FadeTime);
}
else
{
glowSprite.FadeOut();
textLayer.FadeColour(KeyUpTextColor, 0);
textLayer.FadeColour(KeyUpTextColor, FadeTime);
}
}

View File

@ -3,6 +3,7 @@
using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Graphics.UserInterface
@ -22,20 +23,72 @@ namespace osu.Game.Graphics.UserInterface
{
counters.Add(key);
key.IsCounting = this.IsCounting;
key.FadeTime = this.FadeTime;
key.KeyDownTextColor = this.KeyDownTextColor;
key.KeyUpTextColor = this.KeyUpTextColor;
base.Add(key);
}
public override bool Contains(Vector2 screenSpacePos) => true;
//further: change default values here and in KeyCounter if needed, instead of passing them in every constructor
private bool isCounting;
public bool IsCounting
{
get { return isCounting; }
set
{
isCounting = value;
foreach (var child in counters)
child.IsCounting = value;
if (value != isCounting)
{
isCounting = value;
foreach (var child in counters)
child.IsCounting = value;
}
}
}
private int fadeTime = 0;
public int FadeTime
{
get { return fadeTime; }
set
{
if (value != fadeTime)
{
fadeTime = value;
foreach (var child in counters)
child.FadeTime = value;
}
}
}
private Color4 keyDownTextColor = Color4.DarkGray;
public Color4 KeyDownTextColor
{
get { return keyDownTextColor; }
set
{
if (value != keyDownTextColor)
{
keyDownTextColor = value;
foreach (var child in counters)
child.KeyDownTextColor = value;
}
}
}
private Color4 keyUpTextColor = Color4.White;
public Color4 KeyUpTextColor
{
get { return keyUpTextColor; }
set
{
if (value != keyUpTextColor)
{
keyUpTextColor = value;
foreach (var child in counters)
child.KeyUpTextColor = value;
}
}
}
}