mirror of
https://github.com/ppy/osu.git
synced 2025-01-09 03:02:56 +08:00
Use OffsetClock instead of ManualClock
This commit is contained in:
parent
5aa99d8b34
commit
6de244389b
@ -10,7 +10,6 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
using osu.Game.Storyboards.Drawables;
|
using osu.Game.Storyboards.Drawables;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -25,13 +24,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Cached]
|
[Cached]
|
||||||
private MusicController musicController = new MusicController();
|
private MusicController musicController = new MusicController();
|
||||||
|
|
||||||
[Cached]
|
|
||||||
private GameplayClock gameplayClock;
|
|
||||||
|
|
||||||
public TestSceneStoryboard()
|
public TestSceneStoryboard()
|
||||||
{
|
{
|
||||||
Clock = new FramedClock();
|
Clock = new FramedClock();
|
||||||
gameplayClock = new GameplayClock(Clock);
|
|
||||||
|
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Legacy;
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
|
||||||
@ -117,14 +116,6 @@ namespace osu.Game.Screens.Play
|
|||||||
if (beatmap.BeatmapInfo.AudioLeadIn > 0)
|
if (beatmap.BeatmapInfo.AudioLeadIn > 0)
|
||||||
startTime = Math.Min(startTime, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn);
|
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);
|
Seek(startTime);
|
||||||
|
|
||||||
adjustableClock.ProcessFrame();
|
adjustableClock.ProcessFrame();
|
||||||
|
@ -10,7 +10,6 @@ using osu.Framework.Graphics.Textures;
|
|||||||
using osu.Framework.Graphics.Video;
|
using osu.Framework.Graphics.Video;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
|
|
||||||
namespace osu.Game.Storyboards.Drawables
|
namespace osu.Game.Storyboards.Drawables
|
||||||
{
|
{
|
||||||
@ -18,10 +17,6 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
{
|
{
|
||||||
public readonly StoryboardVideo Video;
|
public readonly StoryboardVideo Video;
|
||||||
private VideoSprite videoSprite;
|
private VideoSprite videoSprite;
|
||||||
private ManualClock videoClock;
|
|
||||||
private GameplayClock clock;
|
|
||||||
|
|
||||||
private bool videoStarted;
|
|
||||||
|
|
||||||
public override bool RemoveWhenNotAlive => false;
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
@ -33,13 +28,8 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[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;
|
var path = beatmap.Value.BeatmapSetInfo?.Files?.Find(f => f.Filename.Equals(Video.Path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
|
||||||
|
|
||||||
if (path == null)
|
if (path == null)
|
||||||
@ -56,29 +46,23 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
FillMode = FillMode.Fill,
|
FillMode = FillMode.Fill,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
AlwaysPresent = true,
|
|
||||||
Alpha = 0
|
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)
|
||||||
{
|
{
|
||||||
|
Offset = -Video.StartTime
|
||||||
|
};
|
||||||
|
|
||||||
videoSprite.FadeIn(500);
|
videoSprite.FadeIn(500);
|
||||||
videoStarted = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle seeking before the video starts (break skipping, replay seek)
|
base.LoadComplete();
|
||||||
videoClock.CurrentTime = clock.CurrentTime - Video.StartTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
base.Update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user