Add global FramedBeatmapClock for BeatSyncProvider components

This commit is contained in:
Dean Herbert 2022-08-26 17:44:33 +09:00
parent 9050f54681
commit fec744a7fe

View File

@ -185,6 +185,12 @@ namespace osu.Game
private RealmAccess realm;
/// <summary>
/// For now, this is used as a source specifically for beat synced components.
/// Going forward, it could potentially be used as the single source-of-truth for beatmap timing.
/// </summary>
private readonly FramedBeatmapClock beatmapClock = new FramedBeatmapClock(true);
protected override Container<Drawable> Content => content;
private Container content;
@ -368,10 +374,15 @@ namespace osu.Game
AddInternal(MusicController = new MusicController());
dependencies.CacheAs(MusicController);
MusicController.TrackChanged += onTrackChanged;
AddInternal(beatmapClock);
Ruleset.BindValueChanged(onRulesetChanged);
Beatmap.BindValueChanged(onBeatmapChanged);
}
private void onTrackChanged(WorkingBeatmap beatmap, TrackChangeDirection direction) => beatmapClock.ChangeSource(beatmap.Track);
protected virtual void InitialiseFonts()
{
AddFont(Resources, @"Fonts/osuFont");
@ -587,7 +598,7 @@ namespace osu.Game
}
ControlPointInfo IBeatSyncProvider.ControlPoints => Beatmap.Value.BeatmapLoaded ? Beatmap.Value.Beatmap.ControlPointInfo : null;
IClock IBeatSyncProvider.Clock => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track : (IClock)null;
IClock IBeatSyncProvider.Clock => beatmapClock;
ChannelAmplitudes IHasAmplitudes.CurrentAmplitudes => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track.CurrentAmplitudes : ChannelAmplitudes.Empty;
}
}