1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 22:47:25 +08:00
osu-lazer/osu.Game/Screens/Select/FooterButtonRandom.cs

60 lines
1.6 KiB
C#
Raw Normal View History

2019-04-11 05:47:32 +08: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 System;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Graphics;
using osu.Game.Input.Bindings;
2019-04-11 05:47:32 +08:00
namespace osu.Game.Screens.Select
{
public class FooterButtonRandom : FooterButton
{
public Action NextRandom { get; set; }
public Action PreviousRandom { get; set; }
2020-06-04 16:58:19 +08:00
private bool rewindSearch;
2019-04-11 05:47:32 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
SelectedColour = colours.Green;
DeselectedColour = SelectedColour.Opacity(0.5f);
Text = @"random";
Action = () =>
{
if (rewindSearch)
{
PreviousRandom.Invoke();
}
else
{
NextRandom.Invoke();
}
};
2019-04-11 05:47:32 +08:00
}
public override bool OnPressed(GlobalAction action)
{
rewindSearch = action == GlobalAction.SelectPreviousRandom;
2020-06-07 12:06:18 +08:00
if (action != GlobalAction.SelectNextRandom && !rewindSearch)
{
return false;
}
2020-06-07 12:06:18 +08:00
Click();
return true;
}
public override void OnReleased(GlobalAction action)
{
if (action == GlobalAction.SelectPreviousRandom)
{
2020-06-04 16:58:19 +08:00
rewindSearch = false;
}
}
2019-04-11 05:47:32 +08:00
}
}