From d47a3bb8e4948aefff1d8d07e965eac729455cf6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 1 Jun 2022 20:44:05 +0900 Subject: [PATCH] Use NRT and transfer BPM --- osu.Game/Screens/Edit/Timing/TapButton.cs | 41 ++++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Edit/Timing/TapButton.cs b/osu.Game/Screens/Edit/Timing/TapButton.cs index 9c6dde4ffe..d85edb6cce 100644 --- a/osu.Game/Screens/Edit/Timing/TapButton.cs +++ b/osu.Game/Screens/Edit/Timing/TapButton.cs @@ -1,10 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +#nullable enable + using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -14,6 +17,7 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; using osu.Framework.Threading; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; @@ -27,24 +31,27 @@ namespace osu.Game.Screens.Edit.Timing public const float SIZE = 100; [Resolved] - private OverlayColourProvider colourProvider { get; set; } + private OverlayColourProvider colourProvider { get; set; } = null!; - private Circle hoverLayer; + [Resolved(canBeNull: true)] + private Bindable? selectedGroup { get; set; } - private CircularContainer innerCircle; - private Box innerCircleHighlight; + private Circle hoverLayer = null!; + + private CircularContainer innerCircle = null!; + private Box innerCircleHighlight = null!; private int currentLight; - private Container scaleContainer; - private Container lights; - private Container lightsGlow; - private OsuSpriteText bpmText; - private Container textContainer; + private Container scaleContainer = null!; + private Container lights = null!; + private Container lightsGlow = null!; + private OsuSpriteText bpmText = null!; + private Container textContainer = null!; private bool grabbedMouseDown; - private ScheduledDelegate resetDelegate; + private ScheduledDelegate? resetDelegate; private const int light_count = 6; @@ -280,16 +287,24 @@ namespace osu.Game.Screens.Edit.Timing double bpm = Math.Round(60000 / ((tapTimings.Last() - tapTimings.First()) / (tapTimings.Count - 1))); bpmText.Text = $"{bpm} BPM"; + + var timingPoint = selectedGroup?.Value.ControlPoints.OfType().FirstOrDefault(); + + if (timingPoint != null) + { + // Intentionally use the rounded BPM here. + timingPoint.BeatLength = 60000 / bpm; + } } private class Light : CompositeDrawable { - public Drawable Glow { get; private set; } + public Drawable Glow { get; private set; } = null!; - private Container fillContent; + private Container fillContent = null!; [Resolved] - private OverlayColourProvider colourProvider { get; set; } + private OverlayColourProvider colourProvider { get; set; } = null!; [BackgroundDependencyLoader] private void load()