mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 17:47:29 +08:00
Avoid using scheduled delegates at all for skip overload input handling
This commit is contained in:
parent
956e3c554b
commit
b1a261c902
@ -12,7 +12,6 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -120,6 +119,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
button.Action = () => RequestSkip?.Invoke();
|
||||
displayTime = gameplayClock.CurrentTime;
|
||||
|
||||
fadeContainer.TriggerShow();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -138,7 +139,7 @@ namespace osu.Game.Screens.Play
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
if (isClickable && !e.HasAnyButtonPressed)
|
||||
fadeContainer.Show();
|
||||
fadeContainer.TriggerShow();
|
||||
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
@ -167,34 +168,45 @@ namespace osu.Game.Screens.Play
|
||||
public event Action<Visibility> StateChanged;
|
||||
|
||||
private Visibility state;
|
||||
private ScheduledDelegate scheduledHide;
|
||||
private double? nextHideTime;
|
||||
|
||||
public override bool IsPresent => true;
|
||||
|
||||
public void TriggerShow()
|
||||
{
|
||||
Show();
|
||||
|
||||
if (!IsHovered && !IsDragged)
|
||||
nextHideTime = Time.Current + 1000;
|
||||
else
|
||||
nextHideTime = null;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (nextHideTime != null && nextHideTime <= Time.Current)
|
||||
{
|
||||
Hide();
|
||||
nextHideTime = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Visibility State
|
||||
{
|
||||
get => state;
|
||||
set
|
||||
{
|
||||
bool stateChanged = value != state;
|
||||
if (value == state)
|
||||
return;
|
||||
|
||||
state = value;
|
||||
|
||||
scheduledHide?.Cancel();
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case Visibility.Visible:
|
||||
// we may be triggered to become visible multiple times but we only want to transform once.
|
||||
if (stateChanged)
|
||||
this.FadeIn(500, Easing.OutExpo);
|
||||
|
||||
if (!IsHovered && !IsDragged)
|
||||
{
|
||||
using (BeginDelayedSequence(1000))
|
||||
scheduledHide = Schedule(Hide);
|
||||
}
|
||||
|
||||
this.FadeIn(500, Easing.OutExpo);
|
||||
break;
|
||||
|
||||
case Visibility.Hidden:
|
||||
@ -215,7 +227,7 @@ namespace osu.Game.Screens.Play
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
Show();
|
||||
scheduledHide?.Cancel();
|
||||
nextHideTime = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user