osu/osu.Game/Screens/Select/FooterButtonRandom.cs

67 lines
1.8 KiB
C#
Raw Normal View History

2019-04-10 21:47:32 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
2019-04-10 21:47:32 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
2019-04-10 21:47:32 +00:00
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Select
{
public class FooterButtonRandom : FooterButton
{
private readonly SpriteText secondaryText;
private bool secondaryActive;
public FooterButtonRandom()
{
2019-05-03 08:38:15 +00:00
TextContainer.Add(secondaryText = new OsuSpriteText
2019-04-10 21:47:32 +00:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = @"rewind",
Alpha = 0
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
SelectedColour = colours.Green;
DeselectedColour = SelectedColour.Opacity(0.5f);
Text = @"random";
}
2019-04-10 21:47:32 +00:00
protected override bool OnKeyDown(KeyDownEvent e)
{
secondaryActive = e.ShiftPressed;
updateText();
return base.OnKeyDown(e);
}
protected override bool OnKeyUp(KeyUpEvent e)
{
secondaryActive = e.ShiftPressed;
updateText();
return base.OnKeyUp(e);
}
private void updateText()
{
if (secondaryActive)
{
2019-05-03 08:38:15 +00:00
SpriteText.FadeOut(120, Easing.InQuad);
2019-04-10 21:47:32 +00:00
secondaryText.FadeIn(120, Easing.InQuad);
}
else
{
2019-05-03 08:38:15 +00:00
SpriteText.FadeIn(120, Easing.InQuad);
2019-04-10 21:47:32 +00:00
secondaryText.FadeOut(120, Easing.InQuad);
}
}
}
}