2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-09-26 13:56:05 +08:00
|
|
|
|
|
2017-08-04 14:37:31 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-08-04 14:37:31 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.MathUtils;
|
2017-01-27 20:57:22 +08:00
|
|
|
|
using osu.Game.Screens.Play;
|
2017-08-04 14:37:31 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using OpenTK.Input;
|
2016-09-24 08:57:13 +08:00
|
|
|
|
|
2017-08-04 14:37:31 +08:00
|
|
|
|
namespace osu.Desktop.Tests.Visual
|
2016-09-24 08:57:13 +08:00
|
|
|
|
{
|
2017-08-04 14:37:31 +08:00
|
|
|
|
internal class TestCaseKeyCounter : OsuTestCase
|
2016-09-24 08:57:13 +08:00
|
|
|
|
{
|
|
|
|
|
public override string Description => @"Tests key counter";
|
|
|
|
|
|
2017-07-07 20:05:55 +08:00
|
|
|
|
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[]
|
2016-10-09 17:55:38 +08:00
|
|
|
|
{
|
2017-03-05 02:42:37 +08:00
|
|
|
|
new KeyCounterKeyboard(Key.Z),
|
|
|
|
|
new KeyCounterKeyboard(Key.X),
|
|
|
|
|
new KeyCounterMouse(MouseButton.Left),
|
|
|
|
|
new KeyCounterMouse(MouseButton.Right),
|
2016-10-09 17:55:38 +08:00
|
|
|
|
},
|
2016-12-05 01:03:18 +08:00
|
|
|
|
};
|
2017-08-16 00:10:09 +08:00
|
|
|
|
|
|
|
|
|
AddStep("Add random", () =>
|
2016-12-05 01:03:18 +08:00
|
|
|
|
{
|
|
|
|
|
Key key = (Key)((int)Key.A + RNG.Next(26));
|
2017-03-05 02:42:37 +08:00
|
|
|
|
kc.Add(new KeyCounterKeyboard(key));
|
2016-12-05 01:03:18 +08:00
|
|
|
|
});
|
2017-08-16 00:10:09 +08:00
|
|
|
|
AddSliderStep("Fade time", 0, 200, 50, v => kc.FadeTime = v);
|
2017-04-10 16:10:15 +08:00
|
|
|
|
|
2016-12-05 01:03:18 +08:00
|
|
|
|
Add(kc);
|
2016-09-24 08:57:13 +08:00
|
|
|
|
}
|
2016-12-18 12:36:49 +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-12-18 12:36:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-24 08:57:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|