mirror of
https://github.com/ppy/osu
synced 2024-12-15 03:16:17 +00:00
5ea948aabe
This allows the `FillMode.Fill` to take up the full space of the storyboard container.
61 lines
1.8 KiB
C#
61 lines
1.8 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 System.Threading;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Storyboards.Drawables
|
|
{
|
|
public class DrawableStoryboardLayer : CompositeDrawable
|
|
{
|
|
public StoryboardLayer Layer { get; }
|
|
public bool Enabled;
|
|
|
|
public override bool IsPresent => Enabled && base.IsPresent;
|
|
|
|
protected LayerElementContainer ElementContainer { get; }
|
|
|
|
public DrawableStoryboardLayer(StoryboardLayer layer)
|
|
{
|
|
Layer = layer;
|
|
RelativeSizeAxes = Axes.Both;
|
|
Anchor = Anchor.Centre;
|
|
Origin = Anchor.Centre;
|
|
Enabled = layer.VisibleWhenPassing;
|
|
Masking = layer.Masking;
|
|
|
|
InternalChild = ElementContainer = new LayerElementContainer(layer);
|
|
}
|
|
|
|
protected class LayerElementContainer : LifetimeManagementContainer
|
|
{
|
|
private readonly StoryboardLayer storyboardLayer;
|
|
|
|
public LayerElementContainer(StoryboardLayer layer)
|
|
{
|
|
storyboardLayer = layer;
|
|
|
|
Size = new Vector2(640, 480);
|
|
|
|
Anchor = Anchor.Centre;
|
|
Origin = Anchor.Centre;
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(CancellationToken? cancellationToken)
|
|
{
|
|
foreach (var element in storyboardLayer.Elements)
|
|
{
|
|
cancellationToken?.ThrowIfCancellationRequested();
|
|
|
|
if (element.IsDrawable)
|
|
AddInternal(element.CreateDrawable());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|