2019-01-24 08:43: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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-05-10 07:31:09 +00:00
|
|
|
|
using System.Threading;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Storyboards.Drawables
|
|
|
|
|
{
|
2020-03-30 19:37:20 +00:00
|
|
|
|
public class DrawableStoryboardLayer : CompositeDrawable
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-01-20 04:50:27 +00:00
|
|
|
|
public StoryboardLayer Layer { get; }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public bool Enabled;
|
|
|
|
|
|
|
|
|
|
public override bool IsPresent => Enabled && base.IsPresent;
|
|
|
|
|
|
|
|
|
|
public DrawableStoryboardLayer(StoryboardLayer layer)
|
|
|
|
|
{
|
|
|
|
|
Layer = layer;
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
2020-03-25 02:08:08 +00:00
|
|
|
|
Enabled = layer.VisibleWhenPassing;
|
2020-03-24 05:51:37 +00:00
|
|
|
|
Masking = layer.Masking;
|
2020-03-30 19:37:20 +00:00
|
|
|
|
|
|
|
|
|
InternalChild = new LayerElementContainer(layer);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-30 19:37:20 +00:00
|
|
|
|
private class LayerElementContainer : LifetimeManagementContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-03-30 19:37:20 +00:00
|
|
|
|
private readonly StoryboardLayer storyboardLayer;
|
|
|
|
|
|
|
|
|
|
public LayerElementContainer(StoryboardLayer layer)
|
|
|
|
|
{
|
|
|
|
|
storyboardLayer = layer;
|
|
|
|
|
|
|
|
|
|
Width = 640;
|
|
|
|
|
Height = 480;
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(CancellationToken? cancellationToken)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-03-30 19:37:20 +00:00
|
|
|
|
foreach (var element in storyboardLayer.Elements)
|
|
|
|
|
{
|
|
|
|
|
cancellationToken?.ThrowIfCancellationRequested();
|
2019-05-10 07:31:09 +00:00
|
|
|
|
|
2020-03-30 19:37:20 +00:00
|
|
|
|
if (element.IsDrawable)
|
|
|
|
|
AddInternal(element.CreateDrawable());
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|