1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Fade hold-for-menu button out completely on non-touch devices

This commit is contained in:
Dean Herbert 2024-01-15 17:48:37 +09:00
parent ed89f6474b
commit 52f8348ee3
No known key found for this signature in database

View File

@ -16,6 +16,7 @@ using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
@ -44,6 +45,8 @@ namespace osu.Game.Screens.Play.HUD
Direction = FillDirection.Horizontal;
Spacing = new Vector2(20, 0);
Margin = new MarginPadding(10);
AlwaysPresent = true;
}
[BackgroundDependencyLoader(true)]
@ -66,9 +69,15 @@ namespace osu.Game.Screens.Play.HUD
Action = () => Action(),
}
};
AutoSizeAxes = Axes.Both;
}
[Resolved]
private SessionStatics sessionStatics { get; set; }
private Bindable<bool> touchActive;
protected override void LoadComplete()
{
button.HoldActivationDelay.BindValueChanged(v =>
@ -78,7 +87,20 @@ namespace osu.Game.Screens.Play.HUD
: "press for menu";
}, true);
text.FadeInFromZero(500, Easing.OutQuint).Delay(1500).FadeOut(500, Easing.OutQuint);
touchActive = sessionStatics.GetBindable<bool>(Static.TouchInputActive);
if (touchActive.Value)
{
Alpha = 1f;
text.FadeInFromZero(500, Easing.OutQuint)
.Delay(1500)
.FadeOut(500, Easing.OutQuint);
}
else
{
Alpha = 0;
text.Alpha = 0f;
}
base.LoadComplete();
}
@ -99,9 +121,11 @@ namespace osu.Game.Screens.Play.HUD
Alpha = 1;
else
{
float minAlpha = touchActive.Value ? .08f : 0;
Alpha = Interpolation.ValueAt(
Math.Clamp(Clock.ElapsedFrameTime, 0, 200),
Alpha, Math.Clamp(1 - positionalAdjust, 0.04f, 1), 0, 200, Easing.OutQuint);
Alpha, Math.Clamp(1 - positionalAdjust, minAlpha, 1), 0, 200, Easing.OutQuint);
}
}