2020-03-08 05:32:03 +00: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.
|
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-03-08 05:32:03 +00:00
|
|
|
|
using System;
|
2021-11-19 07:07:55 +00:00
|
|
|
|
using System.Linq;
|
2020-03-08 05:32:03 +00:00
|
|
|
|
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;
|
2021-11-19 07:07:55 +00:00
|
|
|
|
using osu.Game.Extensions;
|
2020-03-08 05:32:03 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Storyboards.Drawables
|
|
|
|
|
{
|
2020-03-11 08:55:20 +00:00
|
|
|
|
public class DrawableStoryboardVideo : CompositeDrawable
|
2020-03-08 05:32:03 +00:00
|
|
|
|
{
|
|
|
|
|
public readonly StoryboardVideo Video;
|
2020-04-03 06:59:56 +00:00
|
|
|
|
private Video video;
|
2020-03-08 05:32:03 +00:00
|
|
|
|
|
|
|
|
|
public override bool RemoveWhenNotAlive => false;
|
|
|
|
|
|
|
|
|
|
public DrawableStoryboardVideo(StoryboardVideo video)
|
|
|
|
|
{
|
|
|
|
|
Video = video;
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-08 06:08:38 +00:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2020-03-11 05:50:20 +00:00
|
|
|
|
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore)
|
2020-03-08 05:32:03 +00:00
|
|
|
|
{
|
2021-11-19 07:07:55 +00:00
|
|
|
|
string path = beatmap.Value.BeatmapSetInfo?.Files.FirstOrDefault(f => f.Filename.Equals(Video.Path, StringComparison.OrdinalIgnoreCase))?.File.GetStoragePath();
|
2020-03-08 05:32:03 +00:00
|
|
|
|
|
|
|
|
|
if (path == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var stream = textureStore.GetStream(path);
|
|
|
|
|
|
|
|
|
|
if (stream == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-04-03 06:59:56 +00:00
|
|
|
|
InternalChild = video = new Video(stream, false)
|
2020-03-08 05:32:03 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2020-03-11 06:11:54 +00:00
|
|
|
|
Alpha = 0,
|
2020-03-11 08:55:20 +00:00
|
|
|
|
};
|
2020-03-08 05:32:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-11 05:50:20 +00:00
|
|
|
|
protected override void LoadComplete()
|
2020-03-08 05:32:03 +00:00
|
|
|
|
{
|
2020-03-11 06:11:54 +00:00
|
|
|
|
base.LoadComplete();
|
2020-03-08 05:32:03 +00:00
|
|
|
|
|
2020-04-03 06:59:56 +00:00
|
|
|
|
if (video == null) return;
|
2020-03-26 16:09:22 +00:00
|
|
|
|
|
2020-07-16 05:25:45 +00:00
|
|
|
|
using (video.BeginAbsoluteSequence(Video.StartTime))
|
|
|
|
|
{
|
|
|
|
|
Schedule(() => video.PlaybackPosition = Time.Current - Video.StartTime);
|
2020-04-03 06:59:56 +00:00
|
|
|
|
video.FadeIn(500);
|
2020-07-16 05:25:45 +00:00
|
|
|
|
}
|
2020-03-08 05:32:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|