2020-03-08 13:32:03 +08:00
|
|
|
|
// 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 System;
|
|
|
|
|
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.Framework.Timing;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Storyboards.Drawables
|
|
|
|
|
{
|
2020-03-11 16:55:20 +08:00
|
|
|
|
public class DrawableStoryboardVideo : CompositeDrawable
|
2020-03-08 13:32:03 +08:00
|
|
|
|
{
|
|
|
|
|
public readonly StoryboardVideo Video;
|
|
|
|
|
private VideoSprite videoSprite;
|
|
|
|
|
|
|
|
|
|
public override bool RemoveWhenNotAlive => false;
|
|
|
|
|
|
|
|
|
|
public DrawableStoryboardVideo(StoryboardVideo video)
|
|
|
|
|
{
|
|
|
|
|
Video = video;
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-08 14:08:38 +08:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2020-03-11 13:50:20 +08:00
|
|
|
|
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore)
|
2020-03-08 13:32:03 +08:00
|
|
|
|
{
|
|
|
|
|
var path = beatmap.Value.BeatmapSetInfo?.Files?.Find(f => f.Filename.Equals(Video.Path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
|
|
|
|
|
|
|
|
|
|
if (path == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var stream = textureStore.GetStream(path);
|
|
|
|
|
|
|
|
|
|
if (stream == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-03-11 16:55:20 +08:00
|
|
|
|
InternalChild = videoSprite = new VideoSprite(stream, false)
|
2020-03-08 13:32:03 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2020-03-11 14:11:54 +08:00
|
|
|
|
Alpha = 0,
|
|
|
|
|
Clock = new FramedOffsetClock(Clock) { Offset = -Video.StartTime }
|
2020-03-11 16:55:20 +08:00
|
|
|
|
};
|
2020-03-08 13:32:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-11 13:50:20 +08:00
|
|
|
|
protected override void LoadComplete()
|
2020-03-08 13:32:03 +08:00
|
|
|
|
{
|
2020-03-11 14:11:54 +08:00
|
|
|
|
base.LoadComplete();
|
2020-03-08 13:32:03 +08:00
|
|
|
|
|
2020-03-27 00:09:22 +08:00
|
|
|
|
if (videoSprite == null) return;
|
|
|
|
|
|
2020-03-11 14:11:54 +08:00
|
|
|
|
using (videoSprite.BeginAbsoluteSequence(0))
|
2020-03-11 13:50:20 +08:00
|
|
|
|
videoSprite.FadeIn(500);
|
2020-03-08 13:32:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|