From 52f8348ee31d1cecdc5a514565811588aaf31073 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 Jan 2024 17:48:37 +0900 Subject: [PATCH] Fade hold-for-menu button out completely on non-touch devices --- .../Screens/Play/HUD/HoldForMenuButton.cs | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs index 0921a9f18a..1cf3d25dad 100644 --- a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs +++ b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs @@ -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 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(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); } }