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-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
|
using osu.Game.IO;
|
2019-03-18 06:25:54 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Storyboards.Drawables
|
|
|
|
|
{
|
|
|
|
|
public class DrawableStoryboard : Container<DrawableStoryboardLayer>
|
|
|
|
|
{
|
|
|
|
|
public Storyboard Storyboard { get; private set; }
|
|
|
|
|
|
|
|
|
|
private readonly Container<DrawableStoryboardLayer> content;
|
|
|
|
|
protected override Container<DrawableStoryboardLayer> Content => content;
|
|
|
|
|
|
|
|
|
|
protected override Vector2 DrawScale => new Vector2(Parent.DrawHeight / 480);
|
|
|
|
|
|
|
|
|
|
private bool passing = true;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public bool Passing
|
|
|
|
|
{
|
2019-02-28 04:58:19 +00:00
|
|
|
|
get => passing;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (passing == value) return;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
passing = value;
|
|
|
|
|
updateLayerVisibility();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool RemoveCompletedTransforms => false;
|
|
|
|
|
|
|
|
|
|
private DependencyContainer dependencies;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2018-07-11 08:07:14 +00:00
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
|
|
|
|
|
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
public DrawableStoryboard(Storyboard storyboard)
|
|
|
|
|
{
|
|
|
|
|
Storyboard = storyboard;
|
|
|
|
|
Size = new Vector2(640, 480);
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
AddInternal(content = new Container<DrawableStoryboardLayer>
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(640, 480),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-18 06:50:34 +00:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2019-05-10 08:42:45 +00:00
|
|
|
|
private void load(FileStore fileStore, GameplayClock clock, CancellationToken? cancellationToken)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-03-18 09:19:59 +00:00
|
|
|
|
if (clock != null)
|
2019-03-18 06:25:54 +00:00
|
|
|
|
Clock = clock;
|
|
|
|
|
|
2018-09-07 09:49:59 +00:00
|
|
|
|
dependencies.Cache(new TextureStore(new TextureLoaderStore(fileStore.Store), false, scaleAdjust: 1));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
foreach (var layer in Storyboard.Layers)
|
2019-05-10 07:31:09 +00:00
|
|
|
|
{
|
2019-05-10 08:42:45 +00:00
|
|
|
|
cancellationToken?.ThrowIfCancellationRequested();
|
2019-05-10 07:31:09 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Add(layer.CreateDrawable());
|
2019-05-10 07:31:09 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateLayerVisibility()
|
|
|
|
|
{
|
|
|
|
|
foreach (var layer in Children)
|
|
|
|
|
layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|