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.
|
|
|
|
|
|
2020-06-04 04:07:50 +00:00
|
|
|
|
using System;
|
2019-05-08 10:03:26 +00:00
|
|
|
|
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;
|
2019-05-08 10:03:26 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2019-04-10 21:47:32 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2020-06-04 04:07:50 +00:00
|
|
|
|
using osu.Game.Input.Bindings;
|
2019-04-10 21:47:32 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class FooterButtonRandom : FooterButton
|
|
|
|
|
{
|
2020-06-04 09:00:29 +00:00
|
|
|
|
public Action NextRandom { get; set; }
|
|
|
|
|
public Action PreviousRandom { get; set; }
|
2020-06-04 04:07:50 +00:00
|
|
|
|
|
2019-04-10 21:47:32 +00:00
|
|
|
|
private readonly SpriteText secondaryText;
|
2020-06-04 08:58:19 +00:00
|
|
|
|
private bool rewindSearch;
|
2019-04-10 21:47:32 +00:00
|
|
|
|
|
|
|
|
|
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",
|
2020-01-29 17:59:51 +00:00
|
|
|
|
Alpha = 0,
|
2019-04-10 21:47:32 +00:00
|
|
|
|
});
|
2020-01-29 17:59:51 +00:00
|
|
|
|
|
|
|
|
|
// force both text sprites to always be present to avoid width flickering while they're being swapped out
|
|
|
|
|
SpriteText.AlwaysPresent = secondaryText.AlwaysPresent = true;
|
2019-04-10 21:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 10:03:26 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
SelectedColour = colours.Green;
|
|
|
|
|
DeselectedColour = SelectedColour.Opacity(0.5f);
|
|
|
|
|
Text = @"random";
|
2019-04-10 21:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateText()
|
|
|
|
|
{
|
2020-06-04 08:58:19 +00:00
|
|
|
|
if (rewindSearch)
|
2019-04-10 21:47:32 +00:00
|
|
|
|
{
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-04 04:07:50 +00:00
|
|
|
|
|
|
|
|
|
public override bool OnPressed(GlobalAction action)
|
|
|
|
|
{
|
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case GlobalAction.SelectPreviousRandom:
|
2020-06-04 08:58:19 +00:00
|
|
|
|
rewindSearch = true;
|
2020-06-04 09:00:29 +00:00
|
|
|
|
Action = PreviousRandom;
|
2020-06-04 04:07:50 +00:00
|
|
|
|
updateText();
|
|
|
|
|
Click();
|
|
|
|
|
return true;
|
2020-06-04 04:59:04 +00:00
|
|
|
|
|
2020-06-04 04:07:50 +00:00
|
|
|
|
case GlobalAction.SelectNextRandom:
|
2020-06-04 09:00:29 +00:00
|
|
|
|
Action = NextRandom;
|
2020-06-04 04:07:50 +00:00
|
|
|
|
updateText();
|
|
|
|
|
Click();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-06-04 08:57:24 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
2020-06-04 04:07:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReleased(GlobalAction action)
|
|
|
|
|
{
|
|
|
|
|
if (action == GlobalAction.SelectPreviousRandom)
|
|
|
|
|
{
|
2020-06-04 08:58:19 +00:00
|
|
|
|
rewindSearch = false;
|
2020-06-04 04:07:50 +00:00
|
|
|
|
updateText();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-10 21:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|