Merge pull request #217 from huoyaoyuan/generic-container

Make KeyCounterCollection generic
This commit is contained in:
Thomas Müller 2016-12-03 10:12:12 +01:00 committed by GitHub
commit 08f9d329b9
4 changed files with 11 additions and 25 deletions

@ -1 +1 @@
Subproject commit e611e186e3c8951d7e58a6c92c75e1b587e825a2
Subproject commit 7ca1719b5cdc8b0a9600abe6472b38a426abedb0

View File

@ -25,7 +25,7 @@ public override void Reset()
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
IsCounting = true,
Counters = new KeyCounter[]
Children = new KeyCounter[]
{
new KeyCounterKeyboard(@"Z", Key.Z),
new KeyCounterKeyboard(@"X", Key.X),

View File

@ -39,7 +39,7 @@ public class OsuScoreOverlay : ScoreOverlay
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Margin = new MarginPadding(10),
Counters = new KeyCounter[]
Children = new KeyCounter[]
{
new KeyCounterKeyboard(@"Z", Key.Z),
new KeyCounterKeyboard(@"X", Key.X),

View File

@ -1,7 +1,6 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Graphics;
using OpenTK;
using OpenTK.Graphics;
@ -9,7 +8,7 @@
namespace osu.Game.Graphics.UserInterface
{
public class KeyCounterCollection : FlowContainer
public class KeyCounterCollection : FlowContainer<KeyCounter>
{
public KeyCounterCollection()
{
@ -17,22 +16,9 @@ public KeyCounterCollection()
AutoSizeAxes = Axes.Both;
}
private List<KeyCounter> counters = new List<KeyCounter>();
public IEnumerable<KeyCounter> Counters
public override void Add(KeyCounter key)
{
get { return counters; }
set
{
foreach (var k in value)
addKey(k);
Children = value;
}
}
private void addKey(KeyCounter key)
{
counters.Add(key);
base.Add(key);
key.IsCounting = IsCounting;
key.FadeTime = FadeTime;
key.KeyDownTextColor = KeyDownTextColor;
@ -41,7 +27,7 @@ private void addKey(KeyCounter key)
public void ResetCount()
{
foreach (var counter in counters)
foreach (var counter in Children)
counter.ResetCount();
}
@ -57,7 +43,7 @@ public bool IsCounting
if (value != isCounting)
{
isCounting = value;
foreach (var child in counters)
foreach (var child in Children)
child.IsCounting = value;
}
}
@ -72,7 +58,7 @@ public int FadeTime
if (value != fadeTime)
{
fadeTime = value;
foreach (var child in counters)
foreach (var child in Children)
child.FadeTime = value;
}
}
@ -87,7 +73,7 @@ public Color4 KeyDownTextColor
if (value != keyDownTextColor)
{
keyDownTextColor = value;
foreach (var child in counters)
foreach (var child in Children)
child.KeyDownTextColor = value;
}
}
@ -102,7 +88,7 @@ public Color4 KeyUpTextColor
if (value != keyUpTextColor)
{
keyUpTextColor = value;
foreach (var child in counters)
foreach (var child in Children)
child.KeyUpTextColor = value;
}
}