From b8a8f35ea9f248f0a47841f7d28247ca2c4aff84 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 23 Oct 2024 23:36:22 +0900 Subject: [PATCH] Apply NRT to `HoldForMenuButton` --- .../Screens/Play/HUD/HoldForMenuButton.cs | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs index 806985e19dd3..138c510a0fa0 100644 --- a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs +++ b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Linq; using osu.Framework.Allocation; @@ -36,13 +34,13 @@ public partial class HoldForMenuButton : FillFlowContainer public readonly Bindable ReplayLoaded = new Bindable(); - private HoldButton button; + private HoldButton button = null!; - public Action Action { get; set; } + public Action? Action { get; set; } - private OsuSpriteText text; + private OsuSpriteText text = null!; - private Bindable alwaysShow; + private Bindable alwaysShow = null!; public HoldForMenuButton() { @@ -53,8 +51,8 @@ public HoldForMenuButton() AlwaysPresent = true; } - [BackgroundDependencyLoader(true)] - private void load(Player player, OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(Player? player, OsuConfigManager config) { Children = new Drawable[] { @@ -70,7 +68,7 @@ private void load(Player player, OsuConfigManager config) HoverLost = () => text.FadeOut(500, Easing.OutQuint), IsPaused = { BindTarget = IsPaused }, ReplayLoaded = { BindTarget = ReplayLoaded }, - Action = () => Action(), + Action = () => Action?.Invoke(), } }; @@ -80,9 +78,9 @@ private void load(Player player, OsuConfigManager config) } [Resolved] - private SessionStatics sessionStatics { get; set; } + private SessionStatics sessionStatics { get; set; } = null!; - private Bindable touchActive; + private Bindable touchActive = null!; protected override void LoadComplete() { @@ -144,9 +142,9 @@ protected override void Update() private partial class HoldButton : HoldToConfirmContainer, IKeyBindingHandler { - private SpriteIcon icon; - private CircularProgress circularProgress; - private Circle overlayCircle; + private SpriteIcon icon = null!; + private CircularProgress circularProgress = null!; + private Circle overlayCircle = null!; public readonly Bindable IsPaused = new Bindable(); @@ -154,13 +152,13 @@ private partial class HoldButton : HoldToConfirmContainer, IKeyBindingHandler true; - public Action HoverGained; - public Action HoverLost; + public Action? HoverGained; + public Action? HoverLost; private const double shake_duration = 20; private bool pendingAnimation; - private ScheduledDelegate shakeOperation; + private ScheduledDelegate? shakeOperation; public HoldButton(bool isDangerousAction) : base(isDangerousAction)