1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-25 16:52:55 +08:00
osu-lazer/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.9 KiB
C#
Raw Normal View History

// 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 17:19:50 +08:00
using System.Collections.Generic;
using System.Threading;
2017-09-08 05:55:05 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osuTK;
2018-04-13 17:19:50 +08:00
2017-09-08 05:55:05 +08:00
namespace osu.Game.Storyboards.Drawables
{
public partial class DrawableStoryboardLayer : CompositeDrawable
2017-09-08 05:55:05 +08:00
{
public StoryboardLayer Layer { get; }
2017-09-08 05:55:05 +08:00
public bool Enabled;
2018-04-13 17:19:50 +08:00
2017-09-08 05:55:05 +08:00
public override bool IsPresent => Enabled && base.IsPresent;
2018-04-13 17:19:50 +08:00
protected LayerElementContainer ElementContainer { get; }
2017-09-13 17:22:24 +08:00
public DrawableStoryboardLayer(StoryboardLayer layer)
2017-09-08 05:55:05 +08:00
{
2017-09-13 17:22:24 +08:00
Layer = layer;
2017-09-08 05:55:05 +08:00
RelativeSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
2020-03-25 10:08:08 +08:00
Enabled = layer.VisibleWhenPassing;
Masking = layer.Masking;
InternalChild = ElementContainer = new LayerElementContainer(layer);
2017-09-08 05:55:05 +08:00
}
2018-04-13 17:19:50 +08:00
public partial class LayerElementContainer : LifetimeManagementContainer
2017-09-08 05:55:05 +08:00
{
private readonly StoryboardLayer storyboardLayer;
public IEnumerable<Drawable> Elements => InternalChildren;
public LayerElementContainer(StoryboardLayer layer)
{
storyboardLayer = layer;
Size = new Vector2(640, 480);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
[BackgroundDependencyLoader]
private void load(CancellationToken? cancellationToken)
2017-09-08 05:55:05 +08:00
{
foreach (var element in storyboardLayer.Elements)
{
cancellationToken?.ThrowIfCancellationRequested();
if (element.IsDrawable)
AddInternal(element.CreateDrawable());
}
2017-09-08 05:55:05 +08:00
}
}
}
}