Skip to content

Commit

Permalink
Apply NRT to HoldForMenuButton
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Oct 23, 2024
1 parent 77d2f35 commit b8a8f35
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions osu.Game/Screens/Play/HUD/HoldForMenuButton.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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;
Expand Down Expand Up @@ -36,13 +34,13 @@ public partial class HoldForMenuButton : FillFlowContainer

public readonly Bindable<bool> ReplayLoaded = new Bindable<bool>();

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<bool> alwaysShow;
private Bindable<bool> alwaysShow = null!;

public HoldForMenuButton()
{
Expand All @@ -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[]
{
Expand All @@ -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(),
}
};

Expand All @@ -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<bool> touchActive;
private Bindable<bool> touchActive = null!;

protected override void LoadComplete()
{
Expand Down Expand Up @@ -144,23 +142,23 @@ protected override void Update()

private partial class HoldButton : HoldToConfirmContainer, IKeyBindingHandler<GlobalAction>
{
private SpriteIcon icon;
private CircularProgress circularProgress;
private Circle overlayCircle;
private SpriteIcon icon = null!;
private CircularProgress circularProgress = null!;
private Circle overlayCircle = null!;

public readonly Bindable<bool> IsPaused = new Bindable<bool>();

public readonly Bindable<bool> ReplayLoaded = new Bindable<bool>();

protected override bool AllowMultipleFires => 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)
Expand Down

0 comments on commit b8a8f35

Please sign in to comment.