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