mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 23:23:12 +08:00
Change IBeatSyncProvider.Clock
to always be non-null
This commit is contained in:
parent
9cba24e32c
commit
20e4e2581a
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
@ -283,8 +282,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
if (ReferenceEquals(timingPoints[^1], current))
|
if (ReferenceEquals(timingPoints[^1], current))
|
||||||
{
|
{
|
||||||
Debug.Assert(BeatSyncSource.Clock != null);
|
|
||||||
|
|
||||||
return (int)Math.Ceiling((BeatSyncSource.Clock.CurrentTime - current.Time) / current.BeatLength);
|
return (int)Math.Ceiling((BeatSyncSource.Clock.CurrentTime - current.Time) / current.BeatLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,8 +292,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
Debug.Assert(BeatSyncSource.Clock != null);
|
|
||||||
|
|
||||||
timeUntilNextBeat.Value = TimeUntilNextBeat;
|
timeUntilNextBeat.Value = TimeUntilNextBeat;
|
||||||
timeSinceLastBeat.Value = TimeSinceLastBeat;
|
timeSinceLastBeat.Value = TimeSinceLastBeat;
|
||||||
currentTime.Value = BeatSyncSource.Clock.CurrentTime;
|
currentTime.Value = BeatSyncSource.Clock.CurrentTime;
|
||||||
|
@ -5,14 +5,9 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
public static class BeatSyncProviderExtensions
|
public static class BeatSyncProviderExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Check whether beat sync is currently available.
|
|
||||||
/// </summary>
|
|
||||||
public static bool CheckBeatSyncAvailable(this IBeatSyncProvider provider) => provider.Clock != null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the beat sync provider is currently in a kiai section. Should make everything more epic.
|
/// Whether the beat sync provider is currently in a kiai section. Should make everything more epic.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool CheckIsKiaiTime(this IBeatSyncProvider provider) => provider.Clock != null && provider.ControlPoints?.EffectPointAt(provider.Clock.CurrentTime).KiaiMode == true;
|
public static bool CheckIsKiaiTime(this IBeatSyncProvider provider) => provider.ControlPoints?.EffectPointAt(provider.Clock.CurrentTime).KiaiMode == true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,6 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Access a clock currently responsible for providing beat sync. If <c>null</c>, no current provider is available.
|
/// Access a clock currently responsible for providing beat sync. If <c>null</c>, no current provider is available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IClock? Clock { get; }
|
IClock Clock { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -86,14 +85,12 @@ namespace osu.Game.Graphics.Containers
|
|||||||
TimingControlPoint timingPoint;
|
TimingControlPoint timingPoint;
|
||||||
EffectControlPoint effectPoint;
|
EffectControlPoint effectPoint;
|
||||||
|
|
||||||
IsBeatSyncedWithTrack = BeatSyncSource.CheckBeatSyncAvailable() && BeatSyncSource.Clock?.IsRunning == true;
|
IsBeatSyncedWithTrack = BeatSyncSource.Clock.IsRunning;
|
||||||
|
|
||||||
double currentTrackTime;
|
double currentTrackTime;
|
||||||
|
|
||||||
if (IsBeatSyncedWithTrack)
|
if (IsBeatSyncedWithTrack)
|
||||||
{
|
{
|
||||||
Debug.Assert(BeatSyncSource.Clock != null);
|
|
||||||
|
|
||||||
currentTrackTime = BeatSyncSource.Clock.CurrentTime + EarlyActivationMilliseconds;
|
currentTrackTime = BeatSyncSource.Clock.CurrentTime + EarlyActivationMilliseconds;
|
||||||
|
|
||||||
timingPoint = BeatSyncSource.ControlPoints?.TimingPointAt(currentTrackTime) ?? TimingControlPoint.DEFAULT;
|
timingPoint = BeatSyncSource.ControlPoints?.TimingPointAt(currentTrackTime) ?? TimingControlPoint.DEFAULT;
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
int timeSignature = timingPoint.TimeSignature.Numerator;
|
int timeSignature = timingPoint.TimeSignature.Numerator;
|
||||||
|
|
||||||
// play metronome from one measure before the first object.
|
// play metronome from one measure before the first object.
|
||||||
if (BeatSyncSource.Clock?.CurrentTime < firstHitTime - timingPoint.BeatLength * timeSignature)
|
if (BeatSyncSource.Clock.CurrentTime < firstHitTime - timingPoint.BeatLength * timeSignature)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sample.Frequency.Value = beatIndex % timeSignature == 0 ? 1 : 0.5f;
|
sample.Frequency.Value = beatIndex % timeSignature == 0 ? 1 : 0.5f;
|
||||||
|
@ -240,7 +240,7 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (BeatSyncSource.ControlPoints == null || BeatSyncSource.Clock == null)
|
if (BeatSyncSource.ControlPoints == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
metronomeClock.Rate = IsBeatSyncedWithTrack ? BeatSyncSource.Clock.Rate : 1;
|
metronomeClock.Rate = IsBeatSyncedWithTrack ? BeatSyncSource.Clock.Rate : 1;
|
||||||
@ -259,7 +259,7 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
this.TransformBindableTo(interpolatedBpm, (int)Math.Round(timingPoint.BPM), 600, Easing.OutQuint);
|
this.TransformBindableTo(interpolatedBpm, (int)Math.Round(timingPoint.BPM), 600, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BeatSyncSource.Clock?.IsRunning != true && isSwinging)
|
if (!BeatSyncSource.Clock.IsRunning && isSwinging)
|
||||||
{
|
{
|
||||||
swing.ClearTransforms(true);
|
swing.ClearTransforms(true);
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
}
|
}
|
||||||
|
|
||||||
double averageBeatLength = (tapTimings.Last() - tapTimings.Skip(initial_taps_to_ignore).First()) / (tapTimings.Count - initial_taps_to_ignore - 1);
|
double averageBeatLength = (tapTimings.Last() - tapTimings.Skip(initial_taps_to_ignore).First()) / (tapTimings.Count - initial_taps_to_ignore - 1);
|
||||||
double clockRate = beatSyncSource?.Clock?.Rate ?? 1;
|
double clockRate = beatSyncSource?.Clock.Rate ?? 1;
|
||||||
|
|
||||||
double bpm = Math.Round(60000 / averageBeatLength / clockRate);
|
double bpm = Math.Round(60000 / averageBeatLength / clockRate);
|
||||||
|
|
||||||
|
@ -102,7 +102,6 @@ namespace osu.Game.Screens.Menu
|
|||||||
for (int i = 0; i < temporalAmplitudes.Length; i++)
|
for (int i = 0; i < temporalAmplitudes.Length; i++)
|
||||||
temporalAmplitudes[i] = 0;
|
temporalAmplitudes[i] = 0;
|
||||||
|
|
||||||
if (beatSyncProvider.Clock != null)
|
|
||||||
addAmplitudesFromSource(beatSyncProvider);
|
addAmplitudesFromSource(beatSyncProvider);
|
||||||
|
|
||||||
foreach (var source in amplitudeSources)
|
foreach (var source in amplitudeSources)
|
||||||
|
@ -128,7 +128,7 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
//
|
//
|
||||||
// In the case of storyboard animations, we want to synchronise with game time perfectly
|
// In the case of storyboard animations, we want to synchronise with game time perfectly
|
||||||
// so let's get a correct time based on gameplay clock and earliest transform.
|
// so let's get a correct time based on gameplay clock and earliest transform.
|
||||||
PlaybackPosition = (beatSyncProvider.Clock?.CurrentTime ?? Clock.CurrentTime) - Animation.EarliestTransformTime;
|
PlaybackPosition = beatSyncProvider.Clock.CurrentTime - Animation.EarliestTransformTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void skinSourceChanged()
|
private void skinSourceChanged()
|
||||||
|
Loading…
Reference in New Issue
Block a user