1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 20:33:08 +08:00

Use OffsetClock instead of ManualClock

This commit is contained in:
voidedWarranties 2020-03-10 22:50:20 -07:00
parent 5aa99d8b34
commit 6de244389b
3 changed files with 8 additions and 38 deletions

View File

@ -10,7 +10,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Overlays;
using osu.Game.Screens.Play;
using osu.Game.Storyboards.Drawables;
using osuTK.Graphics;
@ -25,13 +24,9 @@ namespace osu.Game.Tests.Visual.Gameplay
[Cached]
private MusicController musicController = new MusicController();
[Cached]
private GameplayClock gameplayClock;
public TestSceneStoryboard()
{
Clock = new FramedClock();
gameplayClock = new GameplayClock(Clock);
AddRange(new Drawable[]
{

View File

@ -14,7 +14,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Legacy;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
@ -117,14 +116,6 @@ namespace osu.Game.Screens.Play
if (beatmap.BeatmapInfo.AudioLeadIn > 0)
startTime = Math.Min(startTime, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn);
// some beatmaps have no AudioLeadIn but the video starts before the first object
var videoLayer = beatmap.Storyboard.GetLayer(LegacyStoryLayer.Video);
var videoOffset = videoLayer.Elements.SingleOrDefault()?.StartTime;
if (videoOffset != null)
startTime = Math.Min(startTime, videoOffset.GetValueOrDefault());
Seek(startTime);
adjustableClock.ProcessFrame();

View File

@ -10,7 +10,6 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Video;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Screens.Play;
namespace osu.Game.Storyboards.Drawables
{
@ -18,10 +17,6 @@ namespace osu.Game.Storyboards.Drawables
{
public readonly StoryboardVideo Video;
private VideoSprite videoSprite;
private ManualClock videoClock;
private GameplayClock clock;
private bool videoStarted;
public override bool RemoveWhenNotAlive => false;
@ -33,13 +28,8 @@ namespace osu.Game.Storyboards.Drawables
}
[BackgroundDependencyLoader(true)]
private void load(GameplayClock clock, IBindable<WorkingBeatmap> beatmap, TextureStore textureStore)
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore)
{
if (clock == null)
return;
this.clock = clock;
var path = beatmap.Value.BeatmapSetInfo?.Files?.Find(f => f.Filename.Equals(Video.Path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
if (path == null)
@ -56,29 +46,23 @@ namespace osu.Game.Storyboards.Drawables
FillMode = FillMode.Fill,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AlwaysPresent = true,
Alpha = 0
});
videoClock = new ManualClock();
videoSprite.Clock = new FramedClock(videoClock);
}
protected override void Update()
protected override void LoadComplete()
{
if (clock != null && clock.CurrentTime > Video.StartTime)
using (videoSprite.BeginAbsoluteSequence(Video.StartTime))
{
if (!videoStarted)
videoSprite.Clock = new FramedOffsetClock(Clock)
{
videoSprite.FadeIn(500);
videoStarted = true;
}
Offset = -Video.StartTime
};
// handle seeking before the video starts (break skipping, replay seek)
videoClock.CurrentTime = clock.CurrentTime - Video.StartTime;
videoSprite.FadeIn(500);
}
base.Update();
base.LoadComplete();
}
}
}