mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 17:47:29 +08:00
Fix regression in idle behaviour and refactor further
This commit is contained in:
parent
5ecf6511e6
commit
c47ff1919c
@ -21,6 +21,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// This container does not set its own clock to the source used for beat matching.
|
/// This container does not set its own clock to the source used for beat matching.
|
||||||
/// This means that if the beat source clock is playing faster or slower, animations may unexpectedly overlap.
|
/// This means that if the beat source clock is playing faster or slower, animations may unexpectedly overlap.
|
||||||
/// Make sure this container's Clock is also set to the expected source (or within a parent element which provides this).
|
/// Make sure this container's Clock is also set to the expected source (or within a parent element which provides this).
|
||||||
|
///
|
||||||
|
/// This container will also trigger beat events when the beat matching clock is paused at <see cref="TimingControlPoint.DEFAULT"/>'s BPM.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class BeatSyncedContainer : Container
|
public class BeatSyncedContainer : Container
|
||||||
{
|
{
|
||||||
@ -53,6 +55,9 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double MinimumBeatLength { get; set; }
|
public double MinimumBeatLength { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this container is currently tracking a beatmap's timing data.
|
||||||
|
/// </summary>
|
||||||
protected bool IsBeatSyncedWithTrack { get; private set; }
|
protected bool IsBeatSyncedWithTrack { get; private set; }
|
||||||
|
|
||||||
protected virtual void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
protected virtual void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||||
@ -84,35 +89,36 @@ namespace osu.Game.Graphics.Containers
|
|||||||
ITrack track = null;
|
ITrack track = null;
|
||||||
IBeatmap beatmap = null;
|
IBeatmap beatmap = null;
|
||||||
|
|
||||||
double currentTrackTime = 0;
|
TimingControlPoint timingPoint;
|
||||||
|
EffectControlPoint effectPoint;
|
||||||
|
|
||||||
TimingControlPoint timingPoint = null;
|
IClock clock = BeatSyncClock;
|
||||||
EffectControlPoint effectPoint = null;
|
|
||||||
|
|
||||||
var clock = BeatSyncClock;
|
|
||||||
|
|
||||||
if (clock == null)
|
if (clock == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
double currentTrackTime = clock.CurrentTime + EarlyActivationMilliseconds;
|
||||||
|
|
||||||
if (Beatmap.Value.TrackLoaded && Beatmap.Value.BeatmapLoaded)
|
if (Beatmap.Value.TrackLoaded && Beatmap.Value.BeatmapLoaded)
|
||||||
{
|
{
|
||||||
track = Beatmap.Value.Track;
|
track = Beatmap.Value.Track;
|
||||||
beatmap = Beatmap.Value.Beatmap;
|
beatmap = Beatmap.Value.Beatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track != null && beatmap != null && clock.IsRunning && track.Length > 0)
|
IsBeatSyncedWithTrack = beatmap != null && clock.IsRunning && track?.Length > 0;
|
||||||
|
|
||||||
|
if (IsBeatSyncedWithTrack)
|
||||||
{
|
{
|
||||||
currentTrackTime = clock.CurrentTime + EarlyActivationMilliseconds;
|
Debug.Assert(beatmap != null);
|
||||||
|
|
||||||
timingPoint = beatmap.ControlPointInfo.TimingPointAt(currentTrackTime);
|
timingPoint = beatmap.ControlPointInfo.TimingPointAt(currentTrackTime);
|
||||||
effectPoint = beatmap.ControlPointInfo.EffectPointAt(currentTrackTime);
|
effectPoint = beatmap.ControlPointInfo.EffectPointAt(currentTrackTime);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
IsBeatSyncedWithTrack = timingPoint?.BeatLength > 0;
|
|
||||||
|
|
||||||
if (!IsBeatSyncedWithTrack)
|
|
||||||
{
|
{
|
||||||
currentTrackTime = clock.CurrentTime;
|
// this may be the case where the beat syncing clock has been paused.
|
||||||
|
// we still want to show an idle animation, so use this container's time instead.
|
||||||
|
currentTrackTime = Clock.CurrentTime;
|
||||||
timingPoint = TimingControlPoint.DEFAULT;
|
timingPoint = TimingControlPoint.DEFAULT;
|
||||||
effectPoint = EffectControlPoint.DEFAULT;
|
effectPoint = EffectControlPoint.DEFAULT;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user