mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 16:37:26 +08:00
641e651bf2
The `StoryboardResourceLookupStore` cached at storyboard level is supposed to already be handling that; no need for local logic anymore.
65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Textures;
|
|
using osu.Framework.Graphics.Video;
|
|
using osu.Game.Beatmaps;
|
|
|
|
namespace osu.Game.Storyboards.Drawables
|
|
{
|
|
public partial class DrawableStoryboardVideo : CompositeDrawable
|
|
{
|
|
public readonly StoryboardVideo Video;
|
|
|
|
private Video? drawableVideo;
|
|
|
|
public override bool RemoveWhenNotAlive => false;
|
|
|
|
public DrawableStoryboardVideo(StoryboardVideo video)
|
|
{
|
|
Video = video;
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
}
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore)
|
|
{
|
|
var stream = textureStore.GetStream(Video.Path);
|
|
|
|
if (stream == null)
|
|
return;
|
|
|
|
InternalChild = drawableVideo = new Video(stream, false)
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
FillMode = FillMode.Fill,
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Alpha = 0,
|
|
};
|
|
}
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
|
|
if (drawableVideo == null) return;
|
|
|
|
using (drawableVideo.BeginAbsoluteSequence(Video.StartTime))
|
|
{
|
|
Schedule(() => drawableVideo.PlaybackPosition = Time.Current - Video.StartTime);
|
|
|
|
drawableVideo.FadeIn(500);
|
|
|
|
using (drawableVideo.BeginDelayedSequence(drawableVideo.Duration - 500))
|
|
drawableVideo.FadeOut(500);
|
|
}
|
|
}
|
|
}
|
|
}
|