1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 18:33:21 +08:00
osu-lazer/osu.Desktop.Tests/Visual/TestCaseKeyCounter.cs

103 lines
3.3 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-12-05 00:58:52 +08:00
using osu.Framework.Configuration;
using osu.Framework.Graphics;
2017-03-31 16:55:07 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.MathUtils;
2017-01-27 20:57:22 +08:00
using osu.Game.Screens.Play;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
2016-09-24 08:57:13 +08:00
namespace osu.Desktop.Tests.Visual
2016-09-24 08:57:13 +08:00
{
internal class TestCaseKeyCounter : OsuTestCase
2016-09-24 08:57:13 +08:00
{
public override string Description => @"Tests key counter";
public TestCaseKeyCounter()
2016-09-24 08:57:13 +08:00
{
2016-12-05 01:03:18 +08:00
KeyCounterCollection kc = new KeyCounterCollection
2016-12-05 00:58:52 +08:00
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
IsCounting = true,
Children = new KeyCounter[]
{
new KeyCounterKeyboard(Key.Z),
new KeyCounterKeyboard(Key.X),
new KeyCounterMouse(MouseButton.Left),
new KeyCounterMouse(MouseButton.Right),
},
2016-12-05 01:03:18 +08:00
};
2016-12-05 01:06:28 +08:00
BindableInt bindable = new BindableInt { MinValue = 0, MaxValue = 200, Default = 50 };
bindable.ValueChanged += delegate { kc.FadeTime = bindable.Value; };
2017-03-31 16:55:07 +08:00
AddStep("Add Random", () =>
2016-12-05 01:03:18 +08:00
{
Key key = (Key)((int)Key.A + RNG.Next(26));
kc.Add(new KeyCounterKeyboard(key));
2016-12-05 01:03:18 +08:00
});
2017-03-31 16:55:07 +08:00
2017-04-10 16:10:15 +08:00
TestSliderBar<int> sliderBar;
2017-03-31 16:55:07 +08:00
Add(new Container
2016-12-05 01:03:18 +08:00
{
2017-03-31 16:55:07 +08:00
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new SpriteText { Text = "FadeTime" },
sliderBar = new TestSliderBar<int>
2017-03-31 16:55:07 +08:00
{
Width = 150,
Height = 10,
SelectionColor = Color4.Orange,
}
}
2016-12-05 00:58:52 +08:00
});
2017-03-31 16:55:07 +08:00
2017-04-10 16:10:15 +08:00
sliderBar.Current.BindTo(bindable);
2016-12-05 01:03:18 +08:00
Add(kc);
2016-09-24 08:57:13 +08:00
}
private class TestSliderBar<T> : SliderBar<T> where T : struct
{
public Color4 Color
{
get { return Box.Colour; }
set { Box.Colour = value; }
}
public Color4 SelectionColor
{
get { return SelectionBox.Colour; }
set { SelectionBox.Colour = value; }
}
protected readonly Box SelectionBox;
protected readonly Box Box;
public TestSliderBar()
{
Children = new Drawable[]
{
Box = new Box { RelativeSizeAxes = Axes.Both },
SelectionBox = new Box { RelativeSizeAxes = Axes.Both }
};
}
protected override void UpdateValue(float value)
{
SelectionBox.ScaleTo(
new Vector2(value, 1),
2017-07-23 02:50:25 +08:00
300, Easing.OutQuint);
}
}
2016-09-24 08:57:13 +08:00
}
}