mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Implement DimmableVideo component
This commit is contained in:
64
osu.Game/Screens/Play/DimmableVideo.cs
Normal file
64
osu.Game/Screens/Play/DimmableVideo.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// 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.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Video;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play
|
||||||
|
{
|
||||||
|
public class DimmableVideo : UserDimContainer
|
||||||
|
{
|
||||||
|
private readonly VideoSprite video;
|
||||||
|
private DrawableVideo drawableVideo;
|
||||||
|
|
||||||
|
public DimmableVideo(VideoSprite video)
|
||||||
|
{
|
||||||
|
this.video = video;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
initializeVideo(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
ShowStoryboard.BindValueChanged(_ => initializeVideo(true), true);
|
||||||
|
base.LoadComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool ShowDimContent => ShowStoryboard.Value && DimLevel < 1;
|
||||||
|
|
||||||
|
private void initializeVideo(bool async)
|
||||||
|
{
|
||||||
|
if (drawableVideo != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!ShowStoryboard.Value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
drawableVideo = new DrawableVideo(video);
|
||||||
|
|
||||||
|
if (async)
|
||||||
|
LoadComponentAsync(drawableVideo, Add);
|
||||||
|
else
|
||||||
|
Add(drawableVideo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DrawableVideo : Container
|
||||||
|
{
|
||||||
|
public DrawableVideo(VideoSprite video)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
Masking = true;
|
||||||
|
|
||||||
|
AddInternal(video);
|
||||||
|
video.RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -81,6 +81,7 @@ namespace osu.Game.Screens.Play
|
|||||||
protected GameplayClockContainer GameplayClockContainer { get; private set; }
|
protected GameplayClockContainer GameplayClockContainer { get; private set; }
|
||||||
|
|
||||||
protected DimmableStoryboard DimmableStoryboard { get; private set; }
|
protected DimmableStoryboard DimmableStoryboard { get; private set; }
|
||||||
|
protected DimmableVideo DimmableVideo { get; private set; }
|
||||||
|
|
||||||
protected VideoSprite Video { get; private set; }
|
protected VideoSprite Video { get; private set; }
|
||||||
|
|
||||||
@ -146,14 +147,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private void addUnderlayComponents(Container target)
|
private void addUnderlayComponents(Container target)
|
||||||
{
|
{
|
||||||
target.Add(DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both });
|
target.Add(DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both });
|
||||||
|
target.Add(DimmableVideo = new DimmableVideo(Beatmap.Value.Video) { RelativeSizeAxes = Axes.Both });
|
||||||
var video = Beatmap.Value.Video;
|
|
||||||
|
|
||||||
if (video != null)
|
|
||||||
{
|
|
||||||
target.Add(Video = video);
|
|
||||||
Video.RelativeSizeAxes = Axes.Both;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addGameplayComponents(Container target, WorkingBeatmap working)
|
private void addGameplayComponents(Container target, WorkingBeatmap working)
|
||||||
|
Reference in New Issue
Block a user