mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 08:12:55 +08:00
Merge pull request #217 from huoyaoyuan/generic-container
Make KeyCounterCollection generic
This commit is contained in:
commit
08f9d329b9
@ -1 +1 @@
|
|||||||
Subproject commit e611e186e3c8951d7e58a6c92c75e1b587e825a2
|
Subproject commit 7ca1719b5cdc8b0a9600abe6472b38a426abedb0
|
@ -25,7 +25,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
IsCounting = true,
|
IsCounting = true,
|
||||||
Counters = new KeyCounter[]
|
Children = new KeyCounter[]
|
||||||
{
|
{
|
||||||
new KeyCounterKeyboard(@"Z", Key.Z),
|
new KeyCounterKeyboard(@"Z", Key.Z),
|
||||||
new KeyCounterKeyboard(@"X", Key.X),
|
new KeyCounterKeyboard(@"X", Key.X),
|
||||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Modes.Osu.UI
|
|||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
Origin = Anchor.BottomRight,
|
Origin = Anchor.BottomRight,
|
||||||
Margin = new MarginPadding(10),
|
Margin = new MarginPadding(10),
|
||||||
Counters = new KeyCounter[]
|
Children = new KeyCounter[]
|
||||||
{
|
{
|
||||||
new KeyCounterKeyboard(@"Z", Key.Z),
|
new KeyCounterKeyboard(@"Z", Key.Z),
|
||||||
new KeyCounterKeyboard(@"X", Key.X),
|
new KeyCounterKeyboard(@"X", Key.X),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
@ -9,7 +8,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class KeyCounterCollection : FlowContainer
|
public class KeyCounterCollection : FlowContainer<KeyCounter>
|
||||||
{
|
{
|
||||||
public KeyCounterCollection()
|
public KeyCounterCollection()
|
||||||
{
|
{
|
||||||
@ -17,22 +16,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<KeyCounter> counters = new List<KeyCounter>();
|
public override void Add(KeyCounter key)
|
||||||
public IEnumerable<KeyCounter> Counters
|
|
||||||
{
|
{
|
||||||
get { return counters; }
|
base.Add(key);
|
||||||
set
|
|
||||||
{
|
|
||||||
foreach (var k in value)
|
|
||||||
addKey(k);
|
|
||||||
|
|
||||||
Children = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addKey(KeyCounter key)
|
|
||||||
{
|
|
||||||
counters.Add(key);
|
|
||||||
key.IsCounting = IsCounting;
|
key.IsCounting = IsCounting;
|
||||||
key.FadeTime = FadeTime;
|
key.FadeTime = FadeTime;
|
||||||
key.KeyDownTextColor = KeyDownTextColor;
|
key.KeyDownTextColor = KeyDownTextColor;
|
||||||
@ -41,7 +27,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
public void ResetCount()
|
public void ResetCount()
|
||||||
{
|
{
|
||||||
foreach (var counter in counters)
|
foreach (var counter in Children)
|
||||||
counter.ResetCount();
|
counter.ResetCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +43,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (value != isCounting)
|
if (value != isCounting)
|
||||||
{
|
{
|
||||||
isCounting = value;
|
isCounting = value;
|
||||||
foreach (var child in counters)
|
foreach (var child in Children)
|
||||||
child.IsCounting = value;
|
child.IsCounting = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +58,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (value != fadeTime)
|
if (value != fadeTime)
|
||||||
{
|
{
|
||||||
fadeTime = value;
|
fadeTime = value;
|
||||||
foreach (var child in counters)
|
foreach (var child in Children)
|
||||||
child.FadeTime = value;
|
child.FadeTime = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +73,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (value != keyDownTextColor)
|
if (value != keyDownTextColor)
|
||||||
{
|
{
|
||||||
keyDownTextColor = value;
|
keyDownTextColor = value;
|
||||||
foreach (var child in counters)
|
foreach (var child in Children)
|
||||||
child.KeyDownTextColor = value;
|
child.KeyDownTextColor = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,7 +88,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (value != keyUpTextColor)
|
if (value != keyUpTextColor)
|
||||||
{
|
{
|
||||||
keyUpTextColor = value;
|
keyUpTextColor = value;
|
||||||
foreach (var child in counters)
|
foreach (var child in Children)
|
||||||
child.KeyUpTextColor = value;
|
child.KeyUpTextColor = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user