mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Use bindable flow for checking idle time
This commit is contained in:
@ -8,6 +8,7 @@ using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Bindings;
|
||||
@ -27,6 +28,8 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
public event Action<ButtonSystemState> StateChanged;
|
||||
|
||||
private readonly BindableBool isIdle = new BindableBool();
|
||||
|
||||
public Action OnEdit;
|
||||
public Action OnExit;
|
||||
public Action OnDirect;
|
||||
@ -65,8 +68,6 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private SampleChannel sampleBack;
|
||||
|
||||
private IdleTracker idleTracker;
|
||||
|
||||
public ButtonSystem()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
@ -108,10 +109,19 @@ namespace osu.Game.Screens.Menu
|
||||
private void load(AudioManager audio, OsuGame game, IdleTracker idleTracker)
|
||||
{
|
||||
this.game = game;
|
||||
this.idleTracker = idleTracker;
|
||||
|
||||
isIdle.ValueChanged += updateIdleState;
|
||||
isIdle.BindTo(idleTracker.IsIdle);
|
||||
|
||||
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
|
||||
}
|
||||
|
||||
private void updateIdleState(bool isIdle)
|
||||
{
|
||||
if (isIdle && State != ButtonSystemState.Exit)
|
||||
State = ButtonSystemState.Initial;
|
||||
}
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
switch (action)
|
||||
@ -270,9 +280,6 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (idleTracker?.IdleTime > 6000 && State != ButtonSystemState.Exit)
|
||||
State = ButtonSystemState.Initial;
|
||||
|
||||
base.Update();
|
||||
|
||||
if (logo != null)
|
||||
|
Reference in New Issue
Block a user